From 9a1d9c1d6af3bcb38e250a6ca4b760c38d446f55 Mon Sep 17 00:00:00 2001 From: flop Date: Sat, 23 May 2026 12:23:05 +0200 Subject: [PATCH] fix: top align fonts --- ts/src/font/u8g2.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ts/src/font/u8g2.ts b/ts/src/font/u8g2.ts index 8adf212..fc965c3 100644 --- a/ts/src/font/u8g2.ts +++ b/ts/src/font/u8g2.ts @@ -265,11 +265,11 @@ export function rasterizeText( const pixels = new Uint8Array(totalW * cellHeight); - // Centre the full font (ascent + |descent|) vertically in the cell. + // Top-align the full font (ascent + |descent|) within the cell. // header byte 14 is descent of 'g' - stored as a negative signed value. const descent = font.FONT_DATA[14]! > 127 ? font.FONT_DATA[14]! - 256 : font.FONT_DATA[14]!; const fontH = hdr.ascentA - descent; // total font height in pixels - const topPad = Math.floor((cellHeight - fontH) / 2); + const topPad = 0; const baseline = topPad + hdr.ascentA; let x = 0;