#undef lig_props
#undef glyph_props
-namespace OT {
- struct MathGlyphConstruction;
-};
-
-HB_INTERNAL hb_bool_t
-hb_ot_layout_get_math_glyph_construction (hb_font_t *font,
- hb_codepoint_t glyph,
- hb_bool_t horizontal,
- hb_position_t &minConnectorOverlap,
- const OT::MathGlyphConstruction *&glyph_construction);
#endif /* HB_OT_LAYOUT_PRIVATE_HH */
/*
* MATH
*/
+/* TODO Move this to hb-ot-math.cc and separate it from hb_ot_layout_t. */
/**
- * hb_ot_layout_has_math_data:
+ * hb_ot_math_has_data:
*
* @face: #hb_face_t to test
*
* Since: 1.4
**/
hb_bool_t
-hb_ot_layout_has_math_data (hb_face_t *face)
+hb_ot_math_has_data (hb_face_t *face)
{
return &_get_math (face) != &OT::Null(OT::MATH);
}
/**
- * hb_ot_layout_get_math_constant:
+ * hb_ot_math_get_constant:
*
* @font: #hb_font_t from which to retrieve the value
* @constant: #hb_ot_math_constant_t the constant to retrieve
* Since: 1.4
**/
hb_position_t
-hb_ot_layout_get_math_constant (hb_font_t *font,
- hb_ot_math_constant_t constant)
+hb_ot_math_get_constant (hb_font_t *font,
+ hb_ot_math_constant_t constant)
{
const OT::MATH &math = _get_math (font->face);
return math.get_constant(constant, font);
}
/**
- * hb_ot_layout_get_math_italics_correction:
+ * hb_ot_math_get_glyph_italics_correction:
*
* @font: #hb_font_t from which to retrieve the value
* @glyph: glyph index from which to retrieve the value
* Since: 1.4
**/
hb_position_t
-hb_ot_layout_get_math_italics_correction (hb_font_t *font,
- hb_codepoint_t glyph)
+hb_ot_math_get_glyph_italics_correction (hb_font_t *font,
+ hb_codepoint_t glyph)
{
const OT::MATH &math = _get_math (font->face);
return math.get_math_glyph_info().get_italics_correction (glyph, font);
}
/**
- * hb_ot_layout_get_math_top_accent_attachment:
+ * hb_ot_math_get_glyph_top_accent_attachment:
*
* @font: #hb_font_t from which to retrieve the value
* @glyph: glyph index from which to retrieve the value
* Since: 1.4
**/
hb_position_t
-hb_ot_layout_get_math_top_accent_attachment (hb_font_t *font,
- hb_codepoint_t glyph)
+hb_ot_math_get_glyph_top_accent_attachment (hb_font_t *font,
+ hb_codepoint_t glyph)
{
const OT::MATH &math = _get_math (font->face);
return math.get_math_glyph_info().get_top_accent_attachment (glyph, font);
}
/**
- * hb_ot_layout_is_math_extended_shape:
+ * hb_ot_math_is_glyph_extended_shape:
*
* @font: a #hb_font_t to test
* @glyph: a glyph index to test
* Since: 1.4
**/
hb_bool_t
-hb_ot_layout_is_math_extended_shape (hb_face_t *face,
- hb_codepoint_t glyph)
+hb_ot_math_is_glyph_extended_shape (hb_face_t *face,
+ hb_codepoint_t glyph)
{
const OT::MATH &math = _get_math (face);
return math.get_math_glyph_info().is_extended_shape (glyph);
}
/**
- * hb_ot_layout_get_math_kerning:
+ * hb_ot_math_get_glyph_kerning:
*
* @font: #hb_font_t from which to retrieve the value
* @glyph: glyph index from which to retrieve the value
* Since: 1.4
**/
hb_position_t
-hb_ot_layout_get_math_kerning (hb_font_t *font,
- hb_codepoint_t glyph,
- hb_ot_math_kern_t kern,
- hb_position_t correction_height)
+hb_ot_math_get_glyph_kerning (hb_font_t *font,
+ hb_codepoint_t glyph,
+ hb_ot_math_kern_t kern,
+ hb_position_t correction_height)
{
const OT::MATH &math = _get_math (font->face);
return math.get_math_glyph_info().get_kerning (glyph, kern, correction_height, font);
}
unsigned int
-hb_ot_layout_get_math_glyph_variants (hb_font_t *font,
- hb_codepoint_t glyph,
- hb_direction_t direction,
- unsigned int start_offset,
- unsigned int *variants_count, /* IN/OUT */
- hb_math_glyph_variant_t *variants /* OUT */)
+hb_ot_math_get_glyph_variants (hb_font_t *font,
+ hb_codepoint_t glyph,
+ hb_direction_t direction,
+ unsigned int start_offset,
+ unsigned int *variants_count, /* IN/OUT */
+ hb_math_glyph_variant_t *variants /* OUT */)
{
const OT::MATH &math = _get_math (font->face);
return math.get_math_variants().get_glyph_variants (glyph, direction, font,
}
hb_position_t
-hb_ot_layout_get_math_min_connector_overlap (hb_font_t *font,
- hb_direction_t direction)
+hb_ot_math_get_min_connector_overlap (hb_font_t *font,
+ hb_direction_t direction)
{
const OT::MATH &math = _get_math (font->face);
return math.get_math_variants().get_min_connector_overlap (direction, font);
}
unsigned int
-hb_ot_layout_get_math_glyph_assembly (hb_font_t *font,
- hb_codepoint_t glyph,
- hb_direction_t direction,
- unsigned int start_offset,
- unsigned int *parts_count, /* IN/OUT */
- hb_math_glyph_part_t *parts, /* OUT */
- hb_position_t *italics_correction /* OUT */)
+hb_ot_math_get_glyph_assembly (hb_font_t *font,
+ hb_codepoint_t glyph,
+ hb_direction_t direction,
+ unsigned int start_offset,
+ unsigned int *parts_count, /* IN/OUT */
+ hb_math_glyph_part_t *parts, /* OUT */
+ hb_position_t *italics_correction /* OUT */)
{
const OT::MATH &math = _get_math (font->face);
return math.get_math_variants().get_glyph_parts (glyph, direction, font,
/* Methods */
HB_EXTERN hb_bool_t
-hb_ot_layout_has_math_data (hb_face_t *face);
+hb_ot_math_has_data (hb_face_t *face);
HB_EXTERN hb_position_t
-hb_ot_layout_get_math_constant (hb_font_t *font,
- hb_ot_math_constant_t constant);
+hb_ot_math_get_constant (hb_font_t *font,
+ hb_ot_math_constant_t constant);
HB_EXTERN hb_position_t
-hb_ot_layout_get_math_italics_correction (hb_font_t *font,
- hb_codepoint_t glyph);
+hb_ot_math_get_glyph_italics_correction (hb_font_t *font,
+ hb_codepoint_t glyph);
HB_EXTERN hb_position_t
-hb_ot_layout_get_math_top_accent_attachment (hb_font_t *font,
- hb_codepoint_t glyph);
+hb_ot_math_get_glyph_top_accent_attachment (hb_font_t *font,
+ hb_codepoint_t glyph);
HB_EXTERN hb_bool_t
-hb_ot_layout_is_math_extended_shape (hb_face_t *face,
- hb_codepoint_t glyph);
+hb_ot_math_is_glyph_extended_shape (hb_face_t *face,
+ hb_codepoint_t glyph);
HB_EXTERN hb_position_t
-hb_ot_layout_get_math_kerning (hb_font_t *font,
- hb_codepoint_t glyph,
- hb_ot_math_kern_t kern,
- hb_position_t correction_height);
+hb_ot_math_get_glyph_kerning (hb_font_t *font,
+ hb_codepoint_t glyph,
+ hb_ot_math_kern_t kern,
+ hb_position_t correction_height);
HB_EXTERN unsigned int
-hb_ot_layout_get_math_glyph_variants (hb_font_t *font,
- hb_codepoint_t glyph,
- hb_direction_t direction,
- unsigned int start_offset,
- unsigned int *variants_count, /* IN/OUT */
- hb_math_glyph_variant_t *variants /* OUT */);
+hb_ot_math_get_glyph_variants (hb_font_t *font,
+ hb_codepoint_t glyph,
+ hb_direction_t direction,
+ unsigned int start_offset,
+ unsigned int *variants_count, /* IN/OUT */
+ hb_math_glyph_variant_t *variants /* OUT */);
HB_EXTERN hb_position_t
-hb_ot_layout_get_math_min_connector_overlap (hb_font_t *font,
- hb_direction_t direction);
+hb_ot_math_get_min_connector_overlap (hb_font_t *font,
+ hb_direction_t direction);
HB_EXTERN unsigned int
-hb_ot_layout_get_math_glyph_assembly (hb_font_t *font,
- hb_codepoint_t glyph,
- hb_direction_t direction,
- unsigned int start_offset,
- unsigned int *parts_count, /* IN/OUT */
- hb_math_glyph_part_t *parts, /* OUT */
- hb_position_t *italics_correction /* OUT */);
+hb_ot_math_get_glyph_assembly (hb_font_t *font,
+ hb_codepoint_t glyph,
+ hb_direction_t direction,
+ unsigned int start_offset,
+ unsigned int *parts_count, /* IN/OUT */
+ hb_math_glyph_part_t *parts, /* OUT */
+ hb_position_t *italics_correction /* OUT */);
HB_END_DECLS
if HAVE_FREETYPE
TEST_PROGS += \
- test-ot-layout-math \
+ test-ot-math \
$(NULL)
-test_ot_layout_math_LDADD = $(LDADD) $(FREETYPE_LIBS)
-test_ot_layout_math_CPPFLAGS = $(AM_CPPFLAGS) $(FREETYPE_CFLAGS)
+test_ot_math_LDADD = $(LDADD) $(FREETYPE_LIBS)
+test_ot_math_CPPFLAGS = $(AM_CPPFLAGS) $(FREETYPE_CFLAGS)
endif # HAVE_FREETYPE
endif # HAVE_OT
+++ /dev/null
-/*
- * Copyright © 2016 Igalia S.L.
- *
- * This is part of HarfBuzz, a text shaping library.
- *
- * Permission is hereby granted, without written agreement and without
- * license or royalty fees, to use, copy, modify, and distribute this
- * software and its documentation for any purpose, provided that the
- * above copyright notice and the following two paragraphs appear in
- * all copies of this software.
- *
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * Igalia Author(s): Frédéric Wang
- */
-
-
-#include "hb-test.h"
-
-#include "hb-ft.h"
-#include "hb-ot.h"
-
-/* Unit tests for hb-ot-layout.h - OpenType MATH table */
-
-static FT_Library ft_library;
-static FT_Face ft_face;
-static hb_font_t *hb_font;
-static hb_face_t *hb_face;
-
-static inline void
-initFreeType (void)
-{
- FT_Error ft_error;
- if ((ft_error = FT_Init_FreeType (&ft_library)))
- abort();
-}
-
-static inline void
-cleanupFreeType (void)
-{
- FT_Done_FreeType (ft_library);
-}
-
-static void
-openFont(const char* fontFile)
-{
- gchar* path = g_test_build_filename(G_TEST_DIST, fontFile, NULL);
-
- FT_Error ft_error;
- if ((ft_error = FT_New_Face (ft_library, path, 0, &ft_face))) {
- g_free(path);
- abort();
- }
- g_free(path);
-
-#define fontSize 1000
- if ((ft_error = FT_Set_Char_Size (ft_face, fontSize, fontSize, 0, 0)))
- abort();
- hb_font = hb_ft_font_create (ft_face, NULL);
- hb_face = hb_ft_face_create_cached(ft_face);
-}
-
-static inline void
-closeFont (void)
-{
- hb_font_destroy (hb_font);
- FT_Done_Face (ft_face);
-}
-
-static void
-test_has_math_data (void)
-{
- initFreeType();
-
- openFont("fonts/MathTestFontNone.otf");
- g_assert(!hb_ot_layout_has_math_data (hb_face)); // MATH table not available
- closeFont();
-
- openFont("fonts/MathTestFontEmpty.otf");
- g_assert(hb_ot_layout_has_math_data (hb_face)); // MATH table available
- closeFont();
-
- cleanupFreeType();
-}
-
-static void
-test_get_math_constant (void)
-{
- initFreeType();
-
- openFont("fonts/MathTestFontEmpty.otf");
- g_assert_cmpint(hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_DELIMITED_SUB_FORMULA_MIN_HEIGHT), ==, 0); // MathConstants not available
- closeFont();
-
- openFont("fonts/MathTestFontFull.otf");
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_DELIMITED_SUB_FORMULA_MIN_HEIGHT)), ==, 100);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_DISPLAY_OPERATOR_MIN_HEIGHT)), ==, 200);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_MATH_LEADING)), ==, 300);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_AXIS_HEIGHT)), ==, 400);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_ACCENT_BASE_HEIGHT)), ==, 500);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_FLATTENED_ACCENT_BASE_HEIGHT)), ==, 600);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_SUBSCRIPT_SHIFT_DOWN)), ==, 700);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_SUBSCRIPT_TOP_MAX)), ==, 800);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_SUBSCRIPT_BASELINE_DROP_MIN)), ==, 900);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_SUPERSCRIPT_SHIFT_UP)), ==, 1100);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_SUPERSCRIPT_SHIFT_UP_CRAMPED)), ==, 1200);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_SUPERSCRIPT_BOTTOM_MIN)), ==, 1300);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_SUPERSCRIPT_BASELINE_DROP_MAX)), ==, 1400);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_SUB_SUPERSCRIPT_GAP_MIN)), ==, 1500);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_SUPERSCRIPT_BOTTOM_MAX_WITH_SUBSCRIPT)), ==, 1600);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_SPACE_AFTER_SCRIPT)), ==, 1700);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_UPPER_LIMIT_GAP_MIN)), ==, 1800);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_UPPER_LIMIT_BASELINE_RISE_MIN)), ==, 1900);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_LOWER_LIMIT_GAP_MIN)), ==, 2200);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_LOWER_LIMIT_BASELINE_DROP_MIN)), ==, 2300);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_STACK_TOP_SHIFT_UP)), ==, 2400);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_STACK_TOP_DISPLAY_STYLE_SHIFT_UP)), ==, 2500);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_STACK_BOTTOM_SHIFT_DOWN)), ==, 2600);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_STACK_BOTTOM_DISPLAY_STYLE_SHIFT_DOWN)), ==, 2700);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_STACK_GAP_MIN)), ==, 2800);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_STACK_DISPLAY_STYLE_GAP_MIN)), ==, 2900);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_STRETCH_STACK_TOP_SHIFT_UP)), ==, 3000);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_STRETCH_STACK_BOTTOM_SHIFT_DOWN)), ==, 3100);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_STRETCH_STACK_GAP_ABOVE_MIN)), ==, 3200);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_STRETCH_STACK_GAP_BELOW_MIN)), ==, 3300);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_FRACTION_NUMERATOR_SHIFT_UP)), ==, 3400);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_FRACTION_NUMERATOR_DISPLAY_STYLE_SHIFT_UP)), ==, 3500);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_FRACTION_DENOMINATOR_SHIFT_DOWN)), ==, 3600);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_FRACTION_DENOMINATOR_DISPLAY_STYLE_SHIFT_DOWN)), ==, 3700);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_FRACTION_NUMERATOR_GAP_MIN)), ==, 3800);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_FRACTION_NUM_DISPLAY_STYLE_GAP_MIN)), ==, 3900);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_FRACTION_RULE_THICKNESS)), ==, 4000);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_FRACTION_DENOMINATOR_GAP_MIN)), ==, 4100);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_FRACTION_DENOM_DISPLAY_STYLE_GAP_MIN)), ==, 4200);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_SKEWED_FRACTION_HORIZONTAL_GAP)), ==, 4300);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_SKEWED_FRACTION_VERTICAL_GAP)), ==, 4400);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_OVERBAR_VERTICAL_GAP)), ==, 4500);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_OVERBAR_RULE_THICKNESS)), ==, 4600);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_OVERBAR_EXTRA_ASCENDER)), ==, 4700);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_UNDERBAR_VERTICAL_GAP)), ==, 4800);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_UNDERBAR_RULE_THICKNESS)), ==, 4900);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_UNDERBAR_EXTRA_DESCENDER)), ==, 5000);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_RADICAL_VERTICAL_GAP)), ==, 5100);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_RADICAL_DISPLAY_STYLE_VERTICAL_GAP)), ==, 5200);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_RADICAL_RULE_THICKNESS)), ==, 5300);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_RADICAL_EXTRA_ASCENDER)), ==, 5400);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_RADICAL_KERN_BEFORE_DEGREE)), ==, 5500);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_RADICAL_KERN_AFTER_DEGREE)), ==, 5600);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_SCRIPT_PERCENT_SCALE_DOWN)), ==, 87);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_SCRIPT_SCRIPT_PERCENT_SCALE_DOWN)), ==, 76);
- g_assert_cmpint((hb_ot_layout_get_math_constant (hb_font, HB_OT_MATH_CONSTANT_RADICAL_DEGREE_BOTTOM_RAISE_PERCENT)), ==, 65);
- closeFont();
-
- cleanupFreeType();
-}
-
-static void
-test_get_math_italics_correction (void)
-{
- hb_codepoint_t glyph;
- initFreeType();
-
- 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_italics_correction (hb_font, glyph), ==, 0); // 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_italics_correction (hb_font, glyph), ==, 0); // 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_italics_correction (hb_font, glyph), ==, 0); // MathItalicsCorrectionInfo 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_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_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_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_cmpint(hb_ot_layout_get_math_italics_correction (hb_font, glyph), ==, 452);
- closeFont();
-
- cleanupFreeType();
-
-}
-
-static void
-test_get_math_top_accent_attachment (void)
-{
- hb_codepoint_t glyph;
- initFreeType();
-
- 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), ==, 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), ==, 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), ==, 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), ==, 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));
- g_assert_cmpint(hb_ot_layout_get_math_top_accent_attachment (hb_font, glyph), ==, 346);
- g_assert(hb_font_get_glyph_from_name (hb_font, "F", -1, &glyph));
- g_assert_cmpint(hb_ot_layout_get_math_top_accent_attachment (hb_font, glyph), ==, 318);
- closeFont();
-
- cleanupFreeType();
-}
-
-static void
-test_is_math_extended_shape (void)
-{
- hb_codepoint_t glyph;
- initFreeType();
-
- openFont("fonts/MathTestFontEmpty.otf");
- g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
- g_assert(!hb_ot_layout_is_math_extended_shape (hb_face, glyph)); // MathGlyphInfo not available
- closeFont();
-
- openFont("fonts/MathTestFontPartial1.otf");
- g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
- g_assert(!hb_ot_layout_is_math_extended_shape (hb_face, glyph)); // MathGlyphInfo empty
- closeFont();
-
- openFont("fonts/MathTestFontFull.otf");
- g_assert(hb_font_get_glyph_from_name (hb_font, "G", -1, &glyph));
- g_assert(!hb_ot_layout_is_math_extended_shape (hb_face, glyph));
- g_assert(hb_font_get_glyph_from_name (hb_font, "H", -1, &glyph));
- g_assert(hb_ot_layout_is_math_extended_shape (hb_face, glyph));
- closeFont();
-
- cleanupFreeType();
-}
-
-static void
-test_get_math_kerning (void)
-{
- hb_codepoint_t glyph;
- initFreeType();
-
- 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_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 0), ==, 0); // MathGlyphInfo not available
- g_assert_cmpint(hb_ot_layout_get_math_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_LEFT, 0), ==, 0); // MathGlyphInfo not available
- g_assert_cmpint(hb_ot_layout_get_math_kerning (hb_font, glyph, HB_OT_MATH_KERN_BOTTOM_RIGHT, 0), ==, 0); // MathGlyphInfo not available
- g_assert_cmpint(hb_ot_layout_get_math_kerning (hb_font, glyph, HB_OT_MATH_KERN_BOTTOM_LEFT, 0), ==, 0); // MathGlyphInfo not available
- 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_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 0), ==, 0); // MathKernInfo empty
- g_assert_cmpint(hb_ot_layout_get_math_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_LEFT, 0), ==, 0); // MathKernInfo empty
- g_assert_cmpint(hb_ot_layout_get_math_kerning (hb_font, glyph, HB_OT_MATH_KERN_BOTTOM_RIGHT, 0), ==, 0); // MathKernInfo empty
- g_assert_cmpint(hb_ot_layout_get_math_kerning (hb_font, glyph, HB_OT_MATH_KERN_BOTTOM_LEFT, 0), ==, 0); // MathKernInfo empty
- closeFont();
-
- openFont("fonts/MathTestFontPartial3.otf");
- g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
- g_assert_cmpint(hb_ot_layout_get_math_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 0), ==, 0); // MathKernInfoRecords empty
- g_assert_cmpint(hb_ot_layout_get_math_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_LEFT, 0), ==, 0); // MathKernInfoRecords empty
- g_assert_cmpint(hb_ot_layout_get_math_kerning (hb_font, glyph, HB_OT_MATH_KERN_BOTTOM_RIGHT, 0), ==, 0); // MathKernInfoRecords empty
- g_assert_cmpint(hb_ot_layout_get_math_kerning (hb_font, glyph, HB_OT_MATH_KERN_BOTTOM_LEFT, 0), ==, 0); // MathKernInfoRecords empty
- closeFont();
-
- openFont("fonts/MathTestFontFull.otf");
- g_assert(hb_font_get_glyph_from_name (hb_font, "I", -1, &glyph));
-
- g_assert_cmpint(hb_ot_layout_get_math_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 7), ==, 31); // lower than min heigth
- g_assert_cmpint(hb_ot_layout_get_math_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 14), ==, 31); // equal to min height
- g_assert_cmpint(hb_ot_layout_get_math_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 20), ==, 52);
- g_assert_cmpint(hb_ot_layout_get_math_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 23), ==, 52);
- g_assert_cmpint(hb_ot_layout_get_math_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 31), ==, 73);
- g_assert_cmpint(hb_ot_layout_get_math_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 32), ==, 73);
- g_assert_cmpint(hb_ot_layout_get_math_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 86), ==, 199); // equal to max height
- g_assert_cmpint(hb_ot_layout_get_math_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 91), ==, 220); // larger than max height
- g_assert_cmpint(hb_ot_layout_get_math_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 96), ==, 220); // larger than max height
-
- g_assert_cmpint(hb_ot_layout_get_math_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 39), ==, 94); // top right
- g_assert_cmpint(hb_ot_layout_get_math_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_LEFT, 39), ==, 55); // top left
- g_assert_cmpint(hb_ot_layout_get_math_kerning (hb_font, glyph, HB_OT_MATH_KERN_BOTTOM_RIGHT, 39), ==, 22); // bottom right
- g_assert_cmpint(hb_ot_layout_get_math_kerning (hb_font, glyph, HB_OT_MATH_KERN_BOTTOM_LEFT, 39), ==, 50); // bottom left
-
- closeFont();
-
- cleanupFreeType();
-}
-
-
-#if 0
-static void
-test_get_math_italic_correction_for_glyph_assembly (void)
-{
- hb_codepoint_t glyph;
- initFreeType();
-
- 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_italic_correction_for_glyph_assembly (hb_font, glyph, TRUE), ==, 0); // MathVariants not available
- g_assert_cmpint(hb_ot_layout_get_math_italic_correction_for_glyph_assembly (hb_font, glyph, FALSE), ==, 0); // MathVariants 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_italic_correction_for_glyph_assembly (hb_font, glyph, TRUE), ==, 0); // VertGlyphCoverage and HorizGlyphCoverage absent
- g_assert_cmpint(hb_ot_layout_get_math_italic_correction_for_glyph_assembly (hb_font, glyph, FALSE), ==, 0); // VertGlyphCoverage and HorizGlyphCoverage absent
- 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_italic_correction_for_glyph_assembly (hb_font, glyph, TRUE), ==, 0); // VertGlyphCoverage and HorizGlyphCoverage empty
- g_assert_cmpint(hb_ot_layout_get_math_italic_correction_for_glyph_assembly (hb_font, glyph, FALSE), ==, 0); // VertGlyphCoverage and HorizGlyphCoverage empty
- closeFont();
-
- openFont("fonts/MathTestFontPartial3.otf");
- g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
- g_assert_cmpint(hb_ot_layout_get_math_italic_correction_for_glyph_assembly (hb_font, glyph, TRUE), ==, 0); // HorizGlyphConstruction and VertGlyphConstruction empty
- g_assert_cmpint(hb_ot_layout_get_math_italic_correction_for_glyph_assembly (hb_font, glyph, FALSE), ==, 0); // HorizGlyphConstruction and VertGlyphConstruction empty
- closeFont();
-
- openFont("fonts/MathTestFontPartial4.otf");
- g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
- g_assert_cmpint(hb_ot_layout_get_math_italic_correction_for_glyph_assembly (hb_font, glyph, TRUE), ==, 0);
- g_assert_cmpint(hb_ot_layout_get_math_italic_correction_for_glyph_assembly (hb_font, glyph, FALSE), ==, 0);
- closeFont();
-
- openFont("fonts/MathTestFontFull.otf");
- g_assert(hb_font_get_glyph_from_name (hb_font, "arrowleft", -1, &glyph));
- g_assert_cmpint(hb_ot_layout_get_math_italic_correction_for_glyph_assembly (hb_font, glyph, TRUE), ==, 124);
- g_assert_cmpint(hb_ot_layout_get_math_italic_correction_for_glyph_assembly (hb_font, glyph, FALSE), ==, 0);
- g_assert(hb_font_get_glyph_from_name (hb_font, "arrowup", -1, &glyph));
- g_assert_cmpint(hb_ot_layout_get_math_italic_correction_for_glyph_assembly (hb_font, glyph, TRUE), ==, 0);
- g_assert_cmpint(hb_ot_layout_get_math_italic_correction_for_glyph_assembly (hb_font, glyph, FALSE), ==, 331);
- closeFont();
-
- cleanupFreeType();
-}
-#endif
-
-int
-main (int argc, char **argv)
-{
- hb_test_init (&argc, &argv);
-
- hb_test_add (test_has_math_data);
- hb_test_add (test_get_math_constant);
- hb_test_add (test_get_math_italics_correction);
- hb_test_add (test_get_math_top_accent_attachment);
- hb_test_add (test_is_math_extended_shape);
- hb_test_add (test_get_math_kerning);
- //hb_test_add (test_get_math_italic_correction_for_glyph_assembly);
-
- return hb_test_run();
-}
--- /dev/null
+/*
+ * Copyright © 2016 Igalia S.L.
+ *
+ * This is part of HarfBuzz, a text shaping library.
+ *
+ * Permission is hereby granted, without written agreement and without
+ * license or royalty fees, to use, copy, modify, and distribute this
+ * software and its documentation for any purpose, provided that the
+ * above copyright notice and the following two paragraphs appear in
+ * all copies of this software.
+ *
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
+ * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
+ * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ *
+ * Igalia Author(s): Frédéric Wang
+ */
+
+
+#include "hb-test.h"
+
+#include "hb-ft.h"
+#include "hb-ot.h"
+
+/* Unit tests for hb-ot-math.h - OpenType MATH table */
+
+static FT_Library ft_library;
+static FT_Face ft_face;
+static hb_font_t *hb_font;
+static hb_face_t *hb_face;
+
+static inline void
+initFreeType (void)
+{
+ FT_Error ft_error;
+ if ((ft_error = FT_Init_FreeType (&ft_library)))
+ abort();
+}
+
+static inline void
+cleanupFreeType (void)
+{
+ FT_Done_FreeType (ft_library);
+}
+
+static void
+openFont(const char* fontFile)
+{
+ gchar* path = g_test_build_filename(G_TEST_DIST, fontFile, NULL);
+
+ FT_Error ft_error;
+ if ((ft_error = FT_New_Face (ft_library, path, 0, &ft_face))) {
+ g_free(path);
+ abort();
+ }
+ g_free(path);
+
+#define fontSize 1000
+ if ((ft_error = FT_Set_Char_Size (ft_face, fontSize, fontSize, 0, 0)))
+ abort();
+ hb_font = hb_ft_font_create (ft_face, NULL);
+ hb_face = hb_ft_face_create_cached(ft_face);
+}
+
+static inline void
+closeFont (void)
+{
+ hb_font_destroy (hb_font);
+ FT_Done_Face (ft_face);
+}
+
+static void
+test_has_data (void)
+{
+ initFreeType();
+
+ openFont("fonts/MathTestFontNone.otf");
+ g_assert(!hb_ot_math_has_data (hb_face)); // MATH table not available
+ closeFont();
+
+ openFont("fonts/MathTestFontEmpty.otf");
+ g_assert(hb_ot_math_has_data (hb_face)); // MATH table available
+ closeFont();
+
+ cleanupFreeType();
+}
+
+static void
+test_get_constant (void)
+{
+ initFreeType();
+
+ openFont("fonts/MathTestFontEmpty.otf");
+ g_assert_cmpint(hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_DELIMITED_SUB_FORMULA_MIN_HEIGHT), ==, 0); // MathConstants not available
+ closeFont();
+
+ openFont("fonts/MathTestFontFull.otf");
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_DELIMITED_SUB_FORMULA_MIN_HEIGHT)), ==, 100);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_DISPLAY_OPERATOR_MIN_HEIGHT)), ==, 200);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_MATH_LEADING)), ==, 300);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_AXIS_HEIGHT)), ==, 400);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_ACCENT_BASE_HEIGHT)), ==, 500);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_FLATTENED_ACCENT_BASE_HEIGHT)), ==, 600);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_SUBSCRIPT_SHIFT_DOWN)), ==, 700);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_SUBSCRIPT_TOP_MAX)), ==, 800);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_SUBSCRIPT_BASELINE_DROP_MIN)), ==, 900);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_SUPERSCRIPT_SHIFT_UP)), ==, 1100);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_SUPERSCRIPT_SHIFT_UP_CRAMPED)), ==, 1200);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_SUPERSCRIPT_BOTTOM_MIN)), ==, 1300);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_SUPERSCRIPT_BASELINE_DROP_MAX)), ==, 1400);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_SUB_SUPERSCRIPT_GAP_MIN)), ==, 1500);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_SUPERSCRIPT_BOTTOM_MAX_WITH_SUBSCRIPT)), ==, 1600);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_SPACE_AFTER_SCRIPT)), ==, 1700);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_UPPER_LIMIT_GAP_MIN)), ==, 1800);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_UPPER_LIMIT_BASELINE_RISE_MIN)), ==, 1900);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_LOWER_LIMIT_GAP_MIN)), ==, 2200);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_LOWER_LIMIT_BASELINE_DROP_MIN)), ==, 2300);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_STACK_TOP_SHIFT_UP)), ==, 2400);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_STACK_TOP_DISPLAY_STYLE_SHIFT_UP)), ==, 2500);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_STACK_BOTTOM_SHIFT_DOWN)), ==, 2600);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_STACK_BOTTOM_DISPLAY_STYLE_SHIFT_DOWN)), ==, 2700);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_STACK_GAP_MIN)), ==, 2800);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_STACK_DISPLAY_STYLE_GAP_MIN)), ==, 2900);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_STRETCH_STACK_TOP_SHIFT_UP)), ==, 3000);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_STRETCH_STACK_BOTTOM_SHIFT_DOWN)), ==, 3100);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_STRETCH_STACK_GAP_ABOVE_MIN)), ==, 3200);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_STRETCH_STACK_GAP_BELOW_MIN)), ==, 3300);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_FRACTION_NUMERATOR_SHIFT_UP)), ==, 3400);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_FRACTION_NUMERATOR_DISPLAY_STYLE_SHIFT_UP)), ==, 3500);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_FRACTION_DENOMINATOR_SHIFT_DOWN)), ==, 3600);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_FRACTION_DENOMINATOR_DISPLAY_STYLE_SHIFT_DOWN)), ==, 3700);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_FRACTION_NUMERATOR_GAP_MIN)), ==, 3800);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_FRACTION_NUM_DISPLAY_STYLE_GAP_MIN)), ==, 3900);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_FRACTION_RULE_THICKNESS)), ==, 4000);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_FRACTION_DENOMINATOR_GAP_MIN)), ==, 4100);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_FRACTION_DENOM_DISPLAY_STYLE_GAP_MIN)), ==, 4200);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_SKEWED_FRACTION_HORIZONTAL_GAP)), ==, 4300);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_SKEWED_FRACTION_VERTICAL_GAP)), ==, 4400);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_OVERBAR_VERTICAL_GAP)), ==, 4500);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_OVERBAR_RULE_THICKNESS)), ==, 4600);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_OVERBAR_EXTRA_ASCENDER)), ==, 4700);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_UNDERBAR_VERTICAL_GAP)), ==, 4800);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_UNDERBAR_RULE_THICKNESS)), ==, 4900);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_UNDERBAR_EXTRA_DESCENDER)), ==, 5000);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_RADICAL_VERTICAL_GAP)), ==, 5100);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_RADICAL_DISPLAY_STYLE_VERTICAL_GAP)), ==, 5200);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_RADICAL_RULE_THICKNESS)), ==, 5300);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_RADICAL_EXTRA_ASCENDER)), ==, 5400);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_RADICAL_KERN_BEFORE_DEGREE)), ==, 5500);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_RADICAL_KERN_AFTER_DEGREE)), ==, 5600);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_SCRIPT_PERCENT_SCALE_DOWN)), ==, 87);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_SCRIPT_SCRIPT_PERCENT_SCALE_DOWN)), ==, 76);
+ g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_RADICAL_DEGREE_BOTTOM_RAISE_PERCENT)), ==, 65);
+ closeFont();
+
+ cleanupFreeType();
+}
+
+static void
+test_get_glyph_italics_correction (void)
+{
+ hb_codepoint_t glyph;
+ initFreeType();
+
+ openFont("fonts/MathTestFontEmpty.otf");
+ g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
+ g_assert_cmpint(hb_ot_math_get_glyph_italics_correction (hb_font, glyph), ==, 0); // 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_math_get_glyph_italics_correction (hb_font, glyph), ==, 0); // 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_math_get_glyph_italics_correction (hb_font, glyph), ==, 0); // MathItalicsCorrectionInfo empty
+ closeFont();
+
+ openFont("fonts/MathTestFontFull.otf");
+ g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
+ g_assert_cmpint(hb_ot_math_get_glyph_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_cmpint(hb_ot_math_get_glyph_italics_correction (hb_font, glyph), ==, 197);
+ g_assert(hb_font_get_glyph_from_name (hb_font, "B", -1, &glyph));
+ g_assert_cmpint(hb_ot_math_get_glyph_italics_correction (hb_font, glyph), ==, 150);
+ g_assert(hb_font_get_glyph_from_name (hb_font, "C", -1, &glyph));
+ g_assert_cmpint(hb_ot_math_get_glyph_italics_correction (hb_font, glyph), ==, 452);
+ closeFont();
+
+ cleanupFreeType();
+}
+
+static void
+test_get_glyph_top_accent_attachment (void)
+{
+ hb_codepoint_t glyph;
+ initFreeType();
+
+ openFont("fonts/MathTestFontEmpty.otf");
+ g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
+ g_assert_cmpint(hb_ot_math_get_glyph_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_math_get_glyph_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_math_get_glyph_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_math_get_glyph_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_math_get_glyph_top_accent_attachment (hb_font, glyph), ==, 374);
+ g_assert(hb_font_get_glyph_from_name (hb_font, "E", -1, &glyph));
+ g_assert_cmpint(hb_ot_math_get_glyph_top_accent_attachment (hb_font, glyph), ==, 346);
+ g_assert(hb_font_get_glyph_from_name (hb_font, "F", -1, &glyph));
+ g_assert_cmpint(hb_ot_math_get_glyph_top_accent_attachment (hb_font, glyph), ==, 318);
+ closeFont();
+
+ cleanupFreeType();
+}
+
+static void
+test_is_glyph_extended_shape (void)
+{
+ hb_codepoint_t glyph;
+ initFreeType();
+
+ openFont("fonts/MathTestFontEmpty.otf");
+ g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
+ g_assert(!hb_ot_math_is_glyph_extended_shape (hb_face, glyph)); // MathGlyphInfo not available
+ closeFont();
+
+ openFont("fonts/MathTestFontPartial1.otf");
+ g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
+ g_assert(!hb_ot_math_is_glyph_extended_shape (hb_face, glyph)); // MathGlyphInfo empty
+ closeFont();
+
+ openFont("fonts/MathTestFontFull.otf");
+ g_assert(hb_font_get_glyph_from_name (hb_font, "G", -1, &glyph));
+ g_assert(!hb_ot_math_is_glyph_extended_shape (hb_face, glyph));
+ g_assert(hb_font_get_glyph_from_name (hb_font, "H", -1, &glyph));
+ g_assert(hb_ot_math_is_glyph_extended_shape (hb_face, glyph));
+ closeFont();
+
+ cleanupFreeType();
+}
+
+static void
+test_get_glyph_kerning (void)
+{
+ hb_codepoint_t glyph;
+ initFreeType();
+
+ openFont("fonts/MathTestFontEmpty.otf");
+ g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
+ g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 0), ==, 0); // MathGlyphInfo not available
+ g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_LEFT, 0), ==, 0); // MathGlyphInfo not available
+ g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_BOTTOM_RIGHT, 0), ==, 0); // MathGlyphInfo not available
+ g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_BOTTOM_LEFT, 0), ==, 0); // MathGlyphInfo not available
+ closeFont();
+
+ openFont("fonts/MathTestFontPartial2.otf");
+ g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
+ g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 0), ==, 0); // MathKernInfo empty
+ g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_LEFT, 0), ==, 0); // MathKernInfo empty
+ g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_BOTTOM_RIGHT, 0), ==, 0); // MathKernInfo empty
+ g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_BOTTOM_LEFT, 0), ==, 0); // MathKernInfo empty
+ closeFont();
+
+ openFont("fonts/MathTestFontPartial3.otf");
+ g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
+ g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 0), ==, 0); // MathKernInfoRecords empty
+ g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_LEFT, 0), ==, 0); // MathKernInfoRecords empty
+ g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_BOTTOM_RIGHT, 0), ==, 0); // MathKernInfoRecords empty
+ g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_BOTTOM_LEFT, 0), ==, 0); // MathKernInfoRecords empty
+ closeFont();
+
+ openFont("fonts/MathTestFontFull.otf");
+ g_assert(hb_font_get_glyph_from_name (hb_font, "I", -1, &glyph));
+
+ g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 7), ==, 31); // lower than min heigth
+ g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 14), ==, 31); // equal to min height
+ g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 20), ==, 52);
+ g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 23), ==, 52);
+ g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 31), ==, 73);
+ g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 32), ==, 73);
+ g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 86), ==, 199); // equal to max height
+ g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 91), ==, 220); // larger than max height
+ g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 96), ==, 220); // larger than max height
+
+ g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 39), ==, 94); // top right
+ g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_LEFT, 39), ==, 55); // top left
+ g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_BOTTOM_RIGHT, 39), ==, 22); // bottom right
+ g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_BOTTOM_LEFT, 39), ==, 50); // bottom left
+
+ closeFont();
+
+ cleanupFreeType();
+}
+
+
+#if 0
+static void
+test_get_math_italic_correction_for_glyph_assembly (void)
+{
+ hb_codepoint_t glyph;
+ initFreeType();
+
+ 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_italic_correction_for_glyph_assembly (hb_font, glyph, TRUE), ==, 0); // MathVariants not available
+ g_assert_cmpint(hb_ot_layout_get_math_italic_correction_for_glyph_assembly (hb_font, glyph, FALSE), ==, 0); // MathVariants 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_italic_correction_for_glyph_assembly (hb_font, glyph, TRUE), ==, 0); // VertGlyphCoverage and HorizGlyphCoverage absent
+ g_assert_cmpint(hb_ot_layout_get_math_italic_correction_for_glyph_assembly (hb_font, glyph, FALSE), ==, 0); // VertGlyphCoverage and HorizGlyphCoverage absent
+ 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_italic_correction_for_glyph_assembly (hb_font, glyph, TRUE), ==, 0); // VertGlyphCoverage and HorizGlyphCoverage empty
+ g_assert_cmpint(hb_ot_layout_get_math_italic_correction_for_glyph_assembly (hb_font, glyph, FALSE), ==, 0); // VertGlyphCoverage and HorizGlyphCoverage empty
+ closeFont();
+
+ openFont("fonts/MathTestFontPartial3.otf");
+ g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
+ g_assert_cmpint(hb_ot_layout_get_math_italic_correction_for_glyph_assembly (hb_font, glyph, TRUE), ==, 0); // HorizGlyphConstruction and VertGlyphConstruction empty
+ g_assert_cmpint(hb_ot_layout_get_math_italic_correction_for_glyph_assembly (hb_font, glyph, FALSE), ==, 0); // HorizGlyphConstruction and VertGlyphConstruction empty
+ closeFont();
+
+ openFont("fonts/MathTestFontPartial4.otf");
+ g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
+ g_assert_cmpint(hb_ot_layout_get_math_italic_correction_for_glyph_assembly (hb_font, glyph, TRUE), ==, 0);
+ g_assert_cmpint(hb_ot_layout_get_math_italic_correction_for_glyph_assembly (hb_font, glyph, FALSE), ==, 0);
+ closeFont();
+
+ openFont("fonts/MathTestFontFull.otf");
+ g_assert(hb_font_get_glyph_from_name (hb_font, "arrowleft", -1, &glyph));
+ g_assert_cmpint(hb_ot_layout_get_math_italic_correction_for_glyph_assembly (hb_font, glyph, TRUE), ==, 124);
+ g_assert_cmpint(hb_ot_layout_get_math_italic_correction_for_glyph_assembly (hb_font, glyph, FALSE), ==, 0);
+ g_assert(hb_font_get_glyph_from_name (hb_font, "arrowup", -1, &glyph));
+ g_assert_cmpint(hb_ot_layout_get_math_italic_correction_for_glyph_assembly (hb_font, glyph, TRUE), ==, 0);
+ g_assert_cmpint(hb_ot_layout_get_math_italic_correction_for_glyph_assembly (hb_font, glyph, FALSE), ==, 331);
+ closeFont();
+
+ cleanupFreeType();
+}
+#endif
+
+int
+main (int argc, char **argv)
+{
+ hb_test_init (&argc, &argv);
+
+ hb_test_add (test_has_data);
+ hb_test_add (test_get_constant);
+ hb_test_add (test_get_glyph_italics_correction);
+ hb_test_add (test_get_glyph_top_accent_attachment);
+ hb_test_add (test_is_glyph_extended_shape);
+ hb_test_add (test_get_glyph_kerning);
+ //hb_test_add (test_get_math_italic_correction_for_glyph_assembly);
+
+ return hb_test_run();
+}