Delay FT_GLYPH_FORMAT_OUTLINE assignmets.

This assignmets used to be done prematurely before errors were checked
and outlines were actually loaded. Delaying the assignment provides
certain protection against careless usage of malformed input that
should now remain FT_GLYPH_FORMAT_NONE.

* src/cff/cffgload.c (cff_slot_load): Ditto.
* src/cid/cidgload.c (cid_slot_load_glyph): Ditto.
* src/pfr/pfrobjs.c (pfr_slot_load): Ditto.
* src/truetype/ttgload.c (TT_Load_Glyph): Ditto.
* src/type1/t1gload.c (T1_Load_Glyph): Ditto.
master
Alexei Podtelezhnikov 2 months ago
parent afc7000cac
commit 5245fd69fd
  1. 21
      src/cff/cffgload.c
  2. 21
      src/cid/cidgload.c
  3. 10
      src/pfr/pfrobjs.c
  4. 8
      src/truetype/ttgload.c
  5. 25
      src/type1/t1gload.c

@ -461,7 +461,6 @@
glyph->hint = hinting;
glyph->scaled = scaled;
glyph->root.format = FT_GLYPH_FORMAT_OUTLINE; /* by default */
{
#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
@ -596,10 +595,8 @@
{
/* Now, set the metrics -- this is rather simple, as */
/* the left side bearing is the xMin, and the top side */
/* bearing the yMax. */
/* For composite glyphs, return only left side bearing and */
/* advance width. */
/* bearing the yMax. For composite glyphs, return only */
/* left side bearing and advance width. */
if ( load_flags & FT_LOAD_NO_RECURSE )
{
FT_Slot_Internal internal = glyph->root.internal;
@ -618,6 +615,12 @@
FT_Bool has_vertical_info;
glyph->root.format = FT_GLYPH_FORMAT_OUTLINE;
glyph->root.outline.flags = FT_OUTLINE_REVERSE_FILL;
if ( size && size->root.metrics.y_ppem < 24 )
glyph->root.outline.flags |= FT_OUTLINE_HIGH_PRECISION;
if ( face->horizontal.number_Of_HMetrics )
{
FT_Short horiBearingX = 0;
@ -671,14 +674,6 @@
glyph->root.linearVertAdvance = metrics->vertAdvance;
glyph->root.format = FT_GLYPH_FORMAT_OUTLINE;
glyph->root.outline.flags = 0;
if ( size && size->root.metrics.y_ppem < 24 )
glyph->root.outline.flags |= FT_OUTLINE_HIGH_PRECISION;
glyph->root.outline.flags |= FT_OUTLINE_REVERSE_FILL;
/* apply the font matrix, if any */
if ( font_matrix.xx != 0x10000L || font_matrix.yy != 0x10000L ||
font_matrix.xy != 0 || font_matrix.yx != 0 )

@ -458,7 +458,6 @@
glyph->hint = hinting;
glyph->scaled = scaled;
cidglyph->format = FT_GLYPH_FORMAT_OUTLINE;
error = psaux->t1_decoder_funcs->init( &decoder,
cidglyph->face,
@ -498,12 +497,8 @@
/* now set the metrics -- this is rather simple, as */
/* the left side bearing is the xMin, and the top side */
/* bearing the yMax */
cidglyph->outline.flags &= FT_OUTLINE_OWNER;
cidglyph->outline.flags |= FT_OUTLINE_REVERSE_FILL;
/* for composite glyphs, return only left side bearing and */
/* advance width */
/* bearing the yMax; for composite glyphs, return only */
/* left side bearing and advance width */
if ( load_flags & FT_LOAD_NO_RECURSE )
{
FT_Slot_Internal internal = cidglyph->internal;
@ -524,6 +519,13 @@
FT_Glyph_Metrics* metrics = &cidglyph->metrics;
cidglyph->format = FT_GLYPH_FORMAT_OUTLINE;
cidglyph->outline.flags &= FT_OUTLINE_OWNER;
cidglyph->outline.flags |= FT_OUTLINE_REVERSE_FILL;
if ( cidsize->metrics.y_ppem < 24 )
cidglyph->outline.flags |= FT_OUTLINE_HIGH_PRECISION;
/* copy the _unscaled_ advance width */
metrics->horiAdvance =
FIXED_TO_INT( decoder.builder.advance.x );
@ -536,11 +538,6 @@
face->cid.font_bbox.yMin ) >> 16;
cidglyph->linearVertAdvance = metrics->vertAdvance;
cidglyph->format = FT_GLYPH_FORMAT_OUTLINE;
if ( cidsize->metrics.y_ppem < 24 )
cidglyph->outline.flags |= FT_OUTLINE_HIGH_PRECISION;
/* apply the font matrix, if any */
if ( font_matrix.xx != 0x10000L || font_matrix.yy != 0x10000L ||
font_matrix.xy != 0 || font_matrix.yx != 0 )

@ -355,9 +355,8 @@
goto Exit;
}
gchar = face->phy_font.chars + gindex;
pfrslot->format = FT_GLYPH_FORMAT_OUTLINE;
gps_offset = face->header.gps_section_offset;
gchar = face->phy_font.chars + gindex;
gps_offset = face->header.gps_section_offset;
/* load the glyph outline (FT_LOAD_NO_RECURSE isn't supported) */
error = pfr_glyph_load( &slot->glyph, face->root.stream,
@ -369,10 +368,9 @@
FT_Glyph_Metrics* metrics = &pfrslot->metrics;
FT_Pos advance;
FT_UInt em_metrics, em_outline;
FT_Bool scaling;
scaling = FT_BOOL( !( load_flags & FT_LOAD_NO_SCALE ) );
pfrslot->format = FT_GLYPH_FORMAT_OUTLINE;
/* copy outline data */
*outline = slot->glyph.loader->base.outline;
@ -427,7 +425,7 @@
#endif
/* scale when needed */
if ( scaling )
if ( !( load_flags & FT_LOAD_NO_SCALE ) )
{
FT_Int n;
FT_Fixed x_scale = pfrsize->metrics.x_scale;

@ -2595,7 +2595,7 @@
glyph->metrics.horiAdvance = FT_MulFix( advanceX, x_scale );
glyph->metrics.vertAdvance = FT_MulFix( advanceY, y_scale );
return error;
goto Exit;
}
FT_TRACE3(( "Failed to load SVG glyph\n" ));
@ -2623,10 +2623,6 @@
goto Done;
}
glyph->format = FT_GLYPH_FORMAT_OUTLINE;
glyph->num_subglyphs = 0;
glyph->outline.flags = 0;
/* main loading loop */
error = load_truetype_glyph( &loader, glyph_index, 0, FALSE );
if ( !error )
@ -2638,6 +2634,8 @@
}
else
{
glyph->format = FT_GLYPH_FORMAT_OUTLINE;
glyph->outline = loader.gloader->base.outline;
glyph->outline.flags &= ~FT_OUTLINE_SINGLE_PASS;

@ -404,7 +404,6 @@
glyph->hint = hinting;
glyph->scaled = scaled;
t1glyph->format = FT_GLYPH_FORMAT_OUTLINE;
error = decoder_funcs->init( &decoder,
t1glyph->face,
@ -449,16 +448,12 @@
must_finish_decoder = FALSE;
/* now, set the metrics -- this is rather simple, as */
/* the left side bearing is the xMin, and the top side */
/* bearing the yMax */
if ( !error )
{
t1glyph->outline.flags &= FT_OUTLINE_OWNER;
t1glyph->outline.flags |= FT_OUTLINE_REVERSE_FILL;
/* for composite glyphs, return only left side bearing and */
/* advance width */
/* now, set the metrics -- this is rather simple, as */
/* the left side bearing is the xMin, and the top side */
/* bearing the yMax; for composite glyphs, return only */
/* left side bearing and advance width */
if ( load_flags & FT_LOAD_NO_RECURSE )
{
FT_Slot_Internal internal = t1glyph->internal;
@ -479,6 +474,13 @@
FT_Glyph_Metrics* metrics = &t1glyph->metrics;
t1glyph->format = FT_GLYPH_FORMAT_OUTLINE;
t1glyph->outline.flags &= FT_OUTLINE_OWNER;
t1glyph->outline.flags |= FT_OUTLINE_REVERSE_FILL;
if ( t1size && t1size->metrics.y_ppem < 24 )
t1glyph->outline.flags |= FT_OUTLINE_HIGH_PRECISION;
/* copy the _unscaled_ advance width */
metrics->horiAdvance =
FIXED_TO_INT( decoder.builder.advance.x );
@ -501,11 +503,6 @@
FIXED_TO_INT( decoder.builder.advance.y );
}
t1glyph->format = FT_GLYPH_FORMAT_OUTLINE;
if ( t1size && t1size->metrics.y_ppem < 24 )
t1glyph->outline.flags |= FT_OUTLINE_HIGH_PRECISION;
#if 1
/* apply the font matrix, if any */
if ( font_matrix.xx != 0x10000L || font_matrix.yy != 0x10000L ||

Loading…
Cancel
Save