[ft] Pass design, not normalized, coords to freetype

Needed for avar2 to work.
pull/3495/head
Behdad Esfahbod 2 years ago
parent 473a5e5651
commit 61d0c54701
  1. 6
      src/hb-ft.cc
  2. 6
      util/helper-cairo-ft.hh

@ -177,15 +177,15 @@ static void _hb_ft_hb_font_changed (hb_font_t *font, FT_Face ft_face)
#if defined(HAVE_FT_GET_VAR_BLEND_COORDINATES) && !defined(HB_NO_VAR)
unsigned int num_coords;
const int *coords = hb_font_get_var_coords_normalized (font, &num_coords);
const float *coords = hb_font_get_var_coords_design (font, &num_coords);
if (num_coords)
{
FT_Fixed *ft_coords = (FT_Fixed *) hb_calloc (num_coords, sizeof (FT_Fixed));
if (ft_coords)
{
for (unsigned int i = 0; i < num_coords; i++)
ft_coords[i] = coords[i] * 4;
FT_Set_Var_Blend_Coordinates (ft_face, num_coords, ft_coords);
ft_coords[i] = coords[i] * 65536.f;
FT_Set_Var_Design_Coordinates (ft_face, num_coords, ft_coords);
hb_free (ft_coords);
}
}

@ -82,15 +82,15 @@ helper_cairo_create_ft_font_face (const font_options_t *font_opts)
{
#if !defined(HB_NO_VAR) && defined(HAVE_FT_SET_VAR_BLEND_COORDINATES)
unsigned int num_coords;
const int *coords = hb_font_get_var_coords_normalized (font_opts->font, &num_coords);
const float *coords = hb_font_get_var_coords_design (font_opts->font, &num_coords);
if (num_coords)
{
FT_Fixed *ft_coords = (FT_Fixed *) calloc (num_coords, sizeof (FT_Fixed));
if (ft_coords)
{
for (unsigned int i = 0; i < num_coords; i++)
ft_coords[i] = coords[i] << 2;
FT_Set_Var_Blend_Coordinates (ft_face, num_coords, ft_coords);
ft_coords[i] = coords[i] * 65536.f;
FT_Set_Var_Design_Coordinates (ft_face, num_coords, ft_coords);
free (ft_coords);
}
}

Loading…
Cancel
Save