[mm/gxvar] Always detect default instance and use optimized codepath.

Even if it was explicitly set by either design or normalized APIs.

Also update documentation.

* src/truetype/ttgxvar.c (TT_Set_MM_Blend, TT_Set_Var_Design): Use value -2
  of `error` to indicate that we have a non-default instance.
  (TT_Set_Named_Instance): Updated.

* src/base/ftmm.c (FT_Set_Var_Design_Coordinates,
  FT_Set_Var_Blend_Coordinates): Updated.
This commit is contained in:
Behdad Esfahbod 2025-05-23 15:41:26 -06:00 committed by Werner Lemberg
parent deef6d2a3c
commit fa412cf5c5
4 changed files with 65 additions and 11 deletions

View file

@ -49,6 +49,13 @@ CHANGES BETWEEN 2.13.3 and 2.14.0 (2025-Mmm-DD)
III. MISCELLANEOUS
- `FT_Set_Var_Design_Coordinates` and `FT_Set_MM_Blend_Coordinates`
now set the `FT_FACE_FLAG_VARIATION` bit in the `face_flag` field
of `FT_Face` (i.e., the macro `FT_IS_VARIATION` will return true)
also if any of the provided coordinates is different from the
face's default value for the corresponding axis, that is, the set
up face is not at its default position.
- The TrueType instruction interpreter was optimized to produce 15%
gain in the glyph loading speed.

View file

@ -440,6 +440,12 @@ FT_BEGIN_HEADER
* the @FT_FACE_FLAG_VARIATION bit in @FT_Face's `face_flags` field
* (i.e., @FT_IS_VARIATION will return true). If `num_coords` is zero,
* this bit flag gets unset.
*
* [Since 2.14] This function also sets the @FT_FACE_FLAG_VARIATION bit
* in @FT_Face's `face_flags` field (i.e., @FT_IS_VARIATION will return
* true) if any of the provided coordinates is different from the face's
* default value for the corresponding axis, that is, the set up face is
* not at its default position.
*/
FT_EXPORT( FT_Error )
FT_Set_Var_Design_Coordinates( FT_Face face,
@ -526,6 +532,12 @@ FT_BEGIN_HEADER
* the @FT_FACE_FLAG_VARIATION bit in @FT_Face's `face_flags` field
* (i.e., @FT_IS_VARIATION will return true). If `num_coords` is zero,
* this bit flag gets unset.
*
* [Since 2.14] This function also sets the @FT_FACE_FLAG_VARIATION bit
* in @FT_Face's `face_flags` field (i.e., @FT_IS_VARIATION will return
* true) if any of the provided coordinates is different from the face's
* default value for the corresponding axis, that is, the set up face is
* not at its default position.
*/
FT_EXPORT( FT_Error )
FT_Set_MM_Blend_Coordinates( FT_Face face,

View file

@ -302,15 +302,18 @@
if ( service_mm->set_var_design )
error = service_mm->set_var_design( face, num_coords, coords );
if ( !error || error == -1 )
if ( !error || error == -1 || error == -2 )
{
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 ( error != -1 )
{
if ( error == -2 ) /* -2 means is_variable. */
face->face_flags |= FT_FACE_FLAG_VARIATION;
else
face->face_flags &= ~FT_FACE_FLAG_VARIATION;
}
if ( service_mm->construct_ps_name )
{
@ -477,15 +480,18 @@
if ( service_mm->set_mm_blend )
error = service_mm->set_mm_blend( face, num_coords, coords );
if ( !error || error == -1 )
if ( !error || error == -1 || error == -2 )
{
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 ( error != -1 )
{
if ( error == -2 ) /* -2 means is_variable. */
face->face_flags |= FT_FACE_FLAG_VARIATION;
else
face->face_flags &= ~FT_FACE_FLAG_VARIATION;
}
if ( service_mm->construct_ps_name )
{

View file

@ -3157,7 +3157,24 @@
FT_UInt num_coords,
FT_Fixed* coords )
{
return tt_set_mm_blend( (TT_Face)face, num_coords, coords, 1 );
FT_Error error = FT_Err_Ok;
error = tt_set_mm_blend( (TT_Face)face, num_coords, coords, 1 );
if ( error == FT_Err_Ok )
{
FT_UInt i;
for ( i = 0; i < num_coords; i++ )
if ( coords[i] )
{
error = -2; /* -2 means is_variable. */
break;
}
}
return error;
}
@ -3378,6 +3395,15 @@
if ( error )
goto Exit;
for ( i = 0; i < num_coords; i++ )
{
if ( normalized[i] )
{
error = -2; /* -2 means is_variable. */
break;
}
}
Exit:
FT_FREE( normalized );
return error;
@ -3550,6 +3576,9 @@
error = TT_Set_Var_Design( face, 0, NULL );
}
if ( error == -1 || error == -2 )
error = FT_Err_Ok;
Exit:
return error;
}