shithub: freetype+ttf2subf

Download patch

ref: 8db6a0702147a56a5c26fb66e6caf7de9869953e
parent: d473204c007a2cf9aa5662fcf58c3d09cec2492c
author: David Turner <[email protected]>
date: Thu Jul 11 07:26:21 EDT 2002

* include/freetype/t1tables.h, include/freetype/internal/psaux.h,
    src/psaux/psobjs.c, src/type1/t1load.c, src/type1/t1tokens.h:
    fixing a bug in the Type 1 loader that prevented valid font bounding
    boxes to be loaded from multiple master fonts.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2002-07-11  David Turner  <[email protected]>
+
+    * include/freetype/t1tables.h, include/freetype/internal/psaux.h,
+    src/psaux/psobjs.c, src/type1/t1load.c, src/type1/t1tokens.h:
+    fixing a bug in the Type 1 loader that prevented valid font bounding
+    boxes to be loaded from multiple master fonts. 
+
 2002-07-10  David Turner  <[email protected]>
 
     * src/cff/cffobjs.c: small fix to select the Unicode charmap by default
--- a/include/freetype/internal/psaux.h
+++ b/include/freetype/internal/psaux.h
@@ -178,6 +178,7 @@
     T1_FIELD_TYPE_INTEGER,
     T1_FIELD_TYPE_FIXED,
     T1_FIELD_TYPE_STRING,
+    T1_FIELD_TYPE_BBOX,
     T1_FIELD_TYPE_INTEGER_ARRAY,
     T1_FIELD_TYPE_FIXED_ARRAY,
     T1_FIELD_TYPE_CALLBACK,
@@ -194,6 +195,7 @@
     T1_FIELD_LOCATION_FONT_DICT,
     T1_FIELD_LOCATION_FONT_INFO,
     T1_FIELD_LOCATION_PRIVATE,
+    T1_FIELD_LOCATION_BBOX,
 
     /* do not remove */
     T1_FIELD_LOCATION_MAX
@@ -270,6 +272,10 @@
 
 #define T1_FIELD_STRING( _ident, _fname )                             \
           T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_STRING, _fname )
+
+#define T1_FIELD_BBOX( _ident, _fname )                             \
+          T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_BBOX, _fname )
+
 
 #define T1_FIELD_NUM_TABLE( _ident, _fname, _fmax )                \
           T1_NEW_TABLE_FIELD( _ident, T1_FIELD_TYPE_INTEGER_ARRAY, \
--- a/include/freetype/t1tables.h
+++ b/include/freetype/t1tables.h
@@ -208,7 +208,7 @@
 #define T1_MAX_MM_DESIGNS     16
 
   /* maximum number of Multiple Masters axes, as defined in the spec */
-#define T1_MAX_MM_AXIS         4
+#define T1_MAX_MM_AXIS        4
 
   /* maximum number of elements in a design map */
 #define T1_MAX_MM_MAP_POINTS  20
@@ -243,6 +243,8 @@
     PS_Private       privates  [T1_MAX_MM_DESIGNS + 1];
 
     FT_ULong         blend_bitflags;
+
+    FT_BBox*         bboxes    [T1_MAX_MM_DESIGNS + 1];
 
   } PS_BlendRec, *PS_Blend;
 
--- a/src/psaux/psobjs.c
+++ b/src/psaux/psobjs.c
@@ -852,8 +852,26 @@
     cur   = token.start;
     limit = token.limit;
 
-    if ( token.type == T1_TOKEN_TYPE_ARRAY )
+    /* we must detect arrays */
+    if ( field->type == T1_FIELD_TYPE_BBOX )
     {
+      T1_TokenRec  token2;
+      FT_Byte*     old_cur   = parser->cursor;
+      FT_Byte*     old_limit = parser->limit;
+      
+      parser->cursor = token.start;
+      parser->limit  = token.limit;
+      
+      PS_Parser_ToToken( parser, &token2 );
+      parser->cursor = old_cur;
+      parser->limit  = old_limit;
+      
+      if ( token2.type == T1_TOKEN_TYPE_ARRAY )
+        goto FieldArray;
+    }
+    else if ( token.type == T1_TOKEN_TYPE_ARRAY )
+    {
+    FieldArray:
       /* if this is an array, and we have no blend, an error occurs */
       if ( max_objects == 0 )
         goto Fail;
@@ -919,6 +937,23 @@
           string[len] = 0;
 
           *(FT_String**)q = string;
+        }
+        break;
+
+      case T1_FIELD_TYPE_BBOX:
+        {
+          FT_Fixed  temp[4];
+          FT_BBox*  bbox = (FT_BBox*)q;
+          
+          /* we need the '[' and ']' delimiters */
+          token.start--;
+          token.limit++;
+          (void) t1_tofixedarray( &token.start, token.limit, 4, temp, 0 );
+
+          bbox->xMin = FT_RoundFix( temp[0] );
+          bbox->yMin = FT_RoundFix( temp[1] );
+          bbox->xMax = FT_RoundFix( temp[2] );
+          bbox->yMax = FT_RoundFix( temp[3] );
         }
         break;
 
