diff options
Diffstat (limited to 'src/truetype/ttgload.c')
-rw-r--r-- | src/truetype/ttgload.c | 64 |
1 files changed, 63 insertions, 1 deletions
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c index e77305931..33d743bd3 100644 --- a/src/truetype/ttgload.c +++ b/src/truetype/ttgload.c @@ -2919,6 +2919,12 @@ } } + if ( load_flags & FT_LOAD_SBITS_ONLY ) + { + error = FT_THROW( Invalid_Argument ); + goto Exit; + } + #endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ /* if FT_LOAD_NO_SCALE is not set, `ttmetrics' must be valid */ @@ -2928,12 +2934,68 @@ goto Exit; } - if ( load_flags & FT_LOAD_SBITS_ONLY ) +#ifdef FT_CONFIG_OPTION_SVG + + /* check for OT-SVG */ + if ( ( load_flags & FT_LOAD_COLOR ) && ( (TT_Face)glyph->face )->svg ) + { + SFNT_Service sfnt; + + FT_Short leftBearing; + FT_Short topBearing; + FT_UShort advanceX; + FT_UShort advanceY; + + + FT_TRACE3(( "Trying to load SVG glyph\n" )); + sfnt = (SFNT_Service)( (TT_Face)glyph->face )->sfnt; + + error = sfnt->load_svg_doc( glyph, glyph_index ); + if ( !error ) + { + TT_Face face = (TT_Face)glyph->face; + + + FT_TRACE3(( "Successfully loaded SVG glyph\n" )); + + glyph->format = FT_GLYPH_FORMAT_SVG; + + sfnt->get_metrics( face, + FALSE, + glyph_index, + &leftBearing, + &advanceX ); + sfnt->get_metrics( face, + TRUE, + glyph_index, + &topBearing, + &advanceY ); + + advanceX = (FT_UShort)FT_MulDiv( advanceX, + glyph->face->size->metrics.x_ppem, + glyph->face->units_per_EM ); + advanceY = (FT_UShort)FT_MulDiv( advanceY, + glyph->face->size->metrics.y_ppem, + glyph->face->units_per_EM ); + + glyph->metrics.horiAdvance = advanceX << 6; + glyph->metrics.vertAdvance = advanceY << 6; + + return error; + } + + FT_TRACE3(( "Failed to load SVG glyph\n" )); + } + + /* return immediately if we only want SVG glyphs */ + if ( load_flags & FT_LOAD_SVG_ONLY ) { error = FT_THROW( Invalid_Argument ); goto Exit; } +#endif /* FT_CONFIG_OPTION_SVG */ + error = tt_loader_init( &loader, size, glyph, load_flags, FALSE ); if ( error ) goto Exit; |