summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/base/ftmm.c28
-rw-r--r--src/cff/cffdrivr.c48
-rw-r--r--src/sfnt/sfobjs.c3
-rw-r--r--src/truetype/ttdriver.c37
-rw-r--r--src/truetype/ttgxvar.c48
-rw-r--r--src/truetype/ttgxvar.h4
-rw-r--r--src/type1/t1driver.c36
7 files changed, 151 insertions, 53 deletions
diff --git a/src/base/ftmm.c b/src/base/ftmm.c
index a2b4bd03d..781db315e 100644
--- a/src/base/ftmm.c
+++ b/src/base/ftmm.c
@@ -565,4 +565,32 @@
}
+ /* documentation is in ftmm.h */
+
+ FT_EXPORT_DEF( FT_Error )
+ FT_Get_Default_Named_Instance( FT_Face face,
+ FT_UInt *instance_index )
+ {
+ FT_Error error;
+
+ FT_Service_MultiMasters service_mm = NULL;
+
+
+ /* check of `face' delayed to `ft_face_get_mm_service' */
+
+ error = ft_face_get_mm_service( face, &service_mm );
+ if ( !error )
+ {
+ /* no error if `get_default_named_instance` is not available */
+ if ( service_mm->get_default_named_instance )
+ error = service_mm->get_default_named_instance( face,
+ instance_index );
+ else
+ error = FT_Err_Ok;
+ }
+
+ return error;
+ }
+
+
/* END */
diff --git a/src/cff/cffdrivr.c b/src/cff/cffdrivr.c
index 7d45e4641..d9ed35b2b 100644
--- a/src/cff/cffdrivr.c
+++ b/src/cff/cffdrivr.c
@@ -943,6 +943,17 @@
static FT_Error
+ cff_get_default_named_instance( CFF_Face face,
+ FT_UInt *instance_index )
+ {
+ FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm;
+
+
+ return mm->get_default_named_instance( FT_FACE( face ), instance_index );
+ }
+
+
+ static FT_Error
cff_load_item_variation_store( CFF_Face face,
FT_ULong offset,
GX_ItemVarStore itemStore )
@@ -1009,36 +1020,39 @@
FT_DEFINE_SERVICE_MULTIMASTERSREC(
cff_service_multi_masters,
- (FT_Get_MM_Func) NULL, /* get_mm */
- (FT_Set_MM_Design_Func) NULL, /* set_mm_design */
- (FT_Set_MM_Blend_Func) cff_set_mm_blend, /* set_mm_blend */
- (FT_Get_MM_Blend_Func) cff_get_mm_blend, /* get_mm_blend */
- (FT_Get_MM_Var_Func) cff_get_mm_var, /* get_mm_var */
- (FT_Set_Var_Design_Func)cff_set_var_design, /* set_var_design */
- (FT_Get_Var_Design_Func)cff_get_var_design, /* get_var_design */
- (FT_Set_Instance_Func) cff_set_instance, /* set_instance */
+ (FT_Get_MM_Func) NULL, /* get_mm */
+ (FT_Set_MM_Design_Func) NULL, /* set_mm_design */
+ (FT_Set_MM_Blend_Func) cff_set_mm_blend, /* set_mm_blend */
+ (FT_Get_MM_Blend_Func) cff_get_mm_blend, /* get_mm_blend */
+ (FT_Get_MM_Var_Func) cff_get_mm_var, /* get_mm_var */
+ (FT_Set_Var_Design_Func)cff_set_var_design, /* set_var_design */
+ (FT_Get_Var_Design_Func)cff_get_var_design, /* get_var_design */
+ (FT_Set_Instance_Func) cff_set_instance, /* set_instance */
+ (FT_Get_Default_Named_Instance_Func)
+ cff_get_default_named_instance,
+ /* get_default_named_instance */
(FT_Set_MM_WeightVector_Func)
cff_set_mm_weightvector,
- /* set_mm_weightvector */
+ /* set_mm_weightvector */
(FT_Get_MM_WeightVector_Func)
cff_get_mm_weightvector,
- /* get_mm_weightvector */
+ /* get_mm_weightvector */
(FT_Var_Load_Delta_Set_Idx_Map_Func)
cff_load_delta_set_index_mapping,
- /* load_delta_set_idx_map */
+ /* load_delta_set_idx_map */
(FT_Var_Load_Item_Var_Store_Func)
cff_load_item_variation_store,
- /* load_item_variation_store */
+ /* load_item_variation_store */
(FT_Var_Get_Item_Delta_Func)
- cff_get_item_delta, /* get_item_delta */
+ cff_get_item_delta, /* get_item_delta */
(FT_Var_Done_Item_Var_Store_Func)
cff_done_item_variation_store,
- /* done_item_variation_store */
+ /* done_item_variation_store */
(FT_Var_Done_Delta_Set_Idx_Map_Func)
cff_done_delta_set_index_map,
- /* done_delta_set_index_map */
- (FT_Get_Var_Blend_Func) cff_get_var_blend, /* get_var_blend */
- (FT_Done_Blend_Func) cff_done_blend /* done_blend */
+ /* done_delta_set_index_map */
+ (FT_Get_Var_Blend_Func) cff_get_var_blend, /* get_var_blend */
+ (FT_Done_Blend_Func) cff_done_blend /* done_blend */
)
diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c
index 13f2f45f4..1574c353d 100644
--- a/src/sfnt/sfobjs.c
+++ b/src/sfnt/sfobjs.c
@@ -698,6 +698,9 @@
instance_offset += instance_size;
}
+ /* named instance indices start with value 1 */
+ face->var_default_named_instance = i + 1;
+
if ( i == num_instances )
{
/* no default instance in named instance table; */
diff --git a/src/truetype/ttdriver.c b/src/truetype/ttdriver.c
index c2e041cd3..c128be19d 100644
--- a/src/truetype/ttdriver.c
+++ b/src/truetype/ttdriver.c
@@ -517,34 +517,37 @@
FT_DEFINE_SERVICE_MULTIMASTERSREC(
tt_service_gx_multi_masters,
- (FT_Get_MM_Func) NULL, /* get_mm */
- (FT_Set_MM_Design_Func) NULL, /* set_mm_design */
- (FT_Set_MM_Blend_Func) TT_Set_MM_Blend, /* set_mm_blend */
- (FT_Get_MM_Blend_Func) TT_Get_MM_Blend, /* get_mm_blend */
- (FT_Get_MM_Var_Func) TT_Get_MM_Var, /* get_mm_var */
- (FT_Set_Var_Design_Func)TT_Set_Var_Design, /* set_var_design */
- (FT_Get_Var_Design_Func)TT_Get_Var_Design, /* get_var_design */
- (FT_Set_Instance_Func) TT_Set_Named_Instance, /* set_instance */
+ (FT_Get_MM_Func) NULL, /* get_mm */
+ (FT_Set_MM_Design_Func) NULL, /* set_mm_design */
+ (FT_Set_MM_Blend_Func) TT_Set_MM_Blend, /* set_mm_blend */
+ (FT_Get_MM_Blend_Func) TT_Get_MM_Blend, /* get_mm_blend */
+ (FT_Get_MM_Var_Func) TT_Get_MM_Var, /* get_mm_var */
+ (FT_Set_Var_Design_Func)TT_Set_Var_Design, /* set_var_design */
+ (FT_Get_Var_Design_Func)TT_Get_Var_Design, /* get_var_design */
+ (FT_Set_Instance_Func) TT_Set_Named_Instance, /* set_instance */
+ (FT_Get_Default_Named_Instance_Func)
+ TT_Get_Default_Named_Instance,
+ /* get_default_named_instance */
(FT_Set_MM_WeightVector_Func)
- NULL, /* set_mm_weightvector */
+ NULL, /* set_mm_weightvector */
(FT_Get_MM_WeightVector_Func)
- NULL, /* get_mm_weightvector */
+ NULL, /* get_mm_weightvector */
(FT_Var_Load_Delta_Set_Idx_Map_Func)
tt_var_load_delta_set_index_mapping,
- /* load_delta_set_idx_map */
+ /* load_delta_set_idx_map */
(FT_Var_Load_Item_Var_Store_Func)
tt_var_load_item_variation_store,
- /* load_item_variation_store */
+ /* load_item_variation_store */
(FT_Var_Get_Item_Delta_Func)
- tt_var_get_item_delta, /* get_item_delta */
+ tt_var_get_item_delta, /* get_item_delta */
(FT_Var_Done_Item_Var_Store_Func)
tt_var_done_item_variation_store,
- /* done_item_variation_store */
+ /* done_item_variation_store */
(FT_Var_Done_Delta_Set_Idx_Map_Func)
tt_var_done_delta_set_index_map,
- /* done_delta_set_index_map */
- (FT_Get_Var_Blend_Func) tt_get_var_blend, /* get_var_blend */
- (FT_Done_Blend_Func) tt_done_blend /* done_blend */
+ /* done_delta_set_index_map */
+ (FT_Get_Var_Blend_Func) tt_get_var_blend, /* get_var_blend */
+ (FT_Done_Blend_Func) tt_done_blend /* done_blend */
)
FT_DEFINE_SERVICE_METRICSVARIATIONSREC(
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;
+ }
+
+
/*************************************************************************/
/*************************************************************************/
/***** *****/
diff --git a/src/truetype/ttgxvar.h b/src/truetype/ttgxvar.h
index 4fec980dc..0c096f7df 100644
--- a/src/truetype/ttgxvar.h
+++ b/src/truetype/ttgxvar.h
@@ -375,6 +375,10 @@ FT_BEGIN_HEADER
FT_UInt instance_index );
FT_LOCAL( FT_Error )
+ TT_Get_Default_Named_Instance( TT_Face face,
+ FT_UInt *instance_index );
+
+ FT_LOCAL( FT_Error )
tt_face_vary_cvt( TT_Face face,
FT_Stream stream );
diff --git a/src/type1/t1driver.c b/src/type1/t1driver.c
index ded3b264e..5d0fe533c 100644
--- a/src/type1/t1driver.c
+++ b/src/type1/t1driver.c
@@ -121,30 +121,32 @@
#ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT
static const FT_Service_MultiMastersRec t1_service_multi_masters =
{
- (FT_Get_MM_Func) T1_Get_Multi_Master, /* get_mm */
- (FT_Set_MM_Design_Func) T1_Set_MM_Design, /* set_mm_design */
- (FT_Set_MM_Blend_Func) T1_Set_MM_Blend, /* set_mm_blend */
- (FT_Get_MM_Blend_Func) T1_Get_MM_Blend, /* get_mm_blend */
- (FT_Get_MM_Var_Func) T1_Get_MM_Var, /* get_mm_var */
- (FT_Set_Var_Design_Func)T1_Set_Var_Design, /* set_var_design */
- (FT_Get_Var_Design_Func)T1_Get_Var_Design, /* get_var_design */
- (FT_Set_Instance_Func) T1_Reset_MM_Blend, /* set_instance */
+ (FT_Get_MM_Func) T1_Get_Multi_Master, /* get_mm */
+ (FT_Set_MM_Design_Func) T1_Set_MM_Design, /* set_mm_design */
+ (FT_Set_MM_Blend_Func) T1_Set_MM_Blend, /* set_mm_blend */
+ (FT_Get_MM_Blend_Func) T1_Get_MM_Blend, /* get_mm_blend */
+ (FT_Get_MM_Var_Func) T1_Get_MM_Var, /* get_mm_var */
+ (FT_Set_Var_Design_Func)T1_Set_Var_Design, /* set_var_design */
+ (FT_Get_Var_Design_Func)T1_Get_Var_Design, /* get_var_design */
+ (FT_Set_Instance_Func) T1_Reset_MM_Blend, /* set_instance */
+ (FT_Get_Default_Named_Instance_Func)
+ NULL, /* get_default_named_instance */
(FT_Set_MM_WeightVector_Func)
- T1_Set_MM_WeightVector, /* set_mm_weightvector */
+ T1_Set_MM_WeightVector, /* set_mm_weightvector */
(FT_Get_MM_WeightVector_Func)
- T1_Get_MM_WeightVector, /* get_mm_weightvector */
+ T1_Get_MM_WeightVector, /* get_mm_weightvector */
(FT_Var_Load_Delta_Set_Idx_Map_Func)
- NULL, /* load_delta_set_idx_map */
+ NULL, /* load_delta_set_idx_map */
(FT_Var_Load_Item_Var_Store_Func)
- NULL, /* load_item_variation_store */
+ NULL, /* load_item_variation_store */
(FT_Var_Get_Item_Delta_Func)
- NULL, /* get_item_delta */
+ NULL, /* get_item_delta */
(FT_Var_Done_Item_Var_Store_Func)
- NULL, /* done_item_variation_store */
+ NULL, /* done_item_variation_store */
(FT_Var_Done_Delta_Set_Idx_Map_Func)
- NULL, /* done_delta_set_index_map */
- (FT_Get_Var_Blend_Func) NULL, /* get_var_blend */
- (FT_Done_Blend_Func) T1_Done_Blend /* done_blend */
+ NULL, /* done_delta_set_index_map */
+ (FT_Get_Var_Blend_Func) NULL, /* get_var_blend */
+ (FT_Done_Blend_Func) T1_Done_Blend /* done_blend */
};
#endif