diff options
author | Chris Liddell <chris.liddell@artifex.com> | 2021-08-06 15:16:34 +0100 |
---|---|---|
committer | Chris Liddell <chris.liddell@artifex.com> | 2021-08-09 14:39:30 +0100 |
commit | 661719bbb3e0f6fe132b746ddc3f9586902e0d76 (patch) | |
tree | 60eb81583e7af725cdac9c9615da8ac829de0c5a | |
parent | 2d6346ed529de708b8261d173027647f6534c671 (diff) | |
download | ghostpdl-661719bbb3e0f6fe132b746ddc3f9586902e0d76.tar.gz |
Have gs_type42_find_post_name() return an error when no name is found
Previously, gs_type42_find_post_name() would fall back to ".notdef" if there
was no post table, or the index did not have a matching glyph name in the post
table.
This changes it to return an undefined error instead.
-rw-r--r-- | base/gstype42.c | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/base/gstype42.c b/base/gstype42.c index 50c8ffcd5..3cc922136 100644 --- a/base/gstype42.c +++ b/base/gstype42.c @@ -748,7 +748,9 @@ mac_glyph_ordering_t MacintoshOrdering[] = int gs_type42_find_post_name(gs_font_type42 * pfont, gs_glyph glyph, gs_string *gname) { - int code = 0; + /* READ_SFNTS() uses "code" in the macro, so we need code2 to keep track here */ + int code, code2 = gs_error_undefined; + if (pfont->FontType == ft_TrueType) { if (pfont->data.post_offset != 0) { byte ver[4]; @@ -760,6 +762,7 @@ gs_type42_find_post_name(gs_font_type42 * pfont, gs_glyph glyph, gs_string *gnam if (glyph > 257) glyph = 0; gname->data = (byte *)MacintoshOrdering[glyph].name; gname->size = strlen(MacintoshOrdering[glyph].name); + code2 = 0; } else if (!memcmp(ver, ver20, 4)) { byte val[2]; @@ -769,6 +772,7 @@ gs_type42_find_post_name(gs_font_type42 * pfont, gs_glyph glyph, gs_string *gnam if (gind < 258) { gname->data = (byte *)MacintoshOrdering[gind].name; gname->size = strlen(MacintoshOrdering[gind].name); + code2 = 0; } else { int i; @@ -784,8 +788,8 @@ gs_type42_find_post_name(gs_font_type42 * pfont, gs_glyph glyph, gs_string *gnam for (i = 0; i < numglyphs; i++) { if (i == gind) { READ_SFNTS(pfont, offs, 1, val); - code = pfont->data.string_proc(pfont, offs + 1, (uint)val[0], (const byte **)&(gname->data)); - if (code >= 0) + code2 = pfont->data.string_proc(pfont, offs + 1, (uint)val[0], (const byte **)&(gname->data)); + if (code2 >= 0) gname->size = val[0]; break; } @@ -795,24 +799,14 @@ gs_type42_find_post_name(gs_font_type42 * pfont, gs_glyph glyph, gs_string *gnam } } } - else { - gname->data = (byte *)MacintoshOrdering[0].name; - gname->size = strlen(MacintoshOrdering[0].name); - } } } - else { - gname->data = (byte *)MacintoshOrdering[0].name; - gname->size = strlen(MacintoshOrdering[0].name); - } - } - else { - gname->data = (byte *)MacintoshOrdering[0].name; - gname->size = strlen(MacintoshOrdering[0].name); } } else - code = gs_note_error(gs_error_invalidfont); + code2 = gs_error_invalidfont; + + if (code2 < 0) code = gs_note_error(code2); return code; } |