freetype-commit
[Top][All Lists]
Advanced

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

[freetype2] master 4a46686: [type1, cff, cid] Streamline font matrix app


From: Alexei Podtelezhnikov
Subject: [freetype2] master 4a46686: [type1, cff, cid] Streamline font matrix application.
Date: Thu, 13 Aug 2015 03:46:35 +0000

branch: master
commit 4a46686508160d5d131b1d84bc33327f24cdea22
Author: Alexei Podtelezhnikov <address@hidden>
Commit: Alexei Podtelezhnikov <address@hidden>

    [type1,cff,cid] Streamline font matrix application.
    
    * src/type1/t1gload.c (T1_Load_Glyph): Directly modify advances only
    if font matrix is not trivial.
    * src/cff/cffgload.c (cff_slot_load): Ditto.
    * sff/cid/cidgload.c (cid_slot_load_glyph): Ditto for advances and the
    entire outline.
---
 ChangeLog           |   10 ++++++++++
 src/cff/cffgload.c  |   34 +++++++++++++++++-----------------
 src/cid/cidgload.c  |   32 ++++++++++++++++++--------------
 src/type1/t1gload.c |   24 +++++++++++++-----------
 4 files changed, 58 insertions(+), 42 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4221676..e2a62d7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2015-08-12  Alexei Podtelezhnikov  <address@hidden>
+
+       [type1,cff,cid] Streamline font matrix application.
+
+       * src/type1/t1gload.c (T1_Load_Glyph): Directly modify advances only
+       if font matrix is not trivial.
+       * src/cff/cffgload.c (cff_slot_load): Ditto.
+       * sff/cid/cidgload.c (cid_slot_load_glyph): Ditto for advances and the
+       entire outline.
+
 2015-08-11  Werner Lemberg  <address@hidden>
 
        [builds/unix] Minor.
