freetype-commit
[Top][All Lists]
Advanced

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

[freetype2] ewaldhew-wip ef412f6 7/7: fix 2000ppem retry


From: Hew Yih Shiuan Ewald
Subject: [freetype2] ewaldhew-wip ef412f6 7/7: fix 2000ppem retry
Date: Wed, 19 Jul 2017 05:21:00 -0400 (EDT)

branch: ewaldhew-wip
commit ef412f6f4687dfabf056ad3a92f56a605bd2d964
Author: Ewald Hew <address@hidden>
Commit: Ewald Hew <address@hidden>

    fix 2000ppem retry
---
 src/cid/cidgload.c  | 18 +++++++++++++-----
 src/type1/t1gload.c | 25 ++++++++++++++++---------
 2 files changed, 29 insertions(+), 14 deletions(-)

diff --git a/src/cid/cidgload.c b/src/cid/cidgload.c
index 1b95902..1cff59f 100644
--- a/src/cid/cidgload.c
+++ b/src/cid/cidgload.c
@@ -56,6 +56,8 @@
     FT_ULong       glyph_length = 0;
     PSAux_Service  psaux        = (PSAux_Service)face->psaux;
 
+    FT_Bool        force_scaling = FALSE;
+
 #ifdef FT_CONFIG_OPTION_INCREMENTAL
     FT_Incremental_InterfaceRec *inc =
                                   face->root.internal->incremental_interface;
@@ -194,7 +196,6 @@
                                                             charstring + 
cs_offset,
                                                             glyph_length - 
cs_offset );
 
-#if 0
         /* Adobe's engine uses 16.16 numbers everywhere;              */
         /* as a consequence, glyphs larger than 2000ppem get rejected */
         if ( FT_ERR_EQ( error, Glyph_Too_Big ) )
@@ -202,15 +203,14 @@
           /* this time, we retry unhinted and scale up the glyph later on */
           /* (the engine uses and sets the hardcoded value 0x10000 / 64 = */
           /* 0x400 for both `x_scale' and `y_scale' in this case)         */
-          hinting       = FALSE;
+          ((CID_GlyphSlot)decoder->builder.glyph)->hint = FALSE;
+
           force_scaling = TRUE;
-          glyph->hint   = hinting;
 
           error = psaux->t1_decoder_funcs->parse_charstrings( &psdecoder,
                                                               charstring + 
cs_offset,
                                                               glyph_length - 
cs_offset );
         }
-#endif
       }
     }
 
@@ -240,6 +240,8 @@
   Exit:
     FT_FREE( charstring );
 
+    ((CID_GlyphSlot)decoder->builder.glyph)->scaled = force_scaling;
+
     return error;
   }
 
@@ -328,6 +330,7 @@
     T1_DecoderRec  decoder;
     CID_Face       face = (CID_Face)cidglyph->face;
     FT_Bool        hinting;
+    FT_Bool        scaled;
 
     PSAux_Service  psaux = (PSAux_Service)face->psaux;
     FT_Matrix      font_matrix;
@@ -351,8 +354,10 @@
 
     hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE   ) == 0 &&
                        ( load_flags & FT_LOAD_NO_HINTING ) == 0 );
+    scaled  = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE   ) == 0 );
 
     glyph->hint      = hinting;
+    glyph->scaled    = scaled;
     cidglyph->format = FT_GLYPH_FORMAT_OUTLINE;
 
     error = psaux->t1_decoder_funcs->init( &decoder,
@@ -378,6 +383,9 @@
     if ( error )
       goto Exit;
 
+    hinting     = glyph->hint;
+    scaled      = glyph->scaled;
+
     font_matrix = decoder.font_matrix;
     font_offset = decoder.font_offset;
 
@@ -451,7 +459,7 @@
         metrics->vertAdvance += font_offset.y;
       }
 
-      if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 )
+      if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 || scaled )
       {
         /* scale the outline and the metrics */
         FT_Int       n;
diff --git a/src/type1/t1gload.c b/src/type1/t1gload.c
index 1320409..9ada73e 100644
--- a/src/type1/t1gload.c
+++ b/src/type1/t1gload.c
@@ -42,7 +42,8 @@
   static FT_Error
   T1_Parse_Glyph_And_Get_Char_String( T1_Decoder  decoder,
                                       FT_UInt     glyph_index,
-                                      FT_Data*    char_string )
+                                      FT_Data*    char_string,
+                                      FT_Bool*    force_scaling )
   {
     T1_Face   face  = (T1_Face)decoder->builder.face;
     T1_Font   type1 = &face->type1;
@@ -105,7 +106,6 @@
                                                   
(FT_Byte*)char_string->pointer,
                                                   
(FT_ULong)char_string->length );
 
-#if 0 /* TODO(ewaldhew) */
         /* Adobe's engine uses 16.16 numbers everywhere;              */
         /* as a consequence, glyphs larger than 2000ppem get rejected */
         if ( FT_ERR_EQ( error, Glyph_Too_Big ) )
@@ -113,15 +113,14 @@
           /* this time, we retry unhinted and scale up the glyph later on */
           /* (the engine uses and sets the hardcoded value 0x10000 / 64 = */
           /* 0x400 for both `x_scale' and `y_scale' in this case)         */
-          hinting       = FALSE;
-          force_scaling = TRUE;
-          glyph->hint   = hinting;
+          ((T1_GlyphSlot)decoder->builder.glyph)->hint = FALSE;
+
+          *force_scaling = TRUE;
 
           error = decoder_funcs->parse_charstrings( &psdecoder,
                                                     
(FT_Byte*)char_string->pointer,
                                                     
(FT_ULong)char_string->length );
         }
-#endif
       }
 
     }
@@ -158,8 +157,10 @@
                   FT_UInt     glyph_index )
   {
     FT_Data   glyph_data;
+    FT_Bool   force_scaling = FALSE;
     FT_Error  error = T1_Parse_Glyph_And_Get_Char_String(
-                        decoder, glyph_index, &glyph_data );
+                        decoder, glyph_index, &glyph_data,
+                        &force_scaling );
 
 
 #ifdef FT_CONFIG_OPTION_INCREMENTAL
@@ -326,6 +327,8 @@
     T1_DecoderRec           decoder;
     T1_Face                 face = (T1_Face)t1glyph->face;
     FT_Bool                 hinting;
+    FT_Bool                 scaled;
+    FT_Bool                 force_scaling = FALSE;
     T1_Font                 type1         = &face->type1;
     PSAux_Service           psaux         = (PSAux_Service)face->psaux;
     const T1_Decoder_Funcs  decoder_funcs = psaux->t1_decoder_funcs;
@@ -373,8 +376,10 @@
 
     hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE   ) == 0 &&
                        ( load_flags & FT_LOAD_NO_HINTING ) == 0 );
+    scaled  = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE   ) == 0 );
 
     glyph->hint     = hinting;
+    glyph->scaled   = scaled;
     t1glyph->format = FT_GLYPH_FORMAT_OUTLINE;
 
     error = decoder_funcs->init( &decoder,
@@ -404,13 +409,15 @@
 
     /* now load the unscaled outline */
     error = T1_Parse_Glyph_And_Get_Char_String( &decoder, glyph_index,
-                                                &glyph_data );
+                                                &glyph_data,
+                                                &force_scaling );
     if ( error )
       goto Exit;
 #ifdef FT_CONFIG_OPTION_INCREMENTAL
     glyph_data_loaded = 1;
 #endif
 
+    hinting     = glyph->hint;
     font_matrix = decoder.font_matrix;
     font_offset = decoder.font_offset;
 
@@ -500,7 +507,7 @@
         }
 #endif
 
-        if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 )
+        if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 || force_scaling )
         {
           /* scale the outline and the metrics */
           FT_Int       n;



reply via email to

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