Re: Aliasing TT fonts that have Unicode names - Fix for bug #686861

"Igor V. Melichev" <[email protected]>
Newsgroups gmane.comp.printing.ghostscript.patches
Message-ID <[email protected]>
Ray,

IMO the checking of the 1st byte of name isn't a good way to recognize
Unicode.
I didn't check the code strongly, but I believe that the font name
comes from 'name' table of the TT file. However 'name' table
contains PlatformID, SpecificID and LanguadgeID tags, which
determine the encoding for the string. They should be used
to decide about the translation.

Besides, I'm not clear why we need an alias for such fonts.
If the name is translatable from Unicode to ASCII,
the translation to be applied unconditionally,
and no aliasing is needed. If the font name isn't translatable,
a strong automatic method doesn't exist,
and the substituted name to be provided by the user.
For this case I would recommend to use a method similar to lib/cidfmap .

Also the log message isn't clear. A consistent one for this
code change should explain that it is a heuristic/trick for TT fonts.
I have no objections to commit this trick as a temporary solution,
only if an appropriate log message is provided.

> 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.

This is not true in general.
A specific font name may have a Roman character in the 1st position
and Asian characters later. Some encodings encode it with zero byte first.
The patch creates a strange alias for them. This isn't a regression,
but there is no progression for this case.

I suggest to assign Alex to make a complete solution later.

Igor.

----- Original Message ----- 
From: "Ray Johnston" <[email protected]>
To: <[email protected]>
Cc: "Raph Levien" <[email protected]>
Sent: Thursday, July 31, 2003 11:48 AM
Subject: [gs-code-review] Aliasing TT fonts that have Unicode names - Fix
for bug #686861


> 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
>
> _______________________________________________
> gs-code-review mailing list
> [email protected]
> http://www.ghostscript.com/mailman/listinfo/gs-code-review
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.