mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-12-01 18:44:09 +01:00
[test-draw] Test all font funcs
This commit is contained in:
1 parent
d2ccf595bd
commit
d247c116fb
2 files changed
+12
-60
No files matched your search
+1
-10
@@ -223,16 +223,6 @@ hb_test_add_func (const char *test_path,
|
||||
}
|
||||
#define hb_test_add(Func) hb_test_add_func (#Func, Func)
|
||||
|
||||
static inline void
|
||||
hb_test_add_func_flavor (const char *test_path,
|
||||
const char *flavor,
|
||||
hb_test_func_t test_func)
|
||||
{
|
||||
char *path = g_strdup_printf ("%s/%s", test_path, flavor);
|
||||
hb_test_add_func (path, test_func);
|
||||
g_free (path);
|
||||
}
|
||||
#define hb_test_add_flavor(Flavor, Func) hb_test_add_func (#Func, Flavor, Func)
|
||||
|
||||
static inline void
|
||||
hb_test_add_data_func (const char *test_path,
|
||||
@@ -257,6 +247,7 @@ hb_test_add_data_func_flavor (const char *test_path,
|
||||
}
|
||||
#define hb_test_add_data_flavor(UserData, Flavor, Func) hb_test_add_data_func_flavor (#Func, Flavor, UserData, Func)
|
||||
|
||||
#define hb_test_add_flavor(Flavor, Func) hb_test_add_data_flavor (Flavor, Flavor, Func)
|
||||
|
||||
static inline void
|
||||
hb_test_add_vtable (const char *test_path,
|
||||
|
||||
+11
-50
@@ -26,12 +26,6 @@
|
||||
#include <math.h>
|
||||
|
||||
#include <hb.h>
|
||||
#ifdef HAVE_FREETYPE
|
||||
#include <hb-ft.h>
|
||||
#endif
|
||||
#ifdef HAVE_FONTATIONS
|
||||
#include <hb-fontations.h>
|
||||
#endif
|
||||
|
||||
typedef struct draw_data_t
|
||||
{
|
||||
@@ -1078,8 +1072,9 @@ test_hb_draw_immutable (void)
|
||||
}
|
||||
|
||||
static void
|
||||
test_hb_draw_funcs (const char* font_funcs_name)
|
||||
test_hb_draw_funcs (const void* user_data)
|
||||
{
|
||||
const char *font_funcs_name = user_data;
|
||||
char str[1024];
|
||||
draw_data_t draw_data = {
|
||||
.str = str,
|
||||
@@ -1097,12 +1092,6 @@ test_hb_draw_funcs (const char* font_funcs_name)
|
||||
char expected[] = "M50,0L50,750L450,750L450,0L50,0Z";
|
||||
g_assert_cmpmem (str, draw_data.consumed, expected, sizeof (expected) - 1);
|
||||
}
|
||||
{
|
||||
draw_data.consumed = 0;
|
||||
hb_font_draw_glyph (font, 5, funcs, &draw_data);
|
||||
char expected[] = "M15,0Q15,0 15,0Z";
|
||||
g_assert_cmpmem (str, draw_data.consumed, expected, sizeof (expected) - 1);
|
||||
}
|
||||
hb_font_destroy (font);
|
||||
}
|
||||
{
|
||||
@@ -1127,8 +1116,9 @@ test_hb_draw_funcs (const char* font_funcs_name)
|
||||
}
|
||||
|
||||
static void
|
||||
test_hb_draw_compare_ot_funcs (const char* font_funcs_name)
|
||||
test_hb_draw_compare_ot_funcs (const void *user_data)
|
||||
{
|
||||
const char* font_funcs_name = user_data;
|
||||
char str[1024];
|
||||
draw_data_t draw_data = {
|
||||
.str = str,
|
||||
@@ -1162,34 +1152,6 @@ test_hb_draw_compare_ot_funcs (const char* font_funcs_name)
|
||||
hb_face_destroy (face);
|
||||
}
|
||||
|
||||
#ifdef HAVE_FREETYPE
|
||||
static void
|
||||
test_hb_draw_ft (void)
|
||||
{
|
||||
test_hb_draw_funcs ("ft");
|
||||
}
|
||||
|
||||
static void
|
||||
test_hb_draw_compare_ot_ft (void)
|
||||
{
|
||||
test_hb_draw_compare_ot_funcs ("ft");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FONTATIONS
|
||||
static void
|
||||
test_hb_draw_fontations (void)
|
||||
{
|
||||
test_hb_draw_funcs ("fontations");
|
||||
}
|
||||
|
||||
static void
|
||||
test_hb_draw_compare_ot_fontations (void)
|
||||
{
|
||||
test_hb_draw_compare_ot_funcs ("fontations");
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
@@ -1224,14 +1186,13 @@ main (int argc, char **argv)
|
||||
hb_test_add (test_hb_draw_synthetic_slant);
|
||||
hb_test_add (test_hb_draw_subfont_scale);
|
||||
hb_test_add (test_hb_draw_immutable);
|
||||
#ifdef HAVE_FREETYPE
|
||||
hb_test_add (test_hb_draw_ft);
|
||||
hb_test_add (test_hb_draw_compare_ot_ft);
|
||||
#endif
|
||||
#ifdef HAVE_FONTATIONS
|
||||
hb_test_add (test_hb_draw_fontations);
|
||||
hb_test_add (test_hb_draw_compare_ot_fontations);
|
||||
#endif
|
||||
|
||||
const char **font_funcs = hb_font_list_funcs ();
|
||||
for (const char **font_funcs_name = font_funcs; *font_funcs_name; font_funcs_name++)
|
||||
{
|
||||
hb_test_add_flavor (*font_funcs_name, test_hb_draw_funcs);
|
||||
hb_test_add_flavor (*font_funcs_name, test_hb_draw_compare_ot_funcs);
|
||||
}
|
||||
|
||||
unsigned result = hb_test_run ();
|
||||
|
||||
|
||||
Reference in new issue
Block a user