➜ Heavy Round-Tipped Rightwards Arrow (U+279C) scalling in AtlasEngine #18579

Open
opened 2026-01-31 06:18:21 +00:00 by claunia · 0 comments
Owner

Originally created by @kasper93 on GitHub (Oct 2, 2022).

Windows Terminal version

54dc2c4

Windows build number

10.0.19044.0

Other Software

No response

Steps to reproduce

  1. Paste ➜

Expected Behavior

  1. Glyph is centered
  2. Glyph is not truncated

Actual Behavior

  1. Glyph is not centered
  2. Glyph is truncated

Before we start I want to say that I have this arrow in my zsh prompt that's why even small issues are noticeable looking at this all the time :)

There are two issues:

  • After scaling glyphs are not properly centered vertically. Enlarged for dramatic effect:

EDIT: ...and after writing all this, I noticed that this is expected behavior after 97dc5c8d75 Well I'm still complaining, my prompt (not on screenshots) looks ugly and I don't like this new behavior :( Mintty renders it centered.

image
Without scaling it is centered, although truncated. Basically this:

diff --git a/src/renderer/atlas/AtlasEngine.r.cpp b/src/renderer/atlas/AtlasEngine.r.cpp
index 73d6a7092..28008df05 100644
--- a/src/renderer/atlas/AtlasEngine.r.cpp
+++ b/src/renderer/atlas/AtlasEngine.r.cpp
@@ -636,6 +636,7 @@ AtlasEngine::CachedGlyphLayout AtlasEngine::_getCachedGlyphLayout(const wchar_t*
             scale.x = layoutBox.x / actualSizeX;
             scale.y = scale.x;
             scaleCenter.x = layoutBox.x * 0.5f;
+            scaleCenter.y = layoutBox.y * 0.5f;
         }
         if (overhang.top > _r.dipPerPixel || overhang.bottom > _r.dipPerPixel)
         {

With patch:
image

  • Second issue is more tricky. Basically what we do is to scale glyph to fit perfectly in the layout box. But it doesn't work nicely. If you look closely at the screenshots you will notice that both tail and the tip of the arrow is truncated by 1 or 2 pixels. I know it is very nitpicky and actually hard to show, sorry for that. It is more noticeable on normal smaller fonts where we have less pixels. Anyway I haven't read whole code, maybe there is clever way to round down scaling factor so it is always safe to apply, for my local build I just added safe margin around glyph, so that scaling never puts arrow outside allowed area.
    Without margin, tip is flat:
    image
    With margin, tip is nicely round:
    image

I personally think that having such margin/padding (depending how you look at it ;p) is better overall, even tho we are not using 100% of available space, in turn we are not actually overhanging ever due to scaling. But hey, there is probably better way to handle this (round/floor somewhere), I just quickly made the change for this report needs.

EDIT: Maybe we go out of the layout box because of anti-aliasing? Because I think it can alter surrounding (sub)pixels, but if we are exactly on the border and clip it would look worse?

Again sorry, for being nitpicky here, but I think we can make rendering nicer. Or if this is expected look and feel, at least I will know that I tried.

Thanks,
Kacper

/CC @lhecker

Originally created by @kasper93 on GitHub (Oct 2, 2022). ### Windows Terminal version 54dc2c4 ### Windows build number 10.0.19044.0 ### Other Software _No response_ ### Steps to reproduce 1. Paste `➜` ### Expected Behavior 1. Glyph is centered 2. Glyph is not truncated ### Actual Behavior 1. Glyph is not centered 2. Glyph is truncated Before we start I want to say that I have this arrow in my zsh prompt that's why even small issues are noticeable looking at this all the time :) There are two issues: * After scaling glyphs are not properly centered vertically. Enlarged for dramatic effect: EDIT: ...and after writing all this, I noticed that this is expected behavior after https://github.com/microsoft/terminal/commit/97dc5c8d754495d68996d341df961c9515b05804 Well I'm still complaining, my prompt (not on screenshots) looks ugly and I don't like this new behavior :( Mintty renders it centered. ![image](https://user-images.githubusercontent.com/1126053/193429072-f371bf6f-b4c1-4601-bb3e-3c2b369ae3ae.png) Without scaling it is centered, although truncated. Basically this: ``` diff diff --git a/src/renderer/atlas/AtlasEngine.r.cpp b/src/renderer/atlas/AtlasEngine.r.cpp index 73d6a7092..28008df05 100644 --- a/src/renderer/atlas/AtlasEngine.r.cpp +++ b/src/renderer/atlas/AtlasEngine.r.cpp @@ -636,6 +636,7 @@ AtlasEngine::CachedGlyphLayout AtlasEngine::_getCachedGlyphLayout(const wchar_t* scale.x = layoutBox.x / actualSizeX; scale.y = scale.x; scaleCenter.x = layoutBox.x * 0.5f; + scaleCenter.y = layoutBox.y * 0.5f; } if (overhang.top > _r.dipPerPixel || overhang.bottom > _r.dipPerPixel) { ``` With patch: ![image](https://user-images.githubusercontent.com/1126053/193429335-13f6614d-8260-49d1-9961-fe48e0944a10.png) * Second issue is more tricky. Basically what we do is to scale glyph to fit perfectly in the layout box. But it doesn't work nicely. If you look closely at the screenshots you will notice that both tail and the tip of the arrow is truncated by 1 or 2 pixels. I know it is very nitpicky and actually hard to show, sorry for that. It is more noticeable on normal smaller fonts where we have less pixels. Anyway I haven't read whole code, maybe there is clever way to round down scaling factor so it is always safe to apply, for my local build I just added safe margin around glyph, so that scaling never puts arrow outside allowed area. Without margin, tip is flat: ![image](https://user-images.githubusercontent.com/1126053/193430099-0cf307b8-3f89-4742-9284-eb128998ddf2.png) With margin, tip is nicely round: ![image](https://user-images.githubusercontent.com/1126053/193430114-09736ba3-8e73-48a4-98f4-bfa41a6b29f7.png) I personally think that having such margin/padding (depending how you look at it ;p) is better overall, even tho we are not using 100% of available space, in turn we are not actually overhanging ever due to scaling. But hey, there is probably better way to handle this (round/floor somewhere), I just quickly made the change for this report needs. EDIT: Maybe we go out of the layout box because of anti-aliasing? Because I think it can alter surrounding (sub)pixels, but if we are exactly on the border and clip it would look worse? Again sorry, for being nitpicky here, but I think we can make rendering nicer. Or if this is expected look and feel, at least I will know that I tried. Thanks, Kacper /CC @lhecker
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#18579