Commit fa353701 authored by Alexei Podtelezhnikov's avatar Alexei Podtelezhnikov
Browse files

[truetype] Initialize the loader with `hdmx` data.

* include/freetype/internal/tttypes.h (TT_LoaderRec): Add field.
* src/truetype/ttgload.c (compute_glyph_metrics): Relocate the `hdmx`
code from here...
(tt_loader_init): ... to here, before the glyph is loaded.
parent 2e3455b1
......@@ -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;
......
......@@ -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 */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment