diff --git a/src/hb-ot-layout-math-table.hh b/src/hb-ot-layout-math-table.hh index 3899b1612..8f7ce3db2 100644 --- a/src/hb-ot-layout-math-table.hh +++ b/src/hb-ot-layout-math-table.hh @@ -178,7 +178,6 @@ struct MathItalicsCorrectionInfo { unsigned int index = (this+coverage).get_coverage (glyph); return italicsCorrection[index].get_x_value (font, this); - return true; } protected: @@ -205,14 +204,13 @@ struct MathTopAccentAttachment topAccentAttachment.sanitize (c, this)); } - inline bool get_value (hb_font_t *font, hb_codepoint_t glyph, - hb_position_t &value) const + inline hb_position_t get_value (hb_codepoint_t glyph, + hb_font_t *font) const { unsigned int index = (this+topAccentCoverage).get_coverage (glyph); - if (likely (index == NOT_COVERED)) return false; - if (unlikely (index >= topAccentAttachment.len)) return false; - value = topAccentAttachment[index].get_x_value(font, this); - return true; + if (index == NOT_COVERED) + return font->get_glyph_h_advance (glyph) / 2; + return topAccentAttachment[index].get_x_value(font, this); } protected: @@ -366,22 +364,15 @@ struct MathGlyphInfo } inline hb_position_t - get_italics_correction (hb_codepoint_t glyph, - hb_font_t *font) const - { - return (this+mathItalicsCorrectionInfo).get_value (glyph, font); - } + get_italics_correction (hb_codepoint_t glyph, hb_font_t *font) const + { return (this+mathItalicsCorrectionInfo).get_value (glyph, font); } - inline const MathTopAccentAttachment& - get_math_top_accent_attachment (void) const { - return this+mathTopAccentAttachment; - } + inline hb_position_t + get_top_accent_attachment (hb_codepoint_t glyph, hb_font_t *font) const + { return (this+mathTopAccentAttachment).get_value (glyph, font); } inline bool is_extended_shape (hb_codepoint_t glyph) const - { - unsigned int index = (this+extendedShapeCoverage).get_coverage (glyph); - return index != NOT_COVERED; - } + { return (this+extendedShapeCoverage).get_coverage (glyph) != NOT_COVERED; } inline const MathKernInfo &get_math_kern_info (void) const { return this+mathKernInfo; diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index 5f171ca2b..6d6cf5bc6 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -1302,12 +1302,7 @@ hb_ot_layout_get_math_top_accent_attachment (hb_font_t *font, hb_codepoint_t glyph) { const OT::MATH &math = _get_math (font->face); - const OT::MathGlyphInfo &glyphInfo = math.get_math_glyph_info(); - hb_position_t value; - if (glyphInfo.get_math_top_accent_attachment().get_value(font, glyph, value)) - return value; - else - return 0; // XXX font->get_glyph_h_advance (glyph) / 2; + return math.get_math_glyph_info().get_top_accent_attachment (glyph, font); } /** diff --git a/test/api/test-ot-layout-math.c b/test/api/test-ot-layout-math.c index a6f4453cc..d7121a2a2 100644 --- a/test/api/test-ot-layout-math.c +++ b/test/api/test-ot-layout-math.c @@ -204,22 +204,22 @@ test_get_math_top_accent_attachment (void) openFont("fonts/MathTestFontEmpty.otf"); g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph)); - g_assert_cmpint(hb_ot_layout_get_math_top_accent_attachment (hb_font, glyph), ==, 0); // MathGlyphInfo not available + g_assert_cmpint(hb_ot_layout_get_math_top_accent_attachment (hb_font, glyph), ==, 500); // MathGlyphInfo not available closeFont(); openFont("fonts/MathTestFontPartial1.otf"); g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph)); - g_assert_cmpint(hb_ot_layout_get_math_top_accent_attachment (hb_font, glyph), ==, 0); // MathGlyphInfo empty + g_assert_cmpint(hb_ot_layout_get_math_top_accent_attachment (hb_font, glyph), ==, 500); // MathGlyphInfo empty closeFont(); openFont("fonts/MathTestFontPartial2.otf"); g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph)); - g_assert_cmpint(hb_ot_layout_get_math_top_accent_attachment (hb_font, glyph), ==, 0); // MathTopAccentAttachment empty + g_assert_cmpint(hb_ot_layout_get_math_top_accent_attachment (hb_font, glyph), ==, 500); // MathTopAccentAttachment empty closeFont(); openFont("fonts/MathTestFontFull.otf"); g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph)); - g_assert_cmpint(hb_ot_layout_get_math_top_accent_attachment (hb_font, glyph), ==, 0); // Glyph without top accent attachment. + g_assert_cmpint(hb_ot_layout_get_math_top_accent_attachment (hb_font, glyph), ==, 500); // Glyph without top accent attachment. g_assert(hb_font_get_glyph_from_name (hb_font, "D", -1, &glyph)); g_assert_cmpint(hb_ot_layout_get_math_top_accent_attachment (hb_font, glyph), ==, 374); g_assert(hb_font_get_glyph_from_name (hb_font, "E", -1, &glyph));