Add tests for get_mathvariant (#329)
This commit is contained in:
parent
485e4873fb
commit
8d622f1114
@ -515,6 +515,165 @@ test_get_glyph_variants (void)
|
||||
cleanupFreeType();
|
||||
}
|
||||
|
||||
static void
|
||||
test_get_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_math_get_glyph_assembly (hb_font, glyph, HB_DIRECTION_RTL, 0, NULL, NULL, NULL), ==, 0);
|
||||
g_assert_cmpint(hb_ot_math_get_glyph_assembly (hb_font, glyph, HB_DIRECTION_BTT, 0, NULL, NULL, NULL), ==, 0);
|
||||
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_assembly (hb_font, glyph, HB_DIRECTION_RTL, 0, NULL, NULL, NULL), ==, 0);
|
||||
g_assert_cmpint(hb_ot_math_get_glyph_assembly (hb_font, glyph, HB_DIRECTION_BTT, 0, NULL, NULL, NULL), ==, 0);
|
||||
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_assembly (hb_font, glyph, HB_DIRECTION_RTL, 0, NULL, NULL, NULL), ==, 0);
|
||||
g_assert_cmpint(hb_ot_math_get_glyph_assembly (hb_font, glyph, HB_DIRECTION_BTT, 0, NULL, NULL, NULL), ==, 0);
|
||||
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_assembly (hb_font, glyph, HB_DIRECTION_RTL, 0, NULL, NULL, NULL), ==, 0);
|
||||
g_assert_cmpint(hb_ot_math_get_glyph_assembly (hb_font, glyph, HB_DIRECTION_BTT, 0, NULL, NULL, NULL), ==, 0);
|
||||
closeFont();
|
||||
|
||||
openFont("fonts/MathTestFontPartial4.otf");
|
||||
g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
|
||||
g_assert_cmpint(hb_ot_math_get_glyph_assembly (hb_font, glyph, HB_DIRECTION_RTL, 0, NULL, NULL, NULL), ==, 0);
|
||||
g_assert_cmpint(hb_ot_math_get_glyph_assembly (hb_font, glyph, HB_DIRECTION_BTT, 0, NULL, NULL, NULL), ==, 0);
|
||||
closeFont();
|
||||
|
||||
openFont("fonts/MathTestFontFull.otf");
|
||||
|
||||
g_assert(hb_font_get_glyph_from_name (hb_font, "arrowright", -1, &glyph));
|
||||
g_assert_cmpint(hb_ot_math_get_glyph_assembly (hb_font,
|
||||
glyph,
|
||||
HB_DIRECTION_BTT,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL), ==, 0);
|
||||
g_assert_cmpint(hb_ot_math_get_glyph_assembly (hb_font,
|
||||
glyph,
|
||||
HB_DIRECTION_RTL,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL), ==, 3);
|
||||
|
||||
g_assert(hb_font_get_glyph_from_name (hb_font, "arrowdown", -1, &glyph));
|
||||
g_assert_cmpint(hb_ot_math_get_glyph_assembly (hb_font,
|
||||
glyph,
|
||||
HB_DIRECTION_BTT,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL), ==, 5);
|
||||
g_assert_cmpint(hb_ot_math_get_glyph_assembly (hb_font,
|
||||
glyph,
|
||||
HB_DIRECTION_RTL,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL), ==, 0);
|
||||
|
||||
g_assert(hb_font_get_glyph_from_name (hb_font, "arrowright", -1, &glyph));
|
||||
hb_math_glyph_part_t parts[20];
|
||||
unsigned partsSize = sizeof (parts) / sizeof (parts[0]);
|
||||
unsigned int count;
|
||||
unsigned int offset = 0;
|
||||
do {
|
||||
count = partsSize;
|
||||
hb_ot_math_get_glyph_assembly (hb_font,
|
||||
glyph,
|
||||
HB_DIRECTION_RTL,
|
||||
offset,
|
||||
&count,
|
||||
parts,
|
||||
NULL);
|
||||
offset += count;
|
||||
} while (count == partsSize);
|
||||
g_assert_cmpint(offset, ==, 3);
|
||||
g_assert(hb_font_get_glyph_from_name (hb_font, "left", -1, &glyph));
|
||||
g_assert_cmpint(parts[0].glyph, ==, glyph);
|
||||
g_assert_cmpint(parts[0].start_connector_length, ==, 800);
|
||||
g_assert_cmpint(parts[0].end_connector_length, ==, 384);
|
||||
g_assert_cmpint(parts[0].full_advance, ==, 2000);
|
||||
g_assert(!(parts[0].flags & HB_MATH_GLYPH_PART_FLAG_EXTENDER));
|
||||
g_assert(hb_font_get_glyph_from_name (hb_font, "horizontal", -1, &glyph));
|
||||
g_assert_cmpint(parts[1].glyph, ==, glyph);
|
||||
g_assert_cmpint(parts[1].start_connector_length, ==, 524);
|
||||
g_assert_cmpint(parts[1].end_connector_length, ==, 800);
|
||||
g_assert_cmpint(parts[1].full_advance, ==, 2000);
|
||||
g_assert(parts[1].flags & HB_MATH_GLYPH_PART_FLAG_EXTENDER);
|
||||
g_assert(hb_font_get_glyph_from_name (hb_font, "right", -1, &glyph));
|
||||
g_assert_cmpint(parts[2].glyph, ==, glyph);
|
||||
g_assert_cmpint(parts[2].start_connector_length, ==, 316);
|
||||
g_assert_cmpint(parts[2].end_connector_length, ==, 454);
|
||||
g_assert_cmpint(parts[2].full_advance, ==, 2000);
|
||||
g_assert(!(parts[2].flags & HB_MATH_GLYPH_PART_FLAG_EXTENDER));
|
||||
|
||||
g_assert(hb_font_get_glyph_from_name (hb_font, "arrowdown", -1, &glyph));
|
||||
offset = 0;
|
||||
do {
|
||||
count = partsSize;
|
||||
hb_ot_math_get_glyph_assembly (hb_font,
|
||||
glyph,
|
||||
HB_DIRECTION_BTT,
|
||||
offset,
|
||||
&count,
|
||||
parts,
|
||||
NULL);
|
||||
offset += count;
|
||||
} while (count == partsSize);
|
||||
g_assert_cmpint(offset, ==, 5);
|
||||
g_assert(hb_font_get_glyph_from_name (hb_font, "bottom", -1, &glyph));
|
||||
g_assert_cmpint(parts[0].glyph, ==, glyph);
|
||||
g_assert_cmpint(parts[0].start_connector_length, ==, 365);
|
||||
g_assert_cmpint(parts[0].end_connector_length, ==, 158);
|
||||
g_assert_cmpint(parts[0].full_advance, ==, 1000);
|
||||
g_assert(!(parts[0].flags & HB_MATH_GLYPH_PART_FLAG_EXTENDER));
|
||||
g_assert(hb_font_get_glyph_from_name (hb_font, "vertical", -1, &glyph));
|
||||
g_assert_cmpint(parts[1].glyph, ==, glyph);
|
||||
g_assert_cmpint(parts[1].glyph, ==, glyph);
|
||||
g_assert_cmpint(parts[1].start_connector_length, ==, 227);
|
||||
g_assert_cmpint(parts[1].end_connector_length, ==, 365);
|
||||
g_assert_cmpint(parts[1].full_advance, ==, 1000);
|
||||
g_assert(parts[1].flags & HB_MATH_GLYPH_PART_FLAG_EXTENDER);
|
||||
g_assert(hb_font_get_glyph_from_name (hb_font, "center", -1, &glyph));
|
||||
g_assert_cmpint(parts[2].glyph, ==, glyph);
|
||||
g_assert_cmpint(parts[2].start_connector_length, ==, 54);
|
||||
g_assert_cmpint(parts[2].end_connector_length, ==, 158);
|
||||
g_assert_cmpint(parts[2].full_advance, ==, 1000);
|
||||
g_assert(!(parts[2].flags & HB_MATH_GLYPH_PART_FLAG_EXTENDER));
|
||||
g_assert(hb_font_get_glyph_from_name (hb_font, "vertical", -1, &glyph));
|
||||
g_assert_cmpint(parts[3].glyph, ==, glyph);
|
||||
g_assert_cmpint(parts[3].glyph, ==, glyph);
|
||||
g_assert_cmpint(parts[3].glyph, ==, glyph);
|
||||
g_assert_cmpint(parts[3].start_connector_length, ==, 400);
|
||||
g_assert_cmpint(parts[3].end_connector_length, ==, 296);
|
||||
g_assert_cmpint(parts[3].full_advance, ==, 1000);
|
||||
g_assert(parts[1].flags & HB_MATH_GLYPH_PART_FLAG_EXTENDER);
|
||||
g_assert(hb_font_get_glyph_from_name (hb_font, "top", -1, &glyph));
|
||||
g_assert_cmpint(parts[4].glyph, ==, glyph);
|
||||
g_assert_cmpint(parts[4].start_connector_length, ==, 123);
|
||||
g_assert_cmpint(parts[4].end_connector_length, ==, 192);
|
||||
g_assert_cmpint(parts[4].full_advance, ==, 1000);
|
||||
g_assert(!(parts[4].flags & HB_MATH_GLYPH_PART_FLAG_EXTENDER));
|
||||
|
||||
closeFont();
|
||||
|
||||
cleanupFreeType();
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
@ -529,6 +688,7 @@ main (int argc, char **argv)
|
||||
hb_test_add (test_get_glyph_assembly_italics_correction);
|
||||
hb_test_add (test_get_min_connector_overlap);
|
||||
hb_test_add (test_get_glyph_variants);
|
||||
hb_test_add (test_get_glyph_assembly);
|
||||
|
||||
return hb_test_run();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user