IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 38917


Ignore:
Timestamp:
Oct 20, 2015, 8:26:50 PM (11 years ago)
Author:
eugene
Message:

adding PS dX to the font description to get PS string length right

Location:
branches/eam_branches/ipp-20150625/Ohana/src/libkapa
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20150625/Ohana/src/libkapa/Makefile

    r38473 r38917  
    1818FULL_LDFLAGS  = $(BASE_LDFLAGS) -ldvo -lFITS -lohana
    1919
    20 install: $(DESTINC)/kapa.h $(DESTLIB)/libkapa.a $(DESTLIB)/libkapa.$(DLLTYPE)
    21 libkapa: $(LIB)/libkapa.$(ARCH).a $(LIB)/libkapa.$(ARCH).$(DLLTYPE)
     20install: ROTFONT $(DESTINC)/kapa.h $(DESTLIB)/libkapa.a $(DESTLIB)/libkapa.$(DLLTYPE)
     21libkapa: ROTFONT $(LIB)/libkapa.$(ARCH).a $(LIB)/libkapa.$(ARCH).$(DLLTYPE)
     22
     23ROTFONT:
     24        cd rotfont && make all
    2225
    2326INCS = $(DESTINC)/kapa.h
  • branches/eam_branches/ipp-20150625/Ohana/src/libkapa/include/alphabet.h

    r5854 r38917  
     1
     2# if (0)
     3# include "../rotfont/times8.h"
     4
     5# define DEFFONT 1
     6static FontSet HardwiredFonts[] = {
     7  {times8font,  "times", 8}
     8};
     9# endif
     10
     11# if (1)
    112# include "../rotfont/times8.h"
    213# include "../rotfont/times12.h"
     
    4960  {symbol24font, "symbol", 24}
    5061};
     62# endif
    5163
    5264/* put these as static in RotFont.c with accessor functions */
  • branches/eam_branches/ipp-20150625/Ohana/src/libkapa/include/kapa.h

    r38739 r38917  
    109109
    110110typedef struct {
    111   int dx, dy, ascent;
     111  int dx;
     112  int dy;
     113  float dXps;
     114  int ascent;
    112115  unsigned char *bits;
    113116} RotFont;
     
    233236void PSDumpRotSegment PROTO((FILE *f, char *segment, int *Nseg));
    234237void PSSetFont PROTO((FILE *f, char *name, int size));
     238int PSRotStrlen PROTO((char *c));
    235239
    236240/* bDrawFuncs.c */
  • branches/eam_branches/ipp-20150625/Ohana/src/libkapa/src/DrawRotString.c

    r34088 r38917  
    2222    return (TRUE);
    2323}
     24
     25/* position can be one of 9 values center the text in the following way
     26   0 1 2
     27   3 4 5
     28   6 7 8
     29
     30   e.g., 4 has the center of the string at the x,y position
     31         0 has the lower-right corner at the position (left & up justified)
     32*/
    2433
    2534int DrawRotText (int x, int y, char *string, int pos, double angle) {
  • branches/eam_branches/ipp-20150625/Ohana/src/libkapa/src/PSRotFont.c

    r32695 r38917  
    99  int i, N, code, protect;
    1010  int dX, dY, Xoff, Yoff, X, Y, Nseg, NSEG, YoffBase;
    11   double cs, sn, fscale, currentscale;
     11  double cs, sn, currentscale;
    1212  int basesize, currentsize;
    1313  RotFont *currentfont;
     
    2323 
    2424  /* compute string length */
    25   /* PS fonts are somewhat different scales from bitmap font equivalents */
    26   fscale = 1.0;
    27   if (!strcmp (currentname, "times")) fscale = 1.07;
    28   if (!strcmp (currentname, "courier")) fscale = 1.5;
    29   if (!strcmp (currentname, "helvetica")) fscale = 0.9;
    30   if (!strcmp (currentname, "symbol")) fscale = 1.2;
    31   dX = fscale*RotStrlen (string);
     25  dX = PSRotStrlen (string);
    3226  dY = currentfont[65].ascent;
    3327 
     
    201195}
    202196
     197# define NROT 256
     198int PSRotStrlen (char *c) {
     199
     200  int i, N, dX, code;
     201  double currentscale, scale;
     202
     203  RotFont *currentfont = GetRotFontData (&currentscale);
     204  scale = currentscale;
     205
     206  /* find string length */
     207  dX = 0;
     208
     209  code = FALSE;
     210  for (i = 0; i < strlen (c); i++) {
     211    N = (int)(c[i]);
     212    /* skip non-printing characters */
     213    if ((N < 0) || (N >= NROT)) continue;
     214
     215    /* check for special characters */
     216    if (!code) {
     217      if (N == 94) { /* super-script */
     218        scale *= 0.8;
     219        continue;
     220      }
     221      if (N == 95) { /* sub-script */
     222        scale *= 0.8;
     223        continue;
     224      }
     225      if (N == 124) { /* normal-script */
     226        scale = currentscale;
     227        continue;
     228      }
     229      if (N == 92) { /* backslash */
     230        code = TRUE;
     231        continue;
     232      }
     233      if (N == 38) { /* font-code */
     234        i++;
     235        continue;
     236      }
     237    }
     238    code = FALSE;
     239    dX += scale*currentfont[N].dXps + 1;
     240  }
     241  return (dX);
     242}
    203243
    204244
Note: See TracChangeset for help on using the changeset viewer.