* 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.
This commit is contained in:
David Turner 2002-07-11 11:26:21 +00:00
parent d473204c00
commit 8db6a07021
6 changed files with 80 additions and 2 deletions

View File

@ -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

View File

@ -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 )

View File

@ -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;

View File

@ -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;

View File

@ -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 )

View File

@ -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 */