[type1/MM] Round design coordinates.

The design coordinates for MM fonts were not rounded. For example,
`FT_Get_Var_Design_Coordinates` returned values with fractional part.

* src/type1/t1load.c (mm_axis_unmap): Refactor with rounding.

* include/freetype/ftmm.h (FT_Var_Axis, FT_Set_Var_Design_Coordinates,
FT_Get_Var_Design_Coordinates): Reword documentation.
This commit is contained in:
Alexei Podtelezhnikov 2023-02-10 08:24:33 -05:00
parent 23e60caeef
commit dacbb55433
2 changed files with 11 additions and 10 deletions

View File

@ -153,7 +153,7 @@ FT_BEGIN_HEADER
* @note:
* The fields `minimum`, `def`, and `maximum` are 16.16 fractional values
* for TrueType GX and OpenType variation fonts. For Adobe MM fonts, the
* values are integers.
* values are whole numbers (i.e., the fractional part is zero).
*/
typedef struct FT_Var_Axis_
{
@ -399,8 +399,8 @@ FT_BEGIN_HEADER
*
* @note:
* The design coordinates are 16.16 fractional values for TrueType GX and
* OpenType variation fonts. For Adobe MM fonts, the values are
* integers.
* OpenType variation fonts. For Adobe MM fonts, the values are supposed
* to be whole numbers (i.e., the fractional part is zero).
*
* [Since 2.8.1] To reset all axes to the default values, call the
* function with `num_coords` set to zero and `coords` set to `NULL`.
@ -446,8 +446,8 @@ FT_BEGIN_HEADER
*
* @note:
* The design coordinates are 16.16 fractional values for TrueType GX and
* OpenType variation fonts. For Adobe MM fonts, the values are
* integers.
* OpenType variation fonts. For Adobe MM fonts, the values are whole
* numbers (i.e., the fractional part is zero).
*
* @since:
* 2.7.1

View File

@ -225,11 +225,12 @@
for ( j = 1; j < axismap->num_points; j++ )
{
if ( ncv <= axismap->blend_points[j] )
return INT_TO_FIXED( axismap->design_points[j - 1] ) +
( axismap->design_points[j] - axismap->design_points[j - 1] ) *
FT_DivFix( ncv - axismap->blend_points[j - 1],
axismap->blend_points[j] -
axismap->blend_points[j - 1] );
return INT_TO_FIXED( axismap->design_points[j - 1] +
FT_MulDiv( ncv - axismap->blend_points[j - 1],
axismap->design_points[j] -
axismap->design_points[j - 1],
axismap->blend_points[j] -
axismap->blend_points[j - 1] ) );
}
return INT_TO_FIXED( axismap->design_points[axismap->num_points - 1] );