mirror of
https://github.com/rsms/inter.git
synced 2024-12-25 16:44:27 +03:00
tooling: fixes glyphinfo generator script. Some 3rd party library changed, causing output to no longer contain glyphs not explicitly ordered. Yay, dependencies.
This commit is contained in:
parent
4232cde195
commit
c9dac4c440
@ -41,33 +41,16 @@ def localDateTimeToUTCStr(localstr, pattern='%Y/%m/%d %H:%M:%S'):
|
||||
return time.strftime('%Y-%m-%dT%H:%M:%SZ', time.localtime(ts))
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
argparser = ArgumentParser(
|
||||
description='Generate info on name, unicodes and color mark for all glyphs')
|
||||
|
||||
argparser.add_argument(
|
||||
'-ucd', dest='ucdFile', metavar='<file>', type=str,
|
||||
help='UnicodeData.txt file from http://www.unicode.org/')
|
||||
|
||||
argparser.add_argument(
|
||||
'fontPath', metavar='<ufofile>', type=str)
|
||||
|
||||
args = argparser.parse_args()
|
||||
font = Font(args.fontPath)
|
||||
ucd = {}
|
||||
if args.ucdFile:
|
||||
ucd = parseUnicodeDataFile(args.ucdFile)
|
||||
|
||||
glyphs = [] # contains final glyph data printed as JSON
|
||||
|
||||
for name in font.lib['public.glyphOrder']:
|
||||
g = font[name]
|
||||
def processGlyph(g, ucd, seenGlyphnames):
|
||||
name = g.name
|
||||
if name in seenGlyphnames:
|
||||
return None
|
||||
seenGlyphnames.add(name)
|
||||
|
||||
# not exported?
|
||||
if 'com.schriftgestaltung.Glyphs.Export' in g.lib:
|
||||
if not g.lib['com.schriftgestaltung.Glyphs.Export']:
|
||||
continue
|
||||
return None
|
||||
|
||||
# color
|
||||
color = None
|
||||
@ -87,7 +70,6 @@ def main():
|
||||
ucName = unicodeName(ucd.get(uc))
|
||||
# if not ucName and uc >= 0xE000 and uc <= 0xF8FF:
|
||||
# ucName = '[private use %04X]' % uc
|
||||
|
||||
ucstr = '%04X' % uc
|
||||
if color:
|
||||
glyph = [name, isEmpty, ucstr, ucName, color]
|
||||
@ -101,8 +83,45 @@ def main():
|
||||
else:
|
||||
glyph = [name, isEmpty]
|
||||
|
||||
return glyph
|
||||
|
||||
|
||||
def main():
|
||||
argparser = ArgumentParser(
|
||||
description='Generate info on name, unicodes and color mark for all glyphs')
|
||||
|
||||
argparser.add_argument(
|
||||
'-ucd', dest='ucdFile', metavar='<file>', type=str,
|
||||
help='UnicodeData.txt file from http://www.unicode.org/')
|
||||
|
||||
argparser.add_argument(
|
||||
'fontPath', metavar='<ufofile>', type=str)
|
||||
|
||||
args = argparser.parse_args()
|
||||
font = Font(args.fontPath)
|
||||
ucd = {}
|
||||
if args.ucdFile:
|
||||
ucd = parseUnicodeDataFile(args.ucdFile)
|
||||
|
||||
glyphs = [] # contains final glyph data printed as JSON
|
||||
seenGlyphnames = set()
|
||||
|
||||
for name in font.lib['public.glyphOrder']:
|
||||
g = font[name]
|
||||
glyph = processGlyph(g, ucd, seenGlyphnames)
|
||||
if glyph is not None:
|
||||
glyphs.append(glyph)
|
||||
|
||||
unorderedGlyphs = []
|
||||
for g in font:
|
||||
glyph = processGlyph(g, ucd, seenGlyphnames)
|
||||
if glyph is not None:
|
||||
unorderedGlyphs.append(glyph)
|
||||
|
||||
if unorderedGlyphs:
|
||||
# sort by unicode
|
||||
glyphs = glyphs + sorted(unorderedGlyphs, key=lambda g: g[2])
|
||||
|
||||
print('{"glyphs":[')
|
||||
prefix = ' '
|
||||
for g in glyphs:
|
||||
|
Loading…
Reference in New Issue
Block a user