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

Incompatible glyphs must be removed from designspace rules #3

Open
thundernixon opened this issue Jun 25, 2019 · 1 comment
Open

Incompatible glyphs must be removed from designspace rules #3

thundernixon opened this issue Jun 25, 2019 · 1 comment

Comments

@thundernixon
Copy link
Collaborator

I've added a set of rules to a variable font to swap .italic glyphs in for a high range in the slant axis.

However, that means that FontMake is now failing with messages like this:

File "/Users/stephennixon/type-repos/recursive/venv/lib/python3.7/site-packages/fontTools/ttLib/ttFont.py", line 602, in getGlyphID
    glyphID = d[glyphName]
KeyError: ('g', 'SingleSubst[0]', 'Lookup[0]', 'LookupList')

This is because some of the glyphs in my rules were incompatible for cu2qu, and therefore had to be removed. So, for instance, the font can't apply the GSUB rule g.italic, because this glyph is no longer in the varfont-prepped fonts.

Ideally, the prep script should check the designspace for rules, and remove rules that can no longer be supported.

This is dependant on the prep script doing a better job at catching things that can't be processed by cu2qu: #2

@arialcrime
Copy link

Stumbled across the same problem recently too. I helped myself with this quickly amended version of your remove_list-of_glyphs.py script.

from vanilla.dialogs import *
from mojo.UI import AskString
from fontTools.designspaceLib import DesignSpaceDocument

glyphsToDelete = AskString(
    'Input glyphnames to remove, then select designspace').replace("'", "").replace(",", "").split(" ")

instruction = f"select designspace to remove {glyphsToDelete} from"

docPath = getFile(
    instruction, allowsMultipleSelection=False, fileTypes=["designspace"])

doc = DesignSpaceDocument()
doc.read(*docPath)

for gName in glyphsToDelete:
    for rule in doc.rules:
        newSubs = []
        for sub in rule.subs:
            if gName not in sub:
                newSubs.append(sub)
        rule.subs = newSubs
doc.write(*docPath)

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

2 participants