mirror of
https://github.com/rsms/inter.git
synced 2024-11-27 09:49:07 +03:00
change fontbuild rename command to apply Google Fonts standard style names with --google-style flag (replaces flag --compact-style)
This commit is contained in:
parent
51781961e3
commit
0ea8167779
@ -22,7 +22,7 @@ from glyphsLib.interpolation import apply_instance_data
|
|||||||
from fontbuildlib import FontBuilder
|
from fontbuildlib import FontBuilder
|
||||||
from fontbuildlib.util import mkdirs, loadTTFont
|
from fontbuildlib.util import mkdirs, loadTTFont
|
||||||
from fontbuildlib.info import setFontInfo, updateFontVersion
|
from fontbuildlib.info import setFontInfo, updateFontVersion
|
||||||
from fontbuildlib.name import setFamilyName, removeWhitespaceFromStyles
|
from fontbuildlib.name import setFamilyName, renameStylesGoogleFonts
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -581,10 +581,13 @@ class Main(object):
|
|||||||
|
|
||||||
a('-o', '--output', metavar='<file>',
|
a('-o', '--output', metavar='<file>',
|
||||||
help='Output font file. Defaults to input file (overwrite.)')
|
help='Output font file. Defaults to input file (overwrite.)')
|
||||||
|
|
||||||
a('--family', metavar='<name>',
|
a('--family', metavar='<name>',
|
||||||
help='Rename family to <name>')
|
help='Rename family to <name>')
|
||||||
a('--compact-style', action='store_true',
|
|
||||||
help='Rename style names to CamelCase. e.g. "Extra Bold Italic" -> "ExtraBoldItalic"')
|
a('--google-style', action='store_true',
|
||||||
|
help='Rename style names to Google Fonts standards.')
|
||||||
|
|
||||||
a('input', metavar='<file>',
|
a('input', metavar='<file>',
|
||||||
help='Input font file')
|
help='Input font file')
|
||||||
|
|
||||||
@ -600,9 +603,9 @@ class Main(object):
|
|||||||
editCount += 1
|
editCount += 1
|
||||||
setFamilyName(font, args.family)
|
setFamilyName(font, args.family)
|
||||||
|
|
||||||
if args.compact_style:
|
if args.google_style:
|
||||||
editCount += 1
|
editCount += 1
|
||||||
removeWhitespaceFromStyles(font)
|
renameStylesGoogleFonts(font)
|
||||||
|
|
||||||
if editCount == 0:
|
if editCount == 0:
|
||||||
print("no rename options provided", file=sys.stderr)
|
print("no rename options provided", file=sys.stderr)
|
||||||
|
@ -53,7 +53,7 @@ def getFamilyName(font):
|
|||||||
return r.toUnicode()
|
return r.toUnicode()
|
||||||
|
|
||||||
|
|
||||||
def removeWhitespaceFromStyles(font):
|
def renameStylesGoogleFonts(font):
|
||||||
familyName = getFamilyName(font)
|
familyName = getFamilyName(font)
|
||||||
|
|
||||||
# collect subfamily (style) name IDs for variable font's named instances
|
# collect subfamily (style) name IDs for variable font's named instances
|
||||||
@ -75,7 +75,11 @@ def removeWhitespaceFromStyles(font):
|
|||||||
s = removeWhitespace(s)
|
s = removeWhitespace(s)
|
||||||
rec.string = s
|
rec.string = s
|
||||||
if rid in (SUBFAMILY_NAME,) or rid in vfInstanceSubfamilyNameIds:
|
if rid in (SUBFAMILY_NAME,) or rid in vfInstanceSubfamilyNameIds:
|
||||||
rec.string = removeWhitespace(rec.toUnicode())
|
s = removeWhitespace(rec.toUnicode())
|
||||||
|
if s != "Italic" and s.endswith("Italic"):
|
||||||
|
# fixup "ExtraBoldItalic" -> "ExtraBold Italic"
|
||||||
|
s = s[:len(s) - len("Italic")] + " Italic"
|
||||||
|
rec.string = s
|
||||||
# else: ignore standard names unrelated to style
|
# else: ignore standard names unrelated to style
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user