diff --git a/include/freetype/internal/tttypes.h b/include/freetype/internal/tttypes.h index 651131c8d..fcd97cff0 100644 --- a/include/freetype/internal/tttypes.h +++ b/include/freetype/internal/tttypes.h @@ -1769,6 +1769,9 @@ FT_BEGIN_HEADER /* since version 2.6.2 */ FT_ListRec composites; + /* since version 2.11.2 */ + FT_Byte* widthp; + } TT_LoaderRec; diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c index 4419852f3..f18c6c2d2 100644 --- a/src/truetype/ttgload.c +++ b/src/truetype/ttgload.c @@ -2230,10 +2230,6 @@ FT_UInt glyph_index ) { TT_Face face = loader->face; -#if defined TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY || \ - defined TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL - TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( face ); -#endif FT_BBox bbox; FT_Fixed y_scale; @@ -2256,37 +2252,10 @@ glyph->metrics.horiBearingX = bbox.xMin; glyph->metrics.horiBearingY = bbox.yMax; - glyph->metrics.horiAdvance = SUB_LONG(loader->pp2.x, loader->pp1.x); - - /* Adjust advance width to the value contained in the hdmx table */ - /* unless FT_LOAD_COMPUTE_METRICS is set or backward compatibility */ - /* mode of the v40 interpreter is active. See `ttinterp.h' for */ - /* details on backward compatibility mode. */ - if ( IS_HINTED( loader->load_flags ) && - !( loader->load_flags & FT_LOAD_COMPUTE_METRICS ) && -#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL - !( driver->interpreter_version == TT_INTERPRETER_VERSION_40 && - ( loader->exec && loader->exec->backward_compatibility ) ) && -#endif -#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY - !( driver->interpreter_version == TT_INTERPRETER_VERSION_38 && - !SPH_OPTION_BITMAP_WIDTHS && - FT_LOAD_TARGET_MODE( loader->load_flags ) != - FT_RENDER_MODE_MONO && - ( loader->exec && !loader->exec->compatible_widths ) ) && -#endif - !face->postscript.isFixedPitch ) - { - FT_Byte* widthp; - - - widthp = tt_face_get_device_metrics( face, - size->metrics->x_ppem, - glyph_index ); - - if ( widthp ) - glyph->metrics.horiAdvance = *widthp * 64; - } + if ( loader->widthp ) + glyph->metrics.horiAdvance = loader->widthp[glyph_index] * 64; + else + glyph->metrics.horiAdvance = SUB_LONG(loader->pp2.x, loader->pp1.x); /* set glyph dimensions */ glyph->metrics.width = SUB_LONG( bbox.xMax, bbox.xMin ); @@ -2752,6 +2721,32 @@ exec->pedantic_hinting = FT_BOOL( load_flags & FT_LOAD_PEDANTIC ); loader->exec = exec; loader->instructions = exec->glyphIns; + + /* Use the hdmx table if any unless FT_LOAD_COMPUTE_METRICS */ + /* is set or backward compatibility mode of the v38 or v40 */ + /* interpreters is active. See `ttinterp.h' for details on */ + /* backward compatibility mode. */ + if ( IS_HINTED( loader->load_flags ) && + !( loader->load_flags & FT_LOAD_COMPUTE_METRICS ) && +#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL + !( driver->interpreter_version == TT_INTERPRETER_VERSION_40 && + exec->backward_compatibility ) && +#endif +#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY + !( driver->interpreter_version == TT_INTERPRETER_VERSION_38 && + !SPH_OPTION_BITMAP_WIDTHS && + FT_LOAD_TARGET_MODE( loader->load_flags ) != + FT_RENDER_MODE_MONO && + exec->compatible_widths ) && +#endif + !face->postscript.isFixedPitch ) + { + loader->widthp = tt_face_get_device_metrics( face, + size->metrics->x_ppem, + 0 ); + } + else + loader->widthp = NULL; } #endif /* TT_USE_BYTECODE_INTERPRETER */