[wasm] Fix up samples

This commit is contained in:
Behdad Esfahbod 2023-02-25 07:57:04 -07:00
parent 4ad659a608
commit 1023a80d39
4 changed files with 18 additions and 29 deletions

View File

@ -1,8 +1,11 @@
all: CharisSIL-R.wasm.ttf Scheherazade-R.wasm.ttf AwamiNastaliq-Regular.wasm.ttf FONTS = CharisSIL-R.wasm.ttf Scheherazade-R.wasm.ttf AwamiNastaliq-Regular.wasm.ttf
ADD_TABLE = ../../addTable.py
%.wasm: %.cc ../hb-wasm-api.h all: $(FONTS)
%.wasm: %.cc ../../hb-wasm-api.h
emcc \ emcc \
-I .. \ -I ../.. \
-I ~/graphite/include/ \ -I ~/graphite/include/ \
-fvisibility=hidden \ -fvisibility=hidden \
-Wl,--allow-undefined \ -Wl,--allow-undefined \
@ -13,10 +16,10 @@ all: CharisSIL-R.wasm.ttf Scheherazade-R.wasm.ttf AwamiNastaliq-Regular.wasm.ttf
$< \ $< \
-o $@ -o $@
%.wasm.ttf: %.ttf shape.wasm addTable.py %.wasm.ttf: %.ttf shape.wasm $(ADD_TABLE)
python addTable.py $< $@ shape.wasm python $(ADD_TABLE) $< $@ shape.wasm
clean: clean:
$(RM) test.wasm.ttf shape.wasm $(RM) shape.wasm $(FONTS)
.PRECIOUS: shape.wasm .PRECIOUS: shap.wasm

View File

@ -1,16 +0,0 @@
import sys
from fontTools.ttLib import TTFont
from fontTools.ttLib.tables.DefaultTable import DefaultTable
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.data = open(sys.argv[3], "rb").read()
font["Wasm"] = wasm_table
font.save(sys.argv[2])

View File

@ -1,21 +1,23 @@
ADD_TABLE = ../../../addTable.py
all: test-fallback.wasm.ttf test-ot.wasm.ttf all: test-fallback.wasm.ttf test-ot.wasm.ttf
%.wasm: %.cc ../hb-wasm-api.h %.wasm: %.cc ../../../hb-wasm-api.h
clang \ clang \
--target=wasm32-unknown-wasi \ --target=wasm32-unknown-wasi \
-Wl,--no-entry \ -Wl,--no-entry \
-fvisibility=hidden \ -fvisibility=hidden \
-Wl,--allow-undefined \ -Wl,--allow-undefined \
-nostdlib \ -nostdlib \
-I .. \ -I ../../.. \
$< \ $< \
-o $@ -o $@
test-fallback.wasm.ttf: test.ttf shape-fallback.wasm addTable.py test-fallback.wasm.ttf: test.ttf shape-fallback.wasm $(ADD_TABLE)
python addTable.py $< $@ shape-fallback.wasm python $(ADD_TABLE) $< $@ shape-fallback.wasm
test-ot.wasm.ttf: test.ttf shape-ot.wasm addTable.py test-ot.wasm.ttf: test.ttf shape-ot.wasm $(ADD_TABLE)
python addTable.py $< $@ shape-ot.wasm python $(ADD_TABLE) $< $@ shape-ot.wasm
clean: clean:
$(RM) test-fallback.wasm.ttf test-ot.wasm.ttf shape-fallback.wasm shape-ot.wasm $(RM) test-fallback.wasm.ttf test-ot.wasm.ttf shape-fallback.wasm shape-ot.wasm