fontbuild: Clear anchors in generated UFOs and rename italic UFO
This commit is contained in:
parent
d064cad96f
commit
bbefc90d4b
1 changed files with 21 additions and 4 deletions
|
|
@ -166,7 +166,7 @@ def setFontInfo(font, weight, updateCreated=True):
|
||||||
# - Medium => "Family Medium", ("regular" | "italic")
|
# - Medium => "Family Medium", ("regular" | "italic")
|
||||||
# - Black => "Family Black", ("regular" | "italic")
|
# - Black => "Family Black", ("regular" | "italic")
|
||||||
# and so on.
|
# and so on.
|
||||||
subfamily = stripItalic(style) # "A Italic" => "A", "A" => "A"
|
subfamily = stripItalic(style).strip() # "A Italic" => "A", "A" => "A"
|
||||||
if len(subfamily) == 0:
|
if len(subfamily) == 0:
|
||||||
subfamily = "Regular"
|
subfamily = "Regular"
|
||||||
subfamily_lc = subfamily.lower()
|
subfamily_lc = subfamily.lower()
|
||||||
|
|
@ -185,7 +185,7 @@ def setFontInfo(font, weight, updateCreated=True):
|
||||||
else:
|
else:
|
||||||
font.info.styleMapStyleName = "bold"
|
font.info.styleMapStyleName = "bold"
|
||||||
else:
|
else:
|
||||||
font.info.styleMapFamilyName = family + ' ' + subfamily
|
font.info.styleMapFamilyName = (family + ' ' + subfamily).strip()
|
||||||
# name ID 2 "Subfamily name" (legacy, but required)
|
# name ID 2 "Subfamily name" (legacy, but required)
|
||||||
if isitalic:
|
if isitalic:
|
||||||
font.info.styleMapStyleName = "italic"
|
font.info.styleMapStyleName = "italic"
|
||||||
|
|
@ -467,8 +467,17 @@ class Main(object):
|
||||||
# no need to also set the relative 'filename' attribute as that
|
# no need to also set the relative 'filename' attribute as that
|
||||||
# will be auto-updated on writing the designspace document
|
# will be auto-updated on writing the designspace document
|
||||||
|
|
||||||
# name "Inter UI Black" => "black"
|
if source.styleName == "Italic Italic":
|
||||||
source.name = source.styleName.lower().replace(' ', '')
|
# Workaround for Glyphs limitation
|
||||||
|
# (Base italic master can't be called just Italic, so it's called
|
||||||
|
# "Italic Italic" which is converted here to just "Italic")
|
||||||
|
ufo_path = pjoin(master_dir, 'Inter-UI-Italic.ufo')
|
||||||
|
source.styleName = "Italic"
|
||||||
|
source.name = "italic"
|
||||||
|
source.font.info.styleName = "Italic"
|
||||||
|
else:
|
||||||
|
# name "Inter UI Black" => "black"
|
||||||
|
source.name = source.styleName.lower().replace(' ', '')
|
||||||
|
|
||||||
# fixup font info
|
# fixup font info
|
||||||
weight = int(source.location['Weight'])
|
weight = int(source.location['Weight'])
|
||||||
|
|
@ -485,6 +494,10 @@ class Main(object):
|
||||||
source.font.lib.clear()
|
source.font.lib.clear()
|
||||||
source.font.lib.update(lib)
|
source.font.lib.update(lib)
|
||||||
|
|
||||||
|
# clear anchors
|
||||||
|
for g in source.font:
|
||||||
|
g.clearAnchors()
|
||||||
|
|
||||||
# write UFO file
|
# write UFO file
|
||||||
source.path = ufo_path
|
source.path = ufo_path
|
||||||
self.log("write %s" % relpath(ufo_path, os.getcwd()))
|
self.log("write %s" % relpath(ufo_path, os.getcwd()))
|
||||||
|
|
@ -564,6 +577,10 @@ class Main(object):
|
||||||
del font.lib[italicAngleKey]
|
del font.lib[italicAngleKey]
|
||||||
font.info.italicAngle = italicAngle
|
font.info.italicAngle = italicAngle
|
||||||
|
|
||||||
|
# clear anchors
|
||||||
|
for g in font:
|
||||||
|
g.clearAnchors()
|
||||||
|
|
||||||
# update font info
|
# update font info
|
||||||
weight = instance_weight[basename(font.path)]
|
weight = instance_weight[basename(font.path)]
|
||||||
setFontInfo(font, weight)
|
setFontInfo(font, weight)
|
||||||
|
|
|
||||||
Reference in a new issue