From 71f242c26ace99cdebecb9fdda0a580da89e3112 Mon Sep 17 00:00:00 2001 From: Infinality Date: Sun, 16 Dec 2012 19:52:01 -0600 Subject: [PATCH] [truetype ] Remove unusued code. Add minor fixes. --- ChangeLog | 34 ++++++++- src/truetype/ttgload.c | 2 +- src/truetype/ttinterp.c | 159 +++++++++++++--------------------------- src/truetype/ttinterp.h | 5 -- src/truetype/ttobjs.h | 1 + src/truetype/ttsubpix.h | 56 +++++++------- 6 files changed, 117 insertions(+), 140 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2ca32d0cd..bf092dbd9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,36 @@ -2012-12-16 Werner Lemberg +2012-12-16 Infinality + + [truetype] Remove unusued code and variables. Add minor fixes. + + * src/truetype/ttsubpix.h: Updated. + (SKIP_NONPIXEL_Y_MOVES_Rules_Exceptions): Add Trebuchet MS. + (ALLOW_X_DMOVEX_Rules): Remove Arial characters. + (ALLOW_X_DMOVE_Rules): Remove Arial characters. + (RASTERIZER_35_Rules): Verdana no longer needs to be here. + (SKIP_IUP_Rules): Formatting fix. + (DELTAP_SKIP_EXAGGERATED_VALUES_Rules): Remove Segoe UI. + (COMPATIBLE_WIDTHS_Rules): Add Monaco and Trebuchet MS. + (X_SCALING_Rules): Add misc. corrective fixes. + + * src/truetype/ttgload.c: (TT_Process_Simple_Glyph): Adjust correction + factor for emboldening during scaling. + + * src/truetype/ttinterp.h: Updated. + (TT_ExecContextRec): Remove unused variables. + + * src/truetype/ttobjs.h: Updated. + (TT_SizeRec): Add ttfautohinted variable. + + * src/truetype/ttinterp.c: Updated. + (Ins_FDEF): Rework code to fix bugs and add more detection. + (Ins_CALL): Remove unused code. + (Ins_LOOPCALL): Remove unused code. + (TT_RunIns): Remove unusued code. + (Ins_SHPIX): Add logic to handle ttfautohinted fonts. + (Ins_MIRP): Don't round x in cut-in calculation. Add logic to handle + ttfautohinted fonts. + + 2012-12-16 Werner Lemberg [sfnt] Fix Savannah bug #37936. diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c index 805bd95fe..7bde25c38 100644 --- a/src/truetype/ttgload.c +++ b/src/truetype/ttgload.c @@ -932,7 +932,7 @@ /* the amount was determined via experimentation */ if ( x_scale_factor != 1000 && ppem > 11 ) FT_Outline_EmboldenXY( outline, - FT_MulDiv( 16 * ppem, + FT_MulDiv( 80 * ppem, 1000 - x_scale_factor, 0x1000L ), 0 ); #else diff --git a/src/truetype/ttinterp.c b/src/truetype/ttinterp.c index 736bda32c..96f62ea3a 100644 --- a/src/truetype/ttinterp.c +++ b/src/truetype/ttinterp.c @@ -4612,21 +4612,25 @@ TT_DefRecord* limit; #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING -#if 0 - int opcode_pattern[4][12] = { - /* VacuFormRound function */ - {0x45,0x23,0x46,0x60,0x20}, - /* inline delta function 1 */ - {0x4B,0x53,0x23,0x4B,0x51,0x5A,0x58,0x38,0x1B,0x21,0x21,0x59}, - /* inline delta function 2 */ - {0x4B,0x54,0x58,0x38,0x1B,0x5A,0x21,0x21,0x59}, - /* diagonal stroke function */ - {0x20,0x20,0x40,0x60,0x47,0x40,0x23,0x42}, - }; - int opcode_patterns = 4; - int i; - int opcode_pointer[4] = {0,0,0,0}; -#endif /* 0 */ + FT_Byte opcode_pattern[7][12] = { + /* inline delta function 1 */ + {0x4B,0x53,0x23,0x4B,0x51,0x5A,0x58,0x38,0x1B,0x21,0x21,0x59}, + /* inline delta function 2 */ + {0x4B,0x54,0x58,0x38,0x1B,0x5A,0x21,0x21,0x59,}, + /* diagonal stroke function */ + {0x20,0x20,0x40,0x60,0x47,0x40,0x23,0x42,}, + /* VacuFormRound function */ + {0x45,0x23,0x46,0x60,0x20,}, + /* ttfautohinted */ + {0x20,0x64,0xb0,0x60,0x66,0x23,0xb0,}, + /* spacing functions */ + {0x01,0x41,0x43,0x58,}, + {0x01,0x18,0x41,0x43,0x58,}, + }; + FT_UShort opcode_patterns = 7; + FT_UShort opcode_pointer[7] = {0,0,0,0,0,0,0}; + FT_UShort opcode_size[7] = {12,9,8,5,7,4,5}; + FT_UShort i; #endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */ @@ -4677,14 +4681,15 @@ while ( SKIP_Code() == SUCCESS ) { #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING -#if 0 + #ifdef SPH_DEBUG_MORE_VERBOSE - printf ("Opcode: %d ", CUR.opcode); + printf ( "Opcode: %d ", CUR.opcode ); #endif for ( i = 0; i < opcode_patterns; i++ ) { - if ( CUR.opcode == opcode_pattern[i][opcode_pointer[i]] ) + if ( opcode_pointer[i] < opcode_size[i] && + CUR.opcode == opcode_pattern[i][opcode_pointer[i]] ) { #ifdef SPH_DEBUG_MORE_VERBOSE printf( "function %d, opcode ptrn: %d" @@ -4693,51 +4698,33 @@ #endif opcode_pointer[i] += 1; - if ( i == 0 && opcode_pointer[0] == 5 ) + if ( opcode_pointer[i] == opcode_size[i] ) { - - CUR.inline_delta_funcs[CUR.num_delta_funcs] = n; - CUR.num_delta_funcs++; #ifdef SPH_DEBUG - printf( "Vacuform Round FUNCTION %d detected\n", n); + printf( "Function signature %d detected in FDEF %d\n", i, n); #endif - /*rec->active = FALSE;*/ - opcode_pointer[i] = 0; - } - if ( i == 1 && opcode_pointer[1] == 12 ) - { - CUR.inline_delta_funcs[CUR.num_delta_funcs] = n; - CUR.num_delta_funcs++; -#ifdef SPH_DEBUG - printf( "inline delta FUNCTION1 %d detected\n", - n, CUR.num_delta_funcs); -#endif - rec->inline_delta = TRUE; - opcode_pointer[i] = 0; - } + switch ( i ) + { + case 0: + case 1: + rec->inline_delta = TRUE; + break; - if ( i == 2 && opcode_pointer[1] == 9 ) - { - CUR.inline_delta_funcs[CUR.num_delta_funcs] = n; - CUR.num_delta_funcs++; - rec->inline_delta = TRUE; -#ifdef SPH_DEBUG - printf( "inline delta2 FUNCTION2 %d detected\n", - n, CUR.num_delta_funcs); -#endif - opcode_pointer[i] = 0; - } + case 2: + case 3: + rec->active = FALSE; + break; - if ( i == 4 && opcode_pointer[1] == 8 ) - { - CUR.inline_delta_funcs[CUR.num_delta_funcs] = n; - CUR.num_delta_funcs++; - /*rec->active = FALSE;*/ -#ifdef SPH_DEBUG - printf( "diagonal stroke function %d detected\n", - n, CUR.num_delta_funcs); -#endif + case 4: + CUR.size->ttfautohinted = TRUE; + break; + + case 5: + case 6: + rec->active = FALSE; + break; + } opcode_pointer[i] = 0; } } @@ -4745,7 +4732,7 @@ else opcode_pointer[i] = 0; } -#endif /* 0 */ + #endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */ switch ( CUR.opcode ) @@ -4833,10 +4820,6 @@ TT_CallRec* pCrec; TT_DefRecord* def; -#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING - FT_Bool oldF; -#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */ - /* first of all, check the index */ @@ -4874,16 +4857,6 @@ if ( !def->active ) goto Fail; -#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING - /* This is test code used to detect inline delta functions */ - oldF = def->inline_delta; - if ( CUR.ignore_x_mode && def->inline_delta ) - CUR.in_delta_function = TRUE; - -#ifdef SPH_DEBUG - printf("Entering function %d\n", F); -#endif -#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */ /* check the call stack */ if ( CUR.callTop >= CUR.callSize ) @@ -4906,13 +4879,6 @@ def->start ); CUR.step_ins = FALSE; -#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING - CUR.in_delta_function = oldF; - -#ifdef SPH_DEBUG - printf("Leaving function %d\n", F); -#endif -#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */ return; Fail: @@ -4933,10 +4899,6 @@ TT_CallRec* pCrec; TT_DefRecord* def; -#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING - FT_Bool oldF; -#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */ - /* first of all, check the index */ F = args[1]; @@ -4973,13 +4935,6 @@ if ( !def->active ) goto Fail; -#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING - oldF = def->inline_delta; - if ( CUR.ignore_x_mode && def->inline_delta ) - CUR.in_delta_function = TRUE; - -#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */ - /* check stack */ if ( CUR.callTop >= CUR.callSize ) { @@ -5004,10 +4959,6 @@ CUR.step_ins = FALSE; } -#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING - CUR.in_delta_function = oldF; -#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */ - return; Fail: @@ -6147,7 +6098,8 @@ CUR.GS.freeVector.y != 0 && B1 % 64 == 0 && B2 % 64 != 0 && - B1 != B2 ) ) + B1 != B2 && + !CUR.size->ttfautohinted ) ) { #ifdef SPH_DEBUG printf( "Reversing ZP2 move\n" ); @@ -6645,13 +6597,6 @@ if ( FT_ABS( cvt_dist - org_dist ) > control_value_cutin ) cvt_dist = org_dist; } -#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING - if ( CUR.ignore_x_mode && CUR.GS.freeVector.x != 0 ) - distance = ROUND_None( - cvt_dist, - CUR.tt_metrics.compensations[CUR.opcode & 3] ); - else -#endif distance = CUR_Func_round( cvt_dist, @@ -6705,7 +6650,8 @@ if ( ( CUR.sph_tweak_flags & SPH_TWEAK_SKIP_OFFPIXEL_Y_MOVES ) && CUR.GS.freeVector.y != 0 && B1 % 64 == 0 && - B2 % 64 != 0 ) + B2 % 64 != 0 && + !CUR.size->ttfautohinted ) reverse_move = TRUE; if ( ( CUR.sph_tweak_flags & SPH_TWEAK_SKIP_NONPIXEL_Y_MOVES ) && @@ -7473,7 +7419,8 @@ ( ( ( CUR.sph_tweak_flags & SPH_TWEAK_SKIP_OFFPIXEL_Y_MOVES ) && B1 % 64 == 0 && - B2 % 64 != 0 ) || + B2 % 64 != 0 && + !CUR.size->ttfautohinted ) || ( ( CUR.sph_tweak_flags & SPH_TWEAK_SKIP_NONPIXEL_Y_MOVES ) && B1 % 64 != 0 && @@ -8096,11 +8043,7 @@ #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING if ( CUR.ignore_x_mode ) - { - /* ensure some variables are set for this run */ CUR.iup_called = FALSE; - CUR.in_delta_function = FALSE; - } #endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */ /* set CVT functions */ diff --git a/src/truetype/ttinterp.h b/src/truetype/ttinterp.h index 076d9a144..f4336121b 100644 --- a/src/truetype/ttinterp.h +++ b/src/truetype/ttinterp.h @@ -285,14 +285,9 @@ FT_BEGIN_HEADER FT_Int rasterizer_version; /* MS rasterizer version */ FT_Bool iup_called; /* IUP called for glyph? */ - FT_Bool in_delta_function; /* inside an inline delta */ - /* function? */ FT_ULong sph_tweak_flags; /* flags to control */ /* hint tweaks */ - - FT_Int num_delta_funcs; - FT_ULong inline_delta_funcs[5]; #endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */ } TT_ExecContextRec; diff --git a/src/truetype/ttobjs.h b/src/truetype/ttobjs.h index c6724a824..5c3cb067e 100644 --- a/src/truetype/ttobjs.h +++ b/src/truetype/ttobjs.h @@ -334,6 +334,7 @@ FT_BEGIN_HEADER FT_Bool bytecode_ready; FT_Bool cvt_ready; + FT_Bool ttfautohinted; #endif /* TT_USE_BYTECODE_INTERPRETER */ diff --git a/src/truetype/ttsubpix.h b/src/truetype/ttsubpix.h index 45e348144..2fbff2681 100644 --- a/src/truetype/ttsubpix.h +++ b/src/truetype/ttsubpix.h @@ -259,6 +259,7 @@ FT_BEGIN_HEADER "Lucida Console", "Lucida Grande", "Lucida Sans Unicode", + "Lucida Sans Typewriter", "Microsoft Sans Serif", "Monaco", "Tahoma", @@ -414,7 +415,7 @@ FT_BEGIN_HEADER }; -#define SKIP_NONPIXEL_Y_MOVES_RULES_EXCEPTIONS_SIZE 5 +#define SKIP_NONPIXEL_Y_MOVES_RULES_EXCEPTIONS_SIZE 6 SPH_TweakRule SKIP_NONPIXEL_Y_MOVES_Rules_Exceptions [SKIP_NONPIXEL_Y_MOVES_RULES_EXCEPTIONS_SIZE] = @@ -425,6 +426,7 @@ FT_BEGIN_HEADER { "Verdana", 11, "Bold", 'x' }, /* Cyrillic small letter I */ { "Arial", 0, "", 0x438 }, + { "Trebuchet MS", 0, "Bold", 0 }, }; @@ -477,26 +479,21 @@ FT_BEGIN_HEADER /* Allow a Direct_Move_X along X freedom vector if matched. */ -#define ALLOW_X_DMOVEX_RULES_SIZE 2 +#define ALLOW_X_DMOVEX_RULES_SIZE 1 SPH_TweakRule ALLOW_X_DMOVEX_Rules [ALLOW_X_DMOVEX_RULES_SIZE] = { - /* Creates a more consistent appearance for these */ - { "Arial", 13, "Regular", 'e' }, - { "Arial", 13, "Regular", 'o' }, + { "-", 0, "Regular", 0 }, }; /* Allow a Direct_Move along X freedom vector if matched. */ -#define ALLOW_X_DMOVE_RULES_SIZE 3 +#define ALLOW_X_DMOVE_RULES_SIZE 1 SPH_TweakRule ALLOW_X_DMOVE_Rules [ALLOW_X_DMOVE_RULES_SIZE] = { - /* Creates a more consistent appearance for these */ - { "Arial", 13, "Regular", 'e' }, - { "Arial", 13, "Regular", 'o' }, /* Fixes vanishing diagonal in 4 */ { "Verdana", 0, "Regular", '4' }, }; @@ -514,7 +511,7 @@ FT_BEGIN_HEADER /* Return MS rasterizer version 35 if matched. */ -#define RASTERIZER_35_RULES_SIZE 9 +#define RASTERIZER_35_RULES_SIZE 8 SPH_TweakRule RASTERIZER_35_Rules [RASTERIZER_35_RULES_SIZE] = @@ -528,9 +525,6 @@ FT_BEGIN_HEADER { "Times New Roman", 0, "Regular", 'n' }, { "Times New Roman", 0, "Regular", 'p' }, { "Times", 0, "", 0 }, - /* Verdana 5.05 from Windows 7 SP1 has issues at 37+ */ - /* This is only a workaround */ - { "Verdana", 0, "", 0 }, }; @@ -551,9 +545,9 @@ FT_BEGIN_HEADER SPH_TweakRule SKIP_IUP_Rules [SKIP_IUP_RULES_SIZE] = - { - { "Arial", 13, "Regular", 'a' }, - }; + { + { "Arial", 13, "Regular", 'a' }, + }; /* Skip MIAP Twilight hack if matched. */ @@ -567,7 +561,7 @@ FT_BEGIN_HEADER /* Skip DELTAP instructions if matched. */ -#define ALWAYS_SKIP_DELTAP_RULES_SIZE 14 +#define ALWAYS_SKIP_DELTAP_RULES_SIZE 16 SPH_TweakRule ALWAYS_SKIP_DELTAP_Rules [ALWAYS_SKIP_DELTAP_RULES_SIZE] = @@ -575,7 +569,10 @@ FT_BEGIN_HEADER { "Georgia", 0, "Regular", 'k' }, /* fixes problems with W M w */ { "Trebuchet MS", 0, "Italic", 0 }, + /* fix various problems with e in different versions */ { "Trebuchet MS", 14, "Regular", 'e' }, + { "Trebuchet MS", 13, "Regular", 'e' }, + { "Trebuchet MS", 15, "Regular", 'e' }, { "Arial", 11, "Regular", 's' }, { "Verdana", 10, "Regular", 0 }, { "Verdana", 9, "Regular", 0 }, @@ -624,15 +621,13 @@ FT_BEGIN_HEADER /* Skip moves that meet or exceed 1 pixel. */ -#define DELTAP_SKIP_EXAGGERATED_VALUES_RULES_SIZE 2 +#define DELTAP_SKIP_EXAGGERATED_VALUES_RULES_SIZE 1 SPH_TweakRule DELTAP_SKIP_EXAGGERATED_VALUES_Rules [DELTAP_SKIP_EXAGGERATED_VALUES_RULES_SIZE] = { /* Fix vanishing stems */ { "Ubuntu", 0, "Regular", 'M' }, - /* Fix X at larger ppems */ - { "Segoe UI", 0, "Light", 0 }, }; @@ -769,7 +764,7 @@ FT_BEGIN_HEADER /* Use compatible widths with these glyphs. Compatible widths is always */ /* on when doing B/W TrueType instructing, but is used selectively here, */ /* typically on glyphs with 3 or more vertical stems. */ -#define COMPATIBLE_WIDTHS_RULES_SIZE 36 +#define COMPATIBLE_WIDTHS_RULES_SIZE 38 SPH_TweakRule COMPATIBLE_WIDTHS_Rules [COMPATIBLE_WIDTHS_RULES_SIZE] = @@ -792,6 +787,7 @@ FT_BEGIN_HEADER { "Microsoft Sans Serif", 11, "Regular Class", 0 }, { "Microsoft Sans Serif", 12, "Regular Class", 0 }, { "Segoe UI", 11, "Regular Class", 0 }, + { "Monaco", 0, "Regular Class", 0 }, { "Segoe UI", 12, "Regular Class", 'm' }, { "Segoe UI", 14, "Regular Class", 'm' }, { "Tahoma", 11, "Regular Class", 0 }, @@ -799,6 +795,7 @@ FT_BEGIN_HEADER { "Times New Roman", 16, "Regular Class", 'm' }, { "Times New Roman", 16, "Regular Class", 'o' }, { "Times New Roman", 16, "Regular Class", 'w' }, + { "Trebuchet MS", 11, "Regular Class", 0 }, { "Trebuchet MS", 12, "Regular Class", 0 }, { "Trebuchet MS", 14, "Regular Class", 0 }, { "Trebuchet MS", 15, "Regular Class", 0 }, @@ -821,7 +818,7 @@ FT_BEGIN_HEADER /* more visually pleasing glyphs in certain cases. */ /* This sometimes needs to be coordinated with compatible width rules. */ /* A value of 1000 corresponds to a scaled value of 1.0. */ -#define X_SCALING_RULES_SIZE 41 +#define X_SCALING_RULES_SIZE 50 SPH_ScaleRule X_SCALING_Rules [X_SCALING_RULES_SIZE] = @@ -833,6 +830,8 @@ FT_BEGIN_HEADER { "Arial", 12, "Regular Class", 'm', 1050 }, /* Cyrillic small letter el */ { "Arial", 13, "Regular Class", 0x43B, 950 }, + { "Arial", 13, "Regular Class", 'o', 950 }, + { "Arial", 13, "Regular Class", 'e', 950 }, { "Arial", 14, "Regular Class", 'm', 950 }, /* Cyrillic small letter el */ { "Arial", 15, "Regular Class", 0x43B, 925 }, @@ -861,14 +860,21 @@ FT_BEGIN_HEADER { "Segoe UI", 12, "Regular Class", 'H', 1050 }, { "Segoe UI", 12, "Regular Class", 'm', 1050 }, { "Segoe UI", 14, "Regular Class", 'm', 1050 }, - { "Tahoma", 11, "Regular Class", 'm', 975 }, + { "Tahoma", 11, "Regular Class", 'i', 975 }, + { "Tahoma", 11, "Regular Class", 'l', 975 }, + { "Tahoma", 11, "Regular Class", 'j', 900 }, + { "Tahoma", 11, "Regular Class", 'm', 918 }, { "Verdana", 10, "Regular/Italic Class", 0, 1100 }, { "Verdana", 12, "Regular Class", 'm', 975 }, { "Verdana", 12, "Regular/Italic Class", 0, 1050 }, + { "Verdana", 13, "Regular/Italic Class", 'i', 950 }, + { "Verdana", 13, "Regular/Italic Class", 'j', 950 }, + { "Verdana", 13, "Regular/Italic Class", 'l', 950 }, { "Verdana", 16, "Regular Class", 0, 1050 }, { "Verdana", 9, "Regular/Italic Class", 0, 1050 }, - { "Times New Roman", 16, "Regular Class", 'm', 950 }, - { "Trebuchet MS", 12, "Regular Class", 'm', 950 }, + { "Times New Roman", 16, "Regular Class", 'm', 918 }, + { "Trebuchet MS", 11, "Regular Class", 'm', 800 }, + { "Trebuchet MS", 12, "Regular Class", 'm', 800 }, }; #else