aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2017-01-22 17:47:49 -0800
committerBehdad Esfahbod <behdad@behdad.org>2017-01-22 17:47:49 -0800
commit7647a05a0b37c53465560952b412db4e590f2716 (patch)
treede9b727b79f205c24acbb0b02d79876d884464de
parentd2f249e745a9179943ee39c719b73e1057acbc13 (diff)
downloadharfbuzz_ng-7647a05a0b37c53465560952b412db4e590f2716.tar.gz
Minor
-rw-r--r--src/hb-font.cc5
-rw-r--r--src/hb-font.h2
-rw-r--r--src/hb-ft.cc2
-rw-r--r--util/helper-cairo.cc14
4 files changed, 15 insertions, 8 deletions
diff --git a/src/hb-font.cc b/src/hb-font.cc
index 3140ee47c..a3f250d50 100644
--- a/src/hb-font.cc
+++ b/src/hb-font.cc
@@ -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)
{
diff --git a/src/hb-font.h b/src/hb-font.h
index fce4206df..e2e59796f 100644
--- a/src/hb-font.h
+++ b/src/hb-font.h
@@ -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);
diff --git a/src/hb-ft.cc b/src/hb-ft.cc
index 496fff230..48d6a0efb 100644
--- a/src/hb-ft.cc
+++ b/src/hb-ft.cc
@@ -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));
diff --git a/util/helper-cairo.cc b/util/helper-cairo.cc
index df5173b59..2e2952b28 100644
--- a/util/helper-cairo.cc
+++ b/util/helper-cairo.cc
@@ -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);