-
-
Save dperelman/d78e4897743f32e88a4b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from __future__ import print_function | |
import collections | |
import fileinput | |
import sys | |
plop = collections.defaultdict(list) | |
try: | |
import fontTools.agl | |
def map_character(c): | |
try: | |
return fontTools.agl.UV2AGL.get(ord(c), c) | |
except: | |
return c | |
except ImportError: | |
print('WARNING: Package fonttools not found.', file=sys.stderr) | |
# Don't have fonttools package. | |
# TODO: 5 ---> five etc. | |
character_mappings = { | |
' ': 'space', | |
} | |
def map_character(c): | |
return character_mappings.get(c, c) | |
for word in fileinput.input(): | |
word = word.strip() | |
length = len(word) | |
string = '' | |
glue = '' | |
firstletter = '' | |
if length < 6: | |
yooniecode = 'uniE602' | |
elif length > 11: | |
yooniecode = 'uniE600' | |
else: | |
yooniecode = 'uniE601' | |
firstletter = word[0] | |
string = ','.join(map(map_character, word[1:])) | |
line = ' <Ligature components="' + string + '" glyph="' + yooniecode + '"/>' | |
plop[firstletter].append(line) | |
for ltr in plop: | |
print('<LigatureSet glyph="' + ltr + '">') | |
print("\n".join(plop[ltr])) | |
print('</LigatureSet>' + "\n") |
the blackout version sounds good enough for me, if the script can detect the length of the combined ligatures that would be useful.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looking more carefully at Project Seen, it actually doesn't work quite the same way. It still uses ligatures, but it defines a separate ligature glyph for each word unlike SansBullshitSans which defines a small number of them and reuses them for words of the approximately the same length. For the "blackout" version of Project Seen it doesn't really matter (although my script will do a poor job of automatically identifying which ligature glyphs to use because it finds them by looking for repeats), but for the versions that leave the text visible, there's actual graphical manipulation involved which is much more complicated. I couldn't find any source code for Project Seen although I assume the author used a script of some sort to generate it from a word list.