提交 825e4040 编写于 作者: B Behdad Esfahbod

[hb-ft] Remove use of variable-length array

Hopefully also fixes build failure on msvc.
上级 47ee34e8
...@@ -621,17 +621,22 @@ hb_ft_font_create (FT_Face ft_face, ...@@ -621,17 +621,22 @@ hb_ft_font_create (FT_Face ft_face,
FT_MM_Var *mm_var = NULL; FT_MM_Var *mm_var = NULL;
if (!FT_Get_MM_Var (ft_face, &mm_var)) if (!FT_Get_MM_Var (ft_face, &mm_var))
{ {
FT_Fixed coords[mm_var->num_axis]; FT_Fixed *ft_coords = (FT_Fixed *) calloc (mm_var->num_axis, sizeof (FT_Fixed));
int hbCoords[mm_var->num_axis]; int *coords = (int *) calloc (mm_var->num_axis, sizeof (int));
if (!FT_Get_Var_Blend_Coordinates (ft_face, mm_var->num_axis, coords)) if (coords && ft_coords)
{ {
for (unsigned int i = 0; i < mm_var->num_axis; ++i) if (!FT_Get_Var_Blend_Coordinates (ft_face, mm_var->num_axis, ft_coords))
hbCoords[i] = coords[i] >> 2; {
for (unsigned int i = 0; i < mm_var->num_axis; ++i)
hb_font_set_var_coords_normalized (font, hbCoords, mm_var->num_axis); coords[i] = ft_coords[i] >>= 2;
hb_font_set_var_coords_normalized (font, coords, mm_var->num_axis);
}
free (coords);
free (ft_coords);
} }
free (mm_var);
} }
free (mm_var);
#endif #endif
return font; return font;
...@@ -740,10 +745,14 @@ hb_ft_font_set_funcs (hb_font_t *font) ...@@ -740,10 +745,14 @@ hb_ft_font_set_funcs (hb_font_t *font)
int *coords = hb_font_get_var_coords_normalized (font, &num_coords); int *coords = hb_font_get_var_coords_normalized (font, &num_coords);
if (num_coords) if (num_coords)
{ {
FT_Fixed ft_coords[num_coords]; FT_Fixed *ft_coords = (FT_Fixed *) calloc (num_coords, sizeof (FT_Fixed));
for (unsigned int i = 0; i < num_coords; i++) if (ft_coords)
ft_coords[i] = coords[i] << 2; {
FT_Set_Var_Blend_Coordinates (ft_face, num_coords, 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);
free (ft_coords);
}
} }
ft_face->generic.data = blob; ft_face->generic.data = blob;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册