From 4669032e56f4f44ecf6f9e49a50dbf575b2f7dc9 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 18 Oct 2022 12:52:37 -0700 Subject: [PATCH] face: coretext zero the bitmap before render --- src/font/face/coretext.zig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/font/face/coretext.zig b/src/font/face/coretext.zig index 5800789aa..86181f0d0 100644 --- a/src/font/face/coretext.zig +++ b/src/font/face/coretext.zig @@ -107,6 +107,8 @@ pub const Face = struct { _ = glyph_height; const width = @floatToInt(u32, self.metrics.cell_width); const height = @floatToInt(u32, self.metrics.cell_height); + // const width = glyph_width; + // const height = glyph_height; // This bitmap is blank. I've seen it happen in a font, I don't know why. // If it is empty, we just return a valid glyph struct that does nothing. @@ -131,6 +133,7 @@ pub const Face = struct { // TODO(mitchellh): color is going to require a depth here var buf = try alloc.alloc(u8, width * height); defer alloc.free(buf); + std.mem.set(u8, buf, 0); const space = try macos.graphics.ColorSpace.createDeviceGray(); defer space.release(); @@ -155,6 +158,7 @@ pub const Face = struct { ctx.setTextDrawingMode(.fill_stroke); ctx.setTextMatrix(macos.graphics.AffineTransform.identity()); ctx.setTextPosition(0, @intToFloat(f32, height) - self.metrics.cell_baseline); + //ctx.setTextPosition(0, 0); var pos = [_]macos.graphics.Point{.{ .x = 0, .y = 0 }}; self.font.drawGlyphs(&glyphs, &pos, ctx);