summaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
authorMitchell Hashimoto <mitchell.hashimoto@gmail.com>2022-12-12 22:05:27 -0800
committerMitchell Hashimoto <mitchell.hashimoto@gmail.com>2022-12-12 22:05:27 -0800
commit0ab8eff069ba0aa6464dd0b44f8e5be827604aa5 (patch)
tree9b79d3d26963a23987b4e4f34711b7b3331e165b /example
parent21b750fa654771810a86f469674b57eb48db23bb (diff)
update example to show multi-codepoint grapheme
Diffstat (limited to 'example')
-rw-r--r--example/app.ts17
1 files 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);
});