From 2de475b36a4d5d7bcc3bdcc20084860e68d9767c Mon Sep 17 00:00:00 2001 From: Leonard Hecker Date: Tue, 27 Sep 2022 20:59:13 +0200 Subject: [PATCH] AtlasEngine: Partially revert glyph scaling changes (#14085) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change fixes issues with certain fonts that draw _way_ outside the advance width/height black box and expect to remain centered on the baseline. ## Validation Steps Performed * Use MesloLGM Nerd Font * Print U+E0B0 * Ensure it's centered, even if it's cut off ✅ --- src/renderer/atlas/AtlasEngine.r.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/renderer/atlas/AtlasEngine.r.cpp b/src/renderer/atlas/AtlasEngine.r.cpp index 381f43de4d..73d6a70929 100644 --- a/src/renderer/atlas/AtlasEngine.r.cpp +++ b/src/renderer/atlas/AtlasEngine.r.cpp @@ -550,10 +550,12 @@ AtlasEngine::CachedGlyphLayout AtlasEngine::_getCachedGlyphLayout(const wchar_t* static_cast(glyphMetrics.advanceHeight) / static_cast(metrics.designUnitsPerEm) * _r.fontMetrics.fontSizeInDIP, }; + // NOTE: Don't adjust the offset. + // Despite these being block characters, some fonts position them really weird with glyphs hanging out + // on all sides by up to 0.2em. They still expect the glyphs to be drawn on to their regular baseline. + // At the time of writing this can be tested with MesloLGM Nerd Font and U+E0B0 for instance. + scalingRequired = true; - // We always want box drawing glyphs to be centered in their cell. - offset.x = (layoutBox.x - boxSize.x) * 0.5f; - offset.y = (layoutBox.y - boxSize.y) * 0.5f; // We always want box drawing glyphs to exactly match the size of a terminal cell. // But add 1px to the destination size, so that we don't end up with fractional pixels. scale.x = (layoutBox.x + _r.dipPerPixel) / boxSize.x;