src/hb-ot-font.cc | 32 +++++++++++++++++++++----------- src/hb-ot-var-hvar-table.hh | 12 ++++++------ 2 files changed, 27 insertions(+), 17 deletions(-)
New commits: commit 79e8e27ffd3da29ca27d3aebd2ef425bf1cb7f9d Author: Behdad Esfahbod <beh...@behdad.org> Date: Mon Jan 23 17:55:31 2017 -0800 [var] Hook up advance variations to hb-ot-font Yay, works! diff --git a/src/hb-ot-font.cc b/src/hb-ot-font.cc index c597f14..009db20 100644 --- a/src/hb-ot-font.cc +++ b/src/hb-ot-font.cc @@ -138,7 +138,8 @@ struct hb_ot_face_metrics_accelerator_t return this->default_advance; } - return this->table->longMetric[MIN (glyph, this->num_advances - 1)].advance; + return this->table->longMetric[MIN (glyph, this->num_advances - 1)].advance + + this->var->get_advance_var (glyph, font->coords, font->num_coords); // TODO Optimize?! } }; @@ -524,6 +525,7 @@ hb_ot_get_glyph_extents (hb_font_t *font HB_UNUSED, bool ret = ot_font->glyf->get_extents (glyph, extents); if (!ret) ret = ot_font->cbdt->get_extents (glyph, extents); + // TODO Hook up side-bearings variations. extents->x_bearing = font->em_scale_x (extents->x_bearing); extents->y_bearing = font->em_scale_y (extents->y_bearing); extents->width = font->em_scale_x (extents->width); @@ -541,6 +543,7 @@ hb_ot_get_font_h_extents (hb_font_t *font HB_UNUSED, metrics->ascender = font->em_scale_y (ot_font->h_metrics.ascender); metrics->descender = font->em_scale_y (ot_font->h_metrics.descender); metrics->line_gap = font->em_scale_y (ot_font->h_metrics.line_gap); + // TODO Hook up variations. return ot_font->h_metrics.has_font_extents; } @@ -554,6 +557,7 @@ hb_ot_get_font_v_extents (hb_font_t *font HB_UNUSED, metrics->ascender = font->em_scale_x (ot_font->v_metrics.ascender); metrics->descender = font->em_scale_x (ot_font->v_metrics.descender); metrics->line_gap = font->em_scale_x (ot_font->v_metrics.line_gap); + // TODO Hook up variations. return ot_font->v_metrics.has_font_extents; } commit 607434037199ccca422287e4d097487f17f3cfb5 Author: Behdad Esfahbod <beh...@behdad.org> Date: Mon Jan 23 17:55:16 2017 -0800 [var] Fix bug in HVAR/VVAR impl diff --git a/src/hb-ot-var-hvar-table.hh b/src/hb-ot-var-hvar-table.hh index 9931a5e..3a2a820 100644 --- a/src/hb-ot-var-hvar-table.hh +++ b/src/hb-ot-var-hvar-table.hh @@ -71,10 +71,10 @@ struct DeltaSetIndexMap } protected: - inline bool get_width (void) const + inline unsigned int get_width (void) const { return ((format >> 4) & 3) + 1; } - inline bool get_inner_bitcount (void) const + inline unsigned int get_inner_bitcount (void) const { return (format & 0xF) + 1; } protected: commit bd3b11d92663343350813ca29606b369f691af03 Author: Behdad Esfahbod <beh...@behdad.org> Date: Mon Jan 23 17:34:44 2017 -0800 [var] Prepare for hooking up advance variations to hb-ot-font diff --git a/src/hb-ot-font.cc b/src/hb-ot-font.cc index c7286b7..c597f14 100644 --- a/src/hb-ot-font.cc +++ b/src/hb-ot-font.cc @@ -54,9 +54,13 @@ struct hb_ot_face_metrics_accelerator_t const OT::hmtxvmtx *table; hb_blob_t *blob; + const OT::HVARVVAR *var; + hb_blob_t *var_blob; + inline void init (hb_face_t *face, hb_tag_t _hea_tag, hb_tag_t _mtx_tag, + hb_tag_t _var_tag, hb_tag_t os2_tag, unsigned int default_advance = 0) { @@ -109,14 +113,19 @@ struct hb_ot_face_metrics_accelerator_t this->blob = hb_blob_get_empty (); } this->table = OT::Sanitizer<OT::hmtxvmtx>::lock_instance (this->blob); + + this->var_blob = OT::Sanitizer<OT::HVARVVAR>::sanitize (face->reference_table (_var_tag)); + this->var = OT::Sanitizer<OT::HVARVVAR>::lock_instance (this->var_blob); } inline void fini (void) { hb_blob_destroy (this->blob); + hb_blob_destroy (this->var_blob); } - inline unsigned int get_advance (hb_codepoint_t glyph) const + inline unsigned int get_advance (hb_codepoint_t glyph, + hb_font_t *font) const { if (unlikely (glyph >= this->num_metrics)) { @@ -129,10 +138,7 @@ struct hb_ot_face_metrics_accelerator_t return this->default_advance; } - if (glyph >= this->num_advances) - glyph = this->num_advances - 1; - - return this->table->longMetric[glyph].advance; + return this->table->longMetric[MIN (glyph, this->num_advances - 1)].advance; } }; @@ -441,8 +447,8 @@ _hb_ot_font_create (hb_face_t *face) return NULL; ot_font->cmap.init (face); - ot_font->h_metrics.init (face, HB_OT_TAG_hhea, HB_OT_TAG_hmtx, HB_OT_TAG_os2); - ot_font->v_metrics.init (face, HB_OT_TAG_vhea, HB_OT_TAG_vmtx, HB_TAG_NONE, + ot_font->h_metrics.init (face, HB_OT_TAG_hhea, HB_OT_TAG_hmtx, HB_OT_TAG_HVAR, HB_OT_TAG_os2); + ot_font->v_metrics.init (face, HB_OT_TAG_vhea, HB_OT_TAG_vmtx, HB_OT_TAG_VVAR, HB_TAG_NONE, ot_font->h_metrics.ascender - ot_font->h_metrics.descender); /* TODO Can we do this lazily? */ ot_font->glyf.init (face); ot_font->cbdt.init (face); @@ -488,23 +494,23 @@ hb_ot_get_variation_glyph (hb_font_t *font HB_UNUSED, } static hb_position_t -hb_ot_get_glyph_h_advance (hb_font_t *font HB_UNUSED, +hb_ot_get_glyph_h_advance (hb_font_t *font, void *font_data, hb_codepoint_t glyph, void *user_data HB_UNUSED) { const hb_ot_font_t *ot_font = (const hb_ot_font_t *) font_data; - return font->em_scale_x (ot_font->h_metrics.get_advance (glyph)); + return font->em_scale_x (ot_font->h_metrics.get_advance (glyph, font)); } static hb_position_t -hb_ot_get_glyph_v_advance (hb_font_t *font HB_UNUSED, +hb_ot_get_glyph_v_advance (hb_font_t *font, void *font_data, hb_codepoint_t glyph, void *user_data HB_UNUSED) { const hb_ot_font_t *ot_font = (const hb_ot_font_t *) font_data; - return font->em_scale_y (-(int) ot_font->v_metrics.get_advance (glyph)); + return font->em_scale_y (-(int) ot_font->v_metrics.get_advance (glyph, font)); } static hb_bool_t diff --git a/src/hb-ot-var-hvar-table.hh b/src/hb-ot-var-hvar-table.hh index cf22c9d..9931a5e 100644 --- a/src/hb-ot-var-hvar-table.hh +++ b/src/hb-ot-var-hvar-table.hh @@ -98,8 +98,8 @@ struct DeltaSetIndexMap struct HVARVVAR { - static const hb_tag_t HVARTag = HB_OT_TAG_hmtx; - static const hb_tag_t VVARTag = HB_OT_TAG_vmtx; + static const hb_tag_t HVARTag = HB_OT_TAG_HVAR; + static const hb_tag_t VVARTag = HB_OT_TAG_VVAR; inline bool sanitize (hb_sanitize_context_t *c) const { @@ -112,8 +112,8 @@ struct HVARVVAR rsbMap.sanitize (c, this)); } - inline float get_advance_delta (hb_codepoint_t glyph, - int *coords, unsigned int coord_count) const + inline float get_advance_var (hb_codepoint_t glyph, + int *coords, unsigned int coord_count) const { unsigned int varidx = (this+advMap).map (glyph); return (this+varStore).get_delta (varidx, coords, coord_count); _______________________________________________ HarfBuzz mailing list HarfBuzz@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/harfbuzz