... |
... |
@@ -85,8 +85,8 @@ |
85
|
85
|
static grSurface* surface; /* current display surface */
|
86
|
86
|
static grBitmap* bit; /* current display bitmap */
|
87
|
87
|
|
88
|
|
- static int width = DIM_X; /* window width */
|
89
|
|
- static int height = DIM_Y; /* window height */
|
|
88
|
+ static unsigned short width = DIM_X; /* window width */
|
|
89
|
+ static unsigned short height = DIM_Y; /* window height */
|
90
|
90
|
|
91
|
91
|
static int num_glyphs; /* number of glyphs */
|
92
|
92
|
static int ptsize; /* current point size */
|
... |
... |
@@ -94,6 +94,7 @@ |
94
|
94
|
static int hinted = 1; /* is glyph hinting active? */
|
95
|
95
|
static int grouping = 1; /* is axis grouping active? */
|
96
|
96
|
static int antialias = 1; /* is anti-aliasing active? */
|
|
97
|
+ static int fillrule = 0x0; /* flip fill flags or not? */
|
97
|
98
|
static int overlaps = 0x0; /* flip overlap flags or not? */
|
98
|
99
|
static int Num; /* current first glyph index */
|
99
|
100
|
|
... |
... |
@@ -291,7 +292,8 @@ |
291
|
292
|
static void
|
292
|
293
|
Init_Display( void )
|
293
|
294
|
{
|
294
|
|
- grBitmap bitmap = { height, width, 0, gr_pixel_mode_none, 256, NULL };
|
|
295
|
+ grBitmap bitmap = { (int)height, (int)width, 0,
|
|
296
|
+ gr_pixel_mode_none, 256, NULL };
|
295
|
297
|
|
296
|
298
|
|
297
|
299
|
grInitDevices();
|
... |
... |
@@ -319,8 +321,9 @@ |
319
|
321
|
if ( glyph->format != FT_GLYPH_FORMAT_BITMAP )
|
320
|
322
|
{
|
321
|
323
|
/* overlap flags mitigate AA rendering artifacts in overlaps */
|
322
|
|
- /* by oversampling, toggle the flag to test the effect */
|
323
|
|
- glyph->outline.flags ^= overlaps;
|
|
324
|
+ /* by oversampling; even-odd fill rule reveals the overlaps; */
|
|
325
|
+ /* toggle these flag to test the effects */
|
|
326
|
+ glyph->outline.flags ^= overlaps | fillrule;
|
324
|
327
|
|
325
|
328
|
error = FT_Render_Glyph( glyph, antialias ? FT_RENDER_MODE_NORMAL
|
326
|
329
|
: FT_RENDER_MODE_MONO );
|
... |
... |
@@ -370,11 +373,9 @@ |
370
|
373
|
LoadChar( unsigned int idx,
|
371
|
374
|
int hint )
|
372
|
375
|
{
|
373
|
|
- int flags;
|
|
376
|
+ int flags = FT_LOAD_NO_BITMAP;
|
374
|
377
|
|
375
|
378
|
|
376
|
|
- flags = FT_LOAD_NO_BITMAP;
|
377
|
|
-
|
378
|
379
|
if ( !hint )
|
379
|
380
|
flags |= FT_LOAD_NO_HINTING;
|
380
|
381
|
|
... |
... |
@@ -383,27 +384,20 @@ |
383
|
384
|
|
384
|
385
|
|
385
|
386
|
static FT_Error
|
386
|
|
- Render_All( unsigned int first_glyph,
|
387
|
|
- int pt_size )
|
|
387
|
+ Render_All( int first_glyph )
|
388
|
388
|
{
|
389
|
|
- int start_x, start_y, step_y, x, y, w;
|
390
|
|
- unsigned int i;
|
391
|
|
-
|
|
389
|
+ int start_x = 18 * 8;
|
|
390
|
+ int start_y = size->metrics.y_ppem * 4 / 5 + HEADER_HEIGHT * 3;
|
|
391
|
+ int step_y = size->metrics.y_ppem + 10;
|
|
392
|
+ int x, y, w, i;
|
392
|
393
|
|
393
|
|
- start_x = 18 * 8;
|
394
|
|
- start_y = size->metrics.y_ppem * 4 / 5 + HEADER_HEIGHT * 3;
|
395
|
|
- step_y = size->metrics.y_ppem + 10;
|
396
|
394
|
|
397
|
395
|
x = start_x;
|
398
|
396
|
y = start_y;
|
399
|
397
|
|
400
|
398
|
i = first_glyph;
|
401
|
399
|
|
402
|
|
-#if 0
|
403
|
|
- while ( i < first_glyph + 1 )
|
404
|
|
-#else
|
405
|
|
- while ( i < (unsigned int)num_glyphs )
|
406
|
|
-#endif
|
|
400
|
+ while ( i < num_glyphs )
|
407
|
401
|
{
|
408
|
402
|
if ( !( error = LoadChar( i, hinted ) ) )
|
409
|
403
|
{
|
... |
... |
@@ -444,19 +438,16 @@ |
444
|
438
|
|
445
|
439
|
|
446
|
440
|
static FT_Error
|
447
|
|
- Render_Text( unsigned int first_glyph,
|
448
|
|
- int pt_size )
|
|
441
|
+ Render_Text( int first_glyph )
|
449
|
442
|
{
|
450
|
|
- FT_F26Dot6 start_x, start_y, step_y, x, y;
|
451
|
|
- unsigned int i;
|
|
443
|
+ int start_x = 18 * 8;
|
|
444
|
+ int start_y = size->metrics.y_ppem * 4 / 5 + HEADER_HEIGHT * 3;
|
|
445
|
+ int step_y = size->metrics.y_ppem + 10;
|
|
446
|
+ int x, y, i;
|
452
|
447
|
|
453
|
448
|
const unsigned char* p;
|
454
|
449
|
|
455
|
450
|
|
456
|
|
- start_x = 18 * 8;
|
457
|
|
- start_y = size->metrics.y_ppem * 4 / 5 + HEADER_HEIGHT * 3;
|
458
|
|
- step_y = size->metrics.y_ppem + 10;
|
459
|
|
-
|
460
|
451
|
x = start_x;
|
461
|
452
|
y = start_y;
|
462
|
453
|
|
... |
... |
@@ -551,13 +542,15 @@ |
551
|
542
|
grLn();
|
552
|
543
|
grWriteln( "F1, ? display this help screen" );
|
553
|
544
|
grWriteln( "q, ESC quit ftmulti" );
|
|
545
|
+ grLn();
|
554
|
546
|
grWriteln( "F2 toggle axis grouping" );
|
555
|
|
- grWriteln( "F3 toggle outline hinting" );
|
|
547
|
+ grWriteln( "F3 toggle fill rule flags" );
|
556
|
548
|
grWriteln( "F4 toggle overlap flags" );
|
557
|
|
- grWriteln( "F5 toggle anti-aliasing" );
|
|
549
|
+ grWriteln( "F5 toggle outline hinting" );
|
558
|
550
|
grWriteln( "F6 cycle through hinting engines (if available)" );
|
559
|
551
|
grLn();
|
560
|
|
- grWriteln( "space toggle rendering mode" );
|
|
552
|
+ grWriteln( "Tab toggle anti-aliasing" );
|
|
553
|
+ grWriteln( "Space toggle rendering mode" );
|
561
|
554
|
grLn();
|
562
|
555
|
grWriteln( ", . previous/next font" );
|
563
|
556
|
grLn();
|
... |
... |
@@ -624,6 +617,10 @@ |
624
|
617
|
Help();
|
625
|
618
|
break;
|
626
|
619
|
|
|
620
|
+ case grKEY( ',' ):
|
|
621
|
+ case grKEY( '.' ):
|
|
622
|
+ return (int)event.key;
|
|
623
|
+
|
627
|
624
|
/* mode keys */
|
628
|
625
|
|
629
|
626
|
case grKeyF2:
|
... |
... |
@@ -633,10 +630,11 @@ |
633
|
630
|
set_up_axes();
|
634
|
631
|
break;
|
635
|
632
|
|
636
|
|
- case grKeyF5:
|
637
|
|
- antialias = !antialias;
|
638
|
|
- new_header = antialias ? "anti-aliasing is now on"
|
639
|
|
- : "anti-aliasing is now off";
|
|
633
|
+ case grKeyF3:
|
|
634
|
+ fillrule ^= FT_OUTLINE_EVEN_ODD_FILL;
|
|
635
|
+ new_header = fillrule
|
|
636
|
+ ? "fill rule flags are flipped"
|
|
637
|
+ : "fill rule flags are unchanged";
|
640
|
638
|
break;
|
641
|
639
|
|
642
|
640
|
case grKeyF4:
|
... |
... |
@@ -646,22 +644,12 @@ |
646
|
644
|
: "overlap flags are unchanged";
|
647
|
645
|
break;
|
648
|
646
|
|
649
|
|
- case grKEY( ',' ):
|
650
|
|
- case grKEY( '.' ):
|
651
|
|
- return (int)event.key;
|
652
|
|
-
|
653
|
|
- case grKeyF3:
|
|
647
|
+ case grKeyF5:
|
654
|
648
|
hinted = !hinted;
|
655
|
649
|
new_header = hinted ? "glyph hinting is now active"
|
656
|
650
|
: "glyph hinting is now ignored";
|
657
|
651
|
break;
|
658
|
652
|
|
659
|
|
- case grKEY( ' ' ):
|
660
|
|
- render_mode ^= 1;
|
661
|
|
- new_header = render_mode ? "rendering all glyphs in font"
|
662
|
|
- : "rendering test text string";
|
663
|
|
- break;
|
664
|
|
-
|
665
|
653
|
case grKeyF6:
|
666
|
654
|
if ( !strcmp( font_format, "CFF" ) )
|
667
|
655
|
FTDemo_Event_Cff_Hinting_Engine_Change( library,
|
... |
... |
@@ -679,6 +667,18 @@ |
679
|
667
|
tt_interpreter_version_change();
|
680
|
668
|
break;
|
681
|
669
|
|
|
670
|
+ case grKeyTab:
|
|
671
|
+ antialias = !antialias;
|
|
672
|
+ new_header = antialias ? "anti-aliasing is now on"
|
|
673
|
+ : "anti-aliasing is now off";
|
|
674
|
+ break;
|
|
675
|
+
|
|
676
|
+ case grKEY( ' ' ):
|
|
677
|
+ render_mode ^= 1;
|
|
678
|
+ new_header = render_mode ? "rendering all glyphs in font"
|
|
679
|
+ : "rendering test text string";
|
|
680
|
+ break;
|
|
681
|
+
|
682
|
682
|
/* MM-related keys */
|
683
|
683
|
|
684
|
684
|
case grKEY( '+' ):
|
... |
... |
@@ -974,7 +974,7 @@ |
974
|
974
|
break;
|
975
|
975
|
|
976
|
976
|
case 'd':
|
977
|
|
- if ( sscanf( optarg, "%ux%u", &width, &height ) != 2 )
|
|
977
|
+ if ( sscanf( optarg, "%hux%hu", &width, &height ) != 2 )
|
978
|
978
|
usage( execname );
|
979
|
979
|
break;
|
980
|
980
|
|
... |
... |
@@ -1150,11 +1150,11 @@ |
1150
|
1150
|
switch ( render_mode )
|
1151
|
1151
|
{
|
1152
|
1152
|
case 0:
|
1153
|
|
- Render_Text( (unsigned int)Num, ptsize );
|
|
1153
|
+ Render_Text( Num );
|
1154
|
1154
|
break;
|
1155
|
1155
|
|
1156
|
1156
|
default:
|
1157
|
|
- Render_All( (unsigned int)Num, ptsize );
|
|
1157
|
+ Render_All( Num );
|
1158
|
1158
|
}
|
1159
|
1159
|
|
1160
|
1160
|
strbuf_format( header, "%.50s %.50s (file %.100s)",
|