Added support for incrementally loaded Type 1 faces.

This commit is contained in:
Graham Asher 2002-07-18 16:57:43 +00:00
parent e975b6fd90
commit 48c0188aa1
1 changed files with 55 additions and 15 deletions

View File

@ -53,21 +53,62 @@
/*************************************************************************/
FT_CALLBACK_DEF( FT_Error )
T1_Parse_Glyph( T1_Decoder decoder,
FT_UInt glyph_index )
FT_LOCAL_DEF(FT_Error) T1_Parse_Glyph_And_Get_Char_String( T1_Decoder decoder,
FT_UInt glyph_index,
FT_Data* char_string )
{
T1_Face face = (T1_Face)decoder->builder.face;
T1_Font type1 = &face->type1;
T1_Face face = (T1_Face)decoder->builder.face;
T1_Font type1 = &face->type1;
FT_Error error = 0;
decoder->font_matrix = type1->font_matrix;
decoder->font_offset = type1->font_offset;
return decoder->funcs.parse_charstrings(
decoder,
type1->charstrings [glyph_index],
type1->charstrings_len[glyph_index] );
#ifdef FT_CONFIG_OPTION_INCREMENTAL
/* For incremental fonts get the character data using the callback function. */
if (face->root.incremental_interface)
error = face->root.incremental_interface->funcs->get_glyph_data(face->root.incremental_interface->object,
glyph_index,char_string);
else
#endif
/* For ordinary fonts get the character data stored in the face record. */
{
char_string->pointer = type1->charstrings[glyph_index];
char_string->length = type1->charstrings_len[glyph_index];
}
if (!error)
error = decoder->funcs.parse_charstrings(decoder,(FT_Byte*)char_string->pointer,char_string->length);
#ifdef FT_CONFIG_OPTION_INCREMENTAL
/* Incremental fonts can optionally override the metrics. */
if (!error && face->root.incremental_interface && face->root.incremental_interface->funcs->get_glyph_metrics)
{
FT_Bool found = FALSE;
FT_Basic_Glyph_Metrics metrics;
error = face->root.incremental_interface->funcs->get_glyph_metrics(face->root.incremental_interface->object,
glyph_index,FALSE,&metrics,&found);
if (found)
{
decoder->builder.left_bearing.x = metrics.bearing_x;
decoder->builder.left_bearing.y = metrics.bearing_y;
decoder->builder.advance.x = metrics.advance;
decoder->builder.advance.y = 0;
}
}
#endif
return error;
}
FT_CALLBACK_DEF( FT_Error )
T1_Parse_Glyph( T1_Decoder decoder,
FT_UInt glyph_index )
{
FT_Data data;
return T1_Parse_Glyph_And_Get_Char_String(decoder,glyph_index,&data);
}
@ -154,7 +195,7 @@
FT_Matrix font_matrix;
FT_Vector font_offset;
FT_Data char_string;
if ( load_flags & FT_LOAD_NO_RECURSE )
load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
@ -188,9 +229,8 @@
decoder.subrs = type1->subrs;
decoder.subrs_len = type1->subrs_len;
/* now load the unscaled outline */
error = T1_Parse_Glyph( &decoder, glyph_index );
error = T1_Parse_Glyph_And_Get_Char_String( &decoder, glyph_index, &char_string );
if ( error )
goto Exit;
@ -311,8 +351,8 @@
/* Set control data to the glyph charstrings. Note that this is */
/* _not_ zero-terminated. */
glyph->root.control_data = type1->charstrings [glyph_index];
glyph->root.control_len = type1->charstrings_len[glyph_index];
glyph->root.control_data = (FT_Byte*)char_string.pointer;
glyph->root.control_len = char_string.length;
}
Exit: