Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subsetter drops nameIDs that make font unusable on OS X #1170

Closed
o-t-w opened this issue Feb 6, 2018 · 26 comments
Closed

Subsetter drops nameIDs that make font unusable on OS X #1170

o-t-w opened this issue Feb 6, 2018 · 26 comments

Comments

@o-t-w
Copy link

o-t-w commented Feb 6, 2018

I am trying to add a font to Font Book (the Mac application).
It is displaying errors. When I install the font before subsetting, there are no errors.
screen shot 2018-02-06 at 15 53 51

The font in question is the variable version of Source Sans Pro

@o-t-w o-t-w changed the title MissingGlyphsSubsettingError ValueError: invalid literal for int() with base 16: '0020\xe2\x80\x93007F' Feb 6, 2018
@o-t-w o-t-w changed the title ValueError: invalid literal for int() with base 16: '0020\xe2\x80\x93007F' Errors highlighted by Font Book Feb 6, 2018
@miguelsousa
Copy link
Collaborator

@o-t-w are you trying to subset a variable font? I don't think that's supported yet.

@o-t-w
Copy link
Author

o-t-w commented Feb 6, 2018

Yep, I’m trying to subset the variable version of source sans. Source Sans is gigantic without subsetting, wiping out the benefits of using a variable font :(

@miguelsousa miguelsousa changed the title Errors highlighted by Font Book Cannot subset variable font Feb 6, 2018
@miguelsousa
Copy link
Collaborator

Using the complete Source Sans variable fonts is still a smaller payload than using all of the individual fonts, so it's not a complete wipe out 😁

The only workaround you have right now is to build the variable font(s) from source, subsetting the master OTFs before they get merged as a variable font. It's not that difficult; I've done it with other projects.

It seems that you're already familiar with pyftsubset, so all you have to do is to add a command like this to buildVFs.sh,

# subset Roman master OTFs
masters=`find Roman/Masters/master_* -type f | egrep -i '\.otf$' | sed 's:^\./::'` # sed removes the trailing './'
for otf in $masters
do
	echo 'Subsetting' $otf
	pyftsubset $otf --unicodes=20,21,24,26,2c-2e,30-3b,3f,41-5a,61-7a,a3,2019,20ac --notdef-outline --name-IDs='*' --layout-features+=case,dnom,lnum,numr,onum,ordn,pnum,sinf,subs,sups,tnum,zero --layout-features-=locl --drop-tables-=BASE --no-subset-tables+=BASE
	mv $(echo $otf | sed 's/.otf/.subset.otf/') $otf
done

This chunk should be placed after buildMasterOTFs and before buildCFF2VF.

@o-t-w
Copy link
Author

o-t-w commented Feb 7, 2018

Thanks for the info Miguel! I will try that. As a front-end developer rather than a typographer, I am curious what those tables are and do. How hazardous is it to use a font with a busted sfnt and name table?
There is a popular tutorial that recommends subsetting variable fonts with fonttools, so I think a lot of people will try already.

@o-t-w
Copy link
Author

o-t-w commented Feb 8, 2018

Are there plans to support variable fonts?

@justvanrossum
Copy link
Collaborator

Subsetting Var TTF shouldn't be too hard I reckon. What else is there to do besides subsetting the gvar table?

@behdad
Copy link
Member

behdad commented Feb 8, 2018

Subsetting Var TTF shouldn't be too hard I reckon. What else is there to do besides subsetting the gvar table?

gvar is trivial. In fact, it's already implemented. What's not implemented right now is GDEF VarStore I think, which should be easy to get going without pruning it of unused entries.

@behdad
Copy link
Member

behdad commented Feb 9, 2018

Actually, I take that back. I just tested and subsetting variable fonts works. The VarStore in GDEF is not trimmed so it's large, but otherwise it works:

behdad:fonttools 0 (master)$ ./fonttools ttx -l NotoSansArabic-VF.subset.ttf 
Listing table info for "NotoSansArabic-VF.subset.ttf":
    tag     checksum   length   offset
    ----  ----------  -------  -------
    GDEF  0x02E7683D   110527     3648
    GPOS  0x44764C75       32   114176
    GSUB  0xE2F1EBC8      148   114208
    MVAR  0xDCD88C8D      180   114356
    OS/2  0x883C5B66       96     1788
    avar  0x2A7D4002       48   115024
    cmap  0x0C7C0CED       72     1884
    fvar  0x6E78DEFF      488   114536
    glyf  0x47B8A608     1268      284
    gvar  0xB1383411     7444   115072
    head  0x10C9200B       54     1624
    hhea  0x0DC903F4       36     1752
    hmtx  0x25220202       72     1680
    loca  0x0A720931       38     1584
    maxp  0x003F02E9       32     1552
    name  0xE08E168B     1658     1956
    post  0xFF9F0032       32     3616

behdad:fonttools 0 (master)$ 

Your error seems to be something else. Can you elaborate?

@behdad
Copy link
Member

behdad commented Feb 9, 2018

It might be that we drop psname during subsetting by default? Though I thought we fixed that.

@o-t-w
Copy link
Author

o-t-w commented Feb 9, 2018

I ran the command pyftsubset SourceSansPro-var.ttf --unicodes="U+0020-007F,U+00A,U+00A9,U+00BB,U+00A0"
Trying to add the font to Font Book after subsetting displayed the errors.
As a test I tried adding the variable version of source sans without subsetting to Font Book and saw no errors.

@behdad
Copy link
Member

behdad commented Feb 9, 2018

Right. But what if you do with a non-variable version of the font? Does that work? At any rate, this seems to be a bug, NOT a missing feature. It's expected to work.

@khaledhosny
Copy link
Collaborator

khaledhosny commented Feb 9, 2018

It is complaining about name table, and there is a thread on typedrawers with the exact same error for non-variable font. My guess is that some of the name IDs that the subsetter drops by default are required here, so --name-IDs='*' might do the trick.

@o-t-w
Copy link
Author

o-t-w commented Feb 9, 2018

I tried running some non-variable fonts throught pyftsubset and I'm getting the same error.

@o-t-w
Copy link
Author

o-t-w commented Feb 9, 2018

--name-IDs='*' resolves the issue

@behdad
Copy link
Member

behdad commented Feb 9, 2018

Right. As I said, I think it's the postscriptname.

Try with --name-IDs+=6. If didn't work, try with +=4 as well.

@behdad behdad changed the title Cannot subset variable font Subsetter drops nameIDs that make font unusable on OS X Feb 9, 2018
@o-t-w
Copy link
Author

o-t-w commented Feb 9, 2018

Excuse my ignorance - I wish i knew more about font files. Could you explain why --name-IDs+=6 is better than --name-IDs='*'

@behdad
Copy link
Member

behdad commented Feb 9, 2018

--name-IDs='*' retains all nameIDs. That might be what you want. I'm interested in figuring out what's causing the rejection to change the default to be the minimum acceptable. Thanks.

@behdad
Copy link
Member

behdad commented Feb 9, 2018

Maybe @anthrotype can test that on a Mac.

@miguelsousa
Copy link
Collaborator

miguelsousa commented Feb 10, 2018

@behdad I've just tested. Font Book stops complaining if the font contains nameIDs 3, 4 and 6, in addition to what gets added by default (1, 2, and IDs referenced by STAT table).

Here's the full command that makes a subset of Source Sans Variable valid according to Font Book:
pyftsubset SourceSansVariable-Roman.ttf --unicodes="U+0020-007F,U+00A,U+00A9,U+00BB,U+00A0" --name-IDs+=3,4,6

The original font is at https://github.com/adobe-fonts/source-sans-pro/releases/tag/variable-fonts

@RoelN
Copy link

RoelN commented Feb 13, 2018

@behdad Sorry to comment on a closed issue, am I correct to understand the only thing missing from a fully functional pyftsubset for variable fonts is cleaning up the VarStore in GDEF? Is that on the roadmap or shall I open an issue?

Edit: it looks like VarStore is nicely cleaned up when using pyftsubset with FontTools 3.21.3.dev0, so I might have misunderstood your comment. It appears subsetting variable fonts fully works?

@behdad
Copy link
Member

behdad commented Feb 13, 2018

@behdad Sorry to comment on a closed issue, am I correct to understand the only thing missing from a fully functional pyftsubset for variable fonts is cleaning up the VarStore in GDEF? Is that on the roadmap or shall I open an issue?

Edit: it looks like VarStore is nicely cleaned up when using pyftsubset with FontTools 3.21.3.dev0, so I might have misunderstood your comment. It appears subsetting variable fonts fully works?

I'm sure VarStore is NOT cleaned up. So, yes, that's left. I think that's the only thing. Wait. Checking the code, we don't subset HVAR/VVAR either. That's trivial to add.

Yes, open an issue for finishing subsetting of varfonts and I'll try to do it.

@anthrotype
Copy link
Member

about the new --name-ids default value, note that the --help is still saying we only keep only 1 and 2.

By re-reading these related issues, I think the consensus was to keep all the basic name ids from 1 to 6, including 5 (which wasn't included with commit 43ea974)

#114
#605

@behdad
Copy link
Member

behdad commented Feb 16, 2018

Thanks. Fixed. Added 0 as well.

@brawer
Copy link
Collaborator

brawer commented Feb 26, 2018

I’ve done some more testing on MacOS 10.13.3.

  • If a font contains only Windows names, it works perfectly fine and passes all validation tests on MacOS.

  • However, if a font contains any Macintosh names, at least name IDs 1, 2, 3, and 6 must be present for the Macintosh platform for validation to succeed.

Just mentioning for later reference.

@anthrotype anthrotype reopened this Feb 26, 2018
@anthrotype
Copy link
Member

thanks sascha. shall we keep this open then?
the subsetter defaults to dropping all mac legacy names. Maybe we just need to document this somewhere (in the subsetter --help probably)

@anthrotype
Copy link
Member

actually no, we are now keeping all nameIDs from 0 to 6 by default, so that should cover all the ones you mentioned. I don't think we need to do anything else on our side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants