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
1 changed files with 56 additions and 37 deletions
|
|
@ -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))
|
return time.strftime('%Y-%m-%dT%H:%M:%SZ', time.localtime(ts))
|
||||||
|
|
||||||
|
|
||||||
|
def processGlyph(g, ucd, seenGlyphnames):
|
||||||
def main():
|
name = g.name
|
||||||
argparser = ArgumentParser(
|
if name in seenGlyphnames:
|
||||||
description='Generate info on name, unicodes and color mark for all glyphs')
|
return None
|
||||||
|
seenGlyphnames.add(name)
|
||||||
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]
|
|
||||||
|
|
||||||
# not exported?
|
# not exported?
|
||||||
if 'com.schriftgestaltung.Glyphs.Export' in g.lib:
|
if 'com.schriftgestaltung.Glyphs.Export' in g.lib:
|
||||||
if not g.lib['com.schriftgestaltung.Glyphs.Export']:
|
if not g.lib['com.schriftgestaltung.Glyphs.Export']:
|
||||||
continue
|
return None
|
||||||
|
|
||||||
# color
|
# color
|
||||||
color = None
|
color = None
|
||||||
|
|
@ -87,7 +70,6 @@ def main():
|
||||||
ucName = unicodeName(ucd.get(uc))
|
ucName = unicodeName(ucd.get(uc))
|
||||||
# if not ucName and uc >= 0xE000 and uc <= 0xF8FF:
|
# if not ucName and uc >= 0xE000 and uc <= 0xF8FF:
|
||||||
# ucName = '[private use %04X]' % uc
|
# ucName = '[private use %04X]' % uc
|
||||||
|
|
||||||
ucstr = '%04X' % uc
|
ucstr = '%04X' % uc
|
||||||
if color:
|
if color:
|
||||||
glyph = [name, isEmpty, ucstr, ucName, color]
|
glyph = [name, isEmpty, ucstr, ucName, color]
|
||||||
|
|
@ -101,8 +83,45 @@ def main():
|
||||||
else:
|
else:
|
||||||
glyph = [name, isEmpty]
|
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)
|
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":[')
|
print('{"glyphs":[')
|
||||||
prefix = ' '
|
prefix = ' '
|
||||||
for g in glyphs:
|
for g in glyphs:
|
||||||
|
|
|
||||||
Reference in a new issue