update example to show multi-codepoint grapheme

This commit is contained in:
Mitchell Hashimoto
2022-12-12 22:05:27 -08:00
parent 21b750fa65
commit 0ab8eff069

View File

@ -98,7 +98,7 @@ fetch(url.href).then(response =>
const emoji = ["🐏","🌞","🌚","🍱","💿","🐈","📃","📀","🕡","🙃"]; const emoji = ["🐏","🌞","🌚","🍱","💿","🐈","📃","📀","🕡","🙃"];
for (let i = 0; i < emoji.length; i++) { for (let i = 0; i < emoji.length; i++) {
const cp = emoji[i].codePointAt(0); 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); group_cache_render_glyph(group_cache, font_idx, cp, 0);
} }
@ -108,6 +108,16 @@ fetch(url.href).then(response =>
// Debug our canvas // Debug our canvas
//face_debug_canvas(face); //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 // Debug our atlas canvas
{ {
const atlas = group_cache_atlas_greyscale(group_cache); 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)); 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); //face_free(face);
}); });