From dbad6cdfec7df9c5934ad153bfa53fe3ba39a9f0 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 10 Mar 2025 23:20:54 -0600 Subject: [PATCH 1/8] [test-c(plusplus)] Add more headers --- test/api/meson.build | 2 +- test/api/test-c.c | 21 +++++++++++++++++++++ test/api/test-cplusplus.cc | 20 ++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/test/api/meson.build b/test/api/meson.build index 0f7ac6900..1b68de01f 100644 --- a/test/api/meson.build +++ b/test/api/meson.build @@ -102,7 +102,7 @@ foreach source : tests cpp_args = [] test_name = source.split('.')[0] - deps = [glib_dep, freetype_dep, thread_dep, libharfbuzz_dep, libharfbuzz_icu_dep] + deps = [glib_dep, freetype_dep, cairo_dep, graphite2_dep, thread_dep, libharfbuzz_dep, libharfbuzz_icu_dep] suite = ['api'] if test_name.contains('-subset') or test_name.contains('-instance') deps += libharfbuzz_subset_dep diff --git a/test/api/test-c.c b/test/api/test-c.c index 59eef4242..69c6e826f 100644 --- a/test/api/test-c.c +++ b/test/api/test-c.c @@ -32,6 +32,7 @@ #endif #include +#include #include #include @@ -47,10 +48,30 @@ #include #endif +#ifdef HAVE_FONTATIONS +#include +#endif + +#ifdef HAVE_GRAPHITE2 +#include +#endif + +#ifdef HAVE_CAIRO +#include +#endif + +#ifdef HAVE_GDI +#include +#endif + #ifdef HAVE_UNISCRIBE #include #endif +#ifdef HAVE_DIRECTWRITE +#include +#endif + #ifdef HAVE_CORETEXT #include #endif diff --git a/test/api/test-cplusplus.cc b/test/api/test-cplusplus.cc index 01b000271..c5226e246 100644 --- a/test/api/test-cplusplus.cc +++ b/test/api/test-cplusplus.cc @@ -49,10 +49,30 @@ #include #endif +#ifdef HAVE_FONTATIONS +#include +#endif + +#ifdef HAVE_GRAPHITE2 +#include +#endif + +#ifdef HAVE_CAIRO +#include +#endif + +#ifdef HAVE_GDI +#include +#endif + #ifdef HAVE_UNISCRIBE #include #endif +#ifdef HAVE_DIRECTWRITE +#include +#endif + #ifdef HAVE_CORETEXT #include #endif From 57deae5fd4dd97b94ed31bdf278607b92557308d Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 10 Mar 2025 23:40:22 -0600 Subject: [PATCH 2/8] [meson] Check correct dependency Ouch! --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 4ca64243a..1f0f4e720 100644 --- a/meson.build +++ b/meson.build @@ -314,7 +314,7 @@ endif gdi_uniscribe_deps = [] # GDI (Uniscribe) (Windows) if host_machine.system() == 'windows' and not get_option('gdi').disabled() - if (get_option('directwrite').enabled() and + if (get_option('gdi').enabled() and not (cpp.has_header('usp10.h') and cpp.has_header('windows.h'))) error('GDI/Uniscribe was enabled explicitly, but required headers are missing.') endif From 41dcc493e5ce3838a02671667f44984ea8ed8206 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 10 Mar 2025 23:40:39 -0600 Subject: [PATCH 3/8] [test-cplusplus] Simplify --- meson.build | 3 ++- src/hb-directwrite.h | 2 ++ src/meson.build | 1 + test/api/meson.build | 12 ++++++++- test/api/test-c.c | 38 ++++++++++++++++------------ test/api/test-cplusplus.cc | 52 +++----------------------------------- 6 files changed, 41 insertions(+), 67 deletions(-) diff --git a/meson.build b/meson.build index 1f0f4e720..2aa816ea7 100644 --- a/meson.build +++ b/meson.build @@ -333,11 +333,12 @@ if host_machine.system() == 'windows' and not get_option('gdi').disabled() endif # DirectWrite (Windows) +directwrite_dep = [] if host_machine.system() == 'windows' and not get_option('directwrite').disabled() if get_option('directwrite').enabled() and not cpp.has_header('dwrite_1.h') error('DirectWrite was enabled explicitly, but required header is missing.') endif - + directwrite_dep = cpp.find_library('dwrite', required: false) conf.set('HAVE_DIRECTWRITE', 1) endif diff --git a/src/hb-directwrite.h b/src/hb-directwrite.h index 121569c15..1735e80fd 100644 --- a/src/hb-directwrite.h +++ b/src/hb-directwrite.h @@ -27,6 +27,8 @@ #include "hb.h" +#include + HB_BEGIN_DECLS HB_EXTERN hb_face_t * diff --git a/src/meson.build b/src/meson.build index a2d23b1e2..34b184160 100644 --- a/src/meson.build +++ b/src/meson.build @@ -506,6 +506,7 @@ endif if conf.get('HAVE_DIRECTWRITE', 0) == 1 hb_sources += hb_directwrite_sources hb_headers += hb_directwrite_headers + harfbuzz_deps += directwrite_dep # hb-directwrite needs a C++ linker libharfbuzz_link_language = 'cpp' endif diff --git a/test/api/meson.build b/test/api/meson.build index 1b68de01f..186366f23 100644 --- a/test/api/meson.build +++ b/test/api/meson.build @@ -102,7 +102,17 @@ foreach source : tests cpp_args = [] test_name = source.split('.')[0] - deps = [glib_dep, freetype_dep, cairo_dep, graphite2_dep, thread_dep, libharfbuzz_dep, libharfbuzz_icu_dep] + deps = [directwrite_dep, + coretext_deps, + freetype_dep, + gdi_uniscribe_deps, + glib_dep, + graphite2_dep, + thread_dep, + libharfbuzz_dep, + libharfbuzz_icu_dep, + libharfbuzz_cairo_dep, + libharfbuzz_gobject_dep] suite = ['api'] if test_name.contains('-subset') or test_name.contains('-instance') deps += libharfbuzz_subset_dep diff --git a/test/api/test-c.c b/test/api/test-c.c index 69c6e826f..f0087d510 100644 --- a/test/api/test-c.c +++ b/test/api/test-c.c @@ -36,12 +36,16 @@ #include #include -#ifdef HAVE_GLIB -#include +#ifdef HAVE_CAIRO +#include #endif -#ifdef HAVE_ICU -#include +#ifdef HAVE_CORETEXT +#include +#endif + +#ifdef HAVE_DIRECTWRITE +#include #endif #ifdef HAVE_FREETYPE @@ -52,32 +56,34 @@ #include #endif +#ifdef HAVE_GDI +#include +#endif + +#ifdef HAVE_GLIB +#include +#endif + #ifdef HAVE_GRAPHITE2 #include #endif -#ifdef HAVE_CAIRO -#include +#ifdef HAVE_GOBJECT +#include #endif -#ifdef HAVE_GDI -#include +#ifdef HAVE_ICU +#include #endif #ifdef HAVE_UNISCRIBE #include #endif -#ifdef HAVE_DIRECTWRITE -#include -#endif - -#ifdef HAVE_CORETEXT -#include -#endif - +#ifndef NO_MAIN int main (void) { return !*hb_shape_list_shapers (); } +#endif diff --git a/test/api/test-cplusplus.cc b/test/api/test-cplusplus.cc index c5226e246..41cb43496 100644 --- a/test/api/test-cplusplus.cc +++ b/test/api/test-cplusplus.cc @@ -28,55 +28,9 @@ /* This file tests that all headers can be included from C++ files, * as well as test the C++ API. */ -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include - -#ifdef HAVE_GLIB -#include -#endif - -#ifdef HAVE_ICU -#include -#endif - -#ifdef HAVE_FREETYPE -#include -#endif - -#ifdef HAVE_FONTATIONS -#include -#endif - -#ifdef HAVE_GRAPHITE2 -#include -#endif - -#ifdef HAVE_CAIRO -#include -#endif - -#ifdef HAVE_GDI -#include -#endif - -#ifdef HAVE_UNISCRIBE -#include -#endif - -#ifdef HAVE_DIRECTWRITE -#include -#endif - -#ifdef HAVE_CORETEXT -#include -#endif - +#define NO_MAIN +#include "test-c.c" +#undef NO_MAIN /* Test C++ API. */ From d2ccf595bd8017dbdac2abf1faaa69c30da12b1d Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 11 Mar 2025 00:15:19 -0600 Subject: [PATCH 4/8] Directwrite is a C++ header? --- test/api/test-c.c | 4 ---- test/api/test-cplusplus.cc | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/test/api/test-c.c b/test/api/test-c.c index f0087d510..87e14b876 100644 --- a/test/api/test-c.c +++ b/test/api/test-c.c @@ -44,10 +44,6 @@ #include #endif -#ifdef HAVE_DIRECTWRITE -#include -#endif - #ifdef HAVE_FREETYPE #include #endif diff --git a/test/api/test-cplusplus.cc b/test/api/test-cplusplus.cc index 41cb43496..74e4fb265 100644 --- a/test/api/test-cplusplus.cc +++ b/test/api/test-cplusplus.cc @@ -32,6 +32,11 @@ #include "test-c.c" #undef NO_MAIN +#ifdef HAVE_DIRECTWRITE +#include +#endif + + /* Test C++ API. */ #include "hb-cplusplus.hh" From d247c116fb71969ccdae722c96cce95bf24428b6 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 11 Mar 2025 00:11:41 -0600 Subject: [PATCH 5/8] [test-draw] Test all font funcs --- test/api/hb-test.h | 11 +------- test/api/test-draw.c | 61 ++++++++------------------------------------ 2 files changed, 12 insertions(+), 60 deletions(-) diff --git a/test/api/hb-test.h b/test/api/hb-test.h index 25d07ce0a..cdf355580 100644 --- a/test/api/hb-test.h +++ b/test/api/hb-test.h @@ -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, diff --git a/test/api/test-draw.c b/test/api/test-draw.c index a068c78f6..f8ec18ca3 100644 --- a/test/api/test-draw.c +++ b/test/api/test-draw.c @@ -26,12 +26,6 @@ #include #include -#ifdef HAVE_FREETYPE -#include -#endif -#ifdef HAVE_FONTATIONS -#include -#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 (); From 8ca892b0e223767ae67cdc3d3edd1fac49eb36c4 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 11 Mar 2025 00:19:34 -0600 Subject: [PATCH 6/8] [directwrite] Simplify headers --- meson.build | 2 +- src/hb-directwrite.cc | 3 --- src/hb-directwrite.h | 2 +- test/api/test-directwrite.cc | 2 -- 4 files changed, 2 insertions(+), 7 deletions(-) diff --git a/meson.build b/meson.build index 2aa816ea7..a93d723c2 100644 --- a/meson.build +++ b/meson.build @@ -335,7 +335,7 @@ endif # DirectWrite (Windows) directwrite_dep = [] if host_machine.system() == 'windows' and not get_option('directwrite').disabled() - if get_option('directwrite').enabled() and not cpp.has_header('dwrite_1.h') + if get_option('directwrite').enabled() and not cpp.has_header('dwrite_3.h') error('DirectWrite was enabled explicitly, but required header is missing.') endif directwrite_dep = cpp.find_library('dwrite', required: false) diff --git a/src/hb-directwrite.cc b/src/hb-directwrite.cc index f138bd4f3..ddd765a84 100644 --- a/src/hb-directwrite.cc +++ b/src/hb-directwrite.cc @@ -28,9 +28,6 @@ #include "hb-shaper-impl.hh" -#include -#include - #include "hb-directwrite.h" #include "hb-ms-feature-ranges.hh" diff --git a/src/hb-directwrite.h b/src/hb-directwrite.h index 1735e80fd..b5b314e16 100644 --- a/src/hb-directwrite.h +++ b/src/hb-directwrite.h @@ -27,7 +27,7 @@ #include "hb.h" -#include +#include HB_BEGIN_DECLS diff --git a/test/api/test-directwrite.cc b/test/api/test-directwrite.cc index 345b9d2a9..c48572192 100644 --- a/test/api/test-directwrite.cc +++ b/test/api/test-directwrite.cc @@ -25,8 +25,6 @@ */ -#include - #include "hb-test.h" #include "hb-directwrite.h" From 6b2f8592324ffeb5a5c86447de72f9b02d0e7cb1 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 11 Mar 2025 00:27:32 -0600 Subject: [PATCH 7/8] [test-c] Disable gobject include It can't find its dependent headers since not installed. --- test/api/meson.build | 3 ++- test/api/test-c.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/test/api/meson.build b/test/api/meson.build index 186366f23..273248a91 100644 --- a/test/api/meson.build +++ b/test/api/meson.build @@ -112,7 +112,8 @@ foreach source : tests libharfbuzz_dep, libharfbuzz_icu_dep, libharfbuzz_cairo_dep, - libharfbuzz_gobject_dep] + #libharfbuzz_gobject_dep + ] suite = ['api'] if test_name.contains('-subset') or test_name.contains('-instance') deps += libharfbuzz_subset_dep diff --git a/test/api/test-c.c b/test/api/test-c.c index 87e14b876..d0bdc9d6d 100644 --- a/test/api/test-c.c +++ b/test/api/test-c.c @@ -65,7 +65,7 @@ #endif #ifdef HAVE_GOBJECT -#include +//#include // Doesn't work uninstalled #endif #ifdef HAVE_ICU From 756668d35c3e64447e3dc297472745ff144f9311 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 11 Mar 2025 11:27:02 -0600 Subject: [PATCH 8/8] [directwrite] Drop dependency again as per review https://github.com/harfbuzz/harfbuzz/pull/5132#issuecomment-2714186460 --- meson.build | 2 -- src/meson.build | 1 - test/api/meson.build | 3 +-- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/meson.build b/meson.build index a93d723c2..31fa1aaf1 100644 --- a/meson.build +++ b/meson.build @@ -333,12 +333,10 @@ if host_machine.system() == 'windows' and not get_option('gdi').disabled() endif # DirectWrite (Windows) -directwrite_dep = [] if host_machine.system() == 'windows' and not get_option('directwrite').disabled() if get_option('directwrite').enabled() and not cpp.has_header('dwrite_3.h') error('DirectWrite was enabled explicitly, but required header is missing.') endif - directwrite_dep = cpp.find_library('dwrite', required: false) conf.set('HAVE_DIRECTWRITE', 1) endif diff --git a/src/meson.build b/src/meson.build index 34b184160..a2d23b1e2 100644 --- a/src/meson.build +++ b/src/meson.build @@ -506,7 +506,6 @@ endif if conf.get('HAVE_DIRECTWRITE', 0) == 1 hb_sources += hb_directwrite_sources hb_headers += hb_directwrite_headers - harfbuzz_deps += directwrite_dep # hb-directwrite needs a C++ linker libharfbuzz_link_language = 'cpp' endif diff --git a/test/api/meson.build b/test/api/meson.build index 273248a91..24d0d854f 100644 --- a/test/api/meson.build +++ b/test/api/meson.build @@ -102,8 +102,7 @@ foreach source : tests cpp_args = [] test_name = source.split('.')[0] - deps = [directwrite_dep, - coretext_deps, + deps = [coretext_deps, freetype_dep, gdi_uniscribe_deps, glib_dep,