the T1_Face definition changed slightly to clearly separate the

Type 1 font content from the rest. This implied some changes to
the following files.
This commit is contained in:
David Turner 2000-01-27 13:35:16 +00:00
parent b3a85b00c4
commit 76bbd5793f
5 changed files with 108 additions and 111 deletions

View File

@ -191,9 +191,9 @@
glyph_name = t1_standard_strings[t1_standard_encoding[charcode]];
for ( n = 0; n < face->num_glyphs; n++ )
for ( n = 0; n < face->type1.num_glyphs; n++ )
{
T1_String* name = (T1_String*)face->glyph_names[n];
T1_String* name = (T1_String*)face->type1.glyph_names[n];
if ( name && strcmp(name,glyph_name) == 0 )
return n;
@ -238,6 +238,7 @@
FT_Outline* cur = &decoder->builder.current;
FT_Outline* base = &decoder->builder.base;
T1_Vector left_bearing, advance;
T1_Font* type1 = &face->type1;
bchar_index = lookup_glyph_by_stdcharcode( face, bchar );
achar_index = lookup_glyph_by_stdcharcode( face, achar );
@ -257,11 +258,11 @@
cur->contours = base->contours + base->n_contours;
error = T1_Parse_CharStrings( decoder,
face->charstrings [bchar_index],
face->charstrings_len[bchar_index],
face->num_subrs,
face->subrs,
face->subrs_len );
type1->charstrings [bchar_index],
type1->charstrings_len[bchar_index],
type1->num_subrs,
type1->subrs,
type1->subrs_len );
if (error) return error;
n_base_points = cur->n_points;
@ -284,11 +285,11 @@
cur->contours = base->contours + base->n_contours;
error = T1_Parse_CharStrings( decoder,
face->charstrings [achar_index],
face->charstrings_len[achar_index],
face->num_subrs,
face->subrs,
face->subrs_len );
type1->charstrings [achar_index],
type1->charstrings_len[achar_index],
type1->num_subrs,
type1->subrs,
type1->subrs_len );
if (error) return error;
/* adjust contours in accented character outline */
@ -1063,6 +1064,7 @@
T1_Error error;
T1_Decoder decoder;
T1_Int glyph_index;
T1_Font* type1 = &face->type1;
*max_advance = 0;
@ -1074,15 +1076,15 @@
/* For each glyph, parse the glyph charstring and extract */
/* the advance width.. */
for ( glyph_index = 0; glyph_index < face->num_glyphs; glyph_index++ )
for ( glyph_index = 0; glyph_index < type1->num_glyphs; glyph_index++ )
{
/* now get load the unscaled outline */
error = T1_Parse_CharStrings( &decoder,
face->charstrings [glyph_index],
face->charstrings_len[glyph_index],
face->num_subrs,
face->subrs,
face->subrs_len );
type1->charstrings [glyph_index],
type1->charstrings_len[glyph_index],
type1->num_subrs,
type1->subrs,
type1->subrs_len );
/* ignore the error if one occured - skip to next glyph */
(void)error;
}
@ -1274,9 +1276,9 @@
/* type is set to 1, this means that we have an "open path", */
/* also called a 'stroke'. The FreeType raster doesn't support */
/* opened path, so we'll close it explicitely there.. */
if ( builder->path_begun && builder->face->paint_type == 1 )
if ( builder->path_begun && builder->face->type1.paint_type == 1 )
{
if ( builder->face->paint_type == 1 )
if ( builder->face->type1.paint_type == 1 )
{
error = close_open_path( builder );
if (error) return error;
@ -1411,6 +1413,7 @@
T1_Decoder decoder;
T1_Face face = (T1_Face)glyph->root.face;
T1_Bool hinting;
T1_Font* type1 = &face->type1;
glyph->x_scale = size->root.metrics.x_scale;
glyph->y_scale = size->root.metrics.y_scale;
@ -1450,11 +1453,11 @@
glyph->hints->vert_stems.num_stems = 0;
error = T1_Parse_CharStrings( &decoder,
face->charstrings [glyph_index],
face->charstrings_len[glyph_index],
face->num_subrs,
face->subrs,
face->subrs_len );
type1->charstrings [glyph_index],
type1->charstrings_len[glyph_index],
type1->num_subrs,
type1->subrs,
type1->subrs_len );
/* All right, pass 1 is finished, now grid-fit all stem hints */
T1_Hint_Stems( &decoder.builder );
@ -1467,11 +1470,11 @@
decoder.builder.pass = 1;
error = T1_Parse_CharStrings( &decoder,
face->charstrings [glyph_index],
face->charstrings_len[glyph_index],
face->num_subrs,
face->subrs,
face->subrs_len );
type1->charstrings [glyph_index],
type1->charstrings_len[glyph_index],
type1->num_subrs,
type1->subrs,
type1->subrs_len );
/* save new glyph tables */
T1_Done_Builder( &decoder.builder );
@ -1486,11 +1489,11 @@
/* now load the unscaled outline */
error = T1_Parse_CharStrings( &decoder,
face->charstrings [glyph_index],
face->charstrings_len[glyph_index],
face->num_subrs,
face->subrs,
face->subrs_len );
type1->charstrings [glyph_index],
type1->charstrings_len[glyph_index],
type1->num_subrs,
type1->subrs,
type1->subrs_len );
/* save new glyph tables */
T1_Done_Builder( &decoder.builder );

