diff options
Diffstat (limited to 'src/truetype/ttgxvar.c')
-rw-r--r-- | src/truetype/ttgxvar.c | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/src/truetype/ttgxvar.c b/src/truetype/ttgxvar.c index 963dcb7e3..d28cc245e 100644 --- a/src/truetype/ttgxvar.c +++ b/src/truetype/ttgxvar.c @@ -2630,8 +2630,10 @@ FT_UInt strid = ~0U; - /* the default instance is missing in array the */ - /* of named instances; try to synthesize an entry */ + /* The default instance is missing in array the */ + /* of named instances; try to synthesize an entry. */ + /* If this fails, `default_named_instance` remains */ + /* at value zero, which doesn't do any harm. */ found = sfnt->get_name_id( face, TT_NAME_ID_TYPOGRAPHIC_SUBFAMILY, &dummy1, @@ -2659,6 +2661,9 @@ FT_TRACE5(( "TT_Get_MM_Var:" " Adding default instance to named instances\n" )); + /* named instance indices start with value 1 */ + face->var_default_named_instance = num_instances; + ns = &mmvar->namedstyle[fvar_head.instanceCount]; ns->strid = strid; @@ -3386,6 +3391,45 @@ } + /************************************************************************** + * + * @Function: + * TT_Get_Default_Named_Instance + * + * @Description: + * Get the default named instance. + * + * @Input: + * face :: + * A handle to the source face. + * + * @Output: + * instance_index :: + * The default named instance index. + * + * @Return: + * FreeType error code. 0~means success. + */ + FT_LOCAL_DEF( FT_Error ) + TT_Get_Default_Named_Instance( TT_Face face, + FT_UInt *instance_index ) + { + FT_Error error = FT_Err_Ok; + + + if ( !face->blend ) + { + if ( FT_SET_ERROR( TT_Get_MM_Var( face, NULL ) ) ) + goto Exit; + } + + *instance_index = face->var_default_named_instance; + + Exit: + return error; + } + + /*************************************************************************/ /*************************************************************************/ /***** *****/ |