Alexei Podtelezhnikov pushed to branch svg_metrics at FreeType / FreeType
Commits:
-
d54a7ea8
by Alexei Podtelezhnikov at 2022-10-21T07:18:06-04:00
2 changed files:
Changes:
... | ... | @@ -356,18 +356,14 @@ |
356 | 356 | |
357 | 357 | #ifdef FT_CONFIG_OPTION_SVG
|
358 | 358 | /* check for OT-SVG */
|
359 | - if ( ( load_flags & FT_LOAD_COLOR ) &&
|
|
360 | - ( (TT_Face)glyph->root.face )->svg )
|
|
359 | + if ( ( load_flags & FT_LOAD_COLOR ) && face->svg )
|
|
361 | 360 | {
|
362 | 361 | /*
|
363 | 362 | * We load the SVG document and try to grab the advances from the
|
364 | 363 | * table. For the bearings we rely on the presetting hook to do that.
|
365 | 364 | */
|
366 | 365 | |
367 | - FT_Short dummy;
|
|
368 | - FT_UShort advanceX;
|
|
369 | - FT_UShort advanceY;
|
|
370 | - SFNT_Service sfnt;
|
|
366 | + SFNT_Service sfnt = (SFNT_Service)face->sfnt;
|
|
371 | 367 | |
372 | 368 | |
373 | 369 | if ( size && (size->root.metrics.x_ppem < 1 ||
|
... | ... | @@ -379,10 +375,17 @@ |
379 | 375 | |
380 | 376 | FT_TRACE3(( "Trying to load SVG glyph\n" ));
|
381 | 377 | |
382 | - sfnt = (SFNT_Service)((TT_Face)glyph->root.face)->sfnt;
|
|
383 | 378 | error = sfnt->load_svg_doc( (FT_GlyphSlot)glyph, glyph_index );
|
384 | 379 | if ( !error )
|
385 | 380 | {
|
381 | + FT_Fixed x_scale = size->root.metrics.x_scale;
|
|
382 | + FT_Fixed y_scale = size->root.metrics.y_scale;
|
|
383 | + |
|
384 | + FT_Short dummy;
|
|
385 | + FT_UShort advanceX;
|
|
386 | + FT_UShort advanceY;
|
|
387 | + |
|
388 | + |
|
386 | 389 | FT_TRACE3(( "Successfully loaded SVG glyph\n" ));
|
387 | 390 | |
388 | 391 | glyph->root.format = FT_GLYPH_FORMAT_SVG;
|
... | ... | @@ -407,17 +410,8 @@ |
407 | 410 | glyph->root.linearHoriAdvance = advanceX;
|
408 | 411 | glyph->root.linearVertAdvance = advanceY;
|
409 | 412 | |
410 | - advanceX =
|
|
411 | - (FT_UShort)FT_MulDiv( advanceX,
|
|
412 | - glyph->root.face->size->metrics.x_ppem,
|
|
413 | - glyph->root.face->units_per_EM );
|
|
414 | - advanceY =
|
|
415 | - (FT_UShort)FT_MulDiv( advanceY,
|
|
416 | - glyph->root.face->size->metrics.y_ppem,
|
|
417 | - glyph->root.face->units_per_EM );
|
|
418 | - |
|
419 | - glyph->root.metrics.horiAdvance = advanceX << 6;
|
|
420 | - glyph->root.metrics.vertAdvance = advanceY << 6;
|
|
413 | + glyph->root.metrics.horiAdvance = FT_MulFix( advanceX, x_scale );
|
|
414 | + glyph->root.metrics.vertAdvance = FT_MulFix( advanceY, y_scale );
|
|
421 | 415 | |
422 | 416 | return error;
|
423 | 417 | }
|
... | ... | @@ -2871,21 +2871,22 @@ |
2871 | 2871 | /* check for OT-SVG */
|
2872 | 2872 | if ( ( load_flags & FT_LOAD_COLOR ) && ( (TT_Face)glyph->face )->svg )
|
2873 | 2873 | {
|
2874 | - SFNT_Service sfnt;
|
|
2875 | - |
|
2876 | - FT_Short leftBearing;
|
|
2877 | - FT_Short topBearing;
|
|
2878 | - FT_UShort advanceX;
|
|
2879 | - FT_UShort advanceY;
|
|
2874 | + TT_Face face = (TT_Face)glyph->face;
|
|
2875 | + SFNT_Service sfnt = (SFNT_Service)face->sfnt;
|
|
2880 | 2876 | |
2881 | 2877 | |
2882 | 2878 | FT_TRACE3(( "Trying to load SVG glyph\n" ));
|
2883 | - sfnt = (SFNT_Service)( (TT_Face)glyph->face )->sfnt;
|
|
2884 | 2879 | |
2885 | 2880 | error = sfnt->load_svg_doc( glyph, glyph_index );
|
2886 | 2881 | if ( !error )
|
2887 | 2882 | {
|
2888 | - TT_Face face = (TT_Face)glyph->face;
|
|
2883 | + FT_Fixed x_scale = size->root.metrics.x_scale;
|
|
2884 | + FT_Fixed y_scale = size->root.metrics.y_scale;
|
|
2885 | + |
|
2886 | + FT_Short leftBearing;
|
|
2887 | + FT_Short topBearing;
|
|
2888 | + FT_UShort advanceX;
|
|
2889 | + FT_UShort advanceY;
|
|
2889 | 2890 | |
2890 | 2891 | |
2891 | 2892 | FT_TRACE3(( "Successfully loaded SVG glyph\n" ));
|
... | ... | @@ -2906,15 +2907,8 @@ |
2906 | 2907 | glyph->linearHoriAdvance = advanceX;
|
2907 | 2908 | glyph->linearVertAdvance = advanceY;
|
2908 | 2909 | |
2909 | - advanceX = (FT_UShort)FT_MulDiv( advanceX,
|
|
2910 | - glyph->face->size->metrics.x_ppem,
|
|
2911 | - glyph->face->units_per_EM );
|
|
2912 | - advanceY = (FT_UShort)FT_MulDiv( advanceY,
|
|
2913 | - glyph->face->size->metrics.y_ppem,
|
|
2914 | - glyph->face->units_per_EM );
|
|
2915 | - |
|
2916 | - glyph->metrics.horiAdvance = advanceX << 6;
|
|
2917 | - glyph->metrics.vertAdvance = advanceY << 6;
|
|
2910 | + glyph->metrics.horiAdvance = FT_MulFix( advanceX, x_scale );
|
|
2911 | + glyph->metrics.vertAdvance = FT_MulFix( advanceY, y_scale );
|
|
2918 | 2912 | |
2919 | 2913 | return error;
|
2920 | 2914 | }
|