summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2014-09-17 08:33:44 +0200
committerBehdad Esfahbod <behdad@behdad.org>2014-09-17 08:33:44 +0200
commit5fa98e45bc2db9f79ce4c7147af3d4c15c850fa2 (patch)
tree63086d3b06e1ae5ea271c0b1362f1b70d0bd8d0e
parentd88c6d90f2537a602c34f3b21c9f97ab9a20196d (diff)
[fonttools] Add one more snippet
-rwxr-xr-xfonttools/fonttools_slides.py1
-rw-r--r--fonttools/snippets/drop_glyphnames_cff.py6
2 files changed, 7 insertions, 0 deletions
diff --git a/fonttools/fonttools_slides.py b/fonttools/fonttools_slides.py
index 1bebe92..f2660a8 100755
--- a/fonttools/fonttools_slides.py
+++ b/fonttools/fonttools_slides.py
@@ -454,6 +454,7 @@ bullet_list_slide("Future work: optimization", [
slide("<b>Q?</b>", data={"desc":title_font})
python_slide('')
+python_slide(open("snippets/drop_glyphnames_cff.py").read())
xml_slide(open("snippets/tofu.ttx").read())
if __name__ == "__main__":
diff --git a/fonttools/snippets/drop_glyphnames_cff.py b/fonttools/snippets/drop_glyphnames_cff.py
new file mode 100644
index 0000000..0cc750c
--- /dev/null
+++ b/fonttools/snippets/drop_glyphnames_cff.py
@@ -0,0 +1,6 @@
+cff = font['CFF '].cff.topDictIndex[0]
+cff.ROS = ('Adobe','Identity',0)
+mapping = {name:("cid"+str(n) if n else ".notdef") for n,name in enumerate(cff.charset)}
+charstrings = cff.CharStrings
+charstrings.charStrings = {mapping[name]:v for name,v in charstrings.charStrings.items()}
+cff.charset = ["cid"+str(n) if n else ".notdef" for n in range(len(cff.charset))]