microsoft / cascadia-code

This is a fun, new monospaced font that includes programming ligatures and is designed to enhance the modern look and feel of the Windows Terminal.
Other
25.1k stars 793 forks source link

Cascadia Code arrow segments not displaying correctly #740

Open riverar opened 1 month ago

riverar commented 1 month ago

Cascadia family version

2404.023

Cascadia family variant(s)

Cascadia Code (the version with ligatures)

Font file format(s)

Windows Terminal included version (TTF (variable))

Platform

Windows

Other Software

Microsoft Terminal 1.21.1272.0

What happened?

See also: https://github.com/microsoft/terminal/issues/17217

Steps to reproduce

  1. Create a text file on your desktop with the following content:

    Howdy! 🤠
    
    =>
    
    ==>
    
    ===>
    
    ====>
    
    =====>
    
    ======>
    
    =======>
    
    ========>
    
    =========>
    
    ==========>
    
    ===========>
    
    ============>
    
    =============>
    
    ==============>
  2. Launch Terminal app

  3. Display content in Terminal (e.g., Get-Content test.txt)

  4. Observe arrow segments are not connected together cleanly

Expected Behavior

Arrows with cleanly connected segments (https://github.com/microsoft/cascadia-code/blob/main/images/arrow_support.png)

Actual Behavior

Arrows without cleanly joined segments at various font sizes, such as 26px, 28px, 50px, 84px, etc.

image

aaronbell commented 1 month ago

This is a rendering bug caused by the rasterization environment. Unfortunately I don't know if there's anything I can do to fix this in the font. @DHowett, the issue is similar to #350, if you have any ideas...

Nahor commented 1 month ago

The arrows are not the only ones.

See the oblique bar for the "Large Type N": image

Or how the oblique bars join the verticals: image

Or how "██████████" creates lines (but only when using cleartype antialiasing): image

PhMajerus commented 1 month ago

All of those issues are exactly at the cells boundaries.

I believe there is a problem with the way the Terminal renderer handles characters that at some scales do not fit a round number of pixels, so some alignent is snapped to the closest integer pixel while some is handled as subpixels/fractional, ending up with some space or overlap at the subpixel level, which shows as darker or brighter pixels where glyphs are supposed to join precisely. The Cleartype problem is the same, as it effectively triples the horizontal resolution, again making the integer vs float alignments differ.

We have more details about this in discussions about the Terminal custom rendering of box drawing: https://github.com/microsoft/terminal/pull/16729#issuecomment-1960252937

I think the same problem is causing the multi-cells ligatures I tried to build for the large type pieces to drift slightly and not join properly the separate cells on other rows, as explained in https://github.com/microsoft/cascadia-code/pull/723#issuecomment-2072139022

riverar commented 1 month ago

@dhowett asserted this was a font issue, so it's not clear to me if Dustin has some information we're missing here. https://github.com/microsoft/terminal/issues/17217

DHowett commented 1 month ago

It reproduces anywhere there are overlapping glyphs due to antialiased edges alpha-blending on the edges of shapes. It reproduces in Chromium (Skia?) in addition to Windows Terminal. It is somewhere in between a font and a renderer issue.