From 74f992ade1ff2673f1ef620fb547ba7e3f0910f8 Mon Sep 17 00:00:00 2001 From: Matthew Date: Sun, 28 Dec 2025 14:00:54 +1100 Subject: [PATCH] fix fonts (properly this time) --- fonts.d | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fonts.d b/fonts.d index c7684c6..935cc2b 100644 --- a/fonts.d +++ b/fonts.d @@ -87,7 +87,7 @@ DeMultiply(u8 color, u8 alpha) } FontAtlasBuf -CreateAtlas(Arena* arena, FontFace font, f32 size, u32 dimension) +CreateAtlas(Arena* arena, FontFace font, f32 size, u32 dimension, bool y_origin_top = true) { assert(dimension >= 128, "Dimension must be at least 128"); @@ -240,14 +240,16 @@ CreateAtlas(Arena* arena, FontFace font, f32 size, u32 dimension) f32 height = glyph.metrics.height >> 6; f32 width = glyph.metrics.width >> 6; - f32 top = -font.glyph.bitmap_top; + f32 top = font.glyph.bitmap_top; f32 left = font.glyph.bitmap_left; + static assert(y_origin_top, "only y_origin_top is currently supported"); + g.ch = cast(dchar)char_code; g.advance = cast(f32)(glyph.advance.x >> 6); g.plane_left = left; g.plane_right = g.plane_left + width; - g.plane_top = top; + g.plane_top = cast(f32)(bbox_ymax) - top; g.plane_bottom = g.plane_top + height; g.atlas_top = max_h; @@ -265,3 +267,4 @@ CreateAtlas(Arena* arena, FontFace font, f32 size, u32 dimension) return abuf; } +