Changeset 39595
- Timestamp:
- Jun 11, 2016, 12:44:40 PM (10 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/libkapa/src/DrawRotString.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/libkapa/src/DrawRotString.c
r39457 r39595 88 88 if (!code && !protect) { 89 89 /* subscript, starts with _ */ 90 if (N == 94) { 90 if (N == 94) { // underscore 91 91 SetRotFont (currentname, (int)(0.8*currentsize)); 92 92 currentfont = GetRotFontData (¤tscale); … … 95 95 } 96 96 /* superscript, starts with ^ */ 97 if (N == 95) { 97 if (N == 95) { // caret 98 98 SetRotFont (currentname, (int)(0.8*currentsize)); 99 99 currentfont = GetRotFontData (¤tscale); … … 102 102 } 103 103 /* normal script, starts with | */ 104 if (N == 124) { 104 if (N == 124) { // pipe 105 105 SetRotFont (currentname, basesize); 106 106 currentfont = GetRotFontData (¤tscale); … … 108 108 continue; 109 109 } 110 if (N == 92) { 110 if (N == 92) { // backslash 111 111 code = TRUE; 112 112 continue; 113 113 } 114 if (N == 38) { 114 if (N == 38) { // ampersand 115 if (string[i+1] == 'h') { 116 SetRotFont ("helvetica", currentsize); 117 currentfont = GetRotFontData (¤tscale); 118 } 119 if (string[i+1] == 't') { 120 SetRotFont ("times", currentsize); 121 currentfont = GetRotFontData (¤tscale); 122 } 123 if (string[i+1] == 'c') { 124 SetRotFont ("courier", currentsize); 125 currentfont = GetRotFontData (¤tscale); 126 } 127 if (string[i+1] == 's') { 128 SetRotFont ("symbol", currentsize); 129 currentfont = GetRotFontData (¤tscale); 130 } 131 i++; 132 continue; 133 } 134 } 135 code = FALSE; 136 137 bitmap = currentfont[N].bits; 138 dx = currentfont[N].dx; 139 dy = currentfont[N].dy; 140 X = x + (int)(Xoff*cs - Yoff*sn) + (int)(currentscale*currentfont[N].ascent*sn); 141 Y = y + (int)(Xoff*sn + Yoff*cs) - (int)(currentscale*currentfont[N].ascent*cs); 142 DrawRotBitmap (X, Y, dx, dy, bitmap, TRUE, angle, currentscale); 143 Xoff += 1 + (int)(currentscale*dx + 0.5); 144 } 145 SetRotFont (basename, basesize); 146 return (TRUE); 147 } 148 149 /* 150 latex interpretation rules: 151 \word = special character 152 interpretation is LaTeX math mode 153 154 155 */ 156 157 int DrawRotText_Latex (int x, int y, char *string, int pos, double angle) { 158 159 unsigned char *bitmap; 160 char *currentname, basename[64]; 161 int dy, dx, N, X, Y, code, protect; 162 int dX, Xoff, dY, Yoff, YoffBase; 163 int currentsize, basesize; 164 double cs, sn, currentscale; 165 RotFont *currentfont; 166 167 currentname = GetRotFont (¤tsize); 168 currentfont = GetRotFontData (¤tscale); 169 strcpy (basename, currentname); 170 basesize = currentsize; 171 172 /* strip leading WHITESPACE */ 173 stripwhite (string); 174 if (*string == 0) return (FALSE); 175 176 /* compute string length */ 177 cs = cos(angle*RAD_DEG); 178 sn = sin(angle*RAD_DEG); 179 dX = RotStrlen (string); 180 dY = currentfont[65].ascent; 181 182 /* apply appropriate offset */ 183 Xoff = Yoff = 0; 184 switch (pos) { 185 case 0: Xoff = -dX; Yoff = dY; break; 186 case 1: Xoff = -0.5*dX; Yoff = dY; break; 187 case 2: Xoff = 0; Yoff = dY; break; 188 case 3: Xoff = -dX; Yoff = 0.5*dY; break; 189 case 4: Xoff = -0.5*dX; Yoff = 0.5*dY; break; 190 case 5: Xoff = 0; Yoff = 0.5*dY; break; 191 case 6: Xoff = -dX; Yoff = 0; break; 192 case 7: Xoff = -0.5*dX; Yoff = 0; break; 193 case 8: Xoff = 0; Yoff = 0; break; 194 } 195 196 code = FALSE; 197 protect = FALSE; 198 199 YoffBase = Yoff; 200 /* draw characters one-by-one */ 201 unsigned int i; 202 for (i = 0; i < strlen(string); i++) { 203 N = (int)(string[i]); 204 if ((N < 0) || (N >= NROTCHARS)) continue; 205 206 if (N == 39) { // single-quote 207 protect = protect ? FALSE : TRUE; 208 } 209 210 /* check for special characters */ 211 if (!code && !protect) { 212 /* subscript, starts with _ */ 213 if (N == 94) { // underscore 214 SetRotFont (currentname, (int)(0.8*currentsize)); 215 currentfont = GetRotFontData (¤tscale); 216 Yoff -= 0.5*currentscale*dY; 217 continue; 218 } 219 /* superscript, starts with ^ */ 220 if (N == 95) { // caret 221 SetRotFont (currentname, (int)(0.8*currentsize)); 222 currentfont = GetRotFontData (¤tscale); 223 Yoff += 0.5*currentscale*dY; 224 continue; 225 } 226 /* normal script, starts with | */ 227 if (N == 124) { // pipe 228 SetRotFont (currentname, basesize); 229 currentfont = GetRotFontData (¤tscale); 230 Yoff = YoffBase; 231 continue; 232 } 233 if (N == 92) { // backslash 234 code = TRUE; 235 continue; 236 } 237 if (N == 38) { // ampersand 115 238 if (string[i+1] == 'h') { 116 239 SetRotFont ("helvetica", currentsize);
Note:
See TracChangeset
for help on using the changeset viewer.
