harfbuzz/src/wasm-sample/shape.c

32 lines
718 B
C
Raw Normal View History

2023-02-23 22:28:16 +01:00
#define HB_WASM_INTERFACE(ret_t, name) __attribute__((export_name(#name))) ret_t name
#include <hb-wasm-api.h>
2023-02-23 22:35:01 +01:00
void free (void*);
2023-02-23 22:28:16 +01:00
void debugprint1 (char *s, int32_t);
void debugprint2 (char *s, int32_t, int32_t);
bool_t
shape (font_t *font, buffer_t *buffer)
2023-02-23 22:28:16 +01:00
{
face_t *face = font_get_face (font);
2023-02-23 22:28:16 +01:00
blob_t blob = face_reference_table (face, TAG ('c','m','a','p'));
debugprint1 ("cmap length", blob.length);
2023-02-23 22:54:46 +01:00
blob_free (&blob);
2023-02-23 22:35:01 +01:00
2023-02-23 22:28:16 +01:00
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);
2023-02-23 23:06:18 +01:00
buffer_contents_free (&contents);
2023-02-23 22:28:16 +01:00
return 1;
}