diff --git a/src/cff/cffgload.c b/src/cff/cffgload.c
index a075ddc..5f57403 100644
--- a/src/cff/cffgload.c
+++ b/src/cff/cffgload.c
@@ -2949,7 +2949,6 @@
       {
         FT_BBox            cbox;
         FT_Glyph_Metrics*  metrics = &glyph->root.metrics;
-        FT_Vector          advance;
         FT_Bool            has_vertical_info;
 
 
@@ -3014,26 +3013,27 @@
 
         glyph->root.outline.flags |= FT_OUTLINE_REVERSE_FILL;
 
-        if ( !( font_matrix.xx == 0x10000L &&
-                font_matrix.yy == 0x10000L &&
-                font_matrix.xy == 0        &&
-                font_matrix.yx == 0        ) )
+        /* apply the font matrix, if any */
+        if ( font_matrix.xx != 0x10000L || font_matrix.yy != 0x10000L ||
+             font_matrix.xy != 0        || font_matrix.yx != 0        )
+        {
           FT_Outline_Transform( &glyph->root.outline, &font_matrix );
 
-        if ( !( font_offset.x == 0 &&
-                font_offset.y == 0 ) )
-          FT_Outline_Translate( &glyph->root.outline,
-                                font_offset.x, font_offset.y );
+          metrics->horiAdvance = FT_MulFix( metrics->horiAdvance,
+                                            font_matrix.xx );
+          metrics->vertAdvance = FT_MulFix( metrics->vertAdvance,
+                                            font_matrix.yy );
+        }
 
-        advance.x = metrics->horiAdvance;
-        advance.y = 0;
-        FT_Vector_Transform( &advance, &font_matrix );
-        metrics->horiAdvance = advance.x + font_offset.x;
+        if ( font_offset.x || font_offset.y )
+        {
+          FT_Outline_Translate( &glyph->root.outline,
+                                font_offset.x,
+                                font_offset.y );
 
-        advance.x = 0;
-        advance.y = metrics->vertAdvance;
-        FT_Vector_Transform( &advance, &font_matrix );
-        metrics->vertAdvance = advance.y + font_offset.y;
+          metrics->horiAdvance += font_offset.x;
+          metrics->vertAdvance += font_offset.y;
+        }
 
         if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 || force_scaling )
         {
diff --git a/src/cid/cidgload.c b/src/cid/cidgload.c
index d06293c..d00674f 100644
--- a/src/cid/cidgload.c
+++ b/src/cid/cidgload.c
@@ -357,7 +357,6 @@
     {
       FT_BBox            cbox;
       FT_Glyph_Metrics*  metrics = &cidglyph->metrics;
-      FT_Vector          advance;
 
 
       /* copy the _unscaled_ advance width */
@@ -377,22 +376,27 @@
       if ( cidsize->metrics.y_ppem < 24 )
         cidglyph->outline.flags |= FT_OUTLINE_HIGH_PRECISION;
 
-      /* apply the font matrix */
-      FT_Outline_Transform( &cidglyph->outline, &font_matrix );
+      /* apply the font matrix, if any */
+      if ( font_matrix.xx != 0x10000L || font_matrix.yy != 0x10000L ||
+           font_matrix.xy != 0        || font_matrix.yx != 0        )
+      {
+        FT_Outline_Transform( &cidglyph->outline, &font_matrix );
 
-      FT_Outline_Translate( &cidglyph->outline,
-                            font_offset.x,
-                            font_offset.y );
+        metrics->horiAdvance = FT_MulFix( metrics->horiAdvance,
+                                          font_matrix.xx );
+        metrics->vertAdvance = FT_MulFix( metrics->vertAdvance,
+                                          font_matrix.yy );
+      }
 
-      advance.x = metrics->horiAdvance;
-      advance.y = 0;
-      FT_Vector_Transform( &advance, &font_matrix );
-      metrics->horiAdvance = advance.x + font_offset.x;
+      if ( font_offset.x || font_offset.y )
+      {
+        FT_Outline_Translate( &cidglyph->outline,
+                              font_offset.x,
+                              font_offset.y );
 
-      advance.x = 0;
-      advance.y = metrics->vertAdvance;
-      FT_Vector_Transform( &advance, &font_matrix );
-      metrics->vertAdvance = advance.y + font_offset.y;
+        metrics->horiAdvance += font_offset.x;
+        metrics->vertAdvance += font_offset.y;
+      }
 
       if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 )
       {
diff --git a/src/type1/t1gload.c b/src/type1/t1gload.c
index 829e874..85ada2e 100644
--- a/src/type1/t1gload.c
+++ b/src/type1/t1gload.c
@@ -395,7 +395,6 @@
       {
         FT_BBox            cbox;
         FT_Glyph_Metrics*  metrics = &t1glyph->metrics;
-        FT_Vector          advance;
 
 
         /* copy the _unscaled_ advance width */
@@ -427,23 +426,26 @@
 
 #if 1
         /* apply the font matrix, if any */
-        if ( font_matrix.xx != 0x10000L || font_matrix.yy != font_matrix.xx ||
-             font_matrix.xy != 0        || font_matrix.yx != 0              )
+        if ( font_matrix.xx != 0x10000L || font_matrix.yy != 0x10000L ||
+             font_matrix.xy != 0        || font_matrix.yx != 0        )
+        {
           FT_Outline_Transform( &t1glyph->outline, &font_matrix );
 
+          metrics->horiAdvance = FT_MulFix( metrics->horiAdvance,
+                                            font_matrix.xx );
+          metrics->vertAdvance = FT_MulFix( metrics->vertAdvance,
+                                            font_matrix.yy );
+        }
+
         if ( font_offset.x || font_offset.y )
+        {
           FT_Outline_Translate( &t1glyph->outline,
                                 font_offset.x,
                                 font_offset.y );
 
-        advance.x = metrics->horiAdvance;
-        advance.y = 0;
-        FT_Vector_Transform( &advance, &font_matrix );
-        metrics->horiAdvance = advance.x + font_offset.x;
-        advance.x = 0;
-        advance.y = metrics->vertAdvance;
-        FT_Vector_Transform( &advance, &font_matrix );
-        metrics->vertAdvance = advance.y + font_offset.y;
+          metrics->horiAdvance += font_offset.x;
+          metrics->vertAdvance += font_offset.y;
+        }
 #endif
 
         if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 )



reply via email to

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