[MATH] Clean up get_italics_correction()
This commit is contained in:
parent
06003f71ba
commit
8bcf517fe5
|
@ -173,13 +173,11 @@ struct MathItalicsCorrectionInfo
|
||||||
italicsCorrection.sanitize (c, this));
|
italicsCorrection.sanitize (c, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool get_value (hb_font_t *font, hb_codepoint_t glyph,
|
inline hb_position_t get_value (hb_codepoint_t glyph,
|
||||||
hb_position_t &value) const
|
hb_font_t *font) const
|
||||||
{
|
{
|
||||||
unsigned int index = (this+coverage).get_coverage (glyph);
|
unsigned int index = (this+coverage).get_coverage (glyph);
|
||||||
if (likely (index == NOT_COVERED)) return false;
|
return italicsCorrection[index].get_x_value (font, this);
|
||||||
if (unlikely (index >= italicsCorrection.len)) return false;
|
|
||||||
value = italicsCorrection[index].get_x_value(font, this);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -367,9 +365,11 @@ struct MathGlyphInfo
|
||||||
mathKernInfo.sanitize(c, this));
|
mathKernInfo.sanitize(c, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const MathItalicsCorrectionInfo&
|
inline hb_position_t
|
||||||
get_math_italics_correction_info (void) const {
|
get_italics_correction (hb_codepoint_t glyph,
|
||||||
return this+mathItalicsCorrectionInfo;
|
hb_font_t *font) const
|
||||||
|
{
|
||||||
|
return (this+mathItalicsCorrectionInfo).get_value (glyph, font);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const MathTopAccentAttachment&
|
inline const MathTopAccentAttachment&
|
||||||
|
|
|
@ -1270,26 +1270,21 @@ hb_ot_layout_get_math_constant (hb_font_t *font,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* hb_ot_layout_get_math_italic_correction:
|
* hb_ot_layout_get_math_italics_correction:
|
||||||
*
|
*
|
||||||
* @font: #hb_font_t from which to retrieve the value
|
* @font: #hb_font_t from which to retrieve the value
|
||||||
* @glyph: glyph index from which to retrieve the value
|
* @glyph: glyph index from which to retrieve the value
|
||||||
*
|
*
|
||||||
* Return value: the italic correction of the glyph or 0
|
* Return value: the italics correction of the glyph or 0
|
||||||
*
|
*
|
||||||
* Since: 1.4
|
* Since: 1.4
|
||||||
**/
|
**/
|
||||||
HB_EXTERN hb_position_t
|
HB_EXTERN hb_position_t
|
||||||
hb_ot_layout_get_math_italic_correction (hb_font_t *font,
|
hb_ot_layout_get_math_italics_correction (hb_font_t *font,
|
||||||
hb_codepoint_t glyph)
|
hb_codepoint_t glyph)
|
||||||
{
|
{
|
||||||
const OT::MATH &math = _get_math (font->face);
|
const OT::MATH &math = _get_math (font->face);
|
||||||
const OT::MathGlyphInfo &glyphInfo = math.get_math_glyph_info();
|
return math.get_math_glyph_info().get_italics_correction (glyph, font);
|
||||||
hb_position_t value;
|
|
||||||
if (glyphInfo.get_math_italics_correction_info().get_value(font, glyph, value))
|
|
||||||
return value;
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -311,7 +311,7 @@ hb_ot_layout_get_math_constant (hb_font_t *font,
|
||||||
hb_ot_math_constant_t constant);
|
hb_ot_math_constant_t constant);
|
||||||
|
|
||||||
HB_EXTERN hb_position_t
|
HB_EXTERN hb_position_t
|
||||||
hb_ot_layout_get_math_italic_correction (hb_font_t *font,
|
hb_ot_layout_get_math_italics_correction (hb_font_t *font,
|
||||||
hb_codepoint_t glyph);
|
hb_codepoint_t glyph);
|
||||||
|
|
||||||
HB_EXTERN hb_position_t
|
HB_EXTERN hb_position_t
|
||||||
|
|
|
@ -161,35 +161,35 @@ test_get_math_constant (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_get_math_italic_correction (void)
|
test_get_math_italics_correction (void)
|
||||||
{
|
{
|
||||||
hb_codepoint_t glyph;
|
hb_codepoint_t glyph;
|
||||||
initFreeType();
|
initFreeType();
|
||||||
|
|
||||||
openFont("fonts/MathTestFontEmpty.otf");
|
openFont("fonts/MathTestFontEmpty.otf");
|
||||||
g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
|
g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
|
||||||
g_assert_cmpint(hb_ot_layout_get_math_italic_correction (hb_font, glyph), ==, 0); // MathGlyphInfo not available
|
g_assert_cmpint(hb_ot_layout_get_math_italics_correction (hb_font, glyph), ==, 0); // MathGlyphInfo not available
|
||||||
closeFont();
|
closeFont();
|
||||||
|
|
||||||
openFont("fonts/MathTestFontPartial1.otf");
|
openFont("fonts/MathTestFontPartial1.otf");
|
||||||
g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
|
g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
|
||||||
g_assert_cmpint(hb_ot_layout_get_math_italic_correction (hb_font, glyph), ==, 0); // MathGlyphInfo empty
|
g_assert_cmpint(hb_ot_layout_get_math_italics_correction (hb_font, glyph), ==, 0); // MathGlyphInfo empty
|
||||||
closeFont();
|
closeFont();
|
||||||
|
|
||||||
openFont("fonts/MathTestFontPartial2.otf");
|
openFont("fonts/MathTestFontPartial2.otf");
|
||||||
g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
|
g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
|
||||||
g_assert_cmpint(hb_ot_layout_get_math_italic_correction (hb_font, glyph), ==, 0); // MathItalicsCorrectionInfo empty
|
g_assert_cmpint(hb_ot_layout_get_math_italics_correction (hb_font, glyph), ==, 0); // MathItalicsCorrectionInfo empty
|
||||||
closeFont();
|
closeFont();
|
||||||
|
|
||||||
openFont("fonts/MathTestFontFull.otf");
|
openFont("fonts/MathTestFontFull.otf");
|
||||||
g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
|
g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
|
||||||
g_assert_cmpint(hb_ot_layout_get_math_italic_correction (hb_font, glyph), ==, 0); // Glyph without italic correction.
|
g_assert_cmpint(hb_ot_layout_get_math_italics_correction (hb_font, glyph), ==, 0); // Glyph without italic correction.
|
||||||
g_assert(hb_font_get_glyph_from_name (hb_font, "A", -1, &glyph));
|
g_assert(hb_font_get_glyph_from_name (hb_font, "A", -1, &glyph));
|
||||||
g_assert_cmpint(hb_ot_layout_get_math_italic_correction (hb_font, glyph), ==, 197);
|
g_assert_cmpint(hb_ot_layout_get_math_italics_correction (hb_font, glyph), ==, 197);
|
||||||
g_assert(hb_font_get_glyph_from_name (hb_font, "B", -1, &glyph));
|
g_assert(hb_font_get_glyph_from_name (hb_font, "B", -1, &glyph));
|
||||||
g_assert_cmpint(hb_ot_layout_get_math_italic_correction (hb_font, glyph), ==, 150);
|
g_assert_cmpint(hb_ot_layout_get_math_italics_correction (hb_font, glyph), ==, 150);
|
||||||
g_assert(hb_font_get_glyph_from_name (hb_font, "C", -1, &glyph));
|
g_assert(hb_font_get_glyph_from_name (hb_font, "C", -1, &glyph));
|
||||||
g_assert_cmpint(hb_ot_layout_get_math_italic_correction (hb_font, glyph), ==, 452);
|
g_assert_cmpint(hb_ot_layout_get_math_italics_correction (hb_font, glyph), ==, 452);
|
||||||
closeFont();
|
closeFont();
|
||||||
|
|
||||||
cleanupFreeType();
|
cleanupFreeType();
|
||||||
|
@ -318,7 +318,7 @@ main (int argc, char **argv)
|
||||||
|
|
||||||
hb_test_add (test_has_math_data);
|
hb_test_add (test_has_math_data);
|
||||||
hb_test_add (test_get_math_constant);
|
hb_test_add (test_get_math_constant);
|
||||||
hb_test_add (test_get_math_italic_correction);
|
hb_test_add (test_get_math_italics_correction);
|
||||||
hb_test_add (test_get_math_top_accent_attachment);
|
hb_test_add (test_get_math_top_accent_attachment);
|
||||||
hb_test_add (test_is_math_extended_shape);
|
hb_test_add (test_is_math_extended_shape);
|
||||||
hb_test_add (test_get_math_kerning);
|
hb_test_add (test_get_math_kerning);
|
||||||
|
|
Loading…
Reference in New Issue