[HarfBuzz] harfbuzz: Branch 'master'

Behdad Esfahbod behdad at kemper.freedesktop.org
Mon Jan 23 00:43:08 UTC 2017


 src/hb-ft.cc |   33 +++++++++++++++++++++------------
 1 file changed, 21 insertions(+), 12 deletions(-)

New commits:
commit 825e40407da74576f8e83ce0bacad5b0459b83c8
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sun Jan 22 16:41:45 2017 -0800

    [hb-ft] Remove use of variable-length array
    
    Hopefully also fixes build failure on msvc.

diff --git a/src/hb-ft.cc b/src/hb-ft.cc
index acb7bb1..496fff2 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;


More information about the HarfBuzz mailing list