Simplified the incremental loading system for CFF fonts and fixed
a problem with the handling of the deprecated version of the Type 2 endchar command, that emulates Type 1 'seac'. This version now works with the GhostScript-to-FreeType bridge currently under development.
This commit is contained in:
parent
5c0d3a4dca
commit
9eefed125a
|
@ -570,25 +570,20 @@
|
||||||
/* For incremental fonts get the character data using the */
|
/* For incremental fonts get the character data using the */
|
||||||
/* callback function. */
|
/* callback function. */
|
||||||
if ( face->root.internal->incremental_interface )
|
if ( face->root.internal->incremental_interface )
|
||||||
{
|
{
|
||||||
FT_Data data;
|
FT_Data data;
|
||||||
FT_Error error = face->root.internal->incremental_interface->funcs->get_glyph_data(
|
FT_Error error = face->root.internal->incremental_interface->funcs->get_glyph_data(
|
||||||
face->root.internal->incremental_interface->object,
|
face->root.internal->incremental_interface->object,
|
||||||
glyph_index, &data );
|
glyph_index, &data );
|
||||||
|
|
||||||
|
|
||||||
*pointer = (FT_Byte*)data.pointer;
|
*pointer = (FT_Byte*)data.pointer;
|
||||||
*length = data.length;
|
*length = data.length;
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
|
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
|
||||||
|
|
||||||
{
|
{
|
||||||
CFF_Font cff = (CFF_Font)(face->extra.data);
|
CFF_Font cff = (CFF_Font)(face->extra.data);
|
||||||
|
|
||||||
|
|
||||||
return cff_index_access_element( &cff->charstrings_index, glyph_index,
|
return cff_index_access_element( &cff->charstrings_index, glyph_index,
|
||||||
pointer, length );
|
pointer, length );
|
||||||
}
|
}
|
||||||
|
@ -608,12 +603,10 @@
|
||||||
/* For incremental fonts get the character data using the */
|
/* For incremental fonts get the character data using the */
|
||||||
/* callback function. */
|
/* callback function. */
|
||||||
if ( face->root.internal->incremental_interface )
|
if ( face->root.internal->incremental_interface )
|
||||||
{
|
{
|
||||||
FT_Data data;
|
FT_Data data;
|
||||||
|
data.pointer = *pointer;
|
||||||
|
data.length = length;
|
||||||
data.pointer = *pointer;
|
|
||||||
data.length = length;
|
|
||||||
face->root.internal->incremental_interface->funcs->free_glyph_data(
|
face->root.internal->incremental_interface->funcs->free_glyph_data(
|
||||||
face->root.internal->incremental_interface->object,&data );
|
face->root.internal->incremental_interface->object,&data );
|
||||||
}
|
}
|
||||||
|
@ -621,9 +614,7 @@
|
||||||
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
|
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
|
||||||
|
|
||||||
{
|
{
|
||||||
CFF_Font cff = (CFF_Font)(face->extra.data);
|
CFF_Font cff = (CFF_Font)(face->extra.data);
|
||||||
|
|
||||||
|
|
||||||
cff_index_forget_element( &cff->charstrings_index, pointer );
|
cff_index_forget_element( &cff->charstrings_index, pointer );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -640,14 +631,26 @@
|
||||||
FT_Int bchar_index, achar_index, n_base_points;
|
FT_Int bchar_index, achar_index, n_base_points;
|
||||||
FT_Outline* base = decoder->builder.base;
|
FT_Outline* base = decoder->builder.base;
|
||||||
TT_Face face = decoder->builder.face;
|
TT_Face face = decoder->builder.face;
|
||||||
CFF_Font cff = (CFF_Font)(face->extra.data);
|
|
||||||
FT_Vector left_bearing, advance;
|
FT_Vector left_bearing, advance;
|
||||||
FT_Byte* charstring;
|
FT_Byte* charstring;
|
||||||
FT_ULong charstring_len;
|
FT_ULong charstring_len;
|
||||||
|
|
||||||
|
#ifdef FT_CONFIG_OPTION_INCREMENTAL
|
||||||
|
/* Incremental fonts don't necessarily have valid charsets. */
|
||||||
|
/* They use the character code, not the glyph index, in this case. */
|
||||||
|
if ( face->root.internal->incremental_interface )
|
||||||
|
{
|
||||||
|
bchar_index = bchar;
|
||||||
|
achar_index = achar;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
|
||||||
|
{
|
||||||
|
CFF_Font cff = (CFF_Font)(face->extra.data);
|
||||||
|
|
||||||
bchar_index = cff_lookup_glyph_by_stdcharcode( cff, bchar );
|
bchar_index = cff_lookup_glyph_by_stdcharcode( cff, bchar );
|
||||||
achar_index = cff_lookup_glyph_by_stdcharcode( cff, achar );
|
achar_index = cff_lookup_glyph_by_stdcharcode( cff, achar );
|
||||||
|
}
|
||||||
|
|
||||||
if ( bchar_index < 0 || achar_index < 0 )
|
if ( bchar_index < 0 || achar_index < 0 )
|
||||||
{
|
{
|
||||||
|
@ -699,7 +702,8 @@
|
||||||
&charstring, &charstring_len );
|
&charstring, &charstring_len );
|
||||||
if ( !error )
|
if ( !error )
|
||||||
{
|
{
|
||||||
error = cff_decoder_parse_charstrings( decoder, charstring, charstring_len );
|
error = cff_decoder_parse_charstrings( decoder, charstring,
|
||||||
|
charstring_len );
|
||||||
|
|
||||||
if ( error )
|
if ( error )
|
||||||
goto Exit;
|
goto Exit;
|
||||||
|
@ -2312,7 +2316,7 @@
|
||||||
|
|
||||||
|
|
||||||
#ifdef FT_CONFIG_OPTION_INCREMENTAL
|
#ifdef FT_CONFIG_OPTION_INCREMENTAL
|
||||||
/* Control data and length may not be available for incremental */
|
/* Control data and length may not be available for incremental */
|
||||||
/* fonts. */
|
/* fonts. */
|
||||||
if ( face->root.internal->incremental_interface )
|
if ( face->root.internal->incremental_interface )
|
||||||
{
|
{
|
||||||
|
@ -2326,13 +2330,11 @@
|
||||||
/* See how charstring loads at cff_index_access_element() in */
|
/* See how charstring loads at cff_index_access_element() in */
|
||||||
/* cffload.c. */
|
/* cffload.c. */
|
||||||
{
|
{
|
||||||
CFF_IndexRec csindex = cff->charstrings_index;
|
CFF_IndexRec csindex = cff->charstrings_index;
|
||||||
|
glyph->root.control_data =
|
||||||
|
csindex.bytes + csindex.offsets[glyph_index] - 1;
|
||||||
glyph->root.control_data =
|
glyph->root.control_len =
|
||||||
csindex.bytes + csindex.offsets[glyph_index] - 1;
|
charstring_len;
|
||||||
glyph->root.control_len =
|
|
||||||
charstring_len;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2027,8 +2027,7 @@
|
||||||
FT_LOCAL_DEF( FT_Error )
|
FT_LOCAL_DEF( FT_Error )
|
||||||
cff_font_load( FT_Stream stream,
|
cff_font_load( FT_Stream stream,
|
||||||
FT_Int face_index,
|
FT_Int face_index,
|
||||||
CFF_Font font,
|
CFF_Font font )
|
||||||
CFF_Face face )
|
|
||||||
{
|
{
|
||||||
static const FT_Frame_Field cff_header_fields[] =
|
static const FT_Frame_Field cff_header_fields[] =
|
||||||
{
|
{
|
||||||
|
@ -2048,11 +2047,6 @@
|
||||||
FT_ULong base_offset;
|
FT_ULong base_offset;
|
||||||
CFF_FontRecDict dict;
|
CFF_FontRecDict dict;
|
||||||
|
|
||||||
#ifndef FT_CONFIG_OPTION_INCREMENTAL
|
|
||||||
FT_UNUSED( face );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
FT_ZERO( font );
|
FT_ZERO( font );
|
||||||
|
|
||||||
font->stream = stream;
|
font->stream = stream;
|
||||||
|
@ -2164,27 +2158,21 @@
|
||||||
else
|
else
|
||||||
font->num_subfonts = 0;
|
font->num_subfonts = 0;
|
||||||
|
|
||||||
#ifdef FT_CONFIG_OPTION_INCREMENTAL
|
/* read the charstrings index now */
|
||||||
/* Incremental fonts don't need character recipes. */
|
if ( dict->charstrings_offset == 0 )
|
||||||
if ( !face->root.internal->incremental_interface )
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
/* read the charstrings index now */
|
FT_ERROR(( "cff_font_load: no charstrings offset!\n" ));
|
||||||
if ( dict->charstrings_offset == 0 )
|
error = CFF_Err_Unknown_File_Format;
|
||||||
{
|
goto Exit;
|
||||||
FT_ERROR(( "cff_font_load: no charstrings offset!\n" ));
|
|
||||||
error = CFF_Err_Unknown_File_Format;
|
|
||||||
goto Exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( FT_STREAM_SEEK( base_offset + dict->charstrings_offset ) )
|
|
||||||
goto Exit;
|
|
||||||
|
|
||||||
error = cff_new_index( &font->charstrings_index, stream, 0 );
|
|
||||||
if ( error )
|
|
||||||
goto Exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( FT_STREAM_SEEK( base_offset + dict->charstrings_offset ) )
|
||||||
|
goto Exit;
|
||||||
|
|
||||||
|
error = cff_new_index( &font->charstrings_index, stream, 0 );
|
||||||
|
if ( error )
|
||||||
|
goto Exit;
|
||||||
|
|
||||||
/* explicit the global subrs */
|
/* explicit the global subrs */
|
||||||
font->num_global_subrs = font->global_subrs_index.count;
|
font->num_global_subrs = font->global_subrs_index.count;
|
||||||
font->num_glyphs = font->charstrings_index.count;
|
font->num_glyphs = font->charstrings_index.count;
|
||||||
|
@ -2199,7 +2187,7 @@
|
||||||
if ( font->num_glyphs > 0 )
|
if ( font->num_glyphs > 0 )
|
||||||
{
|
{
|
||||||
error = cff_charset_load( &font->charset, font->num_glyphs, stream,
|
error = cff_charset_load( &font->charset, font->num_glyphs, stream,
|
||||||
base_offset, dict->charset_offset );
|
base_offset, dict->charset_offset );
|
||||||
if ( error )
|
if ( error )
|
||||||
goto Exit;
|
goto Exit;
|
||||||
|
|
||||||
|
|
|
@ -55,8 +55,7 @@ FT_BEGIN_HEADER
|
||||||
FT_LOCAL( FT_Error )
|
FT_LOCAL( FT_Error )
|
||||||
cff_font_load( FT_Stream stream,
|
cff_font_load( FT_Stream stream,
|
||||||
FT_Int face_index,
|
FT_Int face_index,
|
||||||
CFF_Font font,
|
CFF_Font font );
|
||||||
CFF_Face face );
|
|
||||||
|
|
||||||
FT_LOCAL( void )
|
FT_LOCAL( void )
|
||||||
cff_font_done( CFF_Font font );
|
cff_font_done( CFF_Font font );
|
||||||
|
|
|
@ -342,7 +342,7 @@
|
||||||
goto Exit;
|
goto Exit;
|
||||||
|
|
||||||
face->extra.data = cff;
|
face->extra.data = cff;
|
||||||
error = cff_font_load( stream, face_index, cff, face );
|
error = cff_font_load( stream, face_index, cff );
|
||||||
if ( error )
|
if ( error )
|
||||||
goto Exit;
|
goto Exit;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue