[wasm] Add wasm-sample/
This commit is contained in:
parent
5cecfe8659
commit
d45a13f101
|
@ -0,0 +1,18 @@
|
|||
all: test.wasm.ttf
|
||||
|
||||
%.so: %.c ../hb-wasm-api.h
|
||||
clang \
|
||||
--target=wasm32-unknown-wasi \
|
||||
-Wl,--no-entry \
|
||||
-fvisibility=hidden \
|
||||
-Wl,--allow-undefined \
|
||||
-nostdlib \
|
||||
-I .. \
|
||||
$< \
|
||||
-o $@
|
||||
|
||||
%.wasm.ttf: %.ttf shape.so addTable.py
|
||||
python addTable.py
|
||||
|
||||
clean:
|
||||
$(RM) test.wasm.ttf shape.so
|
|
@ -0,0 +1,11 @@
|
|||
from fontTools.ttLib import TTFont
|
||||
from fontTools.ttLib.tables.DefaultTable import DefaultTable
|
||||
|
||||
font = TTFont("test.ttf")
|
||||
|
||||
wasm_table = DefaultTable("Wasm")
|
||||
wasm_table.data = open("shape.so", "rb").read()
|
||||
|
||||
font["Wasm"] = wasm_table
|
||||
|
||||
font.save("test.wasm.ttf")
|
|
@ -0,0 +1,25 @@
|
|||
#define HB_WASM_INTERFACE(ret_t, name) __attribute__((export_name(#name))) ret_t name
|
||||
|
||||
#include <hb-wasm-api.h>
|
||||
|
||||
void debugprint1 (char *s, int32_t);
|
||||
void debugprint2 (char *s, int32_t, int32_t);
|
||||
|
||||
bool_t
|
||||
shape (font_t font, buffer_t buffer)
|
||||
{
|
||||
face_t face = font_get_face (font);
|
||||
|
||||
blob_t blob = face_reference_table (face, TAG ('c','m','a','p'));
|
||||
|
||||
debugprint1 ("cmap length", blob.length);
|
||||
|
||||
buffer_contents_t contents = buffer_copy_contents (buffer);
|
||||
|
||||
debugprint1 ("buffer length", contents.length);
|
||||
|
||||
for (unsigned i = 0; i < contents.length; i++)
|
||||
debugprint2 ("Codepoint", i, contents.info[i].codepoint);
|
||||
|
||||
return 1;
|
||||
}
|
Binary file not shown.
Loading…
Reference in New Issue