aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2017-01-22 16:41:45 -0800
committerBehdad Esfahbod <behdad@behdad.org>2017-01-22 16:41:45 -0800
commit825e40407da74576f8e83ce0bacad5b0459b83c8 (patch)
treea753c34346eafee1b9109c82bb4ed823f3e6f6cb
parent47ee34e84745756a9aaeb964772377b6c1417ed1 (diff)
downloadharfbuzz_ng-825e40407da74576f8e83ce0bacad5b0459b83c8.tar.gz
[hb-ft] Remove use of variable-length array
Hopefully also fixes build failure on msvc.
-rw-r--r--src/hb-ft.cc33
1 files changed, 21 insertions, 12 deletions
diff --git a/src/hb-ft.cc b/src/hb-ft.cc
index acb7bb1d0..496fff230 100644
--- a/src/hb-ft.cc
+++ b/src/hb-ft.cc
@@ -621,17 +621,22 @@ hb_ft_font_create (FT_Face ft_face,
FT_MM_Var *mm_var = NULL;
if (!FT_Get_MM_Var (ft_face, &mm_var))
{
- FT_Fixed coords[mm_var->num_axis];
- int hbCoords[mm_var->num_axis];
- if (!FT_Get_Var_Blend_Coordinates (ft_face, mm_var->num_axis, coords))
+ FT_Fixed *ft_coords = (FT_Fixed *) calloc (mm_var->num_axis, sizeof (FT_Fixed));
+ int *coords = (int *) calloc (mm_var->num_axis, sizeof (int));
+ if (coords && ft_coords)
{
- for (unsigned int i = 0; i < mm_var->num_axis; ++i)
- hbCoords[i] = coords[i] >> 2;
-
- hb_font_set_var_coords_normalized (font, hbCoords, mm_var->num_axis);
+ if (!FT_Get_Var_Blend_Coordinates (ft_face, mm_var->num_axis, ft_coords))
+ {
+ for (unsigned int i = 0; i < mm_var->num_axis; ++i)
+ 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
return 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);
if (num_coords)
{
- FT_Fixed ft_coords[num_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_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);
+ free (ft_coords);
+ }
}
ft_face->generic.data = blob;