diff --git a/build.zig.zon b/build.zig.zon index 4f2a010..5ced5a0 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -9,9 +9,8 @@ .dependencies = .{ .zenolith = .{ - //.path = "../zenolith", - .url = "git+https://git.mzte.de/zenolith/zenolith.git#c4ae23938d9f64ffd8dd0662314f7b478818547a", - .hash = "1220aa2f21fb19b4cb741e0709e84308a4d079f446dd655827206b0f834da8efa350", + .url = "git+https://git.mzte.de/zenolith/zenolith.git#6f318242d7bb5dad079e5ad6421900744e5d03b4", + .hash = "122034a7efb688149b6251c939407e31b1574de418c947a9b25478957d91aad69f5f", }, .sdl2 = .{ diff --git a/src/Sdl2Font.zig b/src/Sdl2Font.zig index d5222a6..ad54c07 100644 --- a/src/Sdl2Font.zig +++ b/src/Sdl2Font.zig @@ -65,11 +65,10 @@ pub fn getGlyph(self: *Sdl2Font, codepoint: u21, style: zenolith.text.Style) !ze return glyph; } -pub fn yOffset(self: *Sdl2Font, size: u31) u31 { - _ = self; - // What is supposed to work: - //if (c.FT_Set_Pixel_Sizes(self.face, 0, @intCast(size)) != 0) - // @panic("Unable to FT_Set_Pixel_Sizes for determining y offset"); +pub fn heightMetrics(self: *Sdl2Font, size: u31) zenolith.text.HeightMetrics { + if (c.FT_Set_Pixel_Sizes(self.face, 0, @intCast(size)) != 0) + // TODO: WONK + @panic("Unable to FT_Set_Pixel_Sizes for determining height metrics"); // All these produce equally nonsensical results and there seems to be no consensus which one is actually correct: //return @intCast(self.face.*.size.*.metrics.height >> 6); @@ -77,8 +76,12 @@ pub fn yOffset(self: *Sdl2Font, size: u31) u31 { //return @intCast((c.FT_MulFix(self.face.*.bbox.yMax, self.face.*.size.*.metrics.y_scale) >> 6) - // (c.FT_MulFix(self.face.*.bbox.yMin, self.face.*.size.*.metrics.y_scale) >> 6)); - // What actually works: - return size; + const bpad: u31 = @intCast(@max(0, -(self.face.*.size.*.metrics.descender >> 6))); + + return .{ + .y_offset = size, + .bottom_padding = bpad, + }; } fn getSize(self: *Sdl2Font) zenolith.layout.Size {