* 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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226
diff --git a/ChangeLog b/ChangeLog
index b2f0b2f..deceb2f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2002-07-11 David Turner <david@freetype.org>
+
+ * 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 <david@freetype.org>
* src/cff/cffobjs.c: small fix to select the Unicode charmap by default
diff --git a/include/freetype/internal/psaux.h b/include/freetype/internal/psaux.h
index 2f1557d..fbb7434 100644
--- a/include/freetype/internal/psaux.h
+++ b/include/freetype/internal/psaux.h
@@ -178,6 +178,7 @@ FT_BEGIN_HEADER
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 @@ FT_BEGIN_HEADER
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
@@ -271,6 +273,10 @@ FT_BEGIN_HEADER
#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, \
_fname, _fmax )
diff --git a/include/freetype/t1tables.h b/include/freetype/t1tables.h
index 660ea8a..200ba9b 100644
--- a/include/freetype/t1tables.h
+++ b/include/freetype/t1tables.h
@@ -208,7 +208,7 @@ FT_BEGIN_HEADER
#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
@@ -244,6 +244,8 @@ FT_BEGIN_HEADER
FT_ULong blend_bitflags;
+ FT_BBox* bboxes [T1_MAX_MM_DESIGNS + 1];
+
} PS_BlendRec, *PS_Blend;
diff --git a/src/psaux/psobjs.c b/src/psaux/psobjs.c
index c24a0c7..6bbb1ca 100644
--- 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;
@@ -922,6 +940,23 @@
}
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;
+
default:
/* an error occured */
goto Fail;
diff --git a/src/type1/t1load.c b/src/type1/t1load.c
index 4868a98..00f8d8e 100644
--- 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 )
diff --git a/src/type1/t1tokens.h b/src/type1/t1tokens.h
index 5f5d8ce..dea5054 100644
--- 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 */