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-24 19:03:13 +01:00
|
|
|
extern "C" {
|
2023-02-24 19:53:47 +01:00
|
|
|
void debugprint (const char *s);
|
2023-02-24 19:03:13 +01:00
|
|
|
void debugprint1 (const char *s, int32_t);
|
|
|
|
void debugprint2 (const char *s, int32_t, int32_t);
|
|
|
|
}
|
2023-02-23 22:28:16 +01:00
|
|
|
|
|
|
|
bool_t
|
2023-02-25 01:44:33 +01:00
|
|
|
shape (void *shape_plan,
|
|
|
|
font_t *font,
|
2023-02-24 22:16:11 +01:00
|
|
|
buffer_t *buffer,
|
|
|
|
const feature_t *features,
|
|
|
|
uint32_t num_features)
|
2023-02-23 22:28:16 +01:00
|
|
|
{
|
2023-02-23 23:03:03 +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-25 16:12:16 +01:00
|
|
|
buffer_contents_t contents;
|
|
|
|
if (!buffer_copy_contents (buffer, &contents))
|
|
|
|
return false;
|
2023-02-23 22:28:16 +01:00
|
|
|
|
|
|
|
debugprint1 ("buffer length", contents.length);
|
|
|
|
|
|
|
|
for (unsigned i = 0; i < contents.length; i++)
|
2023-02-23 23:47:56 +01:00
|
|
|
{
|
2023-02-24 19:53:47 +01:00
|
|
|
char name[64];
|
|
|
|
|
|
|
|
font_glyph_to_string (font, contents.info[i].codepoint, name, sizeof (name));
|
|
|
|
|
|
|
|
debugprint (name);
|
|
|
|
|
2023-02-23 23:52:13 +01:00
|
|
|
contents.info[i].codepoint = font_get_glyph (font, contents.info[i].codepoint, 0);
|
|
|
|
contents.pos[i].x_advance = font_get_glyph_h_advance (font, contents.info[i].codepoint);
|
2023-02-23 23:47:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool_t ret = buffer_set_contents (buffer, &contents);
|
2023-02-23 22:28:16 +01:00
|
|
|
|
2023-02-23 23:06:18 +01:00
|
|
|
buffer_contents_free (&contents);
|
|
|
|
|
2023-02-23 23:47:56 +01:00
|
|
|
return ret;
|
2023-02-23 22:28:16 +01:00
|
|
|
}
|