font: fix some JS memory leaks

This commit is contained in:
Mitchell Hashimoto
2022-12-05 15:45:31 -08:00
parent ed4e8c36b0
commit d2afddb7e2
3 changed files with 2 additions and 2 deletions

View File

@ -55,6 +55,7 @@ fetch(url.href).then(response =>
for (let i = 33; i <= 126; i++) { for (let i = 33; i <= 126; i++) {
face_render_glyph(face, atlas, i); face_render_glyph(face, atlas, i);
} }
//face_render_glyph(face, atlas, "橋".codePointAt(0));
//face_render_glyph(face, atlas, "p".codePointAt(0)); //face_render_glyph(face, atlas, "p".codePointAt(0));
// Debug our canvas // Debug our canvas

View File

@ -392,7 +392,7 @@ pub const Wasm = struct {
// This will return the same context on subsequent calls so it // This will return the same context on subsequent calls so it
// is important to reset it. // is important to reset it.
const ctx = try canvas.call(js.Object, "getContext", .{js.string("2d")}); const ctx = try canvas.call(js.Object, "getContext", .{js.string("2d")});
errdefer ctx.deinit(); defer ctx.deinit();
// We need to draw pixels so this is format dependent. // We need to draw pixels so this is format dependent.
var buf: []u8 = switch (self.format) { var buf: []u8 = switch (self.format) {

View File

@ -163,7 +163,6 @@ pub const Face = struct {
}); });
// Draw glyph // Draw glyph
// TODO: may need a +1 on the left/asc here to avoid clipping
try ctx.set("fillStyle", js.string("black")); try ctx.set("fillStyle", js.string("black"));
try ctx.call(void, "fillText", .{ try ctx.call(void, "fillText", .{
glyph_str, glyph_str,