diff options
author | Rasmus Andersson <rasmus@notion.se> | 2020-04-04 22:06:12 +0300 |
---|---|---|
committer | Rasmus Andersson <rasmus@notion.se> | 2020-04-04 22:07:19 +0300 |
commit | 4519bffb7cd52ce60f4b8e2e7c6ee547c9df78a2 (patch) | |
tree | 271cf280166980a1c76dd1c0e5b48731ce909089 /misc/glyphs-scripts/assign-fallback-codepoints.py | |
parent | 6528f926dd8517886e1da0f145d8649602c7202d (diff) | |
download | inter-4519bffb7cd52ce60f4b8e2e7c6ee547c9df78a2.tar.xz |
Removes math codepoint from some enclosed glyphs and removed upsilonlatin.001
The following glyphs have been assigned new private-use codepoints:
- plus.circled E15F
- minus.circled E160
- multiply.circled E161
- divide.circled E162
upsilonlatin.001 has been removed (unused glyph.)
closes #250
Diffstat (limited to 'misc/glyphs-scripts/assign-fallback-codepoints.py')
-rw-r--r-- | misc/glyphs-scripts/assign-fallback-codepoints.py | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/misc/glyphs-scripts/assign-fallback-codepoints.py b/misc/glyphs-scripts/assign-fallback-codepoints.py index d5099a5fd..35b67a39a 100644 --- a/misc/glyphs-scripts/assign-fallback-codepoints.py +++ b/misc/glyphs-scripts/assign-fallback-codepoints.py @@ -1,18 +1,24 @@ -# -# Assigns private-use codepoints to glyphs which are not mapped -# to any Unicode codepoints. -# -# This script will ignore glyphs which name starts with "." as well as -# empty glyphs and glyphs which are not exported. -# +#MenuTitle: Assign fallback codepoints +# -*- coding: utf-8 -*- +__doc__=""" +Assigns private-use codepoints to glyphs which are not mapped +to any Unicode codepoints. + +This script will ignore glyphs: +- glyphs which are not exported +- glyphs which name starts with "." +- glyphs which name ends with ".case" +- empty glyphs +""" import sys from collections import OrderedDict -DRY_RUN = True +DRY_RUN = False font = Glyphs.font font.disableUpdateInterface() + def isEmpty(g): for master in g.parent.masters: layer = g.layers[master.id] @@ -20,6 +26,18 @@ def isEmpty(g): return False return True + +def includeGlyph(g): + if not g.export: + return False + if g.name[0] == '.': + return False + if g.name.endswith(".case"): + return False + # finally, return true if the glyph has no codepoint assigned + return g.unicodes is None or len(g.unicodes) == 0 + + try: # find next unallocated private-use codepoint nextcp = 0xE000 @@ -40,8 +58,7 @@ try: # assign private-use codepoints to glyphs that have no existing unicode mapping for g in font.glyphs: - # only care for glyphs which are being exported (also ignore "special" glyphs) - if g.export and g.name[0] != '.' and (g.unicodes is None or len(g.unicodes) == 0): + if includeGlyph(g): # error on empty glyphs -- there should be no unmapped empty glyphs if isEmpty(g): sys.stderr.write('ERR: glyph %r is empty but has no unicode mapping (skipping)\n' % g.name) |