summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/freetype/internal/services/svmm.h8
-rw-r--r--src/base/ftmm.c82
-rw-r--r--src/cff/cffdrivr.c14
-rw-r--r--src/truetype/ttdriver.c3
-rw-r--r--src/truetype/ttgxvar.c38
-rw-r--r--src/truetype/ttgxvar.h4
-rw-r--r--src/type1/t1driver.c3
-rw-r--r--src/type1/t1load.c9
8 files changed, 123 insertions, 38 deletions
diff --git a/include/freetype/internal/services/svmm.h b/include/freetype/internal/services/svmm.h
index 59910f2e3..982bb47db 100644
--- a/include/freetype/internal/services/svmm.h
+++ b/include/freetype/internal/services/svmm.h
@@ -102,6 +102,9 @@ FT_BEGIN_HEADER
FT_UInt* len,
FT_Fixed* weight_vector );
+ typedef void
+ (*FT_Construct_PS_Name_Func)( FT_Face face );
+
typedef FT_Error
(*FT_Var_Load_Delta_Set_Idx_Map_Func)( FT_Face face,
FT_ULong offset,
@@ -144,6 +147,7 @@ FT_BEGIN_HEADER
FT_Get_MM_WeightVector_Func get_mm_weightvector;
/* for internal use; only needed for code sharing between modules */
+ FT_Construct_PS_Name_Func construct_ps_name;
FT_Var_Load_Delta_Set_Idx_Map_Func load_delta_set_idx_map;
FT_Var_Load_Item_Var_Store_Func load_item_var_store;
FT_Var_Get_Item_Delta_Func get_item_delta;
@@ -166,6 +170,8 @@ FT_BEGIN_HEADER
get_default_named_instance_, \
set_mm_weightvector_, \
get_mm_weightvector_, \
+ \
+ construct_ps_name_, \
load_delta_set_idx_map_, \
load_item_var_store_, \
get_item_delta_, \
@@ -186,6 +192,8 @@ FT_BEGIN_HEADER
get_default_named_instance_, \
set_mm_weightvector_, \
get_mm_weightvector_, \
+ \
+ construct_ps_name_, \
load_delta_set_idx_map_, \
load_item_var_store_, \
get_item_delta_, \
diff --git a/src/base/ftmm.c b/src/base/ftmm.c
index c061431a4..9e2dd7ee7 100644
--- a/src/base/ftmm.c
+++ b/src/base/ftmm.c
@@ -301,10 +301,26 @@
if ( !error || error == -1 )
{
+ FT_Bool is_variation_old = FT_IS_VARIATION( face );
+
+
if ( num_coords )
face->face_flags |= FT_FACE_FLAG_VARIATION;
else
face->face_flags &= ~FT_FACE_FLAG_VARIATION;
+
+ if ( service_mm->construct_ps_name )
+ {
+ if ( error == -1 )
+ {
+ /* The PS name of a named instance and a non-named instance */
+ /* usually differs, even if the axis values are identical. */
+ if ( is_variation_old != FT_IS_VARIATION( face ) )
+ service_mm->construct_ps_name( face );
+ }
+ else
+ service_mm->construct_ps_name( face );
+ }
}
/* internal error code -1 means `no change'; we can exit immediately */
@@ -385,10 +401,26 @@
if ( !error || error == -1 )
{
+ FT_Bool is_variation_old = FT_IS_VARIATION( face );
+
+
if ( num_coords )
face->face_flags |= FT_FACE_FLAG_VARIATION;
else
face->face_flags &= ~FT_FACE_FLAG_VARIATION;
+
+ if ( service_mm->construct_ps_name )
+ {
+ if ( error == -1 )
+ {
+ /* The PS name of a named instance and a non-named instance */
+ /* usually differs, even if the axis values are identical. */
+ if ( is_variation_old != FT_IS_VARIATION( face ) )
+ service_mm->construct_ps_name( face );
+ }
+ else
+ service_mm->construct_ps_name( face );
+ }
}
/* internal error code -1 means `no change'; we can exit immediately */
@@ -444,10 +476,26 @@
if ( !error || error == -1 )
{
+ FT_Bool is_variation_old = FT_IS_VARIATION( face );
+
+
if ( num_coords )
face->face_flags |= FT_FACE_FLAG_VARIATION;
else
face->face_flags &= ~FT_FACE_FLAG_VARIATION;
+
+ if ( service_mm->construct_ps_name )
+ {
+ if ( error == -1 )
+ {
+ /* The PS name of a named instance and a non-named instance */
+ /* usually differs, even if the axis values are identical. */
+ if ( is_variation_old != FT_IS_VARIATION( face ) )
+ service_mm->construct_ps_name( face );
+ }
+ else
+ service_mm->construct_ps_name( face );
+ }
}
/* internal error code -1 means `no change'; we can exit immediately */
@@ -577,6 +625,33 @@
error = FT_ERR( Invalid_Argument );
if ( service_mm->set_named_instance )
error = service_mm->set_named_instance( face, instance_index );
+
+ if ( !error || error == -1 )
+ {
+ FT_Bool is_variation_old = FT_IS_VARIATION( face );
+
+
+ face->face_flags &= ~FT_FACE_FLAG_VARIATION;
+ face->face_index = ( instance_index << 16 ) |
+ ( face->face_index & 0xFFFFL );
+
+ if ( service_mm->construct_ps_name )
+ {
+ if ( error == -1 )
+ {
+ /* The PS name of a named instance and a non-named instance */
+ /* usually differs, even if the axis values are identical. */
+ if ( is_variation_old != FT_IS_VARIATION( face ) )
+ service_mm->construct_ps_name( face );
+ }
+ else
+ service_mm->construct_ps_name( face );
+ }
+ }
+
+ /* internal error code -1 means `no change'; we can exit immediately */
+ if ( error == -1 )
+ return FT_Err_Ok;
}
if ( !error )
@@ -594,13 +669,6 @@
face->autohint.data = NULL;
}
- if ( !error )
- {
- face->face_index = ( instance_index << 16 ) |
- ( face->face_index & 0xFFFFL );
- face->face_flags &= ~FT_FACE_FLAG_VARIATION;
- }
-
return error;
}
diff --git a/src/cff/cffdrivr.c b/src/cff/cffdrivr.c
index 49f18c28d..7e3deca54 100644
--- a/src/cff/cffdrivr.c
+++ b/src/cff/cffdrivr.c
@@ -896,6 +896,16 @@
}
+ static void
+ cff_construct_ps_name( CFF_Face face )
+ {
+ FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm;
+
+
+ mm->construct_ps_name( FT_FACE( face ) );
+ }
+
+
static FT_Error
cff_get_mm_var( CFF_Face face,
FT_MM_Var* *master )
@@ -1039,6 +1049,10 @@
(FT_Get_MM_WeightVector_Func)
cff_get_mm_weightvector,
/* get_mm_weightvector */
+
+ (FT_Construct_PS_Name_Func)
+ cff_construct_ps_name,
+ /* construct_ps_name */
(FT_Var_Load_Delta_Set_Idx_Map_Func)
cff_load_delta_set_index_mapping,
/* load_delta_set_idx_map */
diff --git a/src/truetype/ttdriver.c b/src/truetype/ttdriver.c
index 54ad932ed..8bde30fbf 100644
--- a/src/truetype/ttdriver.c
+++ b/src/truetype/ttdriver.c
@@ -533,6 +533,9 @@
NULL, /* set_mm_weightvector */
(FT_Get_MM_WeightVector_Func)
NULL, /* get_mm_weightvector */
+
+ (FT_Construct_PS_Name_Func)
+ tt_construct_ps_name, /* construct_ps_name */
(FT_Var_Load_Delta_Set_Idx_Map_Func)
tt_var_load_delta_set_index_mapping,
/* load_delta_set_idx_map */
diff --git a/src/truetype/ttgxvar.c b/src/truetype/ttgxvar.c
index 44483625a..aec43c851 100644
--- a/src/truetype/ttgxvar.c
+++ b/src/truetype/ttgxvar.c
@@ -2936,9 +2936,6 @@
}
}
- /* enforce recomputation of the PostScript name; */
- FT_FREE( face->postscript_name );
-
Exit:
return error;
}
@@ -2978,14 +2975,7 @@
FT_UInt num_coords,
FT_Fixed* coords )
{
- FT_Error error;
-
-
- error = tt_set_mm_blend( face, num_coords, coords, 1 );
- if ( error )
- return error;
-
- return FT_Err_Ok;
+ return tt_set_mm_blend( face, num_coords, coords, 1 );
}
@@ -3305,7 +3295,8 @@
* Value 0 indicates to not use an instance.
*
* @Return:
- * FreeType error code. 0~means success.
+ * FreeType error code. 0~means success, -1 means success and unchanged
+ * axis values.
*/
FT_LOCAL_DEF( FT_Error )
TT_Set_Named_Instance( TT_Face face,
@@ -3361,20 +3352,10 @@
error = TT_Set_Var_Design( face,
mmvar->num_axis,
named_style->coords );
- if ( error )
- {
- /* internal error code -1 means `no change' */
- if ( error == -1 )
- error = FT_Err_Ok;
- goto Exit;
- }
}
else
error = TT_Set_Var_Design( face, 0, NULL );
- face->root.face_index = ( instance_index << 16 ) |
- ( face->root.face_index & 0xFFFFL );
-
Exit:
return error;
}
@@ -3419,6 +3400,19 @@
}
+ /* This function triggers (lazy) recomputation of the `postscript_name` */
+ /* field in `TT_Face`. */
+
+ FT_LOCAL_DEF( void )
+ tt_construct_ps_name( TT_Face face )
+ {
+ FT_Memory memory = face->root.memory;
+
+
+ FT_FREE( face->postscript_name );
+ }
+
+
/*************************************************************************/
/*************************************************************************/
/***** *****/
diff --git a/src/truetype/ttgxvar.h b/src/truetype/ttgxvar.h
index 0c096f7df..4de772c87 100644
--- a/src/truetype/ttgxvar.h
+++ b/src/truetype/ttgxvar.h
@@ -378,6 +378,9 @@ FT_BEGIN_HEADER
TT_Get_Default_Named_Instance( TT_Face face,
FT_UInt *instance_index );
+ FT_LOCAL( void )
+ tt_construct_ps_name( TT_Face face );
+
FT_LOCAL( FT_Error )
tt_face_vary_cvt( TT_Face face,
FT_Stream stream );
@@ -401,7 +404,6 @@ FT_BEGIN_HEADER
FT_LOCAL( void )
tt_apply_mvar( TT_Face face );
-
FT_LOCAL( FT_Error )
tt_var_load_item_variation_store( TT_Face face,
FT_ULong offset,
diff --git a/src/type1/t1driver.c b/src/type1/t1driver.c
index 4239d86fe..4abcef173 100644
--- a/src/type1/t1driver.c
+++ b/src/type1/t1driver.c
@@ -136,6 +136,9 @@
T1_Set_MM_WeightVector, /* set_mm_weightvector */
(FT_Get_MM_WeightVector_Func)
T1_Get_MM_WeightVector, /* get_mm_weightvector */
+
+ (FT_Construct_PS_Name_Func)
+ NULL, /* construct_ps_name */
(FT_Var_Load_Delta_Set_Idx_Map_Func)
NULL, /* load_delta_set_idx_map */
(FT_Var_Load_Item_Var_Store_Func)
diff --git a/src/type1/t1load.c b/src/type1/t1load.c
index a3b281009..ee52bf276 100644
--- a/src/type1/t1load.c
+++ b/src/type1/t1load.c
@@ -442,14 +442,7 @@
FT_UInt num_coords,
FT_Fixed* coords )
{
- FT_Error error;
-
-
- error = t1_set_mm_blend( face, num_coords, coords );
- if ( error )
- return error;
-
- return FT_Err_Ok;
+ return t1_set_mm_blend( face, num_coords, coords );
}