From bb1e19268f02d4aad2240c52852e72afcf0f79ad Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 21 Jan 2017 17:41:37 -0800 Subject: [PATCH] [var] Rename var_coord to variation Looks much better. --- src/hb-common.cc | 36 ++++++++++++++++++------------------ src/hb-common.h | 10 +++++----- src/hb-font.cc | 20 ++++++++++---------- src/hb-font.h | 6 +++--- 4 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/hb-common.cc b/src/hb-common.cc index 25c979c59..a804f822b 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 e483fb857..ed0b97dfd 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 39d176914..607bd4893 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 83eb68c98..fce4206df 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,