| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
import sys, tempfile |
| 5 |
import fontforge |
| 6 |
|
| 7 |
fea_contents = """ |
| 8 |
lookup CALookup { |
| 9 |
lookupflag 0; |
| 10 |
sub [D E F ] [A B C ]' [G H I ] by [aaa-l bbb-l ccc-l ]; |
| 11 |
} CALookup; |
| 12 |
|
| 13 |
feature calt { |
| 14 |
|
| 15 |
script DFLT; |
| 16 |
language dflt ; |
| 17 |
lookup CALookup; |
| 18 |
} calt; |
| 19 |
""" |
| 20 |
|
| 21 |
with tempfile.NamedTemporaryFile("w+t", suffix=".fea", delete=False) as f: |
| 22 |
f.write(fea_contents) |
| 23 |
f.close() |
| 24 |
|
| 25 |
ambrosia = sys.argv[1] |
| 26 |
font = fontforge.open(ambrosia) |
| 27 |
|
| 28 |
n_lookups_before = len(font.gsub_lookups) |
| 29 |
|
| 30 |
font["a"].glyphname = "aaa-l" |
| 31 |
font["b"].glyphname = "bbb-l" |
| 32 |
font["c"].glyphname = "ccc-l" |
| 33 |
|
| 34 |
font.mergeFeature(f.name) |
| 35 |
assert len(font.gsub_lookups) - n_lookups_before == 2 |