mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-18 13:30:29 +00:00
font: add method for drawing atlas to canvas
This commit is contained in:
@@ -30,6 +30,7 @@ fetch(url.href).then(response =>
|
||||
face_debug_canvas,
|
||||
atlas_new,
|
||||
atlas_free,
|
||||
atlas_debug_canvas,
|
||||
} = results.instance.exports;
|
||||
// Give us access to the zjs value for debugging.
|
||||
globalThis.zjs = zjs;
|
||||
@@ -47,14 +48,21 @@ fetch(url.href).then(response =>
|
||||
new Uint8Array(memory.buffer, font_ptr).set(font);
|
||||
|
||||
// Call whatever example you want:
|
||||
const face = face_new(font_ptr, font.byteLength, 144);
|
||||
const face = face_new(font_ptr, font.byteLength, 72);
|
||||
free(font_ptr);
|
||||
|
||||
// Render a glyph
|
||||
face_render_glyph(face, atlas, "A".codePointAt(0));
|
||||
for (let i = 33; i <= 126; i++) {
|
||||
face_render_glyph(face, atlas, i);
|
||||
}
|
||||
// face_render_glyph(face, atlas, "A".codePointAt(0));
|
||||
|
||||
// Debug our canvas
|
||||
face_debug_canvas(face);
|
||||
|
||||
// Debug our atlas canvas
|
||||
const id = atlas_debug_canvas(atlas);
|
||||
document.getElementById("atlas-canvas").append(zjs.deleteValue(id));
|
||||
|
||||
//face_free(face);
|
||||
});
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
<body>
|
||||
<p>Open your console, we are just debugging here.</p>
|
||||
<p>The font rendering canvas should show below. This shows a single glyph.</p>
|
||||
<div id="face-canvas" style="display: inline-block; border: 1px solid red;"></div>
|
||||
<div><div id="face-canvas" style="display: inline-block; border: 1px solid red;"></div></div>
|
||||
<p>The current font atlas is rendered below.</p>
|
||||
<div><div id="atlas-canvas" style="display: inline-block; border: 1px solid green;"></div></div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user