From 1023a80d395318e444458d0eebccab363133d5ef Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 25 Feb 2023 07:57:04 -0700 Subject: [PATCH] [wasm] Fix up samples --- src/{wasm/graphite => }/addTable.py | 0 src/wasm/graphite/Makefile | 17 ++++++++++------- src/wasm/sample/addTable.py | 16 ---------------- src/wasm/sample/c/Makefile | 14 ++++++++------ 4 files changed, 18 insertions(+), 29 deletions(-) rename src/{wasm/graphite => }/addTable.py (100%) delete mode 100644 src/wasm/sample/addTable.py diff --git a/src/wasm/graphite/addTable.py b/src/addTable.py similarity index 100% rename from src/wasm/graphite/addTable.py rename to src/addTable.py diff --git a/src/wasm/graphite/Makefile b/src/wasm/graphite/Makefile index 593212cc1..6584df96d 100644 --- a/src/wasm/graphite/Makefile +++ b/src/wasm/graphite/Makefile @@ -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 \ - -I .. \ + -I ../.. \ -I ~/graphite/include/ \ -fvisibility=hidden \ -Wl,--allow-undefined \ @@ -13,10 +16,10 @@ all: CharisSIL-R.wasm.ttf Scheherazade-R.wasm.ttf AwamiNastaliq-Regular.wasm.ttf $< \ -o $@ -%.wasm.ttf: %.ttf shape.wasm addTable.py - python addTable.py $< $@ shape.wasm +%.wasm.ttf: %.ttf shape.wasm $(ADD_TABLE) + python $(ADD_TABLE) $< $@ shape.wasm clean: - $(RM) test.wasm.ttf shape.wasm + $(RM) shape.wasm $(FONTS) -.PRECIOUS: shape.wasm +.PRECIOUS: shap.wasm diff --git a/src/wasm/sample/addTable.py b/src/wasm/sample/addTable.py deleted file mode 100644 index 103f292dd..000000000 --- a/src/wasm/sample/addTable.py +++ /dev/null @@ -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]) diff --git a/src/wasm/sample/c/Makefile b/src/wasm/sample/c/Makefile index 60606e359..4ee073b64 100644 --- a/src/wasm/sample/c/Makefile +++ b/src/wasm/sample/c/Makefile @@ -1,21 +1,23 @@ +ADD_TABLE = ../../../addTable.py + all: test-fallback.wasm.ttf test-ot.wasm.ttf -%.wasm: %.cc ../hb-wasm-api.h +%.wasm: %.cc ../../../hb-wasm-api.h clang \ --target=wasm32-unknown-wasi \ -Wl,--no-entry \ -fvisibility=hidden \ -Wl,--allow-undefined \ -nostdlib \ - -I .. \ + -I ../../.. \ $< \ -o $@ -test-fallback.wasm.ttf: test.ttf shape-fallback.wasm addTable.py - python addTable.py $< $@ shape-fallback.wasm +test-fallback.wasm.ttf: test.ttf shape-fallback.wasm $(ADD_TABLE) + python $(ADD_TABLE) $< $@ shape-fallback.wasm -test-ot.wasm.ttf: test.ttf shape-ot.wasm addTable.py - python addTable.py $< $@ shape-ot.wasm +test-ot.wasm.ttf: test.ttf shape-ot.wasm $(ADD_TABLE) + python $(ADD_TABLE) $< $@ shape-ot.wasm clean: $(RM) test-fallback.wasm.ttf test-ot.wasm.ttf shape-fallback.wasm shape-ot.wasm