-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Detect likely Powerline fonts, add a special powerline preview #15365
Conversation
This comment has been minimized.
This comment has been minimized.
a5529a9
to
37a1f0f
Compare
This comment has been minimized.
This comment has been minimized.
// We're actually checking for the "Extended" PowerLine glyph set. | ||
// They're more fun. | ||
THROW_IF_FAILED(font->HasCharacter(0xE0B6, &exists)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's worth noting that you aren't really checking for PowerLine glyphs here. This is a Private Use Area, and this particular range has been used for Cirth characters in the ConScript Unicode Registry for the past couple of decades. Admittedly there probably aren't a lot of terminal users with Cirth fonts, but it would be nice if there was a safer way to detect PowerLine fonts specifically. Could you not guesstimate that from the name or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you not guesstimate that from the name or something?
That was my first approach! Man, the code was a lot shorter then.
I profiled a bunch of fonts and found that there's:
- fonts with "PL" in them
- at the end
- in the middle ("Xxx PL Mono")
- ... which don't have PowerLine glyphs either ("IBM Plex Mono")
- NerdFonts
- with "NF" at the end or in the middle ("Hack NF")
- with "Nerd Font" at the end or in the middle ("Xxx Nerd Font Propo")
- with "NerdFont" in them somewhere
- A hypothetical category of fonts that don't include a designator in the name, but do have somewhat-correct glyphs there
I know that it'll always be "best effort", and that powerline has coöpted part of the PUA that has already been used, but... it sucks all-up no matter how you slice it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My thinking was that it wouldn't matter that much if you failed to detect some nerd fonts, because they'd just get the regular preview, which isn't the end of the world. Showing the nerd font preview to someone that's using another glyph set seems like a bigger deal.
That said, I've just been looking for a Cirth font to test with, and I couldn't find any monospace variants that could reasonably be used in a terminal (I'm sure I had one in the past, but I might be misremembering that). So feel free to leave it as is. I just wanted to make sure we at least considered other options here.
Edit: @zadjii-msft I just saw your Cirth screenshot now, but I'm assuming that's not a "standard" CSUR font - it's just remapping ASCII characters as Cirth glyphs. I suspect the monospace fonts I remember using in the past were probably doing the same thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally think the codepoint check is more robust, because that's how most terminals detect powerline glyphs anyways. VS Code for instance checks these codepoints to determine if it should increase the contrast of text or not (it won't change the colors for powerline glyphs). Basically, I believe that it's somewhat unlikely for a user to use a Cirth font and much more likely for them to use a powerline font.
Edit: And it will still work correctly for the real terminal after all. This only changes the behavior for the settings preview.
Co-authored-by: Leonard Hecker <lhecker@microsoft.com>
37a1f0f
to
1c89407
Compare
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Carlos Zamora <carlos.zamora@microsoft.com>
When we detect a font that has a glyph for `U+E0B6`, we will switch the preview connection text to contain a special powerline prompt. This will allow people to see how different settings might impact their real-world environment. When we _don't_ detect such support, we fall back to the CMD-style `C:\>` prompt. Pros: - It's beautiful. Cons: - More code Risks: - `U+E0B6` is part of the private use area, and fonts that have symbols there (such as Cirth as sub-allocated by the ConScript Unicode Registry) will result in something unexpected. - Actually, `E0B6` isn't part of base powerline... but I think this specific set of characters looks too good to pass up. (cherry picked from commit 37e8aff) Service-Card-Id: 89468351 Service-Version: 1.18
When we detect a font that has a glyph for
U+E0B6
, we will switch the preview connection text to contain a special powerline prompt. This will allow people to see how different settings might impact their real-world environment.When we don't detect such support, we fall back to the CMD-style
C:\>
prompt.Pros:
Cons:
Risks:
U+E0B6
is part of the private use area, and fonts that have symbols there (such as Cirth as sub-allocated by the ConScript Unicode Registry) will result in something unexpected.E0B6
isn't part of base powerline... but I think this specific set of characters looks too good to pass up.