Add hb_font_glyph_from/to_string
diff --git a/src/hb-font.cc b/src/hb-font.cc index 409b9e8..e5e4af7 100644 --- a/src/hb-font.cc +++ b/src/hb-font.cc
@@ -200,6 +200,7 @@ if (font->parent) return hb_font_get_glyph_name (font->parent, glyph, name, size); + if (size) *name = '\0'; return false; } @@ -410,10 +411,7 @@ hb_codepoint_t glyph, char *name, unsigned int size) { - hb_bool_t ret = font->get_glyph_name (glyph, name, size); - if (!ret) - snprintf (name, size, "gid%u", glyph); - return ret; + return font->get_glyph_name (glyph, name, size); } hb_bool_t @@ -490,6 +488,24 @@ return font->get_glyph_contour_point_for_origin (glyph, point_index, direction, x, y); } +/* Generates gidDDD if glyph has no name. */ +void +hb_font_glyph_to_string (hb_font_t *font, + hb_codepoint_t glyph, + char *s, unsigned int size) +{ + font->glyph_to_string (glyph, s, size); +} + +/* Parses gidDDD and uniUUUU strings automatically. */ +hb_bool_t +hb_font_glyph_from_string (hb_font_t *font, + const char *s, int len, /* -1 means nul-terminated */ + hb_codepoint_t *glyph) +{ + return font->glyph_from_string (s, len, glyph); +} + /* * hb_face_t