aboutsummaryrefslogtreecommitdiffstats
path: root/Lib/defconQt/objects
diff options
context:
space:
mode:
authorDenis Jacquerye2015-10-11 15:09:49 +0100
committerDenis Jacquerye2015-10-12 21:00:01 +0100
commitc4ed699dafd1ae61efb4471ff85564fc40c3985a (patch)
tree2052b46022f323775381b8710157ca42996cda34 /Lib/defconQt/objects
parent9099a3460eacd1061340a8501be35b8ba86032e1 (diff)
downloadtrufont-c4ed699dafd1ae61efb4471ff85564fc40c3985a.tar.bz2
defcon: Add TGlyph.autoUnicode() to get unicode from AGL or uninames (uniXXXX, uXXXX, uXXXXXX)
Diffstat (limited to 'Lib/defconQt/objects')
-rw-r--r--Lib/defconQt/objects/defcon.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/Lib/defconQt/objects/defcon.py b/Lib/defconQt/objects/defcon.py
index d24fa19..75d14c6 100644
--- a/Lib/defconQt/objects/defcon.py
+++ b/Lib/defconQt/objects/defcon.py
@@ -22,8 +22,7 @@ class TFont(Font):
glyph.width = width
# TODO: list ought to be changeable from AGL2UV
if addUnicode:
- if name in AGL2UV:
- glyph.unicode = AGL2UV[name]
+ glyph.autoUnicodes()
glyph.template = asTemplate
return glyph
@@ -54,6 +53,21 @@ class TGlyph(Glyph):
dirty = property(BaseObject._get_dirty, _set_dirty)
+ def autoUnicodes(self):
+ hexes = "ABCDEF0123456789"
+ name = self.name
+ if name in AGL2UV:
+ uni = AGL2UV[name]
+ elif (name.startswith("uni") and len(name) == 7 and
+ all(c in hexes for c in name[3:])):
+ uni = int(name[3:], 16)
+ elif (name.startswith("u") and len(name) in (5, 7) and
+ all(c in hexes for c in name[1:])):
+ uni = int(name[1:], 16)
+ else:
+ return
+ self.unicodes = [uni]
+
class TContour(Contour):
def __init__(self, pointClass=None, **kwargs):
if pointClass is None: