1
1
mirror of https://github.com/rsms/inter.git synced 2024-11-26 23:56:59 +03:00

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
This commit is contained in:
Rasmus Andersson 2020-04-04 12:06:12 -07:00
parent 6528f926dd
commit 4519bffb7c
2 changed files with 68 additions and 717 deletions

View File

@ -1,18 +1,24 @@
# #MenuTitle: Assign fallback codepoints
# Assigns private-use codepoints to glyphs which are not mapped # -*- coding: utf-8 -*-
# to any Unicode codepoints. __doc__="""
# Assigns private-use codepoints to glyphs which are not mapped
# This script will ignore glyphs which name starts with "." as well as to any Unicode codepoints.
# empty glyphs and glyphs which are not exported.
# 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 import sys
from collections import OrderedDict from collections import OrderedDict
DRY_RUN = True DRY_RUN = False
font = Glyphs.font font = Glyphs.font
font.disableUpdateInterface() font.disableUpdateInterface()
def isEmpty(g): def isEmpty(g):
for master in g.parent.masters: for master in g.parent.masters:
layer = g.layers[master.id] layer = g.layers[master.id]
@ -20,6 +26,18 @@ def isEmpty(g):
return False return False
return True 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: try:
# find next unallocated private-use codepoint # find next unallocated private-use codepoint
nextcp = 0xE000 nextcp = 0xE000
@ -40,8 +58,7 @@ try:
# assign private-use codepoints to glyphs that have no existing unicode mapping # assign private-use codepoints to glyphs that have no existing unicode mapping
for g in font.glyphs: for g in font.glyphs:
# only care for glyphs which are being exported (also ignore "special" glyphs) if includeGlyph(g):
if g.export and g.name[0] != '.' and (g.unicodes is None or len(g.unicodes) == 0):
# error on empty glyphs -- there should be no unmapped empty glyphs # error on empty glyphs -- there should be no unmapped empty glyphs
if isEmpty(g): if isEmpty(g):
sys.stderr.write('ERR: glyph %r is empty but has no unicode mapping (skipping)\n' % g.name) sys.stderr.write('ERR: glyph %r is empty but has no unicode mapping (skipping)\n' % g.name)

File diff suppressed because it is too large Load Diff