From 41cbc1a323b506458a0e43728d57d0da195d6822 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 5 Dec 2022 21:33:54 -0800 Subject: [PATCH] wasm: show color atlas in example web app --- example/app.ts | 15 ++++++++++++--- example/index.html | 6 +++--- src/font/GroupCache.zig | 4 ++++ 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/example/app.ts b/example/app.ts index 77d01fb96..ab6ab65d0 100644 --- a/example/app.ts +++ b/example/app.ts @@ -42,6 +42,7 @@ fetch(url.href).then(response => group_cache_index_for_codepoint, group_cache_render_glyph, group_cache_atlas_greyscale, + group_cache_atlas_color, atlas_new, atlas_free, atlas_debug_canvas, @@ -90,9 +91,17 @@ fetch(url.href).then(response => //face_debug_canvas(face); // Debug our atlas canvas - const atlas = group_cache_atlas_greyscale(group_cache); - const id = atlas_debug_canvas(atlas); - document.getElementById("atlas-canvas").append(zjs.deleteValue(id)); + { + const atlas = group_cache_atlas_greyscale(group_cache); + const id = atlas_debug_canvas(atlas); + document.getElementById("atlas-canvas").append(zjs.deleteValue(id)); + } + + { + const atlas = group_cache_atlas_color(group_cache); + const id = atlas_debug_canvas(atlas); + document.getElementById("atlas-color-canvas").append(zjs.deleteValue(id)); + } //face_free(face); }); diff --git a/example/index.html b/example/index.html index a9bd81547..a5fddff0d 100644 --- a/example/index.html +++ b/example/index.html @@ -7,9 +7,9 @@

Open your console, we are just debugging here.

-

The font rendering canvas should show below. This shows a single glyph.

-
-

The current font atlas is rendered below.

+

The current greyscale font atlas is rendered below.

+

The current color font atlas is rendered below.

+
diff --git a/src/font/GroupCache.zig b/src/font/GroupCache.zig index 5af5de4cd..6a69e1c7c 100644 --- a/src/font/GroupCache.zig +++ b/src/font/GroupCache.zig @@ -311,6 +311,10 @@ pub const Wasm = struct { export fn group_cache_atlas_greyscale(self: *GroupCache) *font.Atlas { return &self.atlas_greyscale; } + + export fn group_cache_atlas_color(self: *GroupCache) *font.Atlas { + return &self.atlas_color; + } }; test "resize" {