diff --git a/src/ftgrid.c b/src/ftgrid.c index 13858dd..f45133a 100644 --- a/src/ftgrid.c +++ b/src/ftgrid.c @@ -15,6 +15,7 @@ #include "ftcommon.h" #include "common.h" +#include "afhints.h" #include /* the following header shouldn't be used in normal programs */ @@ -39,17 +40,12 @@ #define snprintf _snprintf #endif - - /* these variables, structures and declarations are for */ - /* communication with the debugger in the autofit module; */ - /* normal programs don't need this */ - struct AF_GlyphHintsRec_; - typedef struct AF_GlyphHintsRec_* AF_GlyphHints; - +/* these variables, structures and declarations are for */ +/* communication with the debugger in the autofit module; */ +/* normal programs don't need this */ int _af_debug_disable_horz_hints; int _af_debug_disable_vert_hints; int _af_debug_disable_blue_hints; - AF_GlyphHints _af_debug_hints; #ifdef __cplusplus extern "C" { @@ -87,12 +83,14 @@ typedef struct status_ grColor on_color; grColor conic_color; grColor cubic_color; + grColor stem_color; int do_horz_hints; int do_vert_hints; int do_blue_hints; int do_outline; int do_dots; + int do_stem; double gamma; const char* header; @@ -116,6 +114,7 @@ grid_status_init( GridStatus st, st->on_color = grFindColor( display->bitmap, 64, 64, 255, 255 ); st->conic_color = grFindColor( display->bitmap, 0, 128, 0, 255 ); st->cubic_color = grFindColor( display->bitmap, 255, 64, 255, 255 ); + st->stem_color = grFindColor( display->bitmap, 64, 255, 128, 64 ); st->disp_width = display->bitmap->width; st->disp_height = display->bitmap->rows; st->disp_bitmap = display->bitmap; @@ -125,6 +124,7 @@ grid_status_init( GridStatus st, st->do_blue_hints = 1; st->do_dots = 1; st->do_outline = 1; + st->do_stem = 0; st->Num = 0; st->gamma = 1.0; @@ -218,6 +218,42 @@ grid_status_draw_grid( GridStatus st ) grFillHLine( st->disp_bitmap, 0, y_org, st->disp_width, st->axis_color ); } +static void +grid_hint_draw_stem( GridStatus st, + AF_GlyphHints hints ) +{ + FT_Int dimension; + int x_org = (int)st->x_origin; + int y_org = (int)st->y_origin; + + + for ( dimension = 1; dimension >= 0; dimension-- ) + { + AF_AxisHints axis = &hints->axis[dimension]; + AF_Segment segments = axis->segments; + AF_Segment limit = segments + axis->num_segments; + AF_Segment seg; + + + for ( seg = segments; seg < limit; seg++ ) + { + FT_Pos pos; + + if ( dimension == AF_DIMENSION_HORZ ) + { + pos = x_org + (int)seg->first->ox * st->scale; + grFillVLine( st->disp_bitmap, (int)pos, 0, + st->disp_height, st->stem_color ); + } + else + { + pos = y_org - (int)seg->first->oy * st->scale; + grFillHLine( st->disp_bitmap, 0, (int)pos, + st->disp_width, st->stem_color ); + } + } + } +} static void ft_bitmap_draw( FT_Bitmap* bitmap, @@ -403,6 +439,10 @@ grid_status_draw_outline( GridStatus st, handle->load_flags | FT_LOAD_NO_BITMAP ) ) return; + /* Draw stem before draw glyph. */ + if ( status.do_stem && handle->autohint ) + grid_hint_draw_stem ( &status, _af_debug_hints ); + slot = size->face->glyph; if ( slot->format == FT_GLYPH_FORMAT_OUTLINE ) { @@ -501,6 +541,7 @@ grid_status_draw_outline( GridStatus st, grLn(); grWriteln( " a : toggle anti-aliasing" ); grWriteln( " f : toggle forced autofit mode" ); + grWriteln( " h : toggle ignore hinting mode" ); grWriteln( " left/right : decrement/increment glyph index" ); grWriteln( " up/down : change character size" ); grLn(); @@ -522,6 +563,7 @@ grid_status_draw_outline( GridStatus st, grWriteln( " H : toggle horizontal hinting" ); grWriteln( " V : toggle vertical hinting" ); grWriteln( " B : toggle blue zone hinting" ); + grWriteln( " s : toggle draw hinting stems" ); #endif grWriteln( " d : toggle dots display" ); grWriteln( " o : toggle outline display" ); @@ -780,6 +822,17 @@ grid_status_draw_outline( GridStatus st, else status.header = "need autofit mode to toggle blue zone hinting"; break; + + case grKEY('s'): + if (handle->autohint) + { + status.do_stem = !status.do_stem; + status.header = status.do_stem ? "stem drawing enabled" + : "stem drawing disabled"; + } + else + status.header = "need autofit mode to draw hinting stem"; + break; #endif /* FT_DEBUG_AUTOFIT */