Add API test for hb_ot_color_get_color_layers
This commit is contained in:
parent
456978d408
commit
d4261b4bb6
|
@ -91,7 +91,8 @@ colr_cpal_rendering (hb_face_t *face, cairo_font_face_t *cairo_face)
|
|||
{
|
||||
unsigned int upem = hb_face_get_upem (face);
|
||||
|
||||
for (hb_codepoint_t gid = 0; gid < hb_face_get_glyph_count (face); ++gid)
|
||||
unsigned glyph_count = hb_face_get_glyph_count (face);
|
||||
for (hb_codepoint_t gid = 0; gid < glyph_count; ++gid)
|
||||
{
|
||||
unsigned int num_layers = hb_ot_color_get_color_layers (face, gid, 0, nullptr, nullptr, nullptr);
|
||||
if (!num_layers)
|
||||
|
|
|
@ -230,7 +230,7 @@ hb_ot_color_get_palette_flags (hb_face_t *face, unsigned int palette)
|
|||
* @HB_OT_COLOR_PALETTE_FLAG_FOR_LIGHT_BACKGROUND: flag indicating that the color palette is suitable for rendering text on light background.
|
||||
* @HB_OT_COLOR_PALETTE_FLAG_FOR_DARK_BACKGROUND: flag indicating that the color palette is suitable for rendering text on dark background.
|
||||
*
|
||||
* Since: REPLACEME
|
||||
* Since: DONTREPLACEME
|
||||
*/
|
||||
typedef enum { /*< flags >*/
|
||||
HB_OT_COLOR_PALETTE_FLAG_DEFAULT = 0x00000000u,
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
/*
|
||||
* Copyright © 2016 Google, Inc.
|
||||
* Copyright © 2018 Khaled Hosny
|
||||
* Copyright © 2018 Ebrahim Byagowi
|
||||
*
|
||||
* This is part of HarfBuzz, a text shaping library.
|
||||
*
|
||||
|
|
|
@ -150,9 +150,9 @@ test_hb_ot_color_get_palette_name_id_v0 (void)
|
|||
static void
|
||||
test_hb_ot_color_get_palette_name_id_v1 (void)
|
||||
{
|
||||
// g_assert_cmpint (hb_ot_color_get_palette_name_id (cpal_v1, 0), ==, 257);
|
||||
g_assert_cmpint (hb_ot_color_get_palette_name_id (cpal_v1, 0), ==, 257);
|
||||
g_assert_cmpint (hb_ot_color_get_palette_name_id (cpal_v1, 1), ==, HB_NAME_ID_INVALID);
|
||||
// g_assert_cmpint (hb_ot_color_get_palette_name_id (cpal_v1, 2), ==, 258);
|
||||
g_assert_cmpint (hb_ot_color_get_palette_name_id (cpal_v1, 2), ==, 258);
|
||||
|
||||
/* numPalettes=3, so palette #3 is out of bounds */
|
||||
g_assert_cmpint (hb_ot_color_get_palette_name_id (cpal_v1, 3), ==, HB_NAME_ID_INVALID);
|
||||
|
@ -290,6 +290,32 @@ test_hb_ot_color_get_palette_colors_v1 (void)
|
|||
assert_color_rgba (colors, 2, 0x77, 0x77, 0x77, 0x77); /* untouched */
|
||||
}
|
||||
|
||||
static void
|
||||
test_hb_ot_color_get_color_layers (void)
|
||||
{
|
||||
hb_codepoint_t layer_gids[1];
|
||||
unsigned int color_indices[1];
|
||||
unsigned int count = 1;
|
||||
|
||||
unsigned int num_layers;
|
||||
num_layers = hb_ot_color_get_color_layers (cpal_v1, 2, 0, &count, layer_gids,
|
||||
color_indices);
|
||||
|
||||
g_assert_cmpuint (num_layers, ==, 2);
|
||||
g_assert_cmpuint (count, ==, 1);
|
||||
g_assert_cmpuint (layer_gids[0], ==, 3);
|
||||
g_assert_cmpuint (color_indices[0], ==, 1);
|
||||
|
||||
count = 1;
|
||||
hb_ot_color_get_color_layers (cpal_v1, 2, 1, &count, layer_gids,
|
||||
color_indices);
|
||||
|
||||
g_assert_cmpuint (num_layers, ==, 2);
|
||||
g_assert_cmpuint (count, ==, 1);
|
||||
g_assert_cmpuint (layer_gids[0], ==, 4);
|
||||
g_assert_cmpuint (color_indices[0], ==, 0);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
|
@ -308,6 +334,7 @@ main (int argc, char **argv)
|
|||
hb_test_add (test_hb_ot_color_get_palette_colors_empty);
|
||||
hb_test_add (test_hb_ot_color_get_palette_colors_v0);
|
||||
hb_test_add (test_hb_ot_color_get_palette_colors_v1);
|
||||
hb_test_add (test_hb_ot_color_get_color_layers);
|
||||
status = hb_test_run();
|
||||
hb_face_destroy (cpal_v0);
|
||||
hb_face_destroy (cpal_v1);
|
||||
|
|
Loading…
Reference in New Issue