[truetype] Fix style name handling for variation fonts.
* include/freetype/internal/tttypes.h (TT_FaceRec): New field `non_var_style_name`. * src/sfnt/sfobjs.c (sfnt_load_face): Initialize `non_var_style_name`. (sfnt_done_face): Free `non_var_style_name`. * src/truetype/ttgxvar.c (TT_Set_Named_Instance): Restore non-VF style name if switching back to non-VF mode.
This commit is contained in:
parent
cc79174dce
commit
ad6fad2888
|
@ -1318,6 +1318,9 @@ FT_BEGIN_HEADER
|
||||||
* var_default_named_instance ::
|
* var_default_named_instance ::
|
||||||
* The index of the default named instance.
|
* The index of the default named instance.
|
||||||
*
|
*
|
||||||
|
* non_var_style_name ::
|
||||||
|
* The non-variation style name, used as a backup.
|
||||||
|
*
|
||||||
* horz_metrics_size ::
|
* horz_metrics_size ::
|
||||||
* The size of the 'hmtx' table.
|
* The size of the 'hmtx' table.
|
||||||
*
|
*
|
||||||
|
@ -1556,6 +1559,8 @@ FT_BEGIN_HEADER
|
||||||
FT_UInt var_postscript_prefix_len; /* since 2.7.2 */
|
FT_UInt var_postscript_prefix_len; /* since 2.7.2 */
|
||||||
|
|
||||||
FT_UInt var_default_named_instance; /* since 2.13.1 */
|
FT_UInt var_default_named_instance; /* since 2.13.1 */
|
||||||
|
|
||||||
|
const char* non_var_style_name; /* since 2.13.1 */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* since version 2.2 */
|
/* since version 2.2 */
|
||||||
|
|
|
@ -1063,6 +1063,16 @@
|
||||||
GET_NAME( FONT_SUBFAMILY, &face->root.style_name );
|
GET_NAME( FONT_SUBFAMILY, &face->root.style_name );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
|
||||||
|
{
|
||||||
|
FT_Memory memory = face->root.memory;
|
||||||
|
|
||||||
|
|
||||||
|
if ( FT_STRDUP( face->non_var_style_name, face->root.style_name ) )
|
||||||
|
goto Exit;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* now set up root fields */
|
/* now set up root fields */
|
||||||
{
|
{
|
||||||
FT_Face root = &face->root;
|
FT_Face root = &face->root;
|
||||||
|
@ -1509,6 +1519,7 @@
|
||||||
|
|
||||||
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
|
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
|
||||||
FT_FREE( face->var_postscript_prefix );
|
FT_FREE( face->var_postscript_prefix );
|
||||||
|
FT_FREE( face->non_var_style_name );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* freeing glyph color palette data */
|
/* freeing glyph color palette data */
|
||||||
|
|
|
@ -3306,6 +3306,8 @@
|
||||||
GX_Blend blend;
|
GX_Blend blend;
|
||||||
FT_MM_Var* mmvar;
|
FT_MM_Var* mmvar;
|
||||||
|
|
||||||
|
FT_Memory memory = face->root.memory;
|
||||||
|
|
||||||
FT_UInt num_instances;
|
FT_UInt num_instances;
|
||||||
|
|
||||||
|
|
||||||
|
@ -3329,7 +3331,6 @@
|
||||||
|
|
||||||
if ( instance_index > 0 )
|
if ( instance_index > 0 )
|
||||||
{
|
{
|
||||||
FT_Memory memory = face->root.memory;
|
|
||||||
SFNT_Service sfnt = (SFNT_Service)face->sfnt;
|
SFNT_Service sfnt = (SFNT_Service)face->sfnt;
|
||||||
|
|
||||||
FT_Var_Named_Style* named_style;
|
FT_Var_Named_Style* named_style;
|
||||||
|
@ -3354,7 +3355,13 @@
|
||||||
named_style->coords );
|
named_style->coords );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
/* restore non-VF style name */
|
||||||
|
FT_FREE( face->root.style_name );
|
||||||
|
if ( FT_STRDUP( face->root.style_name, face->non_var_style_name ) )
|
||||||
|
goto Exit;
|
||||||
error = TT_Set_Var_Design( face, 0, NULL );
|
error = TT_Set_Var_Design( face, 0, NULL );
|
||||||
|
}
|
||||||
|
|
||||||
Exit:
|
Exit:
|
||||||
return error;
|
return error;
|
||||||
|
|
Loading…
Reference in New Issue