View File

@ -105,7 +105,7 @@
T1_Error t1_set_blue_zones( T1_Size size )
{
T1_Face face = (T1_Face)size->root.face;
T1_Private* priv = &face->private_dict;
T1_Font* priv = &face->type1;
T1_Int n;
T1_Int blues[24];
T1_Int num_bottom;
@ -285,8 +285,8 @@
T1_Pos standard_width;
T1_Fixed scale;
T1_Face face = (T1_Face)size->root.face;
T1_Private* priv = &face->private_dict;
T1_Face face = (T1_Face)size->root.face;
T1_Font* priv = &face->type1;
T1_Size_Hints* hints = size->hints;
/* start with horizontal snap zones */
@ -1250,7 +1250,7 @@
void T1_Hint_Stems( T1_Builder* builder )
{
T1_Glyph_Hints* hints = builder->glyph->hints;
T1_Private* priv = &builder->face->private_dict;
T1_Font* priv = &builder->face->type1;
T1_Size size = builder->size;
T1_Fixed scale_x = size->root.metrics.x_scale;

View File

@ -39,13 +39,13 @@
parser->state_index = 0;
parser->state_stack[0] = dict_none;
parser->encoding_type = encoding_none;
parser->encoding_type = t1_encoding_none;
parser->encoding_names = 0;
parser->encoding_offsets = 0;
parser->encoding_lengths = 0;
parser->dump_tokens = 0;
face->private_dict.lenIV = 4; /* XXX : is it sure ?? */
face->type1.lenIV = 4; /* XXX : is it sure ?? */
}
@ -191,7 +191,7 @@
{
T1_Token* token = parser->top+1;
FT_Memory memory = parser->face->root.memory;
T1_Encoding* encode = &parser->face->encoding;
T1_Encoding* encode = &parser->face->type1.encoding;
T1_Error error = 0;
if (token->kind == tok_keyword &&
@ -210,8 +210,8 @@
/* Now copy the encoding */
switch (token->kind2)
{
case key_ExpertEncoding : parser->encoding_type = encoding_expert;
default : parser->encoding_type = encoding_standard; break;
case key_ExpertEncoding : parser->encoding_type = t1_encoding_expert;
default : parser->encoding_type = t1_encoding_standard; break;
}
}
else
@ -260,6 +260,7 @@
{
T1_Token* top = parser->top;
T1_Face face = parser->face;
T1_Font* type1 = &face->type1;
switch ( top[0].kind2 )
{
@ -273,19 +274,19 @@
T1_Error error;
T1_Int len = top[1].len;
if ( ALLOC( face->font_name, len+1 ) )
if ( ALLOC( type1->font_name, len+1 ) )
{
parser->error = error;
return error;
}
MEM_Copy( face->font_name,
MEM_Copy( type1->font_name,
parser->tokenizer->base + top[1].start,
len );
face->font_name[len] = '\0';
type1->font_name[len] = '\0';
}
else
face->font_name = CopyString( parser );
type1->font_name = CopyString( parser );
break;
case imm_Encoding:
@ -293,31 +294,31 @@
break;
case imm_PaintType:
face->paint_type = (T1_Byte)CopyInteger( parser );
type1->paint_type = (T1_Byte)CopyInteger( parser );
break;
case imm_FontType:
face->font_type = (T1_Byte)CopyInteger( parser );
type1->font_type = (T1_Byte)CopyInteger( parser );
break;
case imm_FontMatrix:
CopyMatrix( parser, &face->font_matrix );
CopyMatrix( parser, &type1->font_matrix );
break;
case imm_FontBBox:
CopyBBox( parser, &face->font_bbox );
CopyBBox( parser, &type1->font_bbox );
break;
case imm_UniqueID:
face->unique_id = CopyInteger( parser );
type1->unique_id = CopyInteger( parser );
break;
case imm_StrokeWidth:
face->stroke_width = CopyInteger( parser );
type1->stroke_width = CopyInteger( parser );
break;
case imm_FontID:
face->font_id = CopyInteger( parser );
type1->font_id = CopyInteger( parser );
break;
default:
@ -347,8 +348,8 @@
static
T1_Error Do_Def_FontInfo( T1_Parser* parser )
{
T1_Token* top = parser->top;
T1_FontInfo* info = &parser->face->font_info;
T1_Token* top = parser->top;
T1_Font* info = &parser->face->type1;
switch ( top[0].kind2 )
{
@ -415,8 +416,8 @@
static
T1_Error Do_Def_Private( T1_Parser* parser )
{
T1_Token* top = parser->top;
T1_Private* priv = &parser->face->private_dict;
T1_Token* top = parser->top;
T1_Font* priv = &parser->face->type1;
switch ( top[0].kind2 )
{
@ -605,7 +606,7 @@
T1_Error error = T1_Err_Ok;
T1_Face face = parser->face;
T1_Token* top = parser->top;
T1_Encoding* encode = &face->encoding;
T1_Encoding* encode = &face->type1.encoding;
T1_Int index;
/* record and check the character code */
@ -709,7 +710,7 @@
count = (T1_Int)CopyInteger( parser );
error = parser->error; if (error) goto Exit;
if ( index < 0 || index >= face->num_subrs )
if ( index < 0 || index >= face->type1.num_subrs )
{
FT_ERROR(( "T1.Parse.put: invalid character code\n" ));
goto Syntax_Error;
@ -722,8 +723,8 @@
t1_decrypt( base, count, 4330 );
tokzer->cursor += count;
base += face->private_dict.lenIV;
count -= face->private_dict.lenIV;
base += face->type1.lenIV;
count -= face->type1.lenIV;
error = T1_Add_Table( &parser->table, index, base, count );
}
@ -806,8 +807,8 @@
t1_decrypt( base, count, 4330 );
tokzer->cursor += count; /* skip */
base += face->private_dict.lenIV;
count -= face->private_dict.lenIV;
base += face->type1.lenIV;
count -= face->type1.lenIV;
error = T1_Add_Table( &parser->table, index*2+1, base, count );
}
@ -925,7 +926,7 @@
{
case imm_Encoding:
{
T1_Encoding* encode = &face->encoding;
T1_Encoding* encode = &face->type1.encoding;
new_state = dict_encoding;
@ -941,15 +942,15 @@
error = T1_New_Table( &parser->table, count, memory );
if (error) goto Exit;
parser->encoding_type = encoding_array;
parser->encoding_type = t1_encoding_array;
}
break;
case imm_Subrs:
{
new_state = dict_subrs;
face->num_subrs = count;
new_state = dict_subrs;
face->type1.num_subrs = count;
error = T1_New_Table( &parser->table, count, memory );
if (error) goto Exit;
@ -981,27 +982,28 @@
T1_Error Finalise_Parsing( T1_Parser* parser )
{
T1_Face face = parser->face;
T1_Font* type1 = &face->type1;
FT_Memory memory = face->root.memory;
T1_Table* strings = &parser->table;
T1_Int num_glyphs;
T1_Int n;
T1_Error error;
num_glyphs = face->num_glyphs = parser->cur_name;
num_glyphs = type1->num_glyphs = parser->cur_name;
/* allocate glyph names and charstrings arrays */
if ( ALLOC_ARRAY( face->glyph_names , num_glyphs, T1_String* ) ||
ALLOC_ARRAY( face->charstrings , num_glyphs, T1_Byte* ) ||
ALLOC_ARRAY( face->charstrings_len, num_glyphs, T1_Int* ) )
if ( ALLOC_ARRAY( type1->glyph_names , num_glyphs, T1_String* ) ||
ALLOC_ARRAY( type1->charstrings , num_glyphs, T1_Byte* ) ||
ALLOC_ARRAY( type1->charstrings_len, num_glyphs, T1_Int* ) )
return error;
/* copy glyph names and charstrings offsets and lengths */
face->charstrings_block = strings->block;
type1->charstrings_block = strings->block;
for ( n = 0; n < num_glyphs; n++ )
{
face->glyph_names[n] = (T1_String*)strings->elements[2*n];
face->charstrings[n] = strings->elements[2*n+1];
face->charstrings_len[n] = strings->lengths [2*n+1];
type1->glyph_names[n] = (T1_String*)strings->elements[2*n];
type1->charstrings[n] = strings->elements[2*n+1];
type1->charstrings_len[n] = strings->lengths [2*n+1];
}
/* now free the old tables */
@ -1009,7 +1011,7 @@
FREE( strings->lengths );
/* Compute encoding if required. */
if (parser->encoding_type == encoding_none)
if (parser->encoding_type == t1_encoding_none)
{
FT_ERROR(( "T1.Parse.Finalise : no encoding specified in font file\n" ));
return T1_Err_Syntax_Error;
@ -1017,7 +1019,7 @@
{
T1_Int n;
T1_Encoding* encode = &face->encoding;
T1_Encoding* encode = &type1->encoding;
encode->code_first = encode->num_chars-1;
encode->code_last = 0;
@ -1030,12 +1032,12 @@
switch (parser->encoding_type)
{
case encoding_standard:
case t1_encoding_standard:
index = t1_standard_encoding[n];
names = (T1_String**)t1_standard_strings;
break;
case encoding_expert:
case t1_encoding_expert:
index = t1_expert_encoding[n];
names = (T1_String**)t1_standard_strings;
break;
@ -1056,7 +1058,7 @@
/* lookup glyph index from name */
for ( m = 0; m < num_glyphs; m++ )
{
if ( strncmp( face->glyph_names[m], name, len ) == 0 )
if ( strncmp( type1->glyph_names[m], name, len ) == 0 )
{
encode->char_index[n] = m;
break;
@ -1069,7 +1071,7 @@
}
}
parser->encoding_type = encoding_none;
parser->encoding_type = t1_encoding_none;
FREE( parser->encoding_names );
FREE( parser->encoding_lengths );
FREE( parser->encoding_offsets );
@ -1086,6 +1088,7 @@
T1_Error Parse_T1_FontProgram( T1_Parser* parser )
{
T1_Error error;
T1_Font* type1 = &parser->face->type1;
for (;;)
{
@ -1151,7 +1154,7 @@
dict_charstrings, &count );
if (error) goto Exit;
face->num_glyphs = count;
type1->num_glyphs = count;
error = T1_New_Table( &parser->table, count*2, face->root.memory );
if (error) goto Exit;
@ -1210,14 +1213,12 @@
case dict_subrs:
{
T1_Face face = parser->face;
/* copy recorder sub-routines */
T1_Done_Table( &parser->table );
parser->subrs = parser->table.block;
face->subrs = parser->table.elements;
face->subrs_len = parser->table.lengths;
parser->subrs = parser->table.block;
type1->subrs = parser->table.elements;
type1->subrs_len = parser->table.lengths;
parser->state_index--;
}

View File

@ -217,9 +217,10 @@
/* Init the face object fields */
/* Now set up root face fields */
{
FT_Face root = (FT_Face)&face->root;
FT_Face root = (FT_Face)&face->root;
T1_Font* type1 = &face->type1;
root->num_glyphs = face->num_glyphs;
root->num_glyphs = type1->num_glyphs;
root->num_charmaps = 1;
root->face_index = face_index;
@ -227,17 +228,17 @@
root->face_flags |= FT_FACE_FLAG_HORIZONTAL;
if ( face->font_info.is_fixed_pitch )
if ( type1->is_fixed_pitch )
root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
/* XXX : TO DO - add kerning with .afm support */
/* get style name - be careful, some broken fonts only */
/* have a /FontName dictionary entry .. !! */
root->family_name = face->font_info.family_name;
root->family_name = type1->family_name;
if (root->family_name)
{
char* full = face->font_info.full_name;
char* full = type1->full_name;
char* family = root->family_name;
while ( *family && *full == *family )
@ -251,9 +252,9 @@
else
{
/* do we have a /FontName ?? */
if (face->font_name)
if (type1->font_name)
{
root->family_name = face->font_name;
root->family_name = type1->font_name;
root->style_name = "Regular";
}
}
@ -262,18 +263,18 @@
root->num_fixed_sizes = 0;
root->available_sizes = 0;
root->bbox = face->font_bbox;
root->bbox = type1->font_bbox;
root->units_per_EM = 1000;
root->ascender = (T1_Short)face->font_bbox.yMax;
root->descender = -(T1_Short)face->font_bbox.yMin;
root->ascender = (T1_Short)type1->font_bbox.yMax;
root->descender = -(T1_Short)type1->font_bbox.yMin;
root->height = ((root->ascender + root->descender)*12)/10;
/* now compute the maximum advance width */
root->max_advance_width = face->private_dict.standard_width;
root->max_advance_width = type1->standard_width;
/* compute max advance width for proportional fonts */
if (!face->font_info.is_fixed_pitch)
if (!type1->is_fixed_pitch)
{
T1_Int max_advance;
@ -288,8 +289,8 @@
root->max_advance_height = root->height;
root->underline_position = face->font_info.underline_position;
root->underline_thickness = face->font_info.underline_thickness;
root->underline_position = type1->underline_position;
root->underline_thickness = type1->underline_thickness;
root->max_points = 0;
root->max_contours = 0;

View File

@ -61,14 +61,6 @@
} T1_DictState;
typedef enum T1_EncodingType_
{
encoding_none = 0,
encoding_array,
encoding_standard,
encoding_expert
} T1_EncodingType;
/*************************************************************************
*
* <Struct> T1_Table