diff --git a/src/hb-font-private.hh b/src/hb-font-private.hh index 3a1e31f0683db50951ca7515c30fdd878f48deee..48dc72564c4eab62417a36d737f0276d09910c8a 100644 --- a/src/hb-font-private.hh +++ b/src/hb-font-private.hh @@ -109,8 +109,9 @@ struct hb_font_t { unsigned int y_ppem; /* Font variation coordinates. */ - int *coords; - unsigned int coord_count; + unsigned int num_coords; + int *x_coords; + int *y_coords; hb_font_funcs_t *klass; void *user_data; diff --git a/src/hb-font.cc b/src/hb-font.cc index b4b4d0a52719f3b6d245c218a5fd0ad3d114cc57..75c8515e542a3370bea03545844b0d996f12b9b2 100644 --- a/src/hb-font.cc +++ b/src/hb-font.cc @@ -1165,6 +1165,8 @@ hb_font_create_sub_font (hb_font_t *parent) font->x_ppem = parent->x_ppem; font->y_ppem = parent->y_ppem; + /* TODO: copy variation coordinates. */ + return font; } @@ -1194,8 +1196,9 @@ hb_font_get_empty (void) 0, /* x_ppem */ 0, /* y_ppem */ - NULL, /* coords */ - 0, /* coord_count */ + 0, /* num_coords */ + NULL, /* x_coords */ + NULL, /* y_coords */ const_cast (&_hb_font_funcs_nil), /* klass */ NULL, /* user_data */ @@ -1251,6 +1254,8 @@ hb_font_destroy (hb_font_t *font) hb_face_destroy (font->face); hb_font_funcs_destroy (font->klass); + /* TODO: destroy variation coordinates. */ + free (font); } diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh index a18ce74dc7688ec2b32d50fa79013f7c98d7521b..cd26db338441df7b3e4db2fdca29dce670dcd761 100644 --- a/src/hb-ot-layout-common-private.hh +++ b/src/hb-ot-layout-common-private.hh @@ -1315,10 +1315,10 @@ struct VariationDevice { inline hb_position_t get_x_delta (hb_font_t *font) const - { return font->em_scalef_x (get_delta (font->coords, font->coord_count)); } + { return font->em_scalef_x (get_delta (font->x_coords, font->num_coords)); } inline hb_position_t get_y_delta (hb_font_t *font) const - { return font->em_scalef_y (get_delta (font->coords, font->coord_count)); } + { return font->em_scalef_y (get_delta (font->y_coords, font->num_coords)); } inline bool sanitize (hb_sanitize_context_t *c) const { diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh index bbe390cf7d2f10de4e66cc27cdf621a7ade61545..424a34e40bac5847057ff5b388b1b1b80994e2d0 100644 --- a/src/hb-ot-layout-gpos-table.hh +++ b/src/hb-ot-layout-gpos-table.hh @@ -109,7 +109,6 @@ struct ValueFormat : USHORT const Value *values, hb_glyph_position_t &glyph_pos) const { - unsigned int x_ppem, y_ppem; unsigned int format = *this; hb_bool_t horizontal = HB_DIRECTION_IS_HORIZONTAL (direction); @@ -129,27 +128,28 @@ struct ValueFormat : USHORT if (!has_device ()) return; - x_ppem = font->x_ppem; - y_ppem = font->y_ppem; + bool use_x_device = font->x_ppem || font->num_coords; + bool use_y_device = font->y_ppem || font->num_coords; - if (!x_ppem && !y_ppem) return; + + if (!use_x_device && !use_y_device) return; /* pixel -> fractional pixel */ if (format & xPlaDevice) { - if (x_ppem) glyph_pos.x_offset += (base + get_device (values)).get_x_delta (font); + if (use_x_device) glyph_pos.x_offset += (base + get_device (values)).get_x_delta (font); values++; } if (format & yPlaDevice) { - if (y_ppem) glyph_pos.y_offset += (base + get_device (values)).get_y_delta (font); + if (use_y_device) glyph_pos.y_offset += (base + get_device (values)).get_y_delta (font); values++; } if (format & xAdvDevice) { - if (horizontal && x_ppem) glyph_pos.x_advance += (base + get_device (values)).get_x_delta (font); + if (horizontal && use_x_device) glyph_pos.x_advance += (base + get_device (values)).get_x_delta (font); values++; } if (format & yAdvDevice) { /* y_advance values grow downward but font-space grows upward, hence negation */ - if (!horizontal && y_ppem) glyph_pos.y_advance -= (base + get_device (values)).get_y_delta (font); + if (!horizontal && use_y_device) glyph_pos.y_advance -= (base + get_device (values)).get_y_delta (font); values++; } } @@ -291,9 +291,9 @@ struct AnchorFormat3 *x = font->em_scale_x (xCoordinate); *y = font->em_scale_y (yCoordinate); - if (font->x_ppem) + if (font->x_ppem || font->num_coords) *x += (this+xDeviceTable).get_x_delta (font); - if (font->y_ppem) + if (font->y_ppem || font->num_coords) *y += (this+yDeviceTable).get_x_delta (font); }