Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AtlasEngine: Improve dotted, dashed and curly underlines #16719

Merged
merged 2 commits into from
Feb 22, 2024

Conversation

lhecker
Copy link
Member

@lhecker lhecker commented Feb 15, 2024

This changeset makes 3 improvements:

  • Dotted lines now use a 2:1 ratio between gaps and dots (from 1:1).
    This makes the dots a lot easier to spot at small font sizes.
  • Dashed lines use a 1:2 ratio and a cells-size independent stride.
    By being cell-size independent it works more consistently with a
    wider variety of fonts with weird cell aspect ratios.
  • Curly lines are now cell-size independent as well and have a
    height that equals the double-underline size.
    This ensures that the curve isn't cut off anymore and just like
    with dashed lines, that it works under weird aspect ratios.

Closes #16712

Validation Steps Performed

This was tested using RenderingTests using Cascadia Mono, Consolas,
Courier New, Lucida Console and MS Gothic.

@lhecker lhecker changed the title Improve dotted, dashed and curly underlines AtlasEngine: Improve dotted, dashed and curly underlines Feb 15, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added Issue-Bug It either shouldn't be doing this or needs an investigation. Area-Rendering Text rendering, emoji, complex glyph & font-fallback issues Product-Terminal The new Windows Terminal. labels Feb 15, 2024
@lhecker
Copy link
Member Author

lhecker commented Feb 15, 2024

Cascadia Code, 12pt, 150% display scale (an edge case because it has just barely a 1px underline width):
16719

Zoomed 4x:
16719_zoomed

std::array<u32, 0x100> codepoints;
std::array<u16, 0x100> indices;
std::array<u32, 0xA0> codepoints;
std::array<u16, 0xA0> indices;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happened here?

{
if (const auto idx = indices[i])
if (idx)
{
fontFaceEntry.boxGlyphs.insert(idx);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these probably conflict, don't they :D

@lhecker lhecker merged commit 9c8058c into main Feb 22, 2024
17 of 19 checks passed
@lhecker lhecker deleted the user/lhecker/atlas-engine-underlines branch February 22, 2024 11:53
@lhecker
Copy link
Member Author

lhecker commented Feb 22, 2024

I've force-merged this PR because the ARM64 build was stuck with "Artifact ... already exists for build ...".

DHowett pushed a commit that referenced this pull request Feb 26, 2024
This changeset makes 3 improvements:
* Dotted lines now use a 2:1 ratio between gaps and dots (from 1:1).
  This makes the dots a lot easier to spot at small font sizes.
* Dashed lines use a 1:2 ratio and a cells-size independent stride.
  By being cell-size independent it works more consistently with a
  wider variety of fonts with weird cell aspect ratios.
* Curly lines are now cell-size independent as well and have a
  height that equals the double-underline size.
  This ensures that the curve isn't cut off anymore and just like
  with dashed lines, that it works under weird aspect ratios.

Closes #16712

## Validation Steps Performed
This was tested using RenderingTests using Cascadia Mono, Consolas,
Courier New, Lucida Console and MS Gothic.

(cherry picked from commit 9c8058c)
Service-Card-Id: 91922825
Service-Version: 1.19
DHowett pushed a commit that referenced this pull request Feb 26, 2024
This changeset makes 3 improvements:
* Dotted lines now use a 2:1 ratio between gaps and dots (from 1:1).
  This makes the dots a lot easier to spot at small font sizes.
* Dashed lines use a 1:2 ratio and a cells-size independent stride.
  By being cell-size independent it works more consistently with a
  wider variety of fonts with weird cell aspect ratios.
* Curly lines are now cell-size independent as well and have a
  height that equals the double-underline size.
  This ensures that the curve isn't cut off anymore and just like
  with dashed lines, that it works under weird aspect ratios.

Closes #16712

## Validation Steps Performed
This was tested using RenderingTests using Cascadia Mono, Consolas,
Courier New, Lucida Console and MS Gothic.

(cherry picked from commit 9c8058c)
Service-Card-Id: 91922826
Service-Version: 1.20
@Hrxn
Copy link

Hrxn commented Feb 28, 2024

Am I correct in the assumption that different styles for underlining are still not considered, well, a standard? Simply something that some terminal emulators added on their own?

So, what's the proper way to use them in WT? Like, with PowerShell?

@lhecker
Copy link
Member Author

lhecker commented Feb 28, 2024

A significant portion of "standards" are actually just "things that most terminals agree on" and not actually standardized. If you want to go for maximum compatibility, you should only use straight ("`e[4m") and double underlines ("`e[21m"). If I was writing a terminal application today, I'd just rely on underline styles and make it an option for users to not use them if they want to.

@Hrxn
Copy link

Hrxn commented Feb 28, 2024

True, it's more a "standard" and not a standard, should've made that more clear.

I think I found it:

Underline Style ANSI SGR Sequence (Powershell)
no underline `e[4:0m
straight underline `e[4:1m
double underline `e[4:2m
curly underline `e[4:3m
dotted underline `e[4:4m
dashed underline `e[4:5m
straight underline (for backwards compat) `e[4m
no underline (for backwards compat) `e[24m

Colors for underline styles seem to work as well, nice!

"string with `e[4:4mdotted underline`e[24m, and `e[4:4m`e[58:5:166mdotted underline in color`e[0m, yay!"

The trick is that you need : as a separator for the values in the ANSI sequence, I wasn't sure if PowerShell could properly handle that..

But it seems that is the case..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Rendering Text rendering, emoji, complex glyph & font-fallback issues Issue-Bug It either shouldn't be doing this or needs an investigation. Product-Terminal The new Windows Terminal.
Projects
Development

Successfully merging this pull request may close these issues.

Hyperlink uses different underscore dots when not hover over it
4 participants