Debian Codegraph @

fontforgeexe/cvdgloss.c

raw symbols SCIP
1 /* Copyright (C) 2005-2012 by George Williams */
2 /*
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are met:
5
6 * Redistributions of source code must retain the above copyright notice, this
7 * list of conditions and the following disclaimer.
8
9 * Redistributions in binary form must reproduce the above copyright notice,
10 * this list of conditions and the following disclaimer in the documentation
11 * and/or other materials provided with the distribution.
12
13 * The name of the author may not be used to endorse or promote products
14 * dercved from this software without specific prior written permission.
15
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28 #include <fontforge-config.h>
29
30 #include "fontforgeui.h"
31 #include "gkeysym.h"
32 #include "ustring.h"
33
34 #include <math.h>
35 #include <stdarg.h>
36
37 extern GBox _ggadget_Default_Box;
38 #define MAIN_FOREGROUND (_ggadget_Default_Box.main_foreground)
39
40 #ifdef FREETYPE_HAS_DEBUGGER
41
42 #include <ft2build.h>
43 #include FT_FREETYPE_H
44
45 #if FREETYPE_MAJOR == 2 && (FREETYPE_MINOR < 10 || (FREETYPE_MINOR == 10 && FREETYPE_PATCH < 3))
46 # include <internal/internal.h>
47 #endif
48 #include <ttinterp.h>
49
50 #define PPEMX(exc) ((exc)->size->root.metrics.x_ppem)
51 #define PPEMY(exc) ((exc)->size->root.metrics.y_ppem)
52
53 struct scr {
54 int y, fh;
55 int lines;
56 GWindow pixmap;
57 };
58
59 static int ttround(int val, TT_ExecContext exc) {
60 if ( val<0 )
61 return( -ttround(-val,exc));
62
63 switch ( exc->GS.round_state ) {
64 case TT_Round_To_Grid:
65 val = 64*((val+32)/64);
66 break;
67 case TT_Round_Down_To_Grid:
68 val = 64*(val/64);
69 break;
70 case TT_Round_Up_To_Grid:
71 val = 64*((val+63)/64);
72 break;
73 case TT_Round_To_Half_Grid:
74 val = 64*(val/64)+32;
75 break;
76 case TT_Round_Super:
77 val = (val - exc->phase + exc->threshold) & -exc->period;
78 val += exc->phase;
79 break;
80 case TT_Round_Super_45:
81 val = ((val - exc->phase + exc->threshold) / exc->period)*exc->period;
82 val += exc->phase;
83 break;
84 }
85 return(val);
86 }
87
88 static void scrprintf(struct scr *scr, char *format, ... ) {
89 va_list ap;
90 char buffer[100];
91
92 va_start(ap,format);
93 vsnprintf(buffer,sizeof(buffer),format,ap);
94 GDrawDrawText8(scr->pixmap,3,scr->y,buffer,-1,MAIN_FOREGROUND);
95 scr->y += scr->fh;
96 ++scr->lines;
97 va_end(ap);
98 }
99
100 static void scrrounding(struct scr *scr, TT_ExecContext exc ) {
101 scrprintf(scr, "RndState: %s",
102 exc->GS.round_state==TT_Round_To_Half_Grid? "To Half Grid" :
103 exc->GS.round_state==TT_Round_To_Grid? "To Grid" :
104 exc->GS.round_state==TT_Round_To_Double_Grid? "To Double Grid" :
105 exc->GS.round_state==TT_Round_Down_To_Grid? "Down To Grid" :
106 exc->GS.round_state==TT_Round_Up_To_Grid? "Up To Grid" :
107 exc->GS.round_state==TT_Round_Off? "Off" :
108 exc->GS.round_state==TT_Round_Super? "Super" :
109 exc->GS.round_state==TT_Round_Super_45? "Super45" :
110 "Unknown" );
111 }
112
113 static void scrfree(struct scr *scr, TT_ExecContext exc ) {
114 scrprintf(scr, "freeVec: %g,%g", (((int)exc->GS.freeVector.x<<16)>>(16+14)) + ((exc->GS.freeVector.x&0x3fff)/16384.0),
115 (((int)exc->GS.freeVector.y<<16)>>(16+14)) + ((exc->GS.freeVector.y&0x3fff)/16384.0) );
116 }
117
118 static void scrproj(struct scr *scr, TT_ExecContext exc ) {
119 scrprintf(scr,"projVec: %g,%g", (((int)exc->GS.projVector.x<<16)>>(16+14)) + ((exc->GS.projVector.x&0x3fff)/16384.0),
120 (((int)exc->GS.projVector.y<<16)>>(16+14)) + ((exc->GS.projVector.y&0x3fff)/16384.0) );
121 }
122
123 static int DVGlossExpose(GWindow pixmap,DebugView *dv,GEvent *event) {
124 TT_ExecContext exc = DebuggerGetEContext(dv->dc);
125 CharView *cv = dv->cv;
126 long val1, val2, ret, i, cnt, off, a1, a2, b1, b2;
127 int operator;
128 BasePoint freedom;
129 struct scr scr;
130 int base;
131
132 GDrawFillRect(pixmap,&event->u.expose.rect,GDrawGetDefaultBackground(screen_display));
133 GDrawSetFont(pixmap,dv->ii.gfont);
134 scr.pixmap = pixmap;
135 scr.y = 3+dv->ii.as - dv->gloss_offtop*dv->ii.fh;
136 scr.lines = 0;
137 scr.fh = dv->ii.fh;
138
139 if ( exc==NULL ) {
140 scrprintf(&scr,"<not running>");
141 return(1);
142 }
143 if ( exc->IP>=exc->codeSize || exc->code==NULL ) {
144 scrprintf(&scr,"<at end>");
145 return(1);
146 }
147
148 operator = ((uint8_t *) exc->code)[exc->IP];
149 if ( operator>=0xc0 && operator <= 0xdf ) {
150 scrprintf(&scr," MDRP: Move Direct Relative Point");
151 if ( operator&0x10 )
152 scrprintf(&scr,(operator&0x10)?" Set rp0 to point":" don't set rp0 to point" );
153 scrprintf(&scr,(operator&8)?" Keep distance>=min dist":" don't keep distance>=min dist");
154 scrprintf(&scr,(operator&4)?" Round distance":" don't round distance");
155 scrprintf(&scr,(operator&3)==0?" Grey":(operator&3)==1?" Black":(operator&3)==2?" White":" Undefined Rounding");
156 scrprintf(&scr,"Move point so cur distance to rp0 is");
157 scrprintf(&scr," the same as the original distance between");
158 val1 = exc->stack[exc->top-1];
159 scrprintf(&scr,"Pops: %d (point (%.2f,%.2f))", val1,
160 exc->zp1.cur[val1].x/64.0,exc->zp1.cur[val1].y/64.0 );
161 scrprintf(&scr," (in zone from zp1: %s)", exc->GS.gep1?"Normal":"Twilight" );
162 val2 = exc->GS.rp0;
163 scrprintf(&scr,"Reference Point rp0: %d (%.2f,%.2f)", val2,
164 exc->zp0.cur[val2].x/64.0,exc->zp0.cur[val2].y/64.0 );
165 scrprintf(&scr," (in zone from zp0: %s)", exc->GS.gep0?"Normal":"Twilight" );
166 scrprintf(&scr,"Sets rp1: %d (rp0)", val2);
167 scrprintf(&scr,"Sets rp2: %d (point)", val1);
168 scrprintf(&scr, "MinDist: %.2f", exc->GS.minimum_distance/64.0 );
169 scrprintf(&scr, "SingWidVal: %.2f", exc->GS.single_width_value/64.0 );
170 scrprintf(&scr, "SingWidCut: %.2f", exc->GS.single_width_cutin/64.0 );
171 scrrounding(&scr,exc);
172 scrfree(&scr,exc);
173 scrproj(&scr,exc);
174 } else if ( operator>=0xe0 && operator <= 0xff ) {
175 scrprintf(&scr," MIRP: Move Indirect Relative Point");
176 if ( operator&0x10 )
177 scrprintf(&scr,(operator&0x10)?" Set rp0 to point":" don't set rp0 to point" );
178 scrprintf(&scr,(operator&8)?" Keep distance>=min dist":" don't keep distance>=min dist");
179 scrprintf(&scr,(operator&4)?" Round distance/use cvt cutin":" don't round distance nor use cvt cutin");
180 scrprintf(&scr,(operator&3)==0?" Grey":(operator&3)==1?" Black":(operator&3)==2?" White":" Undefined Rounding");
181 scrprintf(&scr,"Move point along freedom vector so distance");
182 scrprintf(&scr," measured along projection to rp0 is the");
183 scrprintf(&scr," value in the cvt table");
184 val2 = exc->stack[exc->top-1];
185 val1 = exc->stack[exc->top-2];
186 scrprintf(&scr,"Pops: %d (point (%.2f,%.2f))", val1,
187 exc->zp1.cur[val1].x/64.0,exc->zp1.cur[val1].y/64.0 );
188 scrprintf(&scr," (in zone from zp1: %s)", exc->GS.gep1?"Normal":"Twilight" );
189 scrprintf(&scr,"Pop: %d (cvt %.2f)", val2, exc->cvt[val2]/64.0 );
190 val2 = exc->GS.rp0;
191 scrprintf(&scr,"Reference Point rp0: %d (%.2f,%.2f)", val2,
192 exc->zp0.cur[val2].x/64.0,exc->zp0.cur[val2].y/64.0 );
193 scrprintf(&scr," (in zone from zp0: %s)", exc->GS.gep0?"Normal":"Twilight" );
194 scrprintf(&scr,"Sets rp1: %d (rp0)", val2);
195 scrprintf(&scr,"Sets rp2: %d (point)", val1);
196 scrprintf(&scr, "MinDist: %.2f", exc->GS.minimum_distance/64.0 );
197 scrprintf(&scr, "CvtCutin: %.2f", exc->GS.control_value_cutin/64.0 );
198 scrprintf(&scr, "SingWidVal: %.2f", exc->GS.single_width_value/64.0 );
199 scrprintf(&scr, "SingWidCut: %.2f", exc->GS.single_width_cutin/64.0 );
200 scrprintf(&scr, "AutoFlip: %s", exc->GS.auto_flip?"True": "False" );
201 scrrounding(&scr,exc);
202 scrfree(&scr,exc);
203 scrproj(&scr,exc);
204 } else if ( operator>=0xb0 && operator <= 0xb7 ) {
205 scrprintf(&scr," Pushes %d byte%s", operator+1-0xb0, operator==0xb0?"":"s" );
206 } else if ( operator>=0xb8 && operator <= 0xbf ) {
207 scrprintf(&scr," Pushes %d word%s", operator+1-0xb8, operator==0xb8?"":"s" );
208 } else switch ( operator ) {
209 case 0x0:
210 scrprintf(&scr," Set Freedom/Projection vector to y axis");
211 break;
212 case 0x1:
213 scrprintf(&scr," Set Freedom/Projection vector to x axis");
214 break;
215 case 0x2:
216 scrprintf(&scr," Set Projection vector to y axis");
217 break;
218 case 0x3:
219 scrprintf(&scr," Set Projection vector to x axis");
220 break;
221 case 0x4:
222 scrprintf(&scr," Set Freedom vector to y axis");
223 break;
224 case 0x5:
225 scrprintf(&scr," Set Freedom vector to x axis");
226 break;
227 case 0xb: case 0xa:
228 scrprintf(&scr," Set %s vector from stack", operator==0xb?"Freedom":"Projection");
229 val1 = exc->stack[exc->top-2];
230 val2 = exc->stack[exc->top-1];
231 scrprintf(&scr,"Pops: %.4f (x-coord)", val1/16384.0 );
232 scrprintf(&scr,"Pops: %.4f (y-coord)", val2/16384.0 );
233 scrprintf(&scr,"Sets: %s Vector", operator==0xb?"Freedom":"Projection" );
234 break;
235 case 0xe:
236 scrprintf(&scr," Set Freedom vector to Projection vector");
237 scrprintf(&scr,"projVec: %g,%g", (((int)exc->GS.projVector.x<<16)>>(16+14)) + ((exc->GS.projVector.x&0x3fff)/16384.0),
238 (((int)exc->GS.projVector.y<<16)>>(16+14)) + ((exc->GS.projVector.y&0x3fff)/16384.0) );
239 scrprintf(&scr,"Sets: Freedom Vector" );
240 break;
241 case 0xc: case 0xd:
242 scrprintf(&scr,operator==0xc?" Get Projection Vector":" Get Freedom Vector");
243 scrprintf(&scr,operator==0xc?"Pushes: Projection Vector":"Pushes: Freedom Vector");
244 if ( operator==0xd )
245 scrfree(&scr,exc);
246 else
247 scrproj(&scr,exc);
248 break;
249 case 0xf:
250 scrprintf(&scr," Moves point to intersection of two lines");
251 val1 = exc->stack[exc->top-5];
252 a1 = exc->stack[exc->top-4];
253 a2 = exc->stack[exc->top-3];
254 b1 = exc->stack[exc->top-2];
255 b2 = exc->stack[exc->top-1];
256
257 scrprintf(&scr,"Pops: %d (point (%.2f,%.2f))", val1,
258 exc->zp2.cur[val1].x/64.0,exc->zp2.cur[val1].y/64.0 );
259 scrprintf(&scr," (in zone from zp2: %s)", exc->GS.gep2?"Normal":"Twilight" );
260
261 scrprintf(&scr,"Pops: %d (line1.s (%.2f,%.2f))", a1,
262 exc->zp0.cur[a1].x/64.0,exc->zp0.cur[a1].y/64.0 );
263 scrprintf(&scr,"Pops: %d (line1.e (%.2f,%.2f))", a2,
264 exc->zp0.cur[a2].x/64.0,exc->zp0.cur[a2].y/64.0 );
265 scrprintf(&scr," (in zone from zp0: %s)", exc->GS.gep0?"Normal":"Twilight" );
266
267 scrprintf(&scr,"Pops: %d (line2.s (%.2f,%.2f))", b1,
268 exc->zp1.cur[b1].x/64.0,exc->zp1.cur[b1].y/64.0 );
269 scrprintf(&scr,"Pops: %d (line2.e (%.2f,%.2f))", b2,
270 exc->zp1.cur[b2].x/64.0,exc->zp1.cur[b2].y/64.0 );
271 scrprintf(&scr," (in zone from zp1: %s)", exc->GS.gep1?"Normal":"Twilight" );
272
273 scrprintf(&scr,"(ignores freedom vector)");
274 break;
275 case 0x10:
276 scrprintf(&scr," Set Reference Point 0");
277 val1 = exc->stack[exc->top-1];
278 scrprintf(&scr,"Pops: %d (point = new rp0)", val1 );
279 break;
280 case 0x11:
281 scrprintf(&scr," Set Reference Point 1");
282 val1 = exc->stack[exc->top-1];
283 scrprintf(&scr,"Pops: %d (point = new rp1)", val1 );
284 break;
285 case 0x12:
286 scrprintf(&scr," Set Reference Point 2");
287 val1 = exc->stack[exc->top-1];
288 scrprintf(&scr,"Pops: %d (point = new rp2)", val1 );
289 break;
290 case 0x13:
291 scrprintf(&scr," Set Zone Pointer 0");
292 val1 = exc->stack[exc->top-1];
293 scrprintf(&scr,"Pops: %d (new zp0 %s)", val1, val1?"Normal":"Twilight" );
294 break;
295 case 0x14:
296 scrprintf(&scr," Set Zone Pointer 1");
297 val1 = exc->stack[exc->top-1];
298 scrprintf(&scr,"Pops: %d (new zp1 %s)", val1, val1?"Normal":"Twilight" );
299 break;
300 case 0x15:
301 scrprintf(&scr," Set Zone Pointer 2");
302 val1 = exc->stack[exc->top-1];
303 scrprintf(&scr,"Pops: %d (new zp2 %s)", val1, val1?"Normal":"Twilight" );
304 break;
305 case 0x16:
306 scrprintf(&scr," Set Zone Pointers");
307 val1 = exc->stack[exc->top-1];
308 scrprintf(&scr,"Pops: %d (new zp0,zp1,zp2 %s)", val1, val1?"Normal":"Twilight" );
309 break;
310 case 0x17:
311 scrprintf(&scr," Set Loop variable");
312 val1 = exc->stack[exc->top-1];
313 scrprintf(&scr,"Pops: %d (new loop count)", val1 );
314 break;
315 case 0x1A:
316 scrprintf(&scr," Set Minimum Distance");
317 val1 = exc->stack[exc->top-1];
318 scrprintf(&scr,"Pops: %d (new minimum distance)", val1/64.0 );
319 break;
320 case 0x1B: case 0x2D: case 0x59:
321 switch( operator ) {
322 case 0x1B:
323 scrprintf(&scr," Else");
324 break;
325 case 0x2D:
326 scrprintf(&scr," End Function Definition (return)");
327 break;
328 case 0x59:
329 scrprintf(&scr," End If");
330 break;
331 }
332 break;
333 case 0x1C:
334 scrprintf(&scr," Jump Relative (to here)");
335 val1 = exc->stack[exc->top-1];
336 scrprintf(&scr,"Pops: %d (byte offset)", val1 );
337 break;
338 case 0x1D:
339 scrprintf(&scr," Set Control Value Table Cut-In");
340 val1 = exc->stack[exc->top-1];
341 scrprintf(&scr,"Pops: %.2f (new cvt cut-in value)", val1/64.0 );
342 break;
343 case 0x1E:
344 scrprintf(&scr," Set Single Width Cut-In");
345 val1 = exc->stack[exc->top-1];
346 scrprintf(&scr,"Pops: %.2f (new single width cut-in value)", val1/64.0 );
347 break;
348 case 0x1F:
349 scrprintf(&scr," Set Single Width");
350 val1 = exc->stack[exc->top-1];
351 scrprintf(&scr,"Pops: %.2f (new single width value)", val1/64.0 );
352 break;
353 case 0x20:
354 scrprintf(&scr," Duplicate TOS");
355 scrprintf(&scr,"Pushes: %d", exc->stack[exc->top-1] );
356 break;
357 case 0x21:
358 scrprintf(&scr," Pop TOS");
359 scrprintf(&scr,"Pops: %d", exc->stack[exc->top-1] );
360 break;
361 case 0x22:
362 scrprintf(&scr," Clear Stack");
363 scrprintf(&scr,"Pops everything" );
364 break;
365 case 0x23:
366 scrprintf(&scr," Swap top of stack");
367 scrprintf(&scr,"Pops: top two elements" );
368 scrprintf(&scr,"Pushs: top two elements in opposite order" );
369 break;
370 case 0x24:
371 scrprintf(&scr," Depth of Stack");
372 scrprintf(&scr,"Pushes: %d", exc->top );
373 break;
374 case 0x25: case 0x26:
375 val1 = exc->stack[exc->top-1];
376 scrprintf(&scr,operator==0x25?" Copy Indexed element to TOS":" Move Indexed element to TOS");
377 scrprintf(&scr,"Pops: %d", val1 );
378 if ( val1<exc->top ) {
379 val2 = exc->stack[exc->top-1-val1];
380 scrprintf(&scr,"Pushes: %.2f (%d)", val2/64.0, val2 );
381 if ( operator==0x26 )
382 scrprintf(&scr,"(and removes it from further down the stack)" );
383 } else
384 scrprintf(&scr,"*** Stack underflow ***" );
385 break;
386 case 0x27:
387 scrprintf(&scr," Align Points");
388 val2 = exc->stack[exc->top-1];
389 val1 = exc->stack[exc->top-2];
390 scrprintf(&scr,"Pop1: %d (point (%.2f,%.2f))", val1,
391 exc->zp1.cur[val1].x/64.0,exc->zp1.cur[val1].y/64.0 );
392 scrprintf(&scr," (in zone from zp1: %s)", exc->GS.gep1?"Normal":"Twilight" );
393 scrprintf(&scr,"Pop2: %d (point (%.2f,%.2f))", val2,
394 exc->zp0.cur[val2].x/64.0,exc->zp0.cur[val2].y/64.0 );
395 scrprintf(&scr," (in zone from zp0: %s)", exc->GS.gep0?"Normal":"Twilight" );
396 scrfree(&scr,exc);
397 scrproj(&scr,exc);
398 break;
399 case 0x28:
400 scrprintf(&scr," Untouch Point");
401 val1 = exc->stack[exc->top-1];
402 scrprintf(&scr,"Pop1: %d (point (%.2f,%.2f))", val1,
403 exc->zp0.cur[val1].x/64.0,exc->zp0.cur[val1].y/64.0 );
404 scrprintf(&scr," (in zone from zp0: %s)", exc->GS.gep0?"Normal":"Twilight" );
405 scrfree(&scr,exc);
406 break;
407 case 0x2A:
408 case 0x2B:
409 case 0x2C:
410 switch ( operator ) {
411 case 0x2A:
412 scrprintf(&scr," Loop Call Function");
413 break;
414 case 0x2B:
415 scrprintf(&scr," Call Function");
416 break;
417 case 0x2C:
418 scrprintf(&scr," Function Definition");
419 break;
420 }
421 val1 = exc->stack[exc->top-1];
422 scrprintf(&scr,"Pops: %d (function number)", val1 );
423 if ( operator==0x2a ) {
424 val2 = exc->stack[exc->top-2];
425 scrprintf(&scr,"Pops: %d (count)", val2 );
426 }
427 break;
428 case 0x2E: case 0x2F:
429 scrprintf(&scr, operator==0x2E?" MDAP (touch point)":" MDAP (round & touch point)");
430 val1 = exc->stack[exc->top-1];
431 scrprintf(&scr,"Pops: %d (point (%.2f,%.2f))", val1,
432 exc->zp0.cur[val1].x/64.0,exc->zp0.cur[val1].y/64.0 );
433 scrprintf(&scr," (in zone from zp0: %s)", exc->GS.gep0?"Normal":"Twilight" );
434 scrprintf(&scr,"Sets: rp0,rp1 to %d", val1 );
435 if ( operator==0x2F )
436 scrrounding(&scr,exc);
437 scrfree(&scr,exc);
438 scrproj(&scr,exc);
439 break;
440 case 0x30: case 0x31:
441 switch ( operator ) {
442 case 0x30:
443 scrprintf(&scr," Interpolate Untouched Points in y");
444 break;
445 case 0x31:
446 scrprintf(&scr," Interpolate Untouched Points in x");
447 break;
448 }
449 scrprintf(&scr," (in zone from zp2: %s)", exc->GS.gep2?"Normal":"Twilight" );
450 break;
451 case 0x32: case 0x33:
452 scrprintf(&scr," Shift point by amount ref point shifted");
453 if ( operator==0x33 ) {
454 scrprintf(&scr, "Reference point in rp1: %d (point (%.2f,%.2f))", exc->GS.rp2,
455 exc->zp0.cur[exc->GS.rp1].x/64.0,exc->zp0.cur[exc->GS.rp1].y/64.0 );
456 scrprintf(&scr," (in zone from zp0: %s)", exc->GS.gep0?"Normal":"Twilight" );
457 } else {
458 scrprintf(&scr, "Reference point in rp2: %d (point (%.2f,%.2f))", exc->GS.rp2,
459 exc->zp1.cur[exc->GS.rp2].x/64.0,exc->zp1.cur[exc->GS.rp2].y/64.0 );
460 scrprintf(&scr," (in zone from zp1: %s)", exc->GS.gep1?"Normal":"Twilight" );
461 }
462 scrprintf(&scr, "loop: %ld", exc->GS.loop );
463 for ( val1=1; val1<=exc->GS.loop && val1<exc->top; ++val1 ) {
464 val2 = exc->stack[exc->top-val1];
465 scrprintf(&scr,"Pop%d: %d (point (%.2f,%.2f))", val1, val2,
466 exc->zp2.cur[val2].x/64.0,exc->zp2.cur[val2].y/64.0 );
467 }
468 scrprintf(&scr," (in zone from zp2: %s)", exc->GS.gep2?"Normal":"Twilight" );
469 scrfree(&scr,exc);
470 scrproj(&scr,exc);
471 break;
472 case 0x34: case 0x35:
473 scrprintf(&scr," Shift contour by amount ref point shifted");
474 if ( operator==0x35 ) {
475 scrprintf(&scr, "Reference point in rp1: %d (point (%.2f,%.2f))", exc->GS.rp2,
476 exc->zp0.cur[exc->GS.rp1].x/64.0,exc->zp0.cur[exc->GS.rp1].y/64.0 );
477 scrprintf(&scr," (in zone from zp0: %s)", exc->GS.gep0?"Normal":"Twilight" );
478 } else {
479 scrprintf(&scr, "Reference point in rp2: %d (point (%.2f,%.2f))", exc->GS.rp2,
480 exc->zp1.cur[exc->GS.rp2].x/64.0,exc->zp1.cur[exc->GS.rp2].y/64.0 );
481 scrprintf(&scr," (in zone from zp1: %s)", exc->GS.gep1?"Normal":"Twilight" );
482 }
483 scrprintf(&scr, "Pops: %d (contour index)", exc->stack[exc->top-1]);
484 scrprintf(&scr," (in zone from zp2: %s)", exc->GS.gep2?"Normal":"Twilight" );
485 scrfree(&scr,exc);
486 scrproj(&scr,exc);
487 break;
488 case 0x36: case 0x37:
489 scrprintf(&scr," Shift zone by amount ref point shifted");
490 if ( operator==0x37 ) {
491 scrprintf(&scr, "Reference point in rp1: %d (point (%.2f,%.2f))", exc->GS.rp2,
492 exc->zp0.cur[exc->GS.rp1].x/64.0,exc->zp0.cur[exc->GS.rp1].y/64.0 );
493 scrprintf(&scr," (in zone from zp0: %s)", exc->GS.gep0?"Normal":"Twilight" );
494 } else {
495 scrprintf(&scr, "Reference point in rp2: %d (point (%.2f,%.2f))", exc->GS.rp2,
496 exc->zp1.cur[exc->GS.rp2].x/64.0,exc->zp1.cur[exc->GS.rp2].y/64.0 );
497 scrprintf(&scr," (in zone from zp1: %s)", exc->GS.gep1?"Normal":"Twilight" );
498 }
499 scrprintf(&scr, "Pops: %d (%s zone)", exc->stack[exc->top-1],
500 exc->stack[exc->top-1]?"Normal":"Twilight" );
501 scrfree(&scr,exc);
502 scrproj(&scr,exc);
503 break;
504 case 0x38:
505 scrprintf(&scr," Shift point by pixel amount");
506 val1 = exc->stack[exc->top-1];
507 scrprintf(&scr, "Pops: %.2f (pixel amount)", val1/64.0 );
508 scrprintf(&scr, "loop: %ld", exc->GS.loop );
509 for ( val1=2; val1<=exc->GS.loop+1 && val1<exc->top; ++val1 ) {
510 val2 = exc->stack[exc->top-val1];
511 scrprintf(&scr,"Pop%d: %d (point (%.2f,%.2f))", val1, val2,
512 exc->zp2.cur[val2].x/64.0,exc->zp2.cur[val2].y/64.0 );
513 }
514 scrprintf(&scr," (in zone from zp2: %s)", exc->GS.gep2?"Normal":"Twilight" );
515 scrfree(&scr,exc);
516 scrproj(&scr,exc);
517 break;
518 case 0x39:
519 scrprintf(&scr," Interpolated Point");
520 scrprintf(&scr, "Reference point in rp1: %d (point (%.2f,%.2f))", exc->GS.rp1,
521 exc->zp0.cur[exc->GS.rp1].x/64.0,exc->zp0.cur[exc->GS.rp1].y/64.0 );
522 scrprintf(&scr," (in zone from zp0: %s)", exc->GS.gep0?"Normal":"Twilight" );
523 scrprintf(&scr, "Reference point in rp2: %d (point (%.2f,%.2f))", exc->GS.rp2,
524 exc->zp1.cur[exc->GS.rp2].x/64.0,exc->zp1.cur[exc->GS.rp2].y/64.0 );
525 scrprintf(&scr," (in zone from zp1: %s)", exc->GS.gep1?"Normal":"Twilight" );
526 scrprintf(&scr, "loop: %ld", exc->GS.loop );
527 for ( val1=1; val1<=exc->GS.loop && val1<exc->top; ++val1 ) {
528 val2 = exc->stack[exc->top-val1];
529 scrprintf(&scr,"Pop%d: %d (point (%.2f,%.2f))", val1, val2,
530 exc->zp2.cur[val2].x/64.0,exc->zp2.cur[val2].y/64.0 );
531 }
532 scrprintf(&scr," (in zone from zp2: %s)", exc->GS.gep2?"Normal":"Twilight" );
533 scrfree(&scr,exc);
534 scrproj(&scr,exc);
535 break;
536 case 0x3A: case 0x3B:
537 scrprintf(&scr," MSIRP Move Stack Indirect Relative Point");
538 scrprintf(&scr,operator&1?" set rp0 to point":
539 " don't set rp0");
540 scrprintf(&scr,"moves point along freedom vector");
541 scrprintf(&scr," until distance from rp0 along");
542 scrprintf(&scr," projection vector is value from stack");
543 val2 = exc->stack[exc->top-1];
544 val1 = exc->stack[exc->top-2];
545 scrprintf(&scr,"Pop: %d (point (%.2f,%.2f))", val1,
546 exc->zp1.cur[val1].x/64.0,exc->zp1.cur[val1].y/64.0 );
547 scrprintf(&scr," (in zone from zp1: %s)", exc->GS.gep1?"Normal":"Twilight" );
548 scrprintf(&scr, "Reference point in rp0: %d (point (%.2f,%.2f))", exc->GS.rp0,
549 exc->zp0.cur[exc->GS.rp0].x/64.0,exc->zp0.cur[exc->GS.rp0].y/64.0 );
550 scrprintf(&scr," (in zone from zp0: %s)", exc->GS.gep0?"Normal":"Twilight" );
551 scrprintf(&scr,"Pop: %.2f (distance)", val2/64.0 );
552 scrfree(&scr,exc);
553 scrproj(&scr,exc);
554 break;
555 case 0x3C:
556 scrprintf(&scr," Align to Reference Point");
557 scrprintf(&scr, "Reference point in rp0: %d (point (%.2f,%.2f))", exc->GS.rp0,
558 exc->zp0.cur[exc->GS.rp0].x/64.0,exc->zp0.cur[exc->GS.rp0].y/64.0 );
559 scrprintf(&scr," (in zone from zp0: %s)", exc->GS.gep0?"Normal":"Twilight" );
560 scrprintf(&scr, "loop: %ld", exc->GS.loop );
561 for ( val1=1; val1<=exc->GS.loop && val1<exc->top; ++val1 ) {
562 val2 = exc->stack[exc->top-val1];
563 scrprintf(&scr,"Pop%d: %d (point (%.2f,%.2f))", val1, val2,
564 exc->zp1.cur[val2].x/64.0,exc->zp1.cur[val2].y/64.0 );
565 }
566 scrprintf(&scr," (in zone from zp1: %s)", exc->GS.gep1?"Normal":"Twilight" );
567 scrfree(&scr,exc);
568 scrproj(&scr,exc);
569 break;
570 case 0x3E: case 0x3F:
571 scrprintf(&scr," MIAP Move Indirect Absolute Point");
572 scrprintf(&scr,operator&1?" round distance and look at cvt cutin":
573 " don't round distance and look at cvt cutin");
574 scrprintf(&scr,"moves point to cvt value along freedom vector");
575 val2 = exc->stack[exc->top-1];
576 val1 = exc->stack[exc->top-2];
577 scrprintf(&scr,"Pop: %d (point (%.2f,%.2f))", val1,
578 exc->zp0.cur[val1].x/64.0,exc->zp0.cur[val1].y/64.0 );
579 scrprintf(&scr," (in zone from zp0: %s)", exc->GS.gep0?"Normal":"Twilight" );
580 scrprintf(&scr,"Pop: %d (cvt %.2f)", val2, exc->cvt[val2]/64.0 );
581 scrprintf(&scr,"Sets: rp0 and rp1 to point %d", val1 );
582 scrfree(&scr,exc);
583 scrproj(&scr,exc);
584 scrprintf(&scr, "CvtCutin: %.2f", exc->GS.control_value_cutin/64.0 );
585 break;
586 case 0x40:
587 scrprintf(&scr," Push %d Bytes", ((uint8_t *) exc->code)[exc->IP+1]);
588 break;
589 case 0x41:
590 scrprintf(&scr," Push %d Words", ((uint8_t *) exc->code)[exc->IP+1]);
591 break;
592 case 0x42:
593 scrprintf(&scr," Write Store" );
594 val2 = exc->stack[exc->top-1];
595 val1 = exc->stack[exc->top-2];
596 scrprintf(&scr,"Pops: %d (%.2f)", val2, val2/64.0 );
597 scrprintf(&scr,"Pops: %d (store index)", val1 );
598 break;
599 case 0x43:
600 scrprintf(&scr," Read Store" );
601 val1 = exc->stack[exc->top-1];
602 scrprintf(&scr,"Pop: %d (store index)", val1 );
603 scrprintf(&scr,"Pushes: %d (%.2f)", exc->storage[val1], exc->storage[val1]/64.0 );
604 break;
605 case 0x44:
606 scrprintf(&scr," Write CVT entry in Pixels" );
607 val2 = exc->stack[exc->top-1];
608 val1 = exc->stack[exc->top-2];
609 scrprintf(&scr,"Pops: %.2f", val2/64.0 );
610 scrprintf(&scr,"Pops: %d (cvt index)", val1 );
611 break;
612 case 0x45:
613 scrprintf(&scr,"Read Control Value Table entry" );
614 val1 = exc->stack[exc->top-1];
615 scrprintf(&scr,"Pop: %d (cvt index)", val1 );
616 scrprintf(&scr,"Pushes: %.2f (%d)", exc->cvt[val1]/64.0, exc->cvt[val1] );
617 break;
618 case 0x46: case 0x47:
619 scrprintf(&scr,"Get %s point coord projected on projection vector",
620 operator==0x46 ? "current" : "original" );
621 val1 = exc->stack[exc->top-1];
622 if ( operator==0x46 ) {
623 scrprintf(&scr,"Pop: %d (cur point (%.2f,%.2f))", val1,
624 exc->zp2.cur[val1].x/64.0,exc->zp2.cur[val1].y/64.0 );
625 scrprintf(&scr," (in zone from zp2: %s)", exc->GS.gep2?"Normal":"Twilight" );
626 scrprintf(&scr, "projVec: %g,%g", (((int)exc->GS.projVector.x<<16)>>(16+14)) + ((exc->GS.projVector.x&0x3fff)/16384.0),
627 (((int)exc->GS.projVector.y<<16)>>(16+14)) + ((exc->GS.projVector.y&0x3fff)/16384.0) );
628 } else {
629 scrprintf(&scr,"Pop: %d (orig point (%.2f,%.2f))", val1,
630 exc->zp2.org[val1].x/64.0,exc->zp2.org[val1].y/64.0 );
631 scrprintf(&scr," (in zone from zp2: %s)", exc->GS.gep2?"Normal":"Twilight" );
632 scrprintf(&scr,"dualVec: %g,%g", (((int)exc->GS.dualVector.x<<16)>>(16+14)) + ((exc->GS.dualVector.x&0x3fff)/16384.0),
633 (((int)exc->GS.dualVector.y<<16)>>(16+14)) + ((exc->GS.dualVector.y&0x3fff)/16384.0) );
634 }
635 scrprintf(&scr,"Pushes: projection" );
636 break;
637 case 0x48:
638 scrprintf(&scr," Sets coordinate from stack using proj & free vectors" );
639 val2 = exc->stack[exc->top-1];
640 val1 = exc->stack[exc->top-2];
641 scrprintf(&scr,"Moves point along freedom vector until its" );
642 scrprintf(&scr," projection on the projection vector is the" );
643 scrprintf(&scr," desired amount" );
644 scrprintf(&scr,"Pop: %d (cur point (%.2f,%.2f))", val1,
645 exc->zp2.cur[val1].x/64.0,exc->zp2.cur[val1].y/64.0 );
646 scrprintf(&scr," (in zone from zp2: %s)", exc->GS.gep2?"Normal":"Twilight" );
647 scrfree(&scr,exc);
648 scrproj(&scr,exc);
649 break;
650 case 0x49: case 0x4A:
651 switch ( operator ) {
652 case 0x49:
653 scrprintf(&scr," Measure Distance (current)");
654 break;
655 case 0x4A:
656 scrprintf(&scr," Measure Distance (original)");
657 break;
658 }
659
660 val1 = exc->stack[exc->top-1];
661 val2 = exc->stack[exc->top-2];
662 if ( operator==0x49 ) {
663 scrprintf(&scr,"Pop: %d (cur point (%.2f,%.2f))", val1,
664 exc->zp1.cur[val1].x/64.0,exc->zp1.cur[val1].y/64.0 );
665 scrprintf(&scr," (in zone from zp1: %s)", exc->GS.gep1?"Normal":"Twilight" );
666 scrprintf(&scr,"Pop: %d (cur point (%.2f,%.2f))", val2,
667 exc->zp0.cur[val2].x/64.0,exc->zp0.cur[val2].y/64.0 );
668 scrprintf(&scr," (in zone from zp0: %s)", exc->GS.gep0?"Normal":"Twilight" );
669 scrprintf(&scr, "projVec: %g,%g", (((int)exc->GS.projVector.x<<16)>>(16+14)) + ((exc->GS.projVector.x&0x3fff)/16384.0),
670 (((int)exc->GS.projVector.y<<16)>>(16+14)) + ((exc->GS.projVector.y&0x3fff)/16384.0) );
671 } else {
672 scrprintf(&scr,"Pop: %d (orig point (%.2f,%.2f))", val1,
673 exc->zp1.org[val1].x/64.0,exc->zp1.org[val1].y/64.0 );
674 scrprintf(&scr," (in zone from zp1: %s)", exc->GS.gep1?"Normal":"Twilight" );
675 scrprintf(&scr,"Pop: %d (orig point (%.2f,%.2f))", val2,
676 exc->zp0.org[val2].x/64.0,exc->zp0.org[val2].y/64.0 );
677 scrprintf(&scr," (in zone from zp0: %s)", exc->GS.gep0?"Normal":"Twilight" );
678 scrprintf(&scr, "dualVec: %g,%g", (((int)exc->GS.dualVector.x<<16)>>(16+14)) + ((exc->GS.dualVector.x&0x3fff)/16384.0),
679 (((int)exc->GS.dualVector.y<<16)>>(16+14)) + ((exc->GS.dualVector.y&0x3fff)/16384.0) );
680 }
681 scrprintf(&scr,"Pushes: distance" );
682 break;
683 case 0x4B:
684 scrprintf(&scr," MPPEM Push Pixels Per Em");
685 scrprintf(&scr,"Pushes: %d", PPEMY(exc)); /* Actually this depends on the projection vector. But if xppem==yppem it will make no difference */
686 break;
687 case 0x4C:
688 scrprintf(&scr," Push Pointsize");
689 scrprintf(&scr,"(one might assume this returns the pointsize, %d", cv->ft_pointsizey);
690 scrprintf(&scr," as it is documented to do, but instead it");
691 scrprintf(&scr," returns ppem)");
692 scrprintf(&scr,"Pushes: %d", PPEMY(exc) );
693 break;
694 case 0x4D: case 0x4E:
695 switch ( operator ) {
696 case 0x4D:
697 scrprintf(&scr," set auto Flip On");
698 break;
699 case 0x4E:
700 scrprintf(&scr," set auto Flip Off");
701 break;
702 }
703 break;
704 case 0x4F:
705 val1 = exc->stack[exc->top-1];
706 scrprintf(&scr," Debug");
707 scrprintf(&scr,"Pops: %d (debug hook)", val1 );
708 break;
709 case 0x58:
710 val1 = exc->stack[exc->top-1];
711 scrprintf(&scr," If");
712 scrprintf(&scr,"Pops: %d (condition)", val1 );
713 break;
714 case 0x5e:
715 scrprintf(&scr," Set Delta Base");
716 val1 = exc->stack[exc->top-1];
717 scrprintf(&scr,"Pops: %d (new delta base)", val1 );
718 break;
719 case 0x5f:
720 scrprintf(&scr," Set Delta Shift");
721 val1 = exc->stack[exc->top-1];
722 scrprintf(&scr,"Pops: %d (new delta shift)", val1 );
723 break;
724 case 0x8B: case 0x8C:
725 case 0x60: case 0x61: case 0x62: case 0x63:
726 case 0x5A: case 0x5B:
727 case 0x55: case 0x54: case 0x53: case 0x52: case 0x51: case 0x50:
728 val2 = exc->stack[exc->top-1];
729 val1 = exc->stack[exc->top-2];
730 switch( operator ) {
731 case 0x50:
732 scrprintf(&scr," Less Than");
733 ret = val1<val2;
734 break;
735 case 0x51:
736 scrprintf(&scr," Less Than Or Equal");
737 ret = val1<=val2;
738 break;
739 case 0x52:
740 scrprintf(&scr," Greater Than");
741 ret = val1>val2;
742 break;
743 case 0x53:
744 scrprintf(&scr," Greater Than or Equal");
745 ret = val1>=val2;
746 break;
747 case 0x54:
748 scrprintf(&scr," Equal");
749 ret = val1==val2;
750 break;
751 case 0x55:
752 scrprintf(&scr," Not Equal");
753 ret = val1!=val2;
754 break;
755 case 0x5A:
756 scrprintf(&scr," And");
757 ret = val1 & val2;
758 break;
759 case 0x5B:
760 scrprintf(&scr," Or");
761 ret = val1 | val2;
762 break;
763 case 0x60:
764 scrprintf(&scr," Add");
765 ret = val1 + val2;
766 break;
767 case 0x61:
768 scrprintf(&scr," Sub");
769 ret = val1 - val2;
770 break;
771 case 0x62:
772 scrprintf(&scr," Divide");
773 if ( val2!=0 )
774 ret = val1*64/val2;
775 else
776 ret = 0x7fffffff;
777 break;
778 case 0x63:
779 scrprintf(&scr," Multiply");
780 ret = val1*val2/64.0;
781 break;
782 case 0x8B:
783 scrprintf(&scr," Max");
784 ret = val1>val2 ? val1 : val2;
785 break;
786 case 0x8C:
787 scrprintf(&scr," Min");
788 ret = val1<val2 ? val1 : val2;
789 break;
790 }
791 scrprintf(&scr,"Pop1: %.2f (%d)", val1/64.0, val1 );
792 scrprintf(&scr,"Pop2: %.2f (%d)", val2/64.0, val2 );
793 scrprintf(&scr,"Pushes: %.2f (%d)", ret/64.0, ret );
794 break;
795 case 0x64: case 0x65: case 0x66: case 0x67:
796 case 0x57: case 0x5C:
797 val2 = val1 = exc->stack[exc->top-1];
798 switch( operator ) {
799 case 0x64:
800 scrprintf(&scr," Absolute Value");
801 if ( val2<0 ) val2 = -val2;
802 break;
803 case 0x65:
804 scrprintf(&scr," Negate");
805 val2 = -val1;
806 break;
807 case 0x66:
808 scrprintf(&scr," Floor");
809 val2 = 64*(val2/64);
810 break;
811 case 0x67:
812 scrprintf(&scr," Ceiling");
813 val2 = 64*((val2+63)/64);
814 break;
815 case 0x5C:
816 scrprintf(&scr," Not");
817 val2 = !val1;
818 break;
819 case 0x56:
820 scrprintf(&scr," Odd (after rounding)");
821 ret = ttround(val1,exc);
822 if ( ret&64 ) ret = 0; else ret = 1;
823 break;
824 case 0x57:
825 scrprintf(&scr," Even (after rounding)");
826 ret = ttround(val1,exc);
827 if ( ret&64 ) ret = 0; else ret = 1;
828 break;
829 }
830 scrprintf(&scr,"Pops: %.2f (%d)", val1/64.0, val1 );
831 scrprintf(&scr,"Pushes: %.2f (%d)", val2/64.0, val2 );
832 break;
833 case 0x68: case 0x69: case 0x6A: case 0x6B:
834 scrprintf(&scr," Round & adjust for engine characteristics" );
835 scrprintf(&scr,(operator&3)==0?" Grey":(operator&3)==1?" Black":(operator&3)==2?" White":" Undefined Rounding");
836 val1 = exc->stack[exc->top-1];
837 scrprintf(&scr,"Pops: %.2f", val1/64.0 );
838 val1 = ttround(val1,exc);
839 scrprintf(&scr,"Pushes: %.2f", val1/64.0 );
840 break;
841 case 0x6C: case 0x6D: case 0x6E: case 0x6F:
842 scrprintf(&scr," Adjust for engine characteristics without rounding" );
843 scrprintf(&scr,(operator&3)==0?" Grey":(operator&3)==1?" Black":(operator&3)==2?" White":" Undefined Rounding");
844 val1 = exc->stack[exc->top-1];
845 scrprintf(&scr,"Pops: %.2f", val1/64.0 );
846 scrprintf(&scr,"Pushes: %.2f", val1/64.0 );
847 break;
848 case 0x5D: case 0x71: case 0x72:
849 base = operator==0x5D?1:operator-0x6F;
850 scrprintf(&scr," Delta Point%d", base );
851 freedom.x = (((int)exc->GS.freeVector.x<<16)>>(16+14)) + ((exc->GS.freeVector.x&0x3fff)/16384.0);
852 freedom.y = (((int)exc->GS.freeVector.y<<16)>>(16+14)) + ((exc->GS.freeVector.y&0x3fff)/16384.0);
853 cnt = exc->stack[exc->top-1];
854 scrprintf(&scr,"Pops: %d (count)", cnt );
855 for ( i=0; i<cnt; ++i ) {
856 if ( 2*i+3 > exc->top ) {
857 scrprintf(&scr,"*** Stack underflow ***");
858 break;
859 }
860 val1 = exc->stack[exc->top-2-2*i];
861 val2 = exc->stack[exc->top-3-2*i];
862 if ( (val2&0xf)<=7 )
863 off = -8+(val2&0xf);
864 else
865 off = -7+(val2&0xf);
866 off *= 64 / (1L << exc->GS.delta_shift);
867 scrprintf(&scr,"Pops: %d (point (%.2f,%.2f))", val1,
868 exc->zp0.cur[val1].x/64.0,exc->zp0.cur[val1].y/64.0 );
869 scrprintf(&scr,"Pops: %d => at %d ppem, move (%.2f,%.2f)",
870 val2, exc->GS.delta_base+(base-1)*16+((val2>>4)&0xf),
871 freedom.x*off/64.0, freedom.y*off/64.0 );
872 }
873 scrprintf(&scr," (in zone from zp0: %s)", exc->GS.gep0?"Normal":"Twilight" );
874 scrprintf(&scr, "DeltaBase: %d", exc->GS.delta_base );
875 scrprintf(&scr, "DeltaShift: %d", exc->GS.delta_shift );
876 scrprintf(&scr, "freeVec: %g,%g", freedom.x, freedom.y);
877 break;
878 case 0x70:
879 scrprintf(&scr," Write CVT entry in Funits" );
880 val2 = exc->stack[exc->top-1];
881 val1 = exc->stack[exc->top-2];
882 scrprintf(&scr,"Pops: %d (em-units=%.2fpixels)", val2,
883 val2*PPEMX(exc)*64.0/
884 (cv->b.sc->parent->ascent+cv->b.sc->parent->descent));
885 scrprintf(&scr,"Pops: %d (cvt index)", val1 );
886 break;
887 case 0x73: case 0x74: case 0x75:
888 base = operator-0x72;
889 scrprintf(&scr," Delta Point%d", base );
890 cnt = exc->stack[exc->top-1];
891 scrprintf(&scr,"Pops: %d (count)", cnt );
892 for ( i=0; i<cnt; ++i ) {
893 if ( 2*cnt+3 > exc->top ) {
894 scrprintf(&scr,"*** Stack underflow ***");
895 break;
896 }
897 val1 = exc->stack[exc->top-2-2*i];
898 val2 = exc->stack[exc->top-3-2*i];
899 if ( (val2&0xf)<=7 )
900 off = -8+(val2&0xf);
901 else
902 off = -7+(val2&0xf);
903 off *= 64 / (1L << exc->GS.delta_shift);
904 scrprintf(&scr,"Pops: %d (cvt index (%d,%.2f))", val1,
905 exc->cvt[val1],exc->cvt[val1]/64.0 );
906 scrprintf(&scr,"Pops: %d => at %d ppem, change by %.2f",
907 val2, exc->GS.delta_base+(base-1)*16+((val2>>4)&0xf),
908 off/64.0 );
909 }
910 scrprintf(&scr, "DeltaBase: %d", exc->GS.delta_base );
911 scrprintf(&scr, "DeltaShift: %d", exc->GS.delta_shift );
912 break;
913 case 0x78: case 0x79:
914 scrprintf(&scr,operator==0x78?" Jump Relative (to here) on True":" Jump Relative (to here) on False");
915 val1 = exc->stack[exc->top-1];
916 val2 = exc->stack[exc->top-2];
917 scrprintf(&scr,"Pops: %d (condition)", val1 );
918 scrprintf(&scr,"Pops: %d (byte offset)", val2 );
919 break;
920 case 0x18: case 0x19:
921 case 0x3D:
922 case 0x76: case 0x77: case 0x7a: case 0x7c: case 0x7d:
923 scrprintf(&scr, operator==0x7a?" set Rounding off":
924 operator==0x7c?" set Rounding up to grid":
925 operator==0x77?" set Rounding to Super 45":
926 operator==0x7d?" set Rounding down to grid":
927 operator==0x18?" set Rounding to grid":
928 operator==0x3D?" set Rounding to double grid":
929 operator==0x19?" set Rounding to half grid":
930 " set Rounding to Super");
931 scrprintf(&scr,"Sets: Rounding state");
932 break;
933 case 0x7e:
934 scrprintf(&scr," Set Angle Weight (obsolete)");
935 scrprintf(&scr,"Pops: an ignored value");
936 break;
937 case 0x7f:
938 scrprintf(&scr," Adjust Angle");
939 scrprintf(&scr,"Pops: %d (point)", exc->stack[exc->top-1]);
940 break;
941 case 0x80:
942 scrprintf(&scr," Flip Points");
943 scrprintf(&scr, "loop: %ld", exc->GS.loop );
944 for ( val1=1; val1<=exc->GS.loop && val1<exc->top; ++val1 ) {
945 val2 = exc->stack[exc->top-val1];
946 scrprintf(&scr,"Pop%d: %d (point (%.2f,%.2f))", val1, val2,
947 exc->zp0.cur[val2].x/64.0,exc->zp0.cur[val2].y/64.0 );
948 scrprintf(&scr," was %s-curve, becomes %s-curve",
949 exc->pts.tags[val2] & FT_CURVE_TAG_ON ? "on" : "off",
950 exc->pts.tags[val2] & FT_CURVE_TAG_ON ? "off" : "on" );
951 }
952 scrprintf(&scr," (in zone from zp0: %s)", exc->GS.gep0?"Normal":"Twilight" );
953 break;
954 case 0x81: case 0x82:
955 val2 = exc->stack[exc->top-1];
956 val1 = exc->stack[exc->top-2];
957 scrprintf(&scr,operator==0x81?" Flip point range On":" Flip point range Off");
958
959 for ( i=val2; i<=val2; ++i ) {
960 scrprintf(&scr," change point %d (%.2f,%.2f)", i,
961 exc->zp0.cur[i].x/64.0,exc->zp0.cur[i].y/64.0 );
962 scrprintf(&scr," was %s-curve, becomes %s-curve",
963 exc->pts.tags[val2] & FT_CURVE_TAG_ON ? "on" : "off",
964 operator==0x82 ? "off" : "on" );
965 }
966 scrprintf(&scr," (in zone from zp0: %s)", exc->GS.gep0?"Normal":"Twilight" );
967 break;
968 case 0x85:
969 scrprintf(&scr," SCANCTRL Set dropout control" );
970 val1 = exc->stack[exc->top-1];
971 scrprintf(&scr,"Pops: %d (flags)",val1 );
972 if ( val1==0 )
973 scrprintf(&scr,"Turn off dropout control");
974 else {
975 if ( val1&0x100 ) {
976 if ( (val1&0xff)==0xff )
977 scrprintf(&scr,"set dropout control for all ppem");
978 else
979 scrprintf(&scr,"set dropout control for ppem <= %d", (val1&0xff));
980 }
981 if ( val1&0x800 ) {
982 if ( (val1&0xff)==0xff )
983 scrprintf(&scr,"<I can't figure this combination out>");
984 else
985 scrprintf(&scr,"unset dropout control unless ppem <= %d", (val1&0xff));
986 }
987 if ( val1&0x200 )
988 scrprintf(&scr,"set dropout control if glyph rotated");
989 if ( val1&0x1000 )
990 scrprintf(&scr,"unset dropout control unless glyph rotated");
991 if ( val1&0x400 )
992 scrprintf(&scr,"set dropout control if glyph stretched");
993 if ( val1&0x2000 )
994 scrprintf(&scr,"unset dropout control unless glyph stretched");
995 }
996 break;
997 case 0x06: case 0x07:
998 case 0x08: case 0x09:
999 case 0x86: case 0x87:
1000 scrprintf(&scr,operator<0x8?" Sets projection vector from line":
1001 operator<0x86?" Sets freedom vector from line":
1002 " Set dual projection vector from line");
1003 scrprintf(&scr,(operator&1)?"orthogonal to line":"parallel to line");
1004 val1 = exc->stack[exc->top-2];
1005 val2 = exc->stack[exc->top-1];
1006 scrprintf(&scr,"Pops: %d (point (%.2f,%.2f))", val1,
1007 exc->zp1.cur[val1].x/64.0,exc->zp1.cur[val1].y/64.0 );
1008 scrprintf(&scr," (in zone from zp1: %s)", exc->GS.gep1?"Normal":"Twilight" );
1009 scrprintf(&scr,"Pops: %d (point (%.2f,%.2f))", val2,
1010 exc->zp2.cur[val2].x/64.0,exc->zp2.cur[val2].y/64.0 );
1011 scrprintf(&scr," (in zone from zp2: %s)", exc->GS.gep2?"Normal":"Twilight" );
1012 if ( operator>=0x86 ) {
1013 scrprintf(&scr,"Sets: Project vector based on current positions" );
1014 scrprintf(&scr,"Sets: Dual proj vector based on original positions" );
1015 } else
1016 scrprintf(&scr,"Sets: %s vector", operator<8?"Projection":"Freedom" );
1017 break;
1018 case 0x88:
1019 val1 = exc->stack[exc->top-1];
1020 scrprintf(&scr," Get Information");
1021 scrprintf(&scr, "Pops: %d %s%s%s%s%s%s%s%s%s%s", val1,
1022 val1&(1<<0) ? "version (result in bits 0-7) " : "",
1023 val1&(1<<1) ? "rotated (result in bit 8)" : "",
1024 val1&(1<<2) ? "stretched (result in bit 9)" : "",
1025 val1&(1<<3) ? "Undocumented Apple ?variations? (result in bit 10)" : "",
1026 val1&(1<<4) ? "Undocumented Apple ?vertical metrics? (result in bit 11)" : "",
1027 val1&(1<<5) ? "greyscale (result in bit 12)" : "",
1028 val1&(1<<6) ? "ClearType (result in bit 13)" : "",
1029 val1&(1<<7) ? "CT widths compat (result in bit 14)" : "",
1030 val1&(1<<8) ? "CT symmetrical smoothing (result in bit 15)" : "",
1031 val1&(1<<9) ? "CT processes in BGR(1) or RGB(0) (result in bit 16)" : "");
1032 if ( val1&1 ) {
1033 scrprintf(&scr, " Versions: 1 => Mac OS 6" );
1034 scrprintf(&scr, " 2 => Mac OS 7" );
1035 scrprintf(&scr, " 3 => Win 3.1" );
1036 scrprintf(&scr, " 33=> Win rasterizer 1.5" );
1037 scrprintf(&scr, " 34=> Win rasterizer 1.6" );
1038 scrprintf(&scr, " 35=> Win rasterizer 1.7" );
1039 scrprintf(&scr, " 37=> Win rasterizer 1.8" );
1040 scrprintf(&scr, " 38=> Win rasterizer 1.9" );
1041 }
1042 scrprintf(&scr,"Pushes: result");
1043 scrprintf(&scr,"FreeType returns: %s%s%s%s",
1044 (val1&1) ? "(Win 1.7) | ": "",
1045 (val1&2) ? exc->tt_metrics.rotated ? "(rotated) | ": "(not rotated) | " : "",
1046 (val1&4) ? exc->tt_metrics.stretched ? "(stretched) | ": "(not stretched) | " : "",
1047 (val1&32) ? exc->grayscale ? "(grey scale)": "(black/white)" : ""
1048 );
1049 break;
1050 case 0x89:
1051 scrprintf(&scr," Instruction Definition");
1052 val1 = exc->stack[exc->top-1];
1053 scrprintf(&scr,"Pops: %d (opcode)", val1 );
1054 break;
1055 case 0x8a:
1056 scrprintf(&scr," Roll top three stack elements");
1057 break;
1058 case 0x8D:
1059 scrprintf(&scr," SCANTYPE Set dropout control" );
1060 val1 = exc->stack[exc->top-1];
1061 scrprintf(&scr,"Pops: %d (mode)",val1 );
1062 if ( val1==0 )
1063 scrprintf(&scr,"simple dropout control scan conversion including stubs (rules 1,2,3)");
1064 else if ( val1==1 )
1065 scrprintf(&scr,"simple dropout control scan conversion excluding stubs (rules 1,2,4)");
1066 else if ( val1==2 || val1==3 || val1==6 || val1==7 )
1067 scrprintf(&scr,"fast scan conversion; dropout control turned off (rule 1,2)");
1068 else if ( val1==4 )
1069 scrprintf(&scr,"smart dropout control scan conversion including stubs (rule 1,2,5)");
1070 else if ( val1==5 )
1071 scrprintf(&scr,"smart dropout control scan conversion excluding stubs (rule 1,2,6)");
1072 else
1073 scrprintf(&scr,"*** Unknown mode ***");
1074 break;
1075 case 0x8E:
1076 val2 = exc->stack[exc->top-1];
1077 val1 = exc->stack[exc->top-2];
1078 scrprintf(&scr," Instruction Control");
1079 scrprintf(&scr,"Pops: %d (selector)", val1 );
1080 scrprintf(&scr,"Pops: %d (value)", val1 );
1081 if ( val1==1 )
1082 scrprintf(&scr, " => grid fitting %s", val2 ? "inhibited" : "normal" );
1083 else if ( val1==2 )
1084 scrprintf(&scr, " => cvt parameters %s", val2 ? "ignored" : "normal" );
1085 else
1086 scrprintf(&scr, "Unknown selector");
1087 break;
1088 }
1089 return( scr.lines );
1090 }
1091
1092 static void dvgloss_scroll(DebugView *dv,struct sbevent *sb) {
1093 int newpos = dv->cvt_offtop;
1094 GRect size;
1095 int min, max, page;
1096 extern int _GScrollBar_Width;
1097
1098 GScrollBarGetBounds(dv->glosssb,&min,&max,&page);
1099 GDrawGetSize(dv->gloss,&size);
1100 switch( sb->type ) {
1101 case et_sb_top:
1102 newpos = 0;
1103 break;
1104 case et_sb_uppage:
1105 newpos -= size.height/dv->ii.fh;
1106 break;
1107 case et_sb_up:
1108 --newpos;
1109 break;
1110 case et_sb_down:
1111 ++newpos;
1112 break;
1113 case et_sb_downpage:
1114 newpos += size.height/dv->ii.fh;
1115 break;
1116 case et_sb_bottom:
1117 newpos = max-size.height/dv->ii.fh;
1118 break;
1119 case et_sb_thumb:
1120 case et_sb_thumbrelease:
1121 newpos = sb->pos;
1122 break;
1123 case et_sb_halfup: case et_sb_halfdown: break;
1124 }
1125 if ( newpos>max-size.height/dv->ii.fh )
1126 newpos = max-size.height/dv->ii.fh;
1127 if ( newpos<0 ) newpos =0;
1128 if ( newpos!=dv->gloss_offtop ) {
1129 int diff = newpos-dv->gloss_offtop;
1130 dv->gloss_offtop = newpos;
1131 GScrollBarSetPos(dv->glosssb,dv->gloss_offtop);
1132 size.x = size.y = 0;
1133 size.width -= GDrawPointsToPixels(dv->gloss,_GScrollBar_Width);
1134 GDrawScroll(dv->gloss,&size,0,diff*dv->ii.fh);
1135 }
1136 }
1137
1138 static void DVGlossExposeSize(GWindow gw,DebugView *dv,GEvent *event) {
1139 int len = DVGlossExpose(gw,dv,event);
1140 GRect size;
1141 int min, max, page, offtop;
1142
1143 GScrollBarGetBounds(dv->glosssb,&min,&max,&page);
1144 GGadgetGetSize(dv->glosssb,&size);
1145 size.height /= dv->ii.fh;
1146
1147 if ( len!=max || page!=size.height ) {
1148 GScrollBarSetBounds(dv->glosssb,0,len,size.height);
1149 offtop = dv->gloss_offtop;
1150 if ( offtop+size.height > len )
1151 offtop = len-size.height;
1152 if ( offtop < 0 )
1153 offtop = 0;
1154 if ( offtop!=dv->gloss_offtop ) {
1155 dv->gloss_offtop = offtop;
1156 GScrollBarSetPos(dv->glosssb,dv->gloss_offtop);
1157 DVGlossExpose(gw,dv,event);
1158 }
1159 }
1160 }
1161
1162 static int dvgloss_e_h(GWindow gw, GEvent *event) {
1163 DebugView *dv = (DebugView *) GDrawGetUserData(gw);
1164 GRect r,g;
1165 extern int debug_wins;
1166
1167 if ( dv==NULL )
1168 return( true );
1169
1170 switch ( event->type ) {
1171 case et_expose:
1172 DVGlossExposeSize(gw,dv,event);
1173 break;
1174 case et_char:
1175 return( DVChar(dv,event));
1176 break;
1177 case et_controlevent:
1178 switch ( event->u.control.subtype ) {
1179 case et_scrollbarchange:
1180 dvgloss_scroll(dv,&event->u.control.u.sb);
1181 break;
1182 default: break;
1183 }
1184 break;
1185 case et_resize:
1186 GDrawGetSize(gw,&r);
1187 GGadgetGetSize(dv->glosssb,&g);
1188 GGadgetMove(dv->glosssb,r.width-g.width,0);
1189 GGadgetResize(dv->glosssb,g.width,r.height);
1190 GDrawRequestExpose(dv->gloss,NULL,false);
1191 break;
1192 case et_close:
1193 GDrawDestroyWindow(dv->gloss);
1194 debug_wins &= ~dw_gloss;
1195 break;
1196 case et_destroy:
1197 dv->gloss = NULL;
1198 break;
1199 case et_mouseup: case et_mousedown:
1200 case et_mousemove:
1201 GGadgetEndPopup();
1202 break;
1203 default: break;
1204 }
1205 return( true );
1206 }
1207
1208 void DVCreateGloss(DebugView *dv) {
1209 GWindowAttrs wattrs;
1210 GRect pos;
1211 GGadgetData gd;
1212 extern int _GScrollBar_Width;
1213
1214 memset(&wattrs,0,sizeof(wattrs));
1215 wattrs.mask = wam_events|wam_cursor|wam_utf8_wtitle;
1216 wattrs.event_masks = -1;
1217 wattrs.cursor = ct_mypointer;
1218 wattrs.utf8_window_title = _("Instruction Gloss (TrueType)");
1219 pos.width = GGadgetScale(GDrawPointsToPixels(NULL,230)); pos.height = 169;
1220 pos.x = CVXPos(dv,143,pos.width); pos.y = 302;
1221 dv->gloss = GDrawCreateTopWindow(NULL,&pos,dvgloss_e_h,dv,&wattrs);
1222
1223 memset(&gd,0,sizeof(gd));
1224
1225 gd.pos.y = 0; gd.pos.height = pos.height;
1226 gd.pos.width = GDrawPointsToPixels(dv->gloss,_GScrollBar_Width);
1227 gd.pos.x = pos.width-gd.pos.width;
1228 gd.flags = gg_visible|gg_enabled|gg_pos_in_pixels|gg_sb_vert;
1229 dv->glosssb = GScrollBarCreate(dv->gloss,&gd,dv);
1230
1231 GDrawSetVisible(dv->gloss,true);
1232 }
1233
1234 /* ************************************************************************** */
1235 /* Variant of the gloss window: Mark the points to show what the next */
1236 /* instruction will do to them. (Change (usually move) them, or use them */
1237 /* or ignore them */
1238 /* ************************************************************************** */
1239
1240 static SplinePoint *FindPoint(SplineSet *ss,int ptnum) {
1241 SplineSet *spl;
1242 SplinePoint *sp;
1243
1244 for ( spl=ss; spl!=NULL ; spl=spl->next ) {
1245 for ( sp = spl->first; ; ) {
1246 if ( sp->ttfindex==ptnum || sp->nextcpindex==ptnum )
1247 return( sp );
1248 if ( sp->next==NULL )
1249 break;
1250 sp = sp->next->to;
1251 if ( sp==spl->first )
1252 break;
1253 }
1254 }
1255 return( NULL );
1256 }
1257
1258 static void SetBasisPoint(SplineSet *ss, int ptnum) {
1259 SplinePoint *sp = FindPoint(ss,ptnum);
1260 if ( sp==NULL )
1261 return;
1262 /* A roundx point or flexx nextcp means this is the reference */
1263 /* point, etc. */
1264 if ( sp->ttfindex==ptnum )
1265 sp->roundx = true;
1266 else
1267 sp->flexx = true;
1268 }
1269
1270 static void SetChangingPoint(SplineSet *ss, int ptnum) {
1271 SplinePoint *sp = FindPoint(ss,ptnum);
1272 if ( sp==NULL )
1273 return;
1274 /* I reuse these flags. A "selected" point is one which will be */
1275 /* moved by the instruction. A "flexy"ed point means its nextcp */
1276 /* will be moved by the next instruction */
1277 if ( sp->ttfindex==ptnum )
1278 sp->selected = true;
1279 else
1280 sp->flexy = true;
1281 }
1282
1283 void DVMarkPts(DebugView *dv,SplineSet *ss) {
1284 TT_ExecContext exc = DebuggerGetEContext(dv->dc);
1285 long changing_point, basis_point;
1286 int i,cnt,top;
1287 int operator;
1288 SplineSet *spl;
1289 SplinePoint *sp;
1290
1291 for ( spl=ss; spl!=NULL ; spl=spl->next ) {
1292 for ( sp = spl->first; ; ) {
1293 sp->selected = false;
1294 sp->roundx = sp->roundy = false;
1295 sp->flexx = sp->flexy = false;
1296 /* I reuse these flags. A "selected" point is one which will be */
1297 /* moved by the instruction. A "flexy"ed point means its nextcp */
1298 /* will be moved by the next instruction */
1299 /* A roundx point or flexx nextcp means this is the reference */
1300 /* point, etc. */
1301 if ( sp->next==NULL )
1302 break;
1303 sp = sp->next->to;
1304 if ( sp==spl->first )
1305 break;
1306 }
1307 }
1308
1309 if ( exc==NULL )
1310 return; /* Not running */
1311 if ( exc->IP>=exc->codeSize || exc->code==NULL )
1312 return; /* At end */
1313
1314 operator = ((uint8_t *) exc->code)[exc->IP];
1315 changing_point = -1;
1316 basis_point = -1;
1317
1318 if ( operator>=0xc0 && operator <= 0xdf ) {
1319 /* MDRP */
1320 if ( exc->GS.gep1 ) /* No good way to mark twilight points, so only mark normal ones */
1321 changing_point = exc->stack[exc->top-1];
1322 if ( exc->GS.gep0 )
1323 basis_point = exc->GS.rp0;
1324 } else if ( operator>=0xe0 && operator <= 0xff ) {
1325 /* MIRP */
1326 if ( exc->GS.gep1 ) /* No good way to mark twilight points, so only mark normal ones */
1327 changing_point = exc->stack[exc->top-2];
1328 if ( exc->GS.gep0 )
1329 basis_point = exc->GS.rp0;
1330 } else if ( operator>=0xb0 && operator <= 0xbf ) {
1331 /* Push */
1332 } else switch ( operator ) {
1333 case 0xf:
1334 /* Moves point to intersection of two lines */
1335 if ( exc->GS.gep2 ) /* No good way to mark twilight points, so only mark normal ones */
1336 changing_point = exc->stack[exc->top-5];
1337 if ( exc->GS.gep0 ) {
1338 SetBasisPoint(ss,exc->stack[exc->top-4]);
1339 SetBasisPoint(ss,exc->stack[exc->top-3]);
1340 }
1341 if ( exc->GS.gep1 ) {
1342 SetBasisPoint(ss,exc->stack[exc->top-2]);
1343 SetBasisPoint(ss,exc->stack[exc->top-1]);
1344 }
1345 break;
1346 case 0x10: case 0x11: case 0x12:
1347 /* Set Reference Point ? */
1348 basis_point = exc->stack[exc->top-1];
1349 break;
1350 case 0x27:
1351 /* Align Points */
1352 if ( exc->GS.gep0 )
1353 SetChangingPoint(ss,exc->stack[exc->top-1]);
1354 if ( exc->GS.gep1 )
1355 SetChangingPoint(ss,exc->stack[exc->top-2]);
1356 break;
1357 case 0x28:
1358 /* Untouch point */
1359 if ( exc->GS.gep0 )
1360 changing_point = exc->stack[exc->top-1];
1361 break;
1362 case 0x2E:
1363 /* Touch point */
1364 if ( exc->GS.gep0 )
1365 changing_point = exc->stack[exc->top-1];
1366 break;
1367 case 0x2F:
1368 /* Round and Touch point */
1369 if ( exc->GS.gep0 )
1370 changing_point = exc->stack[exc->top-1];
1371 break;
1372 case 0x30:
1373 /* Interpolate Untouched Points in y */
1374 if ( exc->GS.gep2 ) {
1375 TT_GlyphZoneRec *r = &exc->pts;
1376 for ( spl=ss; spl!=NULL ; spl=spl->next ) {
1377 for ( sp = spl->first; ; ) {
1378 if ( sp->ttfindex<r->n_points &&
1379 !(r->tags[sp->ttfindex]&FT_Curve_Tag_Touch_Y) )
1380 sp->selected = true;
1381 if ( sp->nextcpindex<r->n_points &&
1382 !(r->tags[sp->nextcpindex]&FT_Curve_Tag_Touch_Y) )
1383 sp->flexy = true;
1384 /* I reuse these flags. A "selected" point is one which will be */
1385 /* moved by the instruction. A "flexy"ed point means its nextcp */
1386 /* will be moved by the next instruction */
1387 if ( sp->next==NULL )
1388 break;
1389 sp = sp->next->to;
1390 if ( sp==spl->first )
1391 break;
1392 }
1393 }
1394 }
1395 break;
1396 case 0x31:
1397 /* Interpolate Untouched Points in x */
1398 if ( exc->GS.gep2 ) {
1399 TT_GlyphZoneRec *r = &exc->pts;
1400 for ( spl=ss; spl!=NULL ; spl=spl->next ) {
1401 for ( sp = spl->first; ; ) {
1402 if ( sp->ttfindex<r->n_points &&
1403 !(r->tags[sp->ttfindex]&FT_Curve_Tag_Touch_X) )
1404 sp->selected = true;
1405 if ( sp->nextcpindex<r->n_points &&
1406 !(r->tags[sp->nextcpindex]&FT_Curve_Tag_Touch_X) )
1407 sp->flexy = true;
1408 /* I reuse these flags. A "selected" point is one which will be */
1409 /* moved by the instruction. A "flexy"ed point means its nextcp */
1410 /* will be moved by the next instruction */
1411 if ( sp->next==NULL )
1412 break;
1413 sp = sp->next->to;
1414 if ( sp==spl->first )
1415 break;
1416 }
1417 }
1418 }
1419 break;
1420 case 0x32: case 0x33:
1421 /* Shift point by amount ref point shifted */
1422 if ( operator==0x33 ) {
1423 if ( exc->GS.gep0 )
1424 basis_point = exc->GS.rp1;
1425 } else {
1426 if ( exc->GS.gep1 )
1427 basis_point = exc->GS.rp2;
1428 }
1429 if ( exc->GS.gep2 )
1430 for ( i=1; i<=exc->GS.loop && i<exc->top; ++i ) {
1431 SetChangingPoint(ss,exc->stack[exc->top-i]);
1432 }
1433 break;
1434 case 0x34: case 0x35:
1435 /* Shift contour by amount ref point shifted */
1436 if ( operator==0x35 ) {
1437 if ( exc->GS.gep0 )
1438 basis_point = exc->stack[exc->GS.rp1];
1439 } else {
1440 if ( exc->GS.gep1 )
1441 basis_point = exc->stack[exc->GS.rp2];
1442 }
1443 if ( exc->GS.gep2 ) {
1444 for ( spl=ss, i=exc->stack[exc->top-1]; i>0 && spl!=NULL; --i, spl=spl->next );
1445 if ( spl!=NULL ) {
1446 for ( sp = spl->first; ; ) {
1447 if ( sp->ttfindex<0xfff0 )
1448 sp->selected = true;
1449 if ( sp->nextcpindex<0xfff0 )
1450 sp->flexy = true;
1451 /* I reuse these flags. A "selected" point is one which will be */
1452 /* moved by the instruction. A "flexy"ed point means its nextcp */
1453 /* will be moved by the next instruction */
1454 if ( sp->next==NULL )
1455 break;
1456 sp = sp->next->to;
1457 if ( sp==spl->first )
1458 break;
1459 }
1460 }
1461 }
1462 break;
1463 case 0x36: case 0x37:
1464 if ( operator==0x37 ) {
1465 if ( exc->GS.gep0 )
1466 basis_point = exc->stack[exc->GS.rp1];
1467 } else {
1468 if ( exc->GS.gep1 )
1469 basis_point = exc->stack[exc->GS.rp2];
1470 }
1471 if ( exc->stack[exc->top-1] ) {
1472 for ( spl=ss; spl!=NULL; spl=spl->next ) {
1473 for ( sp = spl->first; ; ) {
1474 if ( sp->ttfindex<0xfff0 )
1475 sp->selected = true;
1476 if ( sp->nextcpindex<0xfff0 )
1477 sp->flexy = true;
1478 /* I reuse these flags. A "selected" point is one which will be */
1479 /* moved by the instruction. A "flexy"ed point means its nextcp */
1480 /* will be moved by the next instruction */
1481 if ( sp->next==NULL )
1482 break;
1483 sp = sp->next->to;
1484 if ( sp==spl->first )
1485 break;
1486 }
1487 }
1488 }
1489 break;
1490 case 0x38:
1491 /* Shift point by pixel amount */
1492 if ( exc->GS.gep2 ) {
1493 for ( i=2; i<=exc->GS.loop+1 && i<exc->top; ++i )
1494 SetChangingPoint(ss,exc->stack[exc->top-i]);
1495 }
1496 break;
1497 case 0x39:
1498 /* Interpolated Point */
1499 if ( exc->GS.gep0 )
1500 SetBasisPoint(ss,exc->GS.rp1);
1501 if ( exc->GS.gep1 )
1502 SetBasisPoint(ss,exc->GS.rp2);
1503 if ( exc->GS.gep2 ) {
1504 for ( i=1; i<=exc->GS.loop+1 && i<exc->top; ++i )
1505 SetChangingPoint(ss,exc->stack[exc->top-i]);
1506 }
1507 break;
1508 case 0x3A: case 0x3B:
1509 /* MSIRP Move Stack Indirect Relative Point */
1510 if ( exc->GS.gep1 )
1511 changing_point = exc->stack[exc->top-2];
1512 if ( exc->GS.gep0 )
1513 basis_point = exc->GS.rp0;
1514 break;
1515 case 0x3C:
1516 /* Align to Reference Point */
1517 if ( exc->GS.gep0 )
1518 basis_point = exc->GS.rp0;
1519 if ( exc->GS.gep1 )
1520 for ( i=1; i<=exc->GS.loop && i<exc->top; ++i ) {
1521 SetChangingPoint(ss,exc->stack[exc->top-i]);
1522 }
1523 break;
1524 case 0x3E: case 0x3F:
1525 /* MIAP Move Indirect Absolute Point */
1526 if ( exc->GS.gep0 )
1527 changing_point = exc->stack[exc->top-2];
1528 break;
1529 case 0x46: case 0x47:
1530 /* Get current/original point coord projected on projection vector */
1531 if ( exc->GS.gep2 )
1532 basis_point = exc->stack[exc->top-1];
1533 break;
1534 case 0x48:
1535 /* Sets coordinate from stack using proj & free vectors */
1536 if ( exc->GS.gep2 )
1537 changing_point = exc->stack[exc->top-2];
1538 break;
1539 case 0x49: case 0x4A:
1540 /* Measure Distance */
1541 if ( exc->GS.gep0 )
1542 SetBasisPoint( ss, exc->stack[exc->top-1] );
1543 if ( exc->GS.gep1 )
1544 SetBasisPoint( ss, exc->stack[exc->top-2] );
1545 break;
1546 case 0x5D: case 0x71: case 0x72:
1547 case 0x73: case 0x74: case 0x75:
1548 /* Delta Point */
1549 cnt = exc->stack[exc->top-1];
1550 for ( i=0; i<cnt; ++i ) {
1551 if ( 2*i+3 > exc->top )
1552 break;
1553 if ( exc->GS.gep0 )
1554 SetChangingPoint(ss, exc->stack[exc->top-2-2*i]);
1555 }
1556 break;
1557 case 0x80:
1558 /* Flip Points */
1559 if ( exc->GS.gep0 )
1560 for ( i=1; i<=exc->GS.loop && i<exc->top; ++i ) {
1561 SetChangingPoint(ss,exc->stack[exc->top-i]);
1562 }
1563 break;
1564 case 0x81: case 0x82:
1565 i = exc->stack[exc->top-1];
1566 top = exc->stack[exc->top-2];
1567 if ( exc->GS.gep0 )
1568 for ( ; i<=top; ++i ) {
1569 SetChangingPoint(ss,exc->stack[exc->top-i]);
1570 }
1571 break;
1572 case 0x06: case 0x07:
1573 case 0x08: case 0x09:
1574 case 0x86: case 0x87:
1575 /* Sets vector from line */
1576 if ( exc->GS.gep1 )
1577 SetBasisPoint(ss,exc->stack[exc->top-2]);
1578 if ( exc->GS.gep2 )
1579 SetBasisPoint(ss,exc->stack[exc->top-1]);
1580 break;
1581 default:
1582 /* Many instructions don't refer to points */
1583 break;
1584 }
1585 if ( changing_point!=-1 )
1586 SetChangingPoint(ss,changing_point);
1587 if ( basis_point!=-1 )
1588 SetBasisPoint(ss,basis_point);
1589 }
1590
1591 #else
1592 void DVCreateGloss(DebugView *dv) {
1593 }
1594
1595 void DVMarkPts(DebugView *dv,SplineSet *ss) {
1596 }
1597 #endif /* Has Debugger */