silnrsi / font-ttf-scripts

Font::TTF::Scripts perl module
Artistic License 2.0
19 stars 7 forks source link

`ttfname -n` creates a name table with only one macOS field #21

Closed devosb closed 4 years ago

devosb commented 5 years ago

If you use name() in wscript with Smith then ttfname -n is called, and one of the name fields it creates is for PlatformID 1 (macOS) which might cause issues on macOS based on https://github.com/fonttools/fonttools/issues/1170#issuecomment-368492829 (which is linked from http://silnrsi.github.io/FDBP/en-US/Font_Naming.html)

devosb commented 5 years ago

I don't know if other options (or using no option) with ttfname produce the same issue. Since only older versions of macOS are affected, fixing it is a low priority.

bobh0303 commented 4 years ago

In most cases ttfname creates name table entries only for platform/encoding pairs that already exist in the font. The one exception is the postscript name (NameID = 6) and for that one it makes sure that both 3/1/1033 (MS/Unicode/English) and 1/0/0 (Apple/Roman/English) strings are defined.

I've been looking through archives to find where it was specified that ID 6 was needed in both platforms, but haven't found it. But given the fonttools/fonttools#1170 (comment) to which you linked, it seems that for today's operating systems we shouldn't add any Platform ID 1 name strings unless such are already present in the name table.

@mhosken what would you think of the following patch:

--- a/lib/Font/TTF/Scripts/Name.pm
+++ b/lib/Font/TTF/Scripts/Name.pm
@@ -91,7 +91,6 @@ sub ttfname
 # make sure post name set
         unless ($opts{'p'})
         {
-            $name->{'strings'}[6][1][0]{0} = $post;
             $name->{'strings'}[6][3][1]{1033} = $post;
             $name->set_name(6, $post, $opts{'l'}, @cover);
         }
bobh0303 commented 4 years ago

Additionally, name.pm doesn't strip non-ascii chars from postscript name as required by OT spec.

bobh0303 commented 4 years ago

@ClintGoss I don't know whether you use ttfname in any of your font production, but if you do: would you be willing to run your regression tests on the fix_21 branch?

ClintGoss commented 4 years ago

@bobh0303 Sorry, but I don't use ttfname as such ... I'm working at a lower level and only used font-ttf-scripts as a model in some cases ...