From 7c8ea1623b22247145a438ab2bf081b697e5dc19 Mon Sep 17 00:00:00 2001 From: Chris Liddell Date: Wed, 19 Apr 2023 14:08:14 +0100 Subject: Bug 706594: Postscript - Type 1 glyph name equivalence "mapping" When we load a Type 1 font from a font file (i.e. not an embedded font), we use the Adobe Glyph List to find if a glyph name has other names (based on the Unicode code point). For example, "/ocyrillic" is code point 0x43e, which also commonly maps to the name "/afii10080". Previously, use used "forall" to interate through the CharStrings dictionary, but that causes two problems. Firstly, and most importantly, when we write new entries to that dictionary, if the dictionary has to be extended, it ends up messing with the "forall" indexing. Secondly, it means we do work than necessary because we potentially seek out equivalents for names we've just added. To improve this, populate an array with the original names from the CharStrings dictionary, and iterate through that - thus the changing contents of the dictionary doesn't matter. --- Resource/Init/gs_type1.ps | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'Resource') diff --git a/Resource/Init/gs_type1.ps b/Resource/Init/gs_type1.ps index d696a1539..f17a3f11b 100644 --- a/Resource/Init/gs_type1.ps +++ b/Resource/Init/gs_type1.ps @@ -75,9 +75,10 @@ % 16 bytes is arbitrary, but should be large enough to hold any "uniXXXX" style name //ReverseAdobeGlyphList //AdobeGlyphList 3 -1 roll % scratch(string) RAGL(dict) AGL(dict) CharStrings(dict) - dup - { % scratch(string) RAGL(dict) AGL(dict) CharStrings(dict) gname cstring - exch dup % scratch(string) RAGL(dict) AGL(dict) CharStrings(dict) cstring gname gname + [ 1 index {pop} forall ] % scratch(string) RAGL(dict) AGL(dict) CharStrings(dict) [ glyph names ] + { % scratch(string) RAGL(dict) AGL(dict) CharStrings(dict) gname + 1 index 1 index get % scratch(string) RAGL(dict) AGL(dict) CharStrings(dict) cstring gname + exch dup 4 index exch .knownget { //true} { % scratch(string) RAGL(dict) AGL(dict) CharStrings(dict) cstring gname @@ -86,7 +87,7 @@ { % if we couldn't derive the code point from the AGL, we might derive it % from a formatted "uniXXXX" name. - dup <00000000000000000000000000000000> cvs dup flush (uni) anchorsearch + dup (0000000000000000) cvs dup (uni) anchorsearch { % as luck would have it, we can just replace the "uni" with "16#" % to get something we can convert to a number -- cgit v1.2.1