@ -496,11 +496,91 @@
}
static FT_Error
cff_ps_get_font_extra ( CFF_Face face ,
PS_FontExtraRec * afont_extra )
{
CFF_Font cff = ( CFF_Font ) face - > extra . data ;
FT_Error error = FT_Err_Ok ;
if ( cff & & cff - > font_extra = = NULL )
{
CFF_FontRecDict dict = & cff - > top_font . font_dict ;
PS_FontExtraRec * font_extra = NULL ;
FT_Memory memory = face - > root . memory ;
FT_String * embedded_postscript ;
if ( FT_ALLOC ( font_extra , sizeof ( * font_extra ) ) )
goto Fail ;
font_extra - > fs_type = 0u ;
embedded_postscript = cff_index_get_sid_string (
cff ,
dict - > embedded_postscript ) ;
if ( embedded_postscript )
{
FT_String * start_fstype ;
FT_String * start_def ;
/* Identify the XYZ integer in `/FSType XYZ def' substring. */
if ( ( start_fstype = ft_strstr ( embedded_postscript ,
" /FSType " ) ) ! = NULL & &
( start_def = ft_strstr ( start_fstype +
sizeof ( " /FSType " ) - 1 ,
" def " ) ) ! = NULL )
{
FT_String * s ;
for ( s = start_fstype + sizeof ( " /FSType " ) - 1 ;
s ! = start_def ;
s + + )
{
if ( * s > = ' 0 ' & & * s < = ' 9 ' )
{
FT_UShort prev_fs_type ;
prev_fs_type = font_extra - > fs_type ;
font_extra - > fs_type = 10 * font_extra - > fs_type + * s - ' 0 ' ;
if ( font_extra - > fs_type < prev_fs_type )
{
/* Overflow - ignore the FSType value. */
font_extra - > fs_type = 0U ;
break ;
}
}
else if ( * s ! = ' ' & & * s ! = ' \n ' & & * s ! = ' \r ' )
{
/* Non-whitespace character between `/FSType' and next `def' */
/* - ignore the FSType value. */
font_extra - > fs_type = 0U ;
break ;
}
}
}
}
cff - > font_extra = font_extra ;
}
if ( cff )
* afont_extra = * cff - > font_extra ;
Fail :
return error ;
}
FT_DEFINE_SERVICE_PSINFOREC (
cff_service_ps_info ,
( PS_GetFontInfoFunc ) cff_ps_get_font_info , /* ps_get_font_info */
( PS_GetFontExtraFunc ) NULL , /* ps_get_font_extra */
( PS_GetFontExtraFunc ) cff_ps_get_font_extra , /* ps_get_font_extra */
( PS_HasGlyphNamesFunc ) cff_ps_has_glyph_names , /* ps_has_glyph_names */
/* unsupported with CFF fonts */
( PS_GetFontPrivateFunc ) NULL , /* ps_get_font_private */