[tests] Add more tests for _get_ligature_carets
This commit is contained in:
parent
3dd7b2105b
commit
ca2705f1fb
BIN
test/api/fonts/NotoNastaliqUrdu-Regular.ttf
Normal file
BIN
test/api/fonts/NotoNastaliqUrdu-Regular.ttf
Normal file
Binary file not shown.
@ -28,14 +28,29 @@
|
||||
#include <hb-ot.h>
|
||||
|
||||
static void
|
||||
test_ot_layout_feature_get_name_ids_and_characters (void)
|
||||
test_ot_layout_get_ligature_carets_aat_lcar (void)
|
||||
{
|
||||
hb_face_t *face = hb_test_open_font_file ("fonts/lcar.ttf");
|
||||
hb_font_t *font = hb_font_create (face);
|
||||
hb_font_set_scale (font, hb_face_get_upem (face) * 2, hb_face_get_upem (face) * 4);
|
||||
|
||||
hb_position_t caret_array[2];
|
||||
unsigned int caret_count = 2;
|
||||
hb_position_t caret_array[16];
|
||||
|
||||
/* a normal call */
|
||||
{
|
||||
unsigned caret_count = 16;
|
||||
g_assert_cmpuint (2, ==, hb_ot_layout_get_ligature_carets (font, HB_DIRECTION_LTR,
|
||||
98, 0, &caret_count,
|
||||
caret_array));
|
||||
|
||||
g_assert_cmpuint (2, ==, caret_count);
|
||||
g_assert_cmpuint (1130, ==, caret_array[0]);
|
||||
g_assert_cmpuint (2344, ==, caret_array[1]);
|
||||
}
|
||||
|
||||
/* RTL, maybe needs to be tweaked however */
|
||||
{
|
||||
unsigned caret_count = 16;
|
||||
g_assert_cmpuint (2, ==, hb_ot_layout_get_ligature_carets (font, HB_DIRECTION_RTL,
|
||||
98, 0, &caret_count,
|
||||
caret_array));
|
||||
@ -43,7 +58,11 @@ test_ot_layout_feature_get_name_ids_and_characters (void)
|
||||
g_assert_cmpuint (2, ==, caret_count);
|
||||
g_assert_cmpuint (1130, ==, caret_array[0]);
|
||||
g_assert_cmpuint (2344, ==, caret_array[1]);
|
||||
}
|
||||
|
||||
/* bottom to top call, bigger caret positions as the specified scaling */
|
||||
{
|
||||
unsigned caret_count = 16;
|
||||
g_assert_cmpuint (2, ==, hb_ot_layout_get_ligature_carets (font, HB_DIRECTION_BTT,
|
||||
98, 0, &caret_count,
|
||||
caret_array));
|
||||
@ -51,6 +70,108 @@ test_ot_layout_feature_get_name_ids_and_characters (void)
|
||||
g_assert_cmpuint (2, ==, caret_count);
|
||||
g_assert_cmpuint (2260, ==, caret_array[0]);
|
||||
g_assert_cmpuint (4688, ==, caret_array[1]);
|
||||
}
|
||||
|
||||
/* empty carets */
|
||||
{
|
||||
unsigned caret_count = 16;
|
||||
g_assert_cmpuint (0, ==, hb_ot_layout_get_ligature_carets (font, HB_DIRECTION_LTR,
|
||||
97, 0, &caret_count,
|
||||
caret_array));
|
||||
|
||||
g_assert_cmpuint (0, ==, caret_count);
|
||||
}
|
||||
|
||||
hb_font_destroy (font);
|
||||
hb_face_destroy (face);
|
||||
}
|
||||
|
||||
static void
|
||||
test_ot_layout_get_ligature_carets_ot_gsub (void)
|
||||
{
|
||||
hb_face_t *face = hb_test_open_font_file ("fonts/NotoNastaliqUrdu-Regular.ttf");
|
||||
hb_font_t *font = hb_font_create (face);
|
||||
hb_font_set_scale (font, hb_face_get_upem (face) * 2, hb_face_get_upem (face) * 4);
|
||||
|
||||
hb_position_t caret_array[16];
|
||||
|
||||
{
|
||||
/*
|
||||
unsigned caret_count = 16;
|
||||
g_assert_cmpuint (210, ==, hb_ot_layout_get_ligature_carets (font, HB_DIRECTION_LTR,
|
||||
188, 0, &caret_count,
|
||||
caret_array));
|
||||
g_assert_cmpuint (3, ==, caret_count);
|
||||
g_assert_cmpuint (2718, ==, caret_array[0]);
|
||||
g_assert_cmpuint (5438, ==, caret_array[1]);
|
||||
g_assert_cmpuint (5438, ==, caret_array[1]);
|
||||
*/
|
||||
}
|
||||
|
||||
{
|
||||
unsigned caret_count = 16;
|
||||
g_assert_cmpuint (3, ==, hb_ot_layout_get_ligature_carets (font, HB_DIRECTION_LTR,
|
||||
1020, 0, &caret_count,
|
||||
caret_array));
|
||||
/*
|
||||
g_assert_cmpuint (3, ==, caret_count);
|
||||
g_assert_cmpuint (2718, ==, caret_array[0]);
|
||||
g_assert_cmpuint (5438, ==, caret_array[1]);
|
||||
g_assert_cmpuint (5438, ==, caret_array[1]);
|
||||
*/
|
||||
}
|
||||
|
||||
{
|
||||
/*
|
||||
unsigned caret_count = 16;
|
||||
g_assert_cmpuint (0, ==, hb_ot_layout_get_ligature_carets (font, HB_DIRECTION_LTR,
|
||||
1021, 0, &caret_count,
|
||||
caret_array));
|
||||
g_assert_cmpuint (0, ==, caret_count);
|
||||
*/
|
||||
}
|
||||
|
||||
{
|
||||
unsigned caret_count = 16;
|
||||
g_assert_cmpuint (1, ==, hb_ot_layout_get_ligature_carets (font, HB_DIRECTION_LTR,
|
||||
1022, 0, &caret_count,
|
||||
caret_array));
|
||||
/*
|
||||
g_assert_cmpuint (1, ==, caret_count);
|
||||
g_assert_cmpuint (3530, ==, caret_array[0]);
|
||||
*/
|
||||
}
|
||||
|
||||
{
|
||||
unsigned caret_count = 16;
|
||||
g_assert_cmpuint (2, ==, hb_ot_layout_get_ligature_carets (font, HB_DIRECTION_LTR,
|
||||
1023, 0, &caret_count,
|
||||
caret_array));
|
||||
/*
|
||||
g_assert_cmpuint (2, ==, caret_count);
|
||||
g_assert_cmpuint (2352, ==, caret_array[0]);
|
||||
g_assert_cmpuint (4706, ==, caret_array[1]);
|
||||
*/
|
||||
}
|
||||
|
||||
hb_font_destroy (font);
|
||||
hb_face_destroy (face);
|
||||
}
|
||||
|
||||
static void
|
||||
test_ot_layout_get_ligature_carets_empty (void)
|
||||
{
|
||||
hb_face_t *face = hb_face_get_empty ();
|
||||
hb_font_t *font = hb_font_create (face);
|
||||
hb_font_set_scale (font, hb_face_get_upem (face) * 2, hb_face_get_upem (face) * 4);
|
||||
|
||||
hb_position_t caret_array[3];
|
||||
unsigned int caret_count = 3;
|
||||
g_assert_cmpuint (0, ==, hb_ot_layout_get_ligature_carets (font, HB_DIRECTION_RTL,
|
||||
1024, 0, &caret_count,
|
||||
caret_array));
|
||||
|
||||
g_assert_cmpuint (0, ==, caret_count);
|
||||
|
||||
hb_font_destroy (font);
|
||||
hb_face_destroy (face);
|
||||
@ -61,7 +182,9 @@ main (int argc, char **argv)
|
||||
{
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
|
||||
hb_test_add (test_ot_layout_feature_get_name_ids_and_characters);
|
||||
hb_test_add (test_ot_layout_get_ligature_carets_aat_lcar);
|
||||
hb_test_add (test_ot_layout_get_ligature_carets_ot_gsub);
|
||||
hb_test_add (test_ot_layout_get_ligature_carets_empty);
|
||||
|
||||
return hb_test_run ();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user