Aliasing TT fonts that have Unicode names - Fix for bug #686861
Ray Johnston <[email protected]>
| Newsgroups | gmane.comp.printing.ghostscript.patches |
|---|---|
| Message-ID | <[email protected]> |
Reviewers,
This bug is seen even when the "Marlett" font is on the system
(Windows has this in /windows/fonts/marlett.ttf) and -sFONTPATH
points to the the correct (/windows/fonts) directory since the
Marlett font name in the font file is in Unicode form.
Ghostscript properly loaded this font, but with the name
(\000M\000a\000r\000l\000e\000t\000t) which would not match the
requested name (Marlett).
The below patch automatically adds an alias of the non-Unicode
form (assuming that we can just ignore the high order byte to
get ASCII).
Adobe Acrobat does manage to find the Marlett font with this
PDF file on the same system, so apparently they do something
similar.
Note that this shouldn't affect Asian fonts with Unicode names
since generally the high byte of the first character will not
be 0 (NUL). Even if some extra aliases get defined, it won't
really hurt.
I'll wait a bit for comments, but may commit soon since extra
aliases in the internal Fontmap don't really hurt.
Regards,
Ray
________________________________________________________________
*** ../gs.HEAD/lib/gs_fonts.ps Sat Jul 26 22:41:22 2003
--- lib/gs_fonts.ps Thu Jul 31 00:36:20 2003
***************
*** 118,123 ****
--- 118,136 ----
% resource machinery is loaded.
/.definefontmap % <fontname> <file|alias>
.definefontmap -
{ % Since Fontmap is global, make sure the values are
storable.
+ % If the fontname contains Unicode (first byte == \000) and
+ % this is not an alias definition, define an alias using ASCII
+ % (stripping out the high bytes). Observed with some TT fonts.
+ 1 index 100 string cvs 0 get 0 eq 1 index type /nametype ne and {
+ 1 index 100 string cvs dup length 2 div cvi string
+ 0 1 2 index length 1 sub {
+ % stack: fontname filename fontnamestring newstring index
+ dup 3 index exch 2 mul 1 add get 2 index 3 1 roll put
+ } for
+ DEBUG { (\nAdding alias for: ) print 1 index ==only
+ ( as: ) print dup == flush } if
+ cvn exch cvn .definefontmap % recurse with an alias
+ } if
.currentglobal 3 1 roll true .setglobal
dup type /stringtype eq
{ dup .gcheck not { dup length string copy } if