Adopt dump-emoji with latest unreleased APIs changes (#1297)

This commit is contained in:
Ebrahim Byagowi 2018-10-23 01:33:45 +03:30 committed by GitHub
parent 7997144b5f
commit 0babf761c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -95,14 +95,13 @@ colr_cpal_rendering (hb_face_t *face, cairo_font_face_t *cairo_face)
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);
unsigned int num_layers = hb_ot_color_glyph_get_layers (face, gid, 0, nullptr, nullptr);
if (!num_layers)
continue;
hb_codepoint_t *layer_gids = (hb_codepoint_t*) calloc (num_layers, sizeof (hb_codepoint_t));
unsigned int *color_indices = (unsigned int*) calloc (num_layers, sizeof (unsigned int));
hb_ot_color_layer_t *layers = (hb_ot_color_layer_t*) malloc (num_layers * sizeof (hb_ot_color_layer_t));
hb_ot_color_get_color_layers (face, gid, 0, &num_layers, layer_gids, color_indices);
hb_ot_color_glyph_get_layers (face, gid, 0, &num_layers, layers);
if (num_layers)
{
// Measure
@ -115,7 +114,7 @@ colr_cpal_rendering (hb_face_t *face, cairo_font_face_t *cairo_face)
cairo_glyph_t *glyphs = (cairo_glyph_t *) calloc (num_layers, sizeof (cairo_glyph_t));
for (unsigned int j = 0; j < num_layers; ++j)
glyphs[j].index = layer_gids[j];
glyphs[j].index = layers[j].glyph;
cairo_glyph_extents (cr, glyphs, num_layers, &extents);
free (glyphs);
cairo_surface_destroy (surface);
@ -129,16 +128,16 @@ colr_cpal_rendering (hb_face_t *face, cairo_font_face_t *cairo_face)
extents.y_bearing -= extents.height / 20;
// Render
unsigned int palette_count = hb_ot_color_get_palette_count (face);
unsigned int palette_count = hb_ot_color_palette_get_count (face);
for (unsigned int palette = 0; palette < palette_count; palette++) {
char output_path[255];
unsigned int num_colors = hb_ot_color_get_palette_colors (face, palette, 0, nullptr, nullptr);
unsigned int num_colors = hb_ot_color_palette_get_colors (face, palette, 0, nullptr, nullptr);
if (!num_colors)
continue;
hb_color_t *colors = (hb_color_t*) calloc (num_colors, sizeof (hb_color_t));
hb_ot_color_get_palette_colors (face, palette, 0, &num_colors, colors);
hb_ot_color_palette_get_colors (face, palette, 0, &num_colors, colors);
if (num_colors)
{
// If we have more than one palette, use a simpler naming
@ -155,8 +154,8 @@ colr_cpal_rendering (hb_face_t *face, cairo_font_face_t *cairo_face)
for (unsigned int layer = 0; layer < num_layers; ++layer)
{
hb_color_t color = 0x000000FF;
if (color_indices[layer] != 0xFFFF)
color = colors[color_indices[layer]];
if (layers[layer].color_index != 0xFFFF)
color = colors[layers[layer].color_index];
cairo_set_source_rgba (cr,
hb_color_get_red (color) / 255.,
hb_color_get_green (color) / 255.,
@ -164,7 +163,7 @@ colr_cpal_rendering (hb_face_t *face, cairo_font_face_t *cairo_face)
hb_color_get_alpha (color) / 255.);
cairo_glyph_t glyph;
glyph.index = layer_gids[layer];
glyph.index = layers[layer].glyph;
glyph.x = -extents.x_bearing;
glyph.y = -extents.y_bearing;
cairo_show_glyphs (cr, &glyph, 1);
@ -177,8 +176,7 @@ colr_cpal_rendering (hb_face_t *face, cairo_font_face_t *cairo_face)
}
}
free (layer_gids);
free (color_indices);
free (layers);
}
}