diff --git a/src/dump-emoji.cc b/src/dump-emoji.cc index e6fddee8e..14376a822 100644 --- a/src/dump-emoji.cc +++ b/src/dump-emoji.cc @@ -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) diff --git a/src/hb-ot-color.cc b/src/hb-ot-color.cc index f5d3d884f..8d444abca 100644 --- a/src/hb-ot-color.cc +++ b/src/hb-ot-color.cc @@ -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, diff --git a/src/hb-ot-color.h b/src/hb-ot-color.h index 0343e5e44..62e873ba1 100644 --- a/src/hb-ot-color.h +++ b/src/hb-ot-color.h @@ -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. * diff --git a/test/api/test-ot-color.c b/test/api/test-ot-color.c index 5cf48a128..1065c4a69 100644 --- a/test/api/test-ot-color.c +++ b/test/api/test-ot-color.c @@ -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);