No need to call `FT_Load_Glyph' with `XX_NO_SCALE'.

We no longer need TTF/CFF outlines for SVG rendering.
This commit is contained in:
Moazin Khatti 2019-08-07 16:26:42 +05:00
parent a227395912
commit 74f80fba49
4 changed files with 36 additions and 18 deletions

View File

@ -893,20 +893,6 @@
if ( load_flags & FT_LOAD_BITMAP_METRICS_ONLY )
load_flags &= ~FT_LOAD_RENDER;
#ifdef FT_CONFIG_OPTION_SVG
if ( ( load_flags & FT_LOAD_COLOR ) &&
( ttface->svg ) )
{
FT_TRACE3(( "SVG table exists, calling `FT_Load_Glyph' with `FT_LOAD_NO_SCALE'\n" ));
/* load the TTF/CFF glyph without any scaling,
* this is so that ultimately, these outlines
* can be used to calculate the bounding box and
* the advance metrics
*/
FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_SCALE);
}
#endif
/*
* Determine whether we need to auto-hint or not.
* The general rules are:

View File

@ -359,6 +359,24 @@
{
FT_TRACE3(( "Successfully loaded SVG glyph\n" ));
glyph->root.format = FT_GLYPH_FORMAT_SVG;
FT_Short leftBearing, topBearing;
FT_UShort advanceX, advanceY;
sfnt->get_metrics( face,
FALSE,
glyph_index,
&leftBearing,
&advanceX );
sfnt->get_metrics( face,
TRUE,
glyph_index,
&topBearing,
&advanceY );
advanceX *= ((float)glyph->root.face->size->metrics.x_ppem)/
((float)glyph->root.face->units_per_EM) * 64.0;
advanceY *= ((float)glyph->root.face->size->metrics.y_ppem)/
((float)glyph->root.face->units_per_EM) * 64.0;
glyph->root.metrics.horiAdvance = advanceX;
glyph->root.metrics.vertAdvance = advanceY;
return error;
}
FT_TRACE3(( "Failed to load SVG glyph\n" ));

View File

@ -328,10 +328,6 @@
FT_TRACE5(( "svg_document:\n%.*s\n", doc_length, doc_list ));
glyph->other = svg_document;
glyph->metrics.horiAdvance *= ((float)glyph->face->size->metrics.x_ppem)/
((float)glyph->face->units_per_EM) * 64.0;
glyph->metrics.vertAdvance *= ((float)glyph->face->size->metrics.y_ppem)/
((float)glyph->face->units_per_EM) * 64.0;
return FT_Err_Ok;
}

View File

@ -2919,6 +2919,24 @@
{
FT_TRACE3(( "Successfully loaded SVG glyph\n" ));
glyph->format = FT_GLYPH_FORMAT_SVG;
FT_Short leftBearing, topBearing;
FT_UShort advanceX, advanceY;
sfnt->get_metrics( glyph->face,
FALSE,
glyph_index,
&leftBearing,
&advanceX );
sfnt->get_metrics( glyph->face,
TRUE,
glyph_index,
&topBearing,
&advanceY );
advanceX *= ((float)glyph->face->size->metrics.x_ppem)/
((float)glyph->face->units_per_EM) * 64.0;
advanceY *= ((float)glyph->face->size->metrics.y_ppem)/
((float)glyph->face->units_per_EM) * 64.0;
glyph->metrics.horiAdvance = advanceX;
glyph->metrics.vertAdvance = advanceY;
return error;
}
FT_TRACE3(( "Failed to load SVG glyph\n" ));