Changeset 5611 for trunk/Ohana/src/kapa/graph/PSRotFont.c
- Timestamp:
- Nov 27, 2005, 9:22:01 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/kapa/graph/PSRotFont.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/kapa/graph/PSRotFont.c
r5610 r5611 1 1 # include "Ximage.h" 2 # include "alphabet.h"2 # define NROTCHARS 256 3 3 4 4 /* writes commands to print string at location and angle using … … 6 6 void PSRotText (FILE *f, int x, int y, char *string, int pos, double angle) { 7 7 8 char *c, *segment, base font[64];8 char *c, *segment, basename[64], *currentname; 9 9 int i, N, code; 10 10 int dX, dY, Xoff, Yoff, X, Y, Nseg, NSEG, YoffBase; 11 double cs, sn, fscale; 12 int basesize; 13 11 double cs, sn, fscale, currentscale; 12 int basesize, currentsize; 13 RotFont *currentfont; 14 15 currentname = GetRotFont (¤tsize); 16 currentfont = GetRotFontData (¤tscale); 17 strcpy (basename, currentname); 18 basesize = currentsize; 19 14 20 /* strip off leading whitespace */ 15 21 for (c = string; (*c == ' ') || (*c == '\t'); c++); … … 24 30 if (!strcmp (currentname, "symbol")) fscale = 1.2; 25 31 dX = fscale*RotStrlen (c); 26 dY = activefont[65].ascent;32 dY = currentfont[65].ascent; 27 33 28 34 /* apply appropriate offset */ … … 44 50 Y = y - Xoff*sn + Yoff*cs; 45 51 46 basesize = currentsize; 47 strcpy (basefont, currentname); 48 49 PSSetFont (f, currentsize); 52 PSSetFont (f, currentname, currentsize); 50 53 fprintf (f, "gsave\n"); 51 54 fprintf (f, " %d %d moveto %f rotate\n", X, Y, -angle); … … 61 64 for (i = 0; i < strlen (c); i++) { 62 65 N = (int)(c[i]); 63 if ((N < 0) || (N >= NROT )) continue;66 if ((N < 0) || (N >= NROTCHARS)) continue; 64 67 65 68 /* check for special characters */ … … 69 72 PSDumpRotSegment (f, segment, &Nseg); 70 73 SetRotFont (currentname, (int)(0.8*currentsize)); 71 Yoff = 0.75*activescale*dY; 74 currentfont = GetRotFontData (¤tscale); 75 Yoff = 0.75*currentscale*dY; 72 76 fprintf (f, "0 %d rmoveto\n", Yoff); 73 77 YoffBase += Yoff; 74 PSSetFont (f, current size);78 PSSetFont (f, currentname, currentsize); 75 79 continue; 76 80 } … … 79 83 PSDumpRotSegment (f, segment, &Nseg); 80 84 SetRotFont (currentname, (int)(0.8*currentsize)); 81 Yoff = -0.5*activescale*dY; 85 currentfont = GetRotFontData (¤tscale); 86 Yoff = -0.5*currentscale*dY; 82 87 fprintf (f, "0 %d rmoveto\n", Yoff); 83 88 YoffBase += Yoff; 84 PSSetFont (f, current size);89 PSSetFont (f, currentname, currentsize); 85 90 continue; 86 91 } … … 89 94 PSDumpRotSegment (f, segment, &Nseg); 90 95 SetRotFont (currentname, basesize); 96 currentfont = GetRotFontData (¤tscale); 91 97 fprintf (f, "0 %d rmoveto\n", -YoffBase); 92 98 YoffBase = 0; 93 PSSetFont (f, current size);99 PSSetFont (f, currentname, currentsize); 94 100 continue; 95 101 } … … 118 124 if (c[i+1] == 'h') { 119 125 SetRotFont ("helvetica", currentsize); 120 PSSetFont (f, currentsize); 126 currentfont = GetRotFontData (¤tscale); 127 PSSetFont (f, currentname, currentsize); 121 128 } 122 129 if (c[i+1] == 't') { 123 130 SetRotFont ("times", currentsize); 124 PSSetFont (f, currentsize); 131 currentfont = GetRotFontData (¤tscale); 132 PSSetFont (f, currentname, currentsize); 125 133 } 126 134 if (c[i+1] == 'c') { 127 135 SetRotFont ("courier", currentsize); 128 PSSetFont (f, currentsize); 136 currentfont = GetRotFontData (¤tscale); 137 PSSetFont (f, currentname, currentsize); 129 138 } 130 139 if (c[i+1] == 's') { 131 140 SetRotFont ("symbol", currentsize); 132 PSSetFont (f, currentsize); 141 currentfont = GetRotFontData (¤tscale); 142 PSSetFont (f, currentname, currentsize); 133 143 } 134 144 i++; … … 144 154 fprintf (f, "stroke grestore\n"); 145 155 free (segment); 146 SetRotFont (base font, basesize);156 SetRotFont (basename, basesize); 147 157 } 148 158 … … 154 164 } 155 165 156 void PSSetFont (FILE *f, int size) {157 if (!strcmp ( currentname, "times"))166 void PSSetFont (FILE *f, char *name, int size) { 167 if (!strcmp (name, "times")) 158 168 fprintf (f, "/Times-Roman findfont %d scalefont setfont\n", size); 159 if (!strcmp ( currentname, "helvetica"))169 if (!strcmp (name, "helvetica")) 160 170 fprintf (f, "/Helvetica findfont %d scalefont setfont\n", size); 161 if (!strcmp ( currentname, "courier"))171 if (!strcmp (name, "courier")) 162 172 fprintf (f, "/Courier findfont %d scalefont setfont\n", size); 163 if (!strcmp ( currentname, "symbol"))173 if (!strcmp (name, "symbol")) 164 174 fprintf (f, "/Symbol findfont %d scalefont setfont\n", size); 165 175 }
Note:
See TracChangeset
for help on using the changeset viewer.
