[draw] Remove return value of hb_font_draw_glyph()

This commit is contained in:
Behdad Esfahbod 2022-02-02 16:16:57 -06:00
parent ddc36df332
commit e157b50345
3 changed files with 14 additions and 15 deletions

View File

@ -42,23 +42,22 @@
* Returns: Whether the font had the glyph and the operation completed successfully. * Returns: Whether the font had the glyph and the operation completed successfully.
* Since: REPLACEME * Since: REPLACEME
**/ **/
hb_bool_t void
hb_font_draw_glyph (hb_font_t *font, hb_codepoint_t glyph, hb_font_draw_glyph (hb_font_t *font,
hb_codepoint_t glyph,
const hb_draw_funcs_t *funcs, const hb_draw_funcs_t *funcs,
void *user_data) void *user_data)
{ {
if (unlikely (funcs == &Null (hb_draw_funcs_t) || if (unlikely (funcs == &Null (hb_draw_funcs_t) ||
glyph >= font->face->get_num_glyphs ())) glyph >= font->face->get_num_glyphs ()))
return false; return;
draw_helper_t draw_helper (funcs, user_data); draw_helper_t draw_helper (funcs, user_data);
if (font->face->table.glyf->get_path (font, glyph, draw_helper)) return true; if (font->face->table.glyf->get_path (font, glyph, draw_helper)) return;
#ifndef HB_NO_CFF #ifndef HB_NO_CFF
if (font->face->table.cff1->get_path (font, glyph, draw_helper)) return true; if (font->face->table.cff1->get_path (font, glyph, draw_helper)) return;
if (font->face->table.cff2->get_path (font, glyph, draw_helper)) return true; if (font->face->table.cff2->get_path (font, glyph, draw_helper)) return;
#endif #endif
return false;
} }
#endif #endif

View File

@ -1056,9 +1056,11 @@ HB_EXTERN void
hb_font_set_var_named_instance (hb_font_t *font, hb_font_set_var_named_instance (hb_font_t *font,
unsigned instance_index); unsigned instance_index);
HB_EXTERN hb_bool_t HB_EXTERN void
hb_font_draw_glyph (hb_font_t *font, hb_codepoint_t glyph, hb_font_draw_glyph (hb_font_t *font,
const hb_draw_funcs_t *funcs, void *user_data); hb_codepoint_t glyph,
const hb_draw_funcs_t *funcs,
void *user_data);
HB_END_DECLS HB_END_DECLS

View File

@ -232,8 +232,7 @@ layered_glyph_dump (hb_font_t *font, hb_draw_funcs_t *funcs, unsigned face_index
if (hb_color_get_alpha (color) != 255) if (hb_color_get_alpha (color) != 255)
fprintf (f, "fill-opacity=\"%.3f\"", (double) hb_color_get_alpha (color) / 255.); fprintf (f, "fill-opacity=\"%.3f\"", (double) hb_color_get_alpha (color) / 255.);
fprintf (f, "d=\""); fprintf (f, "d=\"");
if (!hb_font_draw_glyph (font, layers[layer].glyph, funcs, &user_data)) hb_font_draw_glyph (font, layers[layer].glyph, funcs, &user_data);
printf ("Failed to decompose layer %d while %d\n", layers[layer].glyph, gid);
fprintf (f, "\"/>\n"); fprintf (f, "\"/>\n");
} }
@ -272,8 +271,7 @@ dump_glyphs (hb_font_t *font, hb_draw_funcs_t *funcs, unsigned face_index)
user_data_t user_data; user_data_t user_data;
user_data.ascender = font_extents.ascender; user_data.ascender = font_extents.ascender;
user_data.f = f; user_data.f = f;
if (!hb_font_draw_glyph (font, gid, funcs, &user_data)) hb_font_draw_glyph (font, gid, funcs, &user_data);
printf ("Failed to decompose gid: %d\n", gid);
fprintf (f, "\"/></svg>"); fprintf (f, "\"/></svg>");
fclose (f); fclose (f);
} }