shape-fallback.cc (1551B)
1 #define HB_WASM_INTERFACE(ret_t, name) __attribute__((export_name(#name))) ret_t name 2 3 #include <hb-wasm-api.h> 4 5 extern "C" { 6 void debugprint (const char *s); 7 void debugprint1 (const char *s, int32_t); 8 void debugprint2 (const char *s, int32_t, int32_t); 9 } 10 11 bool_t 12 shape (void *shape_plan, 13 font_t *font, 14 buffer_t *buffer, 15 const feature_t *features, 16 uint32_t num_features) 17 { 18 face_t *face = font_get_face (font); 19 20 blob_t blob = BLOB_INIT; 21 face_copy_table (face, TAG ('c','m','a','p'), &blob); 22 23 debugprint1 ("cmap length", blob.length); 24 25 blob_free (&blob); 26 27 buffer_contents_t contents = BUFFER_CONTENTS_INIT; 28 if (!buffer_copy_contents (buffer, &contents)) 29 return false; 30 31 debugprint1 ("buffer length", contents.length); 32 33 glyph_outline_t outline = GLYPH_OUTLINE_INIT; 34 35 for (unsigned i = 0; i < contents.length; i++) 36 { 37 char name[64]; 38 39 debugprint1 ("glyph at", i); 40 41 font_glyph_to_string (font, contents.info[i].codepoint, name, sizeof (name)); 42 43 debugprint (name); 44 45 contents.info[i].codepoint = font_get_glyph (font, contents.info[i].codepoint, 0); 46 contents.pos[i].x_advance = font_get_glyph_h_advance (font, contents.info[i].codepoint); 47 48 font_copy_glyph_outline (font, contents.info[i].codepoint, &outline); 49 debugprint1 ("num outline points", outline.n_points); 50 debugprint1 ("num outline contours", outline.n_contours); 51 } 52 53 glyph_outline_free (&outline); 54 55 bool_t ret = buffer_set_contents (buffer, &contents); 56 57 buffer_contents_free (&contents); 58 59 return ret; 60 }