Skip to content

Commit

Permalink
Handle case that rcjk font has .notdef already
Browse files Browse the repository at this point in the history
  • Loading branch information
behdad committed Jan 23, 2024
1 parent f039ec9 commit ac06049
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions font.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
async def createFontBuilder(rcjkfont, family_name, style, glyphs, glyphDataFormat=0):
upem = await rcjkfont.getUnitsPerEm()

glyphOrder = [".notdef"] + list(glyphs.keys())
glyphOrder = list(glyphs.keys())
metrics = {}

revCmap = await rcjkfont.getGlyphMap()
cmap = {}
for glyph in glyphs.values():
Expand All @@ -13,14 +15,17 @@ async def createFontBuilder(rcjkfont, family_name, style, glyphs, glyphDataForma
# assert unicode not in cmap, (hex(unicode), glyphname, cmap[unicode])
cmap[unicode] = glyph.name

metrics = {".notdef": (upem, 0)}
for glyphname in glyphOrder[1:]:
for glyphname in glyphOrder:
glyph = await rcjkfont.getGlyph(glyphname)
assert glyph.sources[0].name == "<default>"
assert glyph.sources[0].layerName == "foreground"
advance = glyph.layers["foreground"].glyph.xAdvance
metrics[glyphname] = (max(advance, 0), 0) # TODO lsb

if ".notdef" not in glyphOrder:
glyphOrder.insert(0, ".notdef")
metrics[".notdef"] = (upem, 0)

nameStrings = dict(
familyName=dict(en=family_name),
styleName=dict(en=style),
Expand Down

0 comments on commit ac06049

Please sign in to comment.