freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2] GSoC-2019-moazin 9583292 3/3: No need to call `FT_Load_Glyph


From: Moazin Khatti
Subject: [freetype2] GSoC-2019-moazin 9583292 3/3: No need to call `FT_Load_Glyph' with `XX_NO_SCALE'.
Date: Wed, 7 Aug 2019 07:27:31 -0400 (EDT)

branch: GSoC-2019-moazin
commit 9583292513e58b2f198ccccd0fb5b4d9a014e04c
Author: Moazin Khatti <address@hidden>
Commit: Moazin Khatti <address@hidden>

    No need to call `FT_Load_Glyph' with `XX_NO_SCALE'.
    
    We no longer need TTF/CFF outlines for SVG rendering.
---
 src/base/ftobjs.c      | 14 --------------
 src/cff/cffgload.c     | 18 ++++++++++++++++++
 src/truetype/ttgload.c | 18 ++++++++++++++++++
 3 files changed, 36 insertions(+), 14 deletions(-)

diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index a77c985..5e5da50 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -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:
diff --git a/src/cff/cffgload.c b/src/cff/cffgload.c
index 629b9b1..9911e8a 100644
--- a/src/cff/cffgload.c
+++ b/src/cff/cffgload.c
@@ -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" ));
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index 817852a..f92cbd1 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -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" ));



reply via email to

[Prev in Thread] Current Thread [Next in Thread]