--- a/src/type1/t1load.c
+++ b/src/type1/t1load.c
@@ -123,6 +123,7 @@
         /* allocate the blend `private' and `font_info' dictionaries */
         if ( FT_NEW_ARRAY( blend->font_infos[1], num_designs     ) ||
              FT_NEW_ARRAY( blend->privates[1], num_designs       ) ||
+             FT_NEW_ARRAY( blend->bboxes[1], num_designs         ) ||
              FT_NEW_ARRAY( blend->weight_vector, num_designs * 2 ) )
           goto Exit;
 
@@ -130,11 +131,13 @@
 
         blend->font_infos[0] = &face->type1.font_info;
         blend->privates  [0] = &face->type1.private_dict;
+        blend->bboxes    [0] = &face->type1.font_bbox;
 
         for ( nn = 2; nn <= num_designs; nn++ )
         {
           blend->privates[nn]   = blend->privates  [nn - 1] + 1;
           blend->font_infos[nn] = blend->font_infos[nn - 1] + 1;
+          blend->bboxes[nn]     = blend->bboxes    [nn - 1] + 1;
         }
 
         blend->num_designs   = num_designs;
@@ -347,11 +350,13 @@
       /* release blend `private' and `font info' dictionaries */
       FT_FREE( blend->privates[1] );
       FT_FREE( blend->font_infos[1] );
+      FT_FREE( blend->bboxes[1] );
 
       for ( n = 0; n < num_designs; n++ )
       {
         blend->privates  [n] = 0;
         blend->font_infos[n] = 0;
+        blend->bboxes    [n] = 0;
       }
 
       /* release weight vectors */
@@ -735,6 +740,18 @@
       }
       break;
 
+    case T1_FIELD_LOCATION_BBOX:
+      dummy_object = &face->type1.font_bbox;
+      objects      = &dummy_object;
+      max_objects  = 0;
+
+      if ( blend )
+      {
+        objects     = (void**)blend->bboxes;
+        max_objects = blend->num_designs;
+      }
+      break;
+
     default:
       dummy_object = &face->type1;
       objects      = &dummy_object;
@@ -863,6 +880,7 @@
   }
 
 
+#if 0
   static void
   parse_font_bbox( T1_Face    face,
                    T1_Loader  loader )
@@ -878,6 +896,7 @@
     bbox->xMax = FT_RoundFix( temp[2] );
     bbox->yMax = FT_RoundFix( temp[3] );
   }
+#endif
 
 
   static void
@@ -1464,7 +1483,9 @@
 
     /* now add the special functions... */
     T1_FIELD_CALLBACK( "FontName", parse_font_name )
+#if 0    
     T1_FIELD_CALLBACK( "FontBBox", parse_font_bbox )
+#endif    
     T1_FIELD_CALLBACK( "FontMatrix", parse_font_matrix )
     T1_FIELD_CALLBACK( "Encoding", parse_encoding )
     T1_FIELD_CALLBACK( "Subrs", parse_subrs )
--- a/src/type1/t1tokens.h
+++ b/src/type1/t1tokens.h
@@ -69,5 +69,12 @@
   T1_FIELD_NUM( "FontType", font_type )
   T1_FIELD_NUM( "StrokeWidth", stroke_width )
 
+#undef  FT_STRUCTURE
+#define FT_STRUCTURE  FT_BBox
+#undef  T1CODE
+#define T1CODE        T1_FIELD_LOCATION_BBOX
+
+  T1_FIELD_BBOX("FontBBox", xMin )
+
 
 /* END */