[buffer] Better parse glyph names
diff --git a/src/hb-buffer-deserialize-json.rl b/src/hb-buffer-deserialize-json.rl
index d93765a..7351b2a 100644
--- a/src/hb-buffer-deserialize-json.rl
+++ b/src/hb-buffer-deserialize-json.rl
@@ -72,10 +72,13 @@
 comma = space* ',' space*;
 colon = space* ':' space*;
 
-glyph_name   = '"' (alnum+ >tok %parse_glyph) '"';
-glyph_number = (unum >tok %parse_gid);
+glyph_id = unum;
+glyph_name = alpha (alnum|'_'|'.'|'-')*;
 
-glyph	= "\"g\""  colon (glyph_name | glyph_number);
+glyph_string   = '"' (glyph_name >tok %parse_glyph) '"';
+glyph_number = (glyph_id >tok %parse_gid);
+
+glyph	= "\"g\""  colon (glyph_string | glyph_number);
 cluster	= "\"cl\"" colon (unum >tok %parse_cluster);
 xoffset	= "\"dx\"" colon (num >tok %parse_x_offset);
 yoffset	= "\"dy\"" colon (num >tok %parse_y_offset);
diff --git a/src/hb-buffer-deserialize-text.rl b/src/hb-buffer-deserialize-text.rl
index 5272690..8856580 100644
--- a/src/hb-buffer-deserialize-text.rl
+++ b/src/hb-buffer-deserialize-text.rl
@@ -68,7 +68,10 @@
 unum	= '0' | [1-9] digit*;
 num	= '-'? unum;
 
-glyph	= alnum+ >tok %parse_glyph;
+glyph_id = unum;
+glyph_name = alpha (alnum|'_'|'.'|'-')*;
+
+glyph	= (glyph_id | glyph_name) >tok %parse_glyph;
 cluster	= '=' (unum >tok %parse_cluster);
 offsets	= '@' (num >tok %parse_x_offset)   ',' (num >tok %parse_y_offset );
 advances= '+' (num >tok %parse_x_advance) (',' (num >tok %parse_y_advance))?;