[HarfBuzz] harfbuzz: Branch 'master' - 10 commits
Behdad Esfahbod
behdad at kemper.freedesktop.org
Sun Jan 22 02:11:20 UTC 2017
src/hb-common.cc | 36 ++++++++++----------
src/hb-common.h | 10 ++---
src/hb-face.cc | 6 ---
src/hb-font.cc | 90 +++++++++++++++++++++++++++++++++++++++++++-------
src/hb-font.h | 15 +++++++-
src/hb-ft.cc | 10 +++++
src/hb-ot-layout.cc | 5 --
src/hb-ot-math.cc | 2 -
src/hb-ot-tag.cc | 3 -
util/helper-cairo.cc | 16 ++++++++
util/options.cc | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++
util/options.hh | 8 +++-
12 files changed, 241 insertions(+), 51 deletions(-)
New commits:
commit 47ee34e84745756a9aaeb964772377b6c1417ed1
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Sat Jan 21 18:10:08 2017 -0800
[var] Hook up variations to FreeType face
hb-view correctly renders variations with ft font-funcs now.
hb-ot-font needs HVAR implementation.
diff --git a/src/hb-ft.cc b/src/hb-ft.cc
index d5f8d52..acb7bb1 100644
--- a/src/hb-ft.cc
+++ b/src/hb-ft.cc
@@ -736,6 +736,16 @@ hb_ft_font_set_funcs (hb_font_t *font)
FT_Set_Transform (ft_face, &matrix, NULL);
}
+ unsigned int num_coords;
+ 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_face->generic.data = blob;
ft_face->generic.finalizer = (FT_Generic_Finalizer) _release_blob;
diff --git a/util/helper-cairo.cc b/util/helper-cairo.cc
index 8f30eea..df5173b 100644
--- a/util/helper-cairo.cc
+++ b/util/helper-cairo.cc
@@ -28,6 +28,7 @@
#include <cairo-ft.h>
#include <hb-ft.h>
+#include FT_MULTIPLE_MASTERS_H
#include "helper-cairo-ansi.hh"
#ifdef CAIRO_HAS_SVG_SURFACE
@@ -76,7 +77,8 @@ helper_cairo_create_scaled_font (const font_options_t *font_opts)
cairo_font_face_t *cairo_face;
/* We cannot use the FT_Face from hb_font_t, as doing so will confuse hb_font_t because
- * cairo will reset the face size. As such, create new face... */
+ * cairo will reset the face size. As such, create new face...
+ * TODO Perhaps add API to hb-ft to encapsulate this code. */
FT_Face ft_face = NULL;//hb_ft_font_get_face (font);
if (!ft_face)
{
@@ -100,7 +102,19 @@ helper_cairo_create_scaled_font (const font_options_t *font_opts)
CAIRO_FONT_WEIGHT_NORMAL);
}
else
+ {
+ unsigned int num_coords;
+ 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);
+ }
+
cairo_face = cairo_ft_font_face_create_for_ft_face (ft_face, 0);
+ }
cairo_matrix_t ctm, font_matrix;
cairo_font_options_t *font_options;
commit 111f3e55178f7cd5a8ae4e8ae111cb48aea4acb5
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Sat Jan 21 17:51:41 2017 -0800
[util] Add --variations
Is hooked up to the font, but not to FreeType, so raster doesn't show yet.
Documentation needs to be done.
diff --git a/util/options.cc b/util/options.cc
index bc699c1..8c79c4a 100644
--- a/util/options.cc
+++ b/util/options.cc
@@ -254,6 +254,47 @@ parse_features (const char *name G_GNUC_UNUSED,
return true;
}
+static gboolean
+parse_variations (const char *name G_GNUC_UNUSED,
+ const char *arg,
+ gpointer data,
+ GError **error G_GNUC_UNUSED)
+{
+ font_options_t *font_opts = (font_options_t *) data;
+ char *s = (char *) arg;
+ char *p;
+
+ font_opts->num_variations = 0;
+ g_free (font_opts->variations);
+ font_opts->variations = NULL;
+
+ if (!*s)
+ return true;
+
+ /* count the variations first, so we can allocate memory */
+ p = s;
+ do {
+ font_opts->num_variations++;
+ p = strchr (p, ',');
+ if (p)
+ p++;
+ } while (p);
+
+ font_opts->variations = (hb_variation_t *) calloc (font_opts->num_variations, sizeof (*font_opts->variations));
+
+ /* now do the actual parsing */
+ p = s;
+ font_opts->num_variations = 0;
+ while (p && *p) {
+ char *end = strchr (p, ',');
+ if (hb_variation_from_string (p, end ? end - p : -1, &font_opts->variations[font_opts->num_variations]))
+ font_opts->num_variations++;
+ p = end ? end + 1 : NULL;
+ }
+
+ return true;
+}
+
void
view_options_t::add_options (option_parser_t *parser)
@@ -415,6 +456,54 @@ font_options_t::add_options (option_parser_t *parser)
"Font options:",
"Options controlling the font",
this);
+
+ const gchar *variations_help = "Comma-separated list of font variations\n"
+ "\n"
+ " XXXXXXXXXXXXXXX\n"
+ " Features can be enabled or disabled, either globally or limited to\n"
+ " specific character ranges. The format for specifying feature settings\n"
+ " follows. All valid CSS font-feature-settings values other than 'normal'\n"
+ " and 'inherited' are also accepted, though, not documented below.\n"
+ "\n"
+ " The range indices refer to the positions between Unicode characters,\n"
+ " unless the --utf8-clusters is provided, in which case range indices\n"
+ " refer to UTF-8 byte indices. The position before the first character\n"
+ " is always 0.\n"
+ "\n"
+ " The format is Python-esque. Here is how it all works:\n"
+ "\n"
+ " Syntax: Value: Start: End:\n"
+ "\n"
+ " Setting value:\n"
+ " \"kern\" 1 0 ∞ # Turn feature on\n"
+ " \"+kern\" 1 0 ∞ # Turn feature on\n"
+ " \"-kern\" 0 0 ∞ # Turn feature off\n"
+ " \"kern=0\" 0 0 ∞ # Turn feature off\n"
+ " \"kern=1\" 1 0 ∞ # Turn feature on\n"
+ " \"aalt=2\" 2 0 ∞ # Choose 2nd alternate\n"
+ "\n"
+ " Setting index:\n"
+ " \"kern[]\" 1 0 ∞ # Turn feature on\n"
+ " \"kern[:]\" 1 0 ∞ # Turn feature on\n"
+ " \"kern[5:]\" 1 5 ∞ # Turn feature on, partial\n"
+ " \"kern[:5]\" 1 0 5 # Turn feature on, partial\n"
+ " \"kern[3:5]\" 1 3 5 # Turn feature on, range\n"
+ " \"kern[3]\" 1 3 3+1 # Turn feature on, single char\n"
+ "\n"
+ " Mixing it all:\n"
+ "\n"
+ " \"aalt[3:5]=2\" 2 3 5 # Turn 2nd alternate on for range";
+
+ GOptionEntry entries2[] =
+ {
+ {"variations", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) &parse_variations, variations_help, "list"},
+ {NULL}
+ };
+ parser->add_group (entries2,
+ "variations",
+ "Varitions options:",
+ "Options controlling font variations used",
+ this);
}
void
@@ -561,6 +650,8 @@ font_options_t::get_font (void) const
hb_font_set_scale (font, scale_x, scale_y);
hb_face_destroy (face);
+ hb_font_set_variations (font, variations, num_variations);
+
void (*set_font_funcs) (hb_font_t *) = NULL;
if (!font_funcs)
{
diff --git a/util/options.hh b/util/options.hh
index 919e4f8..9ed4fd0 100644
--- a/util/options.hh
+++ b/util/options.hh
@@ -285,7 +285,10 @@ struct font_options_t : option_group_t
{
font_options_t (option_parser_t *parser,
int default_font_size_,
- unsigned int subpixel_bits_) {
+ unsigned int subpixel_bits_)
+ {
+ variations = NULL;
+ num_variations = 0;
default_font_size = default_font_size_;
subpixel_bits = subpixel_bits_;
font_file = NULL;
@@ -299,6 +302,7 @@ struct font_options_t : option_group_t
}
~font_options_t (void) {
g_free (font_file);
+ free (variations);
g_free (font_funcs);
hb_font_destroy (font);
}
@@ -309,6 +313,8 @@ struct font_options_t : option_group_t
char *font_file;
int face_index;
+ hb_variation_t *variations;
+ unsigned int num_variations;
int default_font_size;
unsigned int subpixel_bits;
mutable double font_size_x;
commit bb1e19268f02d4aad2240c52852e72afcf0f79ad
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Sat Jan 21 17:41:37 2017 -0800
[var] Rename var_coord to variation
Looks much better.
diff --git a/src/hb-common.cc b/src/hb-common.cc
index 25c979c..a804f82 100644
--- a/src/hb-common.cc
+++ b/src/hb-common.cc
@@ -608,7 +608,7 @@ hb_version_atleast (unsigned int major,
-/* hb_feature_t and hb_var_coord_t */
+/* hb_feature_t and hb_variation_t */
static bool
parse_space (const char **pp, const char *end)
@@ -880,59 +880,59 @@ hb_feature_to_string (hb_feature_t *feature,
buf[len] = '\0';
}
-/* hb_var_coord_t */
+/* hb_variation_t */
static bool
-parse_var_coord_value (const char **pp, const char *end, hb_var_coord_t *var_coord)
+parse_variation_value (const char **pp, const char *end, hb_variation_t *variation)
{
parse_char (pp, end, '='); /* Optional. */
- return parse_float (pp, end, &var_coord->value);
+ return parse_float (pp, end, &variation->value);
}
static bool
-parse_one_var_coord (const char **pp, const char *end, hb_var_coord_t *var_coord)
+parse_one_variation (const char **pp, const char *end, hb_variation_t *variation)
{
- return parse_tag (pp, end, &var_coord->tag) &&
- parse_var_coord_value (pp, end, var_coord) &&
+ return parse_tag (pp, end, &variation->tag) &&
+ parse_variation_value (pp, end, variation) &&
parse_space (pp, end) &&
*pp == end;
}
hb_bool_t
-hb_var_coord_from_string (const char *str, int len,
- hb_var_coord_t *var_coord)
+hb_variation_from_string (const char *str, int len,
+ hb_variation_t *variation)
{
- hb_var_coord_t coord;
+ hb_variation_t var;
if (len < 0)
len = strlen (str);
- if (likely (parse_one_var_coord (&str, str + len, &coord)))
+ if (likely (parse_one_variation (&str, str + len, &var)))
{
- if (var_coord)
- *var_coord = coord;
+ if (variation)
+ *variation = var;
return true;
}
- if (var_coord)
- memset (var_coord, 0, sizeof (*var_coord));
+ if (variation)
+ memset (variation, 0, sizeof (*variation));
return false;
}
void
-hb_var_coord_to_string (hb_var_coord_t *var_coord,
+hb_variation_to_string (hb_variation_t *variation,
char *buf, unsigned int size)
{
if (unlikely (!size)) return;
char s[128];
unsigned int len = 0;
- hb_tag_to_string (var_coord->tag, s + len);
+ hb_tag_to_string (variation->tag, s + len);
len += 4;
while (len && s[len - 1] == ' ')
len--;
s[len++] = '=';
- len += MAX (0, snprintf (s + len, ARRAY_LENGTH (s) - len, "%g", var_coord->value));
+ len += MAX (0, snprintf (s + len, ARRAY_LENGTH (s) - len, "%g", variation->value));
assert (len < ARRAY_LENGTH (s));
len = MIN (len, size - 1);
diff --git a/src/hb-common.h b/src/hb-common.h
index e483fb8..ed0b97d 100644
--- a/src/hb-common.h
+++ b/src/hb-common.h
@@ -379,17 +379,17 @@ HB_EXTERN void
hb_feature_to_string (hb_feature_t *feature,
char *buf, unsigned int size);
-typedef struct hb_var_coord_t {
+typedef struct hb_variation_t {
hb_tag_t tag;
float value;
-} hb_var_coord_t;
+} hb_variation_t;
HB_EXTERN hb_bool_t
-hb_var_coord_from_string (const char *str, int len,
- hb_var_coord_t *var_coord);
+hb_variation_from_string (const char *str, int len,
+ hb_variation_t *variation);
HB_EXTERN void
-hb_var_coord_to_string (hb_var_coord_t *var_coord,
+hb_variation_to_string (hb_variation_t *variation,
char *buf, unsigned int size);
diff --git a/src/hb-font.cc b/src/hb-font.cc
index 39d1769..607bd48 100644
--- a/src/hb-font.cc
+++ b/src/hb-font.cc
@@ -1552,14 +1552,14 @@ _hb_font_adopt_var_coords_normalized (hb_font_t *font,
}
void
-hb_font_set_var_coords (hb_font_t *font,
- const hb_var_coord_t *coords,
- unsigned int coords_length)
+hb_font_set_variations (hb_font_t *font,
+ const hb_variation_t *variations,
+ unsigned int variations_length)
{
if (font->immutable)
return;
- if (!coords_length)
+ if (!variations_length)
{
hb_font_set_var_coords_normalized (font, NULL, 0);
return;
@@ -1567,18 +1567,18 @@ hb_font_set_var_coords (hb_font_t *font,
hb_face_t *face = font->face;
- unsigned int length = hb_ot_var_get_axis_count (face);
+ unsigned int coords_length = hb_ot_var_get_axis_count (face);
- int *normalized = length ? (int *) calloc (length, sizeof (int)) : NULL;
- if (unlikely (length && !normalized))
+ int *normalized = coords_length ? (int *) calloc (coords_length, sizeof (int)) : NULL;
+ if (unlikely (coords_length && !normalized))
return;
/* normalized is filled with zero already. */
- for (unsigned int i = 0; i < coords_length; i++)
+ for (unsigned int i = 0; i < variations_length; i++)
{
unsigned int axis_index;
- if (hb_ot_var_find_axis (face, coords[i].tag, &axis_index, NULL))
- normalized[axis_index] = hb_ot_var_normalize_axis_value (face, axis_index, coords[i].value);
+ if (hb_ot_var_find_axis (face, variations[i].tag, &axis_index, NULL))
+ normalized[axis_index] = hb_ot_var_normalize_axis_value (face, axis_index, variations[i].value);
}
_hb_font_adopt_var_coords_normalized (font, normalized, coords_length);
diff --git a/src/hb-font.h b/src/hb-font.h
index 83eb68c..fce4206 100644
--- a/src/hb-font.h
+++ b/src/hb-font.h
@@ -604,9 +604,9 @@ hb_font_get_ppem (hb_font_t *font,
unsigned int *y_ppem);
HB_EXTERN void
-hb_font_set_var_coords (hb_font_t *font,
- const hb_var_coord_t *coords,
- unsigned int coords_length);
+hb_font_set_variations (hb_font_t *font,
+ const hb_variation_t *variations,
+ unsigned int variations_length);
HB_EXTERN void
hb_font_set_var_coords_design (hb_font_t *font,
commit 64fe92bf2d43a0ea31743d774e073f202021dbd1
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Sat Jan 21 15:36:35 2017 -0800
[var] Remove use of variable-length arrays
diff --git a/src/hb-font.cc b/src/hb-font.cc
index 1b4ed7e..39d1769 100644
--- a/src/hb-font.cc
+++ b/src/hb-font.cc
@@ -1540,6 +1540,17 @@ hb_font_get_ppem (hb_font_t *font,
* Variations
*/
+static void
+_hb_font_adopt_var_coords_normalized (hb_font_t *font,
+ int *coords, /* 2.14 normalized */
+ unsigned int coords_length)
+{
+ free (font->coords);
+
+ font->coords = coords;
+ font->num_coords = coords_length;
+}
+
void
hb_font_set_var_coords (hb_font_t *font,
const hb_var_coord_t *coords,
@@ -1557,10 +1568,12 @@ hb_font_set_var_coords (hb_font_t *font,
hb_face_t *face = font->face;
unsigned int length = hb_ot_var_get_axis_count (face);
- int normalized[length]; // XXX Remove variable-length array use...
- memset (normalized, 0, length * sizeof (normalized[0]));
+ int *normalized = length ? (int *) calloc (length, sizeof (int)) : NULL;
+ if (unlikely (length && !normalized))
+ return;
+ /* normalized is filled with zero already. */
for (unsigned int i = 0; i < coords_length; i++)
{
unsigned int axis_index;
@@ -1568,7 +1581,7 @@ hb_font_set_var_coords (hb_font_t *font,
normalized[axis_index] = hb_ot_var_normalize_axis_value (face, axis_index, coords[i].value);
}
- hb_font_set_var_coords_normalized (font, normalized, coords_length);
+ _hb_font_adopt_var_coords_normalized (font, normalized, coords_length);
}
void
@@ -1579,13 +1592,15 @@ hb_font_set_var_coords_design (hb_font_t *font,
if (font->immutable)
return;
- int normalized[coords_length]; // XXX Remove variable-length array use...
+ int *normalized = coords_length ? (int *) calloc (coords_length, sizeof (int)) : NULL;
+ if (unlikely (coords_length && !normalized))
+ return;
hb_face_t *face = font->face;
for (unsigned int i = 0; i < coords_length; i++)
normalized[i] = hb_ot_var_normalize_axis_value (face, i, coords[i]);
- hb_font_set_var_coords_normalized (font, normalized, coords_length);
+ _hb_font_adopt_var_coords_normalized (font, normalized, coords_length);
}
void
@@ -1603,10 +1618,7 @@ hb_font_set_var_coords_normalized (hb_font_t *font,
if (coords_length)
memcpy (copy, coords, coords_length * sizeof (coords[0]));
- free (font->coords);
-
- font->coords = copy;
- font->num_coords = coords_length;
+ _hb_font_adopt_var_coords_normalized (font, copy, coords_length);
}
int *
commit 2491134b386507f611a47e43e3f7c2766d0d288b
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Sat Jan 21 15:21:50 2017 -0800
[var] Add hb_font_set_var_coords()
diff --git a/src/hb-font.cc b/src/hb-font.cc
index 08c00bf..1b4ed7e 100644
--- a/src/hb-font.cc
+++ b/src/hb-font.cc
@@ -1541,10 +1541,44 @@ hb_font_get_ppem (hb_font_t *font,
*/
void
+hb_font_set_var_coords (hb_font_t *font,
+ const hb_var_coord_t *coords,
+ unsigned int coords_length)
+{
+ if (font->immutable)
+ return;
+
+ if (!coords_length)
+ {
+ hb_font_set_var_coords_normalized (font, NULL, 0);
+ return;
+ }
+
+ hb_face_t *face = font->face;
+
+ unsigned int length = hb_ot_var_get_axis_count (face);
+ int normalized[length]; // XXX Remove variable-length array use...
+
+ memset (normalized, 0, length * sizeof (normalized[0]));
+
+ for (unsigned int i = 0; i < coords_length; i++)
+ {
+ unsigned int axis_index;
+ if (hb_ot_var_find_axis (face, coords[i].tag, &axis_index, NULL))
+ normalized[axis_index] = hb_ot_var_normalize_axis_value (face, axis_index, coords[i].value);
+ }
+
+ hb_font_set_var_coords_normalized (font, normalized, coords_length);
+}
+
+void
hb_font_set_var_coords_design (hb_font_t *font,
- float *coords,
+ const float *coords,
unsigned int coords_length)
{
+ if (font->immutable)
+ return;
+
int normalized[coords_length]; // XXX Remove variable-length array use...
hb_face_t *face = font->face;
@@ -1556,7 +1590,7 @@ hb_font_set_var_coords_design (hb_font_t *font,
void
hb_font_set_var_coords_normalized (hb_font_t *font,
- int *coords, /* 2.14 normalized */
+ const int *coords, /* 2.14 normalized */
unsigned int coords_length)
{
if (font->immutable)
diff --git a/src/hb-font.h b/src/hb-font.h
index 31e5971..83eb68c 100644
--- a/src/hb-font.h
+++ b/src/hb-font.h
@@ -603,15 +603,19 @@ hb_font_get_ppem (hb_font_t *font,
unsigned int *x_ppem,
unsigned int *y_ppem);
+HB_EXTERN void
+hb_font_set_var_coords (hb_font_t *font,
+ const hb_var_coord_t *coords,
+ unsigned int coords_length);
HB_EXTERN void
hb_font_set_var_coords_design (hb_font_t *font,
- float *coords,
+ const float *coords,
unsigned int coords_length);
HB_EXTERN void
hb_font_set_var_coords_normalized (hb_font_t *font,
- int *coords, /* 2.14 normalized */
+ const int *coords, /* 2.14 normalized */
unsigned int coords_length);
HB_EXTERN int *
commit 113393efec5e0c4c10c141a6d4b801d50fcd8ab8
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Sat Jan 21 15:12:03 2017 -0800
Remove a few unused includes
diff --git a/src/hb-face.cc b/src/hb-face.cc
index 6b563bc..1ba9707 100644
--- a/src/hb-face.cc
+++ b/src/hb-face.cc
@@ -28,15 +28,11 @@
#include "hb-private.hh"
-#include "hb-ot-layout-private.hh"
-
-#include "hb-font-private.hh"
+#include "hb-face-private.hh"
#include "hb-open-file-private.hh"
#include "hb-ot-head-table.hh"
#include "hb-ot-maxp-table.hh"
-#include <string.h>
-
/*
* hb_face_t
diff --git a/src/hb-font.cc b/src/hb-font.cc
index e7f5752..08c00bf 100644
--- a/src/hb-font.cc
+++ b/src/hb-font.cc
@@ -28,14 +28,7 @@
#include "hb-private.hh"
-#include "hb-ot-layout-private.hh"
-
#include "hb-font-private.hh"
-#include "hb-open-file-private.hh"
-#include "hb-ot-head-table.hh"
-#include "hb-ot-maxp-table.hh"
-
-#include <string.h>
/*
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index d8d6284..d7ededd 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -34,13 +34,10 @@
#include "hb-ot-layout-gdef-table.hh"
#include "hb-ot-layout-gsub-table.hh"
#include "hb-ot-layout-gpos-table.hh"
-#include "hb-ot-layout-jstf-table.hh"
+#include "hb-ot-layout-jstf-table.hh" // Just so we compile it; unused otherwise.
#include "hb-ot-map-private.hh"
-#include <stdlib.h>
-#include <string.h>
-
HB_SHAPER_DATA_ENSURE_DECLARE(ot, face)
diff --git a/src/hb-ot-tag.cc b/src/hb-ot-tag.cc
index 5c348e8..9b0db50 100644
--- a/src/hb-ot-tag.cc
+++ b/src/hb-ot-tag.cc
@@ -28,9 +28,6 @@
#include "hb-private.hh"
-#include <string.h>
-
-
/* hb_script_t */
commit 2d40923ca914c90304d07d6e7b9b1040c79c76fe
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Sat Jan 21 15:06:15 2017 -0800
Minor
diff --git a/src/hb-ot-math.cc b/src/hb-ot-math.cc
index ec8df2c..eb08bad 100644
--- a/src/hb-ot-math.cc
+++ b/src/hb-ot-math.cc
@@ -120,7 +120,7 @@ hb_ot_math_get_glyph_top_accent_attachment (hb_font_t *font,
/**
* hb_ot_math_is_glyph_extended_shape:
- * @font: a #hb_font_t to test
+ * @face: a #hb_face_t to test
* @glyph: a glyph index to test
*
* Return value: true if the glyph is an extended shape, false otherwise
commit 8b2a58047095604dcdc576ecbe3e8c2ebb8f48f0
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Sat Jan 21 15:05:00 2017 -0800
[var] Add hb_font_set_var_coords_design()
diff --git a/src/hb-font.cc b/src/hb-font.cc
index e2a0a5f..e7f5752 100644
--- a/src/hb-font.cc
+++ b/src/hb-font.cc
@@ -1543,10 +1543,27 @@ hb_font_get_ppem (hb_font_t *font,
if (y_ppem) *y_ppem = font->y_ppem;
}
+/*
+ * Variations
+ */
+
+void
+hb_font_set_var_coords_design (hb_font_t *font,
+ float *coords,
+ unsigned int coords_length)
+{
+ int normalized[coords_length]; // XXX Remove variable-length array use...
+
+ hb_face_t *face = font->face;
+ for (unsigned int i = 0; i < coords_length; i++)
+ normalized[i] = hb_ot_var_normalize_axis_value (face, i, coords[i]);
+
+ hb_font_set_var_coords_normalized (font, normalized, coords_length);
+}
void
hb_font_set_var_coords_normalized (hb_font_t *font,
- int *coords, /* XXX 2.14 normalized */
+ int *coords, /* 2.14 normalized */
unsigned int coords_length)
{
if (font->immutable)
@@ -1570,7 +1587,7 @@ hb_font_get_var_coords_normalized (hb_font_t *font,
unsigned int *length)
{
if (length)
- *length = font->coords_length;
+ *length = font->num_coords;
return font->coords;
}
diff --git a/src/hb-font.h b/src/hb-font.h
index 5f22331..31e5971 100644
--- a/src/hb-font.h
+++ b/src/hb-font.h
@@ -605,8 +605,13 @@ hb_font_get_ppem (hb_font_t *font,
HB_EXTERN void
+hb_font_set_var_coords_design (hb_font_t *font,
+ float *coords,
+ unsigned int coords_length);
+
+HB_EXTERN void
hb_font_set_var_coords_normalized (hb_font_t *font,
- int *coords, /* XXX 2.14 normalized */
+ int *coords, /* 2.14 normalized */
unsigned int coords_length);
HB_EXTERN int *
commit 0dcc7b49a830e2680d3e6d86d953efab85cef6ff
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Sat Jan 21 14:50:22 2017 -0800
[var] Minor lifecycle adjustment
diff --git a/src/hb-font.cc b/src/hb-font.cc
index a8b9e4c..e2a0a5f 100644
--- a/src/hb-font.cc
+++ b/src/hb-font.cc
@@ -1556,11 +1556,11 @@ hb_font_set_var_coords_normalized (hb_font_t *font,
if (unlikely (coords_length && !copy))
return;
- free (font->coords);
-
if (coords_length)
memcpy (copy, coords, coords_length * sizeof (coords[0]));
+ free (font->coords);
+
font->coords = copy;
font->num_coords = coords_length;
}
commit bf0d3a665baac9e33c0f774b22197c321b864c80
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Sat Jan 21 14:48:46 2017 -0800
[var] Add hb_font_get_var_coords_normalized()
diff --git a/src/hb-font.cc b/src/hb-font.cc
index b91a35b..a8b9e4c 100644
--- a/src/hb-font.cc
+++ b/src/hb-font.cc
@@ -1565,6 +1565,16 @@ hb_font_set_var_coords_normalized (hb_font_t *font,
font->num_coords = coords_length;
}
+int *
+hb_font_get_var_coords_normalized (hb_font_t *font,
+ unsigned int *length)
+{
+ if (length)
+ *length = font->coords_length;
+
+ return font->coords;
+}
+
#ifndef HB_DISABLE_DEPRECATED
diff --git a/src/hb-font.h b/src/hb-font.h
index 8813286..5f22331 100644
--- a/src/hb-font.h
+++ b/src/hb-font.h
@@ -609,6 +609,10 @@ hb_font_set_var_coords_normalized (hb_font_t *font,
int *coords, /* XXX 2.14 normalized */
unsigned int coords_length);
+HB_EXTERN int *
+hb_font_get_var_coords_normalized (hb_font_t *font,
+ unsigned int *length);
+
HB_END_DECLS
#endif /* HB_FONT_H */
More information about the HarfBuzz
mailing list