Skip to content

Add support for subpixel positioning and fractional cell sizes #15805

Open

Description

Description of the new feature/enhancement

Subpixel positioning is a popular technique among modern text renderers to increase the horizontal (and sometimes vertical) resolution of glyph origins. With our current approach you get 1 variant of each glyph. No matter where the glyph is supposed to be drawn (e.g. at {84.3px, 19.6px}), the origin of the glyph's bitmap is rounded to the nearest pixel and the bitmap is bit-blit on the screen.

But with a 2x resolution you prepare 2 variants of each glyph, where the additional one is shifted by 0.5px during the initial rasterization into a bitmap. This ends up giving slightly, but noticeably different results. A 3x resolution seems to be the most common.

For instance, Chromium:
image

A great introduction for this is this document from a Google employee: http://goo.gl/yf3M7

Adding support for subpixel positioning would also significantly improve our support for block glyphs like those found in Nerd Fonts, because the font's advance width is seldomly an integer pixel value, which results in either block glyph overlaps (= cut-off appearance), or, even worse, gaps between glyphs.

Proposed technical implementation details (optional)

Supporting this in AtlasEngine is trivial. Direct2D has support for subpixel positioning (at 3x). Keying our glyph cache by subpixel offset would be easily possible by adding another field to the AtlasGlyphEntry structure to form a pair with the glyphIndex.

The real problem is all the code that uses til::point, til::size or other integer values to represent viewport coordinates in pixels. If those were gone and replaced with floats, implementing the rest would be fairly simple.

Activity

  1. added
    Area-RenderingText rendering, emoji, complex glyph & font-fallback issues
    Issue-TaskIt's a feature request, but it doesn't really need a major design.
    Needs-DiscussionSomething that requires a team discussion before we can proceed
    on Aug 7, 2023
  2. removed
    Needs-TriageIt's a new issue that the core contributor team needs to triage at the next triage meeting
    on Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-RenderingText rendering, emoji, complex glyph & font-fallback issuesIssue-TaskIt's a feature request, but it doesn't really need a major design.Product-TerminalThe new Windows Terminal.

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions