shithub: freetype+ttf2subf

Download patch

ref: b2d5fefea8fb242e90b7f06d10602a8a081bec0f
parent: f3bdbb4552065cda62185e08b094cffd74c74753
author: Tom Kacvinsky <[email protected]>
date: Wed Jan 24 17:41:20 EST 2001

In function parse_font_matrix, added heuristic to get units_per_EM
from the font matrix.

In parse_dict, deleted test to see if the FontInfo keyword has been
seen.  Deletion of this test allows fonts without FontInfo
dictionaries to be parsed by the Type 1 driver.

In T1_Open_Face, deleted empty subroutines array test to make sure
fonts with no subroutines still are parsed.

git/fs: mount .git/fs: mount/attach disallowed
--- a/src/type1/t1load.c
+++ b/src/type1/t1load.c
@@ -878,7 +878,9 @@
     T1_ParserRec*  parser = &loader->parser;
     FT_Matrix*     matrix = &face->type1.font_matrix;
     FT_Vector*     offset = &face->type1.font_offset;
+    FT_Face        root   = (FT_Face)&face->root;
     FT_Fixed       temp[6];
+    FT_Fixed       temp_scale;
 
 
     if ( matrix->xx || matrix->yx )
@@ -887,14 +889,21 @@
 
     (void)T1_ToFixedArray( parser, 6, temp, 3 );
 
-    /* we need to scale the values by 1.0/temp[3] */
-    if ( temp[3] != 0x10000L )
+    temp_scale = ABS( temp[3] );
+
+    /* Set Units per EM based on FontMatrix values. We set the value to */
+    /* 1000 / temp_scale, because temp_scale was already multiplied by  */
+    /* 1000 (in t1_tofixed, from psobjs.c).                             */
+    root->units_per_EM = FT_DivFix( 0x10000L, FT_DivFix( temp_scale, 1000 ) );
+
+    /* we need to scale the values by 1.0/temp_scale */
+    if ( temp_scale != 0x10000L )
     {
-      temp[0] = FT_DivFix( temp[0], temp[3] );
-      temp[1] = FT_DivFix( temp[1], temp[3] );
-      temp[2] = FT_DivFix( temp[2], temp[3] );
-      temp[4] = FT_DivFix( temp[4], temp[3] );
-      temp[5] = FT_DivFix( temp[5], temp[3] );
+      temp[0] = FT_DivFix( temp[0], temp_scale );
+      temp[1] = FT_DivFix( temp[1], temp_scale );
+      temp[2] = FT_DivFix( temp[2], temp_scale );
+      temp[4] = FT_DivFix( temp[4], temp_scale );
+      temp[5] = FT_DivFix( temp[5], temp_scale );
       temp[3] = 0x10000L;
     }
 
@@ -1461,13 +1470,7 @@
           len  = cur2 - cur;
           if ( len > 0 && len < 22 )
           {
-            if ( !loader->fontdata )
             {
-              if ( strncmp( (char*)cur, "FontInfo", 8 ) == 0 )
-                loader->fontdata = 1;
-            }
-            else
-            {
               /* now, compare the immediate name to the keyword table */
               T1_Field*  keyword = (T1_Field*)t1_keywords;
 
@@ -1594,10 +1597,13 @@
     /* to the Type1 data                                            */
     type1->num_glyphs = loader.num_glyphs;
 
-    if ( !loader.subrs.init )
+    if ( loader.subrs.init )
     {
-      FT_ERROR(( "T1_Open_Face: no subrs array in face!\n" ));
-      error = T1_Err_Invalid_File_Format;
+      loader.subrs.init  = 0;
+      type1->num_subrs   = loader.num_subrs;
+      type1->subrs_block = loader.subrs.block;
+      type1->subrs       = loader.subrs.elements;
+      type1->subrs_len   = loader.subrs.lengths;
     }
 
     if ( !loader.charstrings.init )
@@ -1605,12 +1611,6 @@
       FT_ERROR(( "T1_Open_Face: no charstrings array in face!\n" ));
       error = T1_Err_Invalid_File_Format;
     }
-
-    loader.subrs.init  = 0;
-    type1->num_subrs   = loader.num_subrs;
-    type1->subrs_block = loader.subrs.block;
-    type1->subrs       = loader.subrs.elements;
-    type1->subrs_len   = loader.subrs.lengths;
 
     loader.charstrings.init  = 0;
     type1->charstrings_block = loader.charstrings.block;