From 0ab8eff069ba0aa6464dd0b44f8e5be827604aa5 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 12 Dec 2022 22:05:27 -0800 Subject: [PATCH] update example to show multi-codepoint grapheme --- example/app.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/example/app.ts b/example/app.ts index c40ac2c74..9f03d2586 100644 --- a/example/app.ts +++ b/example/app.ts @@ -98,7 +98,7 @@ fetch(url.href).then(response => const emoji = ["🐏","🌞","🌚","🍱","πŸ’Ώ","🐈","πŸ“ƒ","πŸ“€","πŸ•‘","πŸ™ƒ"]; for (let i = 0; i < emoji.length; i++) { const cp = emoji[i].codePointAt(0); - const font_idx = group_cache_index_for_codepoint(group_cache, cp, 0, 1 /* emoji */); + const font_idx = group_cache_index_for_codepoint(group_cache, cp, 0, -1 /* best choice */); group_cache_render_glyph(group_cache, font_idx, cp, 0); } @@ -108,6 +108,16 @@ fetch(url.href).then(response => // Debug our canvas //face_debug_canvas(face); + // Let's try shaping + const shaper = shaper_new(120); + //const input = makeStr("hello🐏"); + const input = makeStr("helloπŸπŸ‘πŸ½"); + shaper_test(shaper, group_cache, input.ptr, input.len); + + const cp = 1114112; + const font_idx = group_cache_index_for_codepoint(group_cache, cp, 0, -1 /* best choice */); + group_cache_render_glyph(group_cache, font_idx, cp, -1); + // Debug our atlas canvas { const atlas = group_cache_atlas_greyscale(group_cache); @@ -121,10 +131,5 @@ fetch(url.href).then(response => document.getElementById("atlas-color-canvas").append(zjs.deleteValue(id)); } - // Let's try shaping - const shaper = shaper_new(120); - const input = makeStr("hello"); - shaper_test(shaper, group_cache, input.ptr, input.len); - //face_free(face); });