Skip to content

Fill Empty Glyphs #4

@connordavenport

Description

@connordavenport

This isn't an issue but an idea for:

Instead of removing unsupported glyphs, there should be the option to fill them in from the next-closest master. E.G. ExtraBold Italic glyphs could fill in for missing glyphs in Heavy Italic.
(how would this detect the next-closest master? with the designspace?)

You could just use openTypeOS2WeightClass from the sources? Another idea if the openTypeOS2WeightClass is not set would be to measure the stems and use that. e.g.

from mojo.tools import IntersectGlyphWithLine

stemMap = {}
# Make a dictionary of stem weights
for f in AllFonts():
    xH = f.info.xHeight / 2
    g = f["H"]
    i = IntersectGlyphWithLine(g, ((-200, xH), (g.width+200, xH)))
    stemWidth = abs(i[1][0]-i[0][0])
    stemMap[f.info.styleName] = stemWidth
    current = stemMap[CurrentFont().info.styleName]
    
# too lazy to find better way so just delete currentFont's
del stemMap[CurrentFont().info.styleName]

closest = min(stemMap.values(), key=lambda x:abs(x-current))
for styleName, stemWeight in stemMap.items():
    if stemWeight == closest:
        print(styleName)

Something a long the lines of this^ can work for both ideas to find the closest. I could be totally overthinking this:) Id love to hear your thoughts on this though!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions