I've run into a small issue with hb_ft_get_glyph_from_name: when passed the name of glyph 0 (often, but not always, ".notdef"), although it will (correctly) find the glyph ID and set its glyph outparam appropriately, it will then return false (which normally indicates that a glyph with the given name was NOT found).

This causes a problem when using hb_buffer_deserialize_glyphs if the buffer that was serialized included any instances of glyph 0, and the serialization used glyph names (rather than numeric IDs), as is the default behavior. In this case, deserialization stops when the .notdef glyph is encountered, resulting in a truncated buffer.

As FT_Get_Name_Index doesn't seem to provide any direct means for a caller to distinguish the case of the .notdef glyph's name from an unknown glyph name, I suggest the attached patch. OK, so it's not pretty, but it should resolve the problem.

JK
diff --git a/src/hb-ft.cc b/src/hb-ft.cc
index d63eba2..0c83bee 100644
--- a/src/hb-ft.cc
+++ b/src/hb-ft.cc
@@ -260,6 +260,16 @@ hb_ft_get_glyph_from_name (hb_font_t *font HB_UNUSED,
     *glyph = FT_Get_Name_Index (ft_face, buf);
   }
 
+  if (*glyph == 0) {
+    /* Check whether the given name was actually the name of the .notdef 
glyph. */
+    char buf[128];
+    if (!FT_Get_Glyph_Name(ft_face, 0, buf, sizeof (buf)) &&
+        ((len < 0 && !strcmp (buf, name)) ||
+         (len >= 0 && !strncmp (buf, name, len)))) {
+      return true;
+    }
+  }
+
   return *glyph != 0;
 }
 
_______________________________________________
HarfBuzz mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/harfbuzz

Reply via email to