From a551736532860120c17ec988878d1ee178fcdc24 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 20 Mar 2025 23:23:58 -0600 Subject: [PATCH] [test] Add hb-paint-all --- test/meson.build | 1 + test/paint/hb-paint-all.c | 45 +++++++++++++++++++++++++++++++++++++++ test/paint/meson.build | 6 ++++++ 3 files changed, 52 insertions(+) create mode 100644 test/paint/hb-paint-all.c create mode 100644 test/paint/meson.build diff --git a/test/meson.build b/test/meson.build index e7286932e..d2e3f5b29 100644 --- a/test/meson.build +++ b/test/meson.build @@ -4,3 +4,4 @@ subdir('threads') subdir('shape') subdir('api') subdir('draw') +subdir('paint') diff --git a/test/paint/hb-paint-all.c b/test/paint/hb-paint-all.c new file mode 100644 index 000000000..a29e2ef89 --- /dev/null +++ b/test/paint/hb-paint-all.c @@ -0,0 +1,45 @@ +#include + +#include +#include + +int main (int argc, char **argv) +{ + if (argc < 3) + { + fprintf (stderr, "Usage: %s font-file [font-funcs] [wght]\n", argv[0]); + return 1; + } + + hb_face_t *face = hb_face_create_from_file_or_fail (argv[1], 0); + + if (!face) + { + fprintf (stderr, "Failed to create face\n"); + return 1; + } + + hb_font_t *font = hb_font_create (face); + + if (argc > 2) + hb_font_set_funcs_using (font, argv[2]); + + if (argc > 3) + { + hb_variation_t variations[] = { + { HB_TAG ('w', 'g', 'h', 't'), atoi (argv[3]) }, + }; + hb_font_set_variations (font, variations, 1); + } + + hb_paint_funcs_t *funcs = hb_paint_funcs_create (); + + unsigned glyph_count = hb_face_get_glyph_count (face); + for (unsigned gid = 0; gid < glyph_count; gid++) + hb_font_paint_glyph (font, gid, funcs, NULL, 0, 0); + + hb_paint_funcs_destroy (funcs); + hb_font_destroy (font); + hb_face_destroy (face); + return 0; +} diff --git a/test/paint/meson.build b/test/paint/meson.build new file mode 100644 index 000000000..c0e3f76ea --- /dev/null +++ b/test/paint/meson.build @@ -0,0 +1,6 @@ +hb_paint_all = executable('hb-paint-all', ['hb-paint-all.c'], + cpp_args: cpp_args, + include_directories: [incconfig, incsrc], + link_with: [libharfbuzz], +) +meson.override_find_program('hb-paint-all', hb_paint_all)