[test] Add hb-paint-all

This commit is contained in:
Behdad Esfahbod 2025-03-20 23:23:58 -06:00
parent 6a82561f00
commit a551736532
3 changed files with 52 additions and 0 deletions

View file

@ -4,3 +4,4 @@ subdir('threads')
subdir('shape')
subdir('api')
subdir('draw')
subdir('paint')

45
test/paint/hb-paint-all.c Normal file
View file

@ -0,0 +1,45 @@
#include <hb.h>
#include <stdlib.h>
#include <stdio.h>
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;
}

6
test/paint/meson.build Normal file
View file

@ -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)