diff --git a/include/freetype/config/ftoption.h b/include/freetype/config/ftoption.h index 62bcd505f..6821134a8 100644 --- a/include/freetype/config/ftoption.h +++ b/include/freetype/config/ftoption.h @@ -594,6 +594,16 @@ FT_BEGIN_HEADER #define FT_CONFIG_OPTION_OLD_INTERNALS + /* + * this variable is defined if either unpatented or native TrueType + * hinting is requested by the definitions above. + */ +#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER +# define TT_USE_BYTECODE_INTERPRETER +#elif defined TT_CONFIG_OPTION_UNPATENTED_HINTING +# define TT_USE_BYTECODE_INTERPRETER +#endif + FT_END_HEADER diff --git a/include/freetype/internal/ftcalc.h b/include/freetype/internal/ftcalc.h index 53d7a6770..e0e5c5588 100644 --- a/include/freetype/internal/ftcalc.h +++ b/include/freetype/internal/ftcalc.h @@ -78,7 +78,7 @@ FT_BEGIN_HEADER /*************************************************************************/ -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER +#ifdef TT_USE_BYTECODE_INTERPRETER /*************************************************************************/ /* */ @@ -108,7 +108,7 @@ FT_BEGIN_HEADER FT_Long b, FT_Long c ); -#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ +#endif /* TT_USE_BYTECODE_INTERPRETER */ #define INT_TO_F26DOT6( x ) ( (FT_Long)(x) << 6 ) diff --git a/include/freetype/internal/ftobjs.h b/include/freetype/internal/ftobjs.h index 133f36007..ef3d3f4bc 100644 --- a/include/freetype/internal/ftobjs.h +++ b/include/freetype/internal/ftobjs.h @@ -211,6 +211,27 @@ FT_BEGIN_HEADER /* this data when first opened. This field exists only if */ /* @FT_CONFIG_OPTION_INCREMENTAL is defined. */ /* */ + /* force_autohing :: + /* this boolean flag is used to instruct the glyph loader to */ + /* ignore the format-specific hinter, and use the auto-hinter */ + /* instead to load all glyphs. */ + /* */ + /* if the unpatented bytecode interpreter was compiled withing */ + /* the library then: */ + /* */ + /* - if this is one of the tricky Asian fonts, like Gulim, which */ + /* absolutely require a bytecode interpreter to load anything */ + /* properly, the flag will be set to FALSE */ + /* */ + /* - for other fonts, the flag will be set to TRUE, and the */ + /* auto-hinter will be used to scale the glyphs. */ + /* */ + /* if the unpatented bytecode interpretr was *not* compiled */ + /* within the librayr, the flag will always be FALSE */ + /* */ + /* the detection of "tricky" fonts is located in the TrueType */ + /* face loader. */ + /* */ typedef struct FT_Face_InternalRec_ { #ifdef FT_CONFIG_OPTION_OLD_INTERNALS @@ -227,6 +248,8 @@ FT_BEGIN_HEADER FT_Incremental_InterfaceRec* incremental_interface; #endif + FT_Bool force_autohint; + } FT_Face_InternalRec; @@ -621,7 +644,7 @@ FT_BEGIN_HEADER /* Set this debug hook to a non-null pointer to force unpatented hinting */ - /* for all faces when both TT_CONFIG_OPTION_BYTECODE_INTERPRETER and */ + /* for all faces when both TT_USE_BYTECODE_INTERPRETER and */ /* TT_CONFIG_OPTION_UNPATENTED_HINTING are defined. this is only used */ /* during debugging. */ #define FT_DEBUG_HOOK_UNPATENTED_HINTING 1 diff --git a/src/base/ftcalc.c b/src/base/ftcalc.c index ede9308b5..7cae98812 100644 --- a/src/base/ftcalc.c +++ b/src/base/ftcalc.c @@ -159,7 +159,7 @@ } -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER +#ifdef TT_USE_BYTECODE_INTERPRETER /* documentation is in ftcalc.h */ @@ -183,7 +183,7 @@ return ( s > 0 ) ? d : -d; } -#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ +#endif /* TT_USE_BYTECODE_INTERPRETER */ /* documentation is in freetype.h */ @@ -353,7 +353,7 @@ } -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER +#ifdef TT_USE_BYTECODE_INTERPRETER FT_BASE_DEF( FT_Long ) FT_MulDiv_No_Round( FT_Long a, @@ -387,7 +387,7 @@ return ( s < 0 ? -a : a ); } -#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ +#endif /* TT_USE_BYTECODE_INTERPRETER */ /* documentation is in freetype.h */ diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c index 14085437b..95f297da9 100644 --- a/src/base/ftobjs.c +++ b/src/base/ftobjs.c @@ -567,6 +567,9 @@ if ( FT_LOAD_TARGET_MODE( load_flags ) == FT_RENDER_MODE_LIGHT ) load_flags |= FT_LOAD_FORCE_AUTOHINT; + if ( face->internal->force_autohint ) + load_flags |= FT_LOAD_FORCE_AUTOHINT; + /* auto-hinter is preferred and should be used */ if ( ( !FT_DRIVER_HAS_HINTER( driver ) || ( load_flags & FT_LOAD_FORCE_AUTOHINT ) ) && diff --git a/src/truetype/truetype.c b/src/truetype/truetype.c index 4abb01ec5..5cb342a7d 100644 --- a/src/truetype/truetype.c +++ b/src/truetype/truetype.c @@ -24,7 +24,7 @@ #include "ttgload.c" /* glyph loader */ #include "ttobjs.c" /* object manager */ -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER +#ifdef TT_USE_BYTECODE_INTERPRETER #include "ttinterp.c" #endif diff --git a/src/truetype/ttdriver.c b/src/truetype/ttdriver.c index fa25c25ed..24cbd0eaf 100644 --- a/src/truetype/ttdriver.c +++ b/src/truetype/ttdriver.c @@ -294,7 +294,7 @@ static const FT_Service_TrueTypeEngineRec tt_service_truetype_engine = { -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER +#ifdef TT_USE_BYTECODE_INTERPRETER #ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING FT_TRUETYPE_ENGINE_TYPE_UNPATENTED @@ -302,11 +302,11 @@ FT_TRUETYPE_ENGINE_TYPE_PATENTED #endif -#else /* !TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ +#else /* !TT_USE_BYTECODE_INTERPRETER */ FT_TRUETYPE_ENGINE_TYPE_NONE -#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ +#endif /* TT_USE_BYTECODE_INTERPRETER */ }; static const FT_ServiceDescRec tt_services[] = @@ -354,7 +354,7 @@ { FT_MODULE_FONT_DRIVER | FT_MODULE_DRIVER_SCALABLE | -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER +#ifdef TT_USE_BYTECODE_INTERPRETER FT_MODULE_DRIVER_HAS_HINTER, #else 0, diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c index bbdb7666d..3d901acb7 100644 --- a/src/truetype/ttgload.c +++ b/src/truetype/ttgload.c @@ -310,7 +310,7 @@ goto Fail; } -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER +#ifdef TT_USE_BYTECODE_INTERPRETER if ( IS_HINTED( load->load_flags ) ) { @@ -320,7 +320,7 @@ FT_MEM_COPY( load->exec->glyphIns, p, (FT_Long)n_ins ); } -#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ +#endif /* TT_USE_BYTECODE_INTERPRETER */ p += n_ins; @@ -528,7 +528,7 @@ gloader->current.num_subglyphs = num_subglyphs; -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER +#ifdef TT_USE_BYTECODE_INTERPRETER { FT_Stream stream = loader->stream; @@ -599,14 +599,14 @@ TT_GlyphZone zone = &loader->zone; FT_Pos origin; -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER +#ifdef TT_USE_BYTECODE_INTERPRETER FT_UInt n_ins; #else FT_UNUSED( is_composite ); #endif -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER +#ifdef TT_USE_BYTECODE_INTERPRETER n_ins = loader->glyph->control_len; #endif @@ -615,7 +615,7 @@ if ( origin ) translate_array( zone->n_points, zone->cur, origin, 0 ); -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER +#ifdef TT_USE_BYTECODE_INTERPRETER /* save original point positioin in org */ if ( n_ins > 0 ) FT_ARRAY_COPY( zone->org, zone->cur, zone->n_points ); @@ -627,7 +627,7 @@ zone->cur[zone->n_points - 1].y = FT_PIX_ROUND( zone->cur[zone->n_points - 1].y ); -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER +#ifdef TT_USE_BYTECODE_INTERPRETER if ( n_ins > 0 ) { @@ -966,7 +966,7 @@ outline->tags[outline->n_points + 2] = 0; outline->tags[outline->n_points + 3] = 0; -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER +#ifdef TT_USE_BYTECODE_INTERPRETER { FT_Stream stream = loader->stream; @@ -1435,7 +1435,7 @@ loader->ins_pos = ins_pos; if ( IS_HINTED( loader->load_flags ) && -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER +#ifdef TT_USE_BYTECODE_INTERPRETER subglyph->flags & WE_HAVE_INSTR && @@ -1715,7 +1715,7 @@ FT_MEM_ZERO( loader, sizeof ( TT_LoaderRec ) ); -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER +#ifdef TT_USE_BYTECODE_INTERPRETER /* load execution context */ { @@ -1746,7 +1746,7 @@ loader->instructions = exec->glyphIns; } -#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ +#endif /* TT_USE_BYTECODE_INTERPRETER */ /* seek to the beginning of the glyph table. For Type 42 fonts */ /* the table might be accessed from a Postscript stream or something */ diff --git a/src/truetype/ttgload.h b/src/truetype/ttgload.h index 665c22487..c97caf8f4 100644 --- a/src/truetype/ttgload.h +++ b/src/truetype/ttgload.h @@ -23,7 +23,7 @@ #include #include "ttobjs.h" -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER +#ifdef TT_USE_BYTECODE_INTERPRETER #include "ttinterp.h" #endif diff --git a/src/truetype/ttinterp.c b/src/truetype/ttinterp.c index 183ad7905..c810da9e2 100644 --- a/src/truetype/ttinterp.c +++ b/src/truetype/ttinterp.c @@ -32,7 +32,7 @@ #include "tterrors.h" -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER +#ifdef TT_USE_BYTECODE_INTERPRETER #define TT_MULFIX FT_MulFix @@ -7816,7 +7816,7 @@ } -#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ +#endif /* TT_USE_BYTECODE_INTERPRETER */ /* END */ diff --git a/src/truetype/ttobjs.c b/src/truetype/ttobjs.c index 3f78137ad..3dd8b5c9c 100644 --- a/src/truetype/ttobjs.c +++ b/src/truetype/ttobjs.c @@ -29,7 +29,7 @@ #include "tterrors.h" -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER +#ifdef TT_USE_BYTECODE_INTERPRETER #include "ttinterp.h" #endif @@ -51,7 +51,7 @@ #define FT_COMPONENT trace_ttobjs -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER +#ifdef TT_USE_BYTECODE_INTERPRETER /*************************************************************************/ /* */ @@ -141,7 +141,7 @@ return error; } -#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ +#endif /* TT_USE_BYTECODE_INTERPRETER */ /*************************************************************************/ @@ -205,7 +205,7 @@ goto Bad_Format; } -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER +#ifdef TT_USE_BYTECODE_INTERPRETER face->root.face_flags |= FT_FACE_FLAG_HINTER; #endif @@ -261,6 +261,17 @@ face->unpatented_hinting = TRUE; } + /* compare the face with a list of well-known "tricky' fonts !! + * this list shall be expanded as we find them + */ + if ( !face->unpatented_hinting ) + { + /* XXX: TODO: */ + if ( strcmp( ttface->family_name, "What?" ) == 0 ) + face->unpatented_hinting = 1; + } + + ttface->internal->force_autohint = !face->unpatented_hinting; #endif /* TT_CONFIG_OPTION_UNPATENTED_HINTING */ /* initialize standard glyph loading routines */ @@ -331,7 +342,7 @@ /* */ /*************************************************************************/ -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER +#ifdef TT_USE_BYTECODE_INTERPRETER /*************************************************************************/ /* */ @@ -481,7 +492,7 @@ return error; } -#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ +#endif /* TT_USE_BYTECODE_INTERPRETER */ /*************************************************************************/ @@ -504,7 +515,7 @@ TT_Size size = (TT_Size)ttsize; FT_Error error = TT_Err_Ok; -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER +#ifdef TT_USE_BYTECODE_INTERPRETER TT_Face face = (TT_Face)size->root.face; FT_Memory memory = face->root.memory; @@ -589,7 +600,7 @@ if ( error ) tt_size_done( ttsize ); -#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ +#endif /* TT_USE_BYTECODE_INTERPRETER */ size->ttmetrics.valid = FALSE; size->strike_index = 0xFFFFFFFFUL; @@ -614,7 +625,7 @@ { TT_Size size = (TT_Size)ttsize; -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER +#ifdef TT_USE_BYTECODE_INTERPRETER FT_Memory memory = size->root.face->memory; @@ -728,7 +739,7 @@ } -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER +#ifdef TT_USE_BYTECODE_INTERPRETER { FT_UInt i; @@ -757,7 +768,7 @@ error = tt_size_run_prep( size ); } -#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ +#endif /* TT_USE_BYTECODE_INTERPRETER */ if ( !error ) size->ttmetrics.valid = TRUE; @@ -784,7 +795,7 @@ tt_driver_init( FT_Module ttdriver ) /* TT_Driver */ { -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER +#ifdef TT_USE_BYTECODE_INTERPRETER TT_Driver driver = (TT_Driver)ttdriver; @@ -816,7 +827,7 @@ FT_LOCAL_DEF( void ) tt_driver_done( FT_Module ttdriver ) /* TT_Driver */ { -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER +#ifdef TT_USE_BYTECODE_INTERPRETER TT_Driver driver = (TT_Driver)ttdriver; diff --git a/src/truetype/ttobjs.h b/src/truetype/ttobjs.h index b42b73594..5801af226 100644 --- a/src/truetype/ttobjs.h +++ b/src/truetype/ttobjs.h @@ -109,7 +109,7 @@ FT_BEGIN_HEADER } TT_GraphicsState; -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER +#ifdef TT_USE_BYTECODE_INTERPRETER FT_LOCAL( void ) tt_glyphzone_done( TT_GlyphZone zone ); @@ -120,7 +120,7 @@ FT_BEGIN_HEADER FT_Short maxContours, TT_GlyphZone zone ); -#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ +#endif /* TT_USE_BYTECODE_INTERPRETER */ @@ -324,7 +324,7 @@ FT_BEGIN_HEADER FT_ULong strike_index; /* 0xFFFFFFFF to indicate invalid */ -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER +#ifdef TT_USE_BYTECODE_INTERPRETER FT_UInt num_function_defs; /* number of function definitions */ FT_UInt max_function_defs; @@ -358,7 +358,7 @@ FT_BEGIN_HEADER FT_Bool debug; TT_ExecContext context; -#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ +#endif /* TT_USE_BYTECODE_INTERPRETER */ } TT_SizeRec; @@ -412,7 +412,7 @@ FT_BEGIN_HEADER FT_LOCAL( void ) tt_size_done( FT_Size ttsize ); /* TT_Size */ -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER +#ifdef TT_USE_BYTECODE_INTERPRETER FT_LOCAL( FT_Error ) tt_size_run_fpgm( TT_Size size ); @@ -420,7 +420,7 @@ FT_BEGIN_HEADER FT_LOCAL( FT_Error ) tt_size_run_prep( TT_Size size ); -#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ +#endif /* TT_USE_BYTECODE_INTERPRETER */ FT_LOCAL( FT_Error ) tt_size_reset( TT_Size size ); diff --git a/src/truetype/ttpload.c b/src/truetype/ttpload.c index 36e5a6606..6641fb717 100644 --- a/src/truetype/ttpload.c +++ b/src/truetype/ttpload.c @@ -334,7 +334,7 @@ tt_face_load_cvt( TT_Face face, FT_Stream stream ) { -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER +#ifdef TT_USE_BYTECODE_INTERPRETER FT_Error error; FT_Memory memory = stream->memory; @@ -383,7 +383,7 @@ Exit: return error; -#else /* !TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ +#else /* !TT_USE_BYTECODE_INTERPRETER */ FT_UNUSED( face ); FT_UNUSED( stream ); @@ -415,7 +415,7 @@ tt_face_load_fpgm( TT_Face face, FT_Stream stream ) { -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER +#ifdef TT_USE_BYTECODE_INTERPRETER FT_Error error; FT_ULong table_len; @@ -445,7 +445,7 @@ Exit: return error; -#else /* !TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ +#else /* !TT_USE_BYTECODE_INTERPRETER */ FT_UNUSED( face ); FT_UNUSED( stream ); @@ -477,7 +477,7 @@ tt_face_load_prep( TT_Face face, FT_Stream stream ) { -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER +#ifdef TT_USE_BYTECODE_INTERPRETER FT_Error error; FT_ULong table_len; @@ -506,7 +506,7 @@ Exit: return error; -#else /* !TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ +#else /* !TT_USE_BYTECODE_INTERPRETER */ FT_UNUSED( face ); FT_UNUSED( stream ); diff --git a/src/type42/t42drivr.c b/src/type42/t42drivr.c index e3c469742..82eb0ba1e 100644 --- a/src/type42/t42drivr.c +++ b/src/type42/t42drivr.c @@ -199,7 +199,7 @@ { FT_MODULE_FONT_DRIVER | FT_MODULE_DRIVER_SCALABLE | -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER +#ifdef TT_USE_BYTECODE_INTERPRETER FT_MODULE_DRIVER_HAS_HINTER, #else 0, diff --git a/src/type42/t42objs.c b/src/type42/t42objs.c index 30d9dcc8f..3b6c23b94 100644 --- a/src/type42/t42objs.c +++ b/src/type42/t42objs.c @@ -209,6 +209,9 @@ if ( info->is_fixed_pitch ) root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH; + /* note, only define if we have the patented bytecode interpreter, + * there are no known "tricky" Type42 fonts that could be loaded + * with the unpatented interpreter */ #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER root->face_flags |= FT_FACE_FLAG_HINTER; #endif