Minor
authorBehdad Esfahbod <behdad@behdad.org>
Mon, 23 Jan 2017 01:47:49 +0000 (17:47 -0800)
committerBehdad Esfahbod <behdad@behdad.org>
Mon, 23 Jan 2017 01:47:49 +0000 (17:47 -0800)
src/hb-font.cc
src/hb-font.h
src/hb-ft.cc
util/helper-cairo.cc

index 3140ee4..a3f250d 100644 (file)
@@ -1639,9 +1639,12 @@ hb_font_set_var_coords_normalized (hb_font_t *font,
 /**
  * hb_font_set_var_coords_normalized:
  *
+ * Return value is valid as long as variation coordinates of the font
+ * are not modified.
+ *
  * Since: 1.4.2
  */
-int *
+const int *
 hb_font_get_var_coords_normalized (hb_font_t *font,
                                   unsigned int *length)
 {
index fce4206..e2e5979 100644 (file)
@@ -618,7 +618,7 @@ hb_font_set_var_coords_normalized (hb_font_t *font,
                                   const int *coords, /* 2.14 normalized */
                                   unsigned int coords_length);
 
-HB_EXTERN int *
+HB_EXTERN const int *
 hb_font_get_var_coords_normalized (hb_font_t *font,
                                   unsigned int *length);
 
index 496fff2..48d6a0e 100644 (file)
@@ -742,7 +742,7 @@ hb_ft_font_set_funcs (hb_font_t *font)
   }
 
   unsigned int num_coords;
-  int *coords = hb_font_get_var_coords_normalized (font, &num_coords);
+  const int *coords = hb_font_get_var_coords_normalized (font, &num_coords);
   if (num_coords)
   {
     FT_Fixed *ft_coords = (FT_Fixed *) calloc (num_coords, sizeof (FT_Fixed));
index df5173b..2e2952b 100644 (file)
@@ -104,13 +104,17 @@ helper_cairo_create_scaled_font (const font_options_t *font_opts)
   else
   {
     unsigned int num_coords;
-    int *coords = hb_font_get_var_coords_normalized (font, &num_coords);
+    const 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);
+      }
     }
 
     cairo_face = cairo_ft_font_face_create_for_ft_face (ft_face, 0);