[wasm-sample] Make addTable take args

This commit is contained in:
Behdad Esfahbod 2023-02-23 16:11:54 -07:00
parent 551528a6e6
commit 5ab7f7a7d4
3 changed files with 9 additions and 4 deletions

View File

@ -12,7 +12,7 @@ all: test.wasm.ttf
-o $@ -o $@
%.wasm.ttf: %.ttf shape.so addTable.py %.wasm.ttf: %.ttf shape.so addTable.py
python addTable.py python addTable.py $< $@ shape.so
clean: clean:
$(RM) test.wasm.ttf shape.so $(RM) test.wasm.ttf shape.so

View File

@ -1,11 +1,16 @@
import sys
from fontTools.ttLib import TTFont from fontTools.ttLib import TTFont
from fontTools.ttLib.tables.DefaultTable import DefaultTable from fontTools.ttLib.tables.DefaultTable import DefaultTable
font = TTFont("test.ttf") if len(sys.argv) == 1:
print("usage: python addTable.py input.ttf output.ttf Wasm.bin")
sys.exit(1)
font = TTFont(sys.argv[1])
wasm_table = DefaultTable("Wasm") wasm_table = DefaultTable("Wasm")
wasm_table.data = open("shape.so", "rb").read() wasm_table.data = open(sys.argv[3], "rb").read()
font["Wasm"] = wasm_table font["Wasm"] = wasm_table
font.save("test.wasm.ttf") font.save(sys.argv[2])

Binary file not shown.