-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
Make font name comparison case-insensitive #9494
Conversation
const auto actualFontName = _actualFont.GetFaceName(); | ||
const auto desiredFontName = _desiredFont.GetFaceName(); | ||
|
||
auto caseInsensitiveEquality = [](wchar_t a, wchar_t b) { return ::towlower(a) == ::towlower(b); }; |
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.
Worried that this uses the user's locale for a not-locale-specific font name. Maybe we can use CompareStringOrdinal
with bIgnoreCase=TRUE
to get around that?
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.
Thanks!
@msftbot make sure @miniksa signs off on this |
Hello @DHowett! Because you've given me some instructions on how to help merge this pull request, I'll be modifying my merge approach. Here's how I understand your requirements for merging this pull request:
If this doesn't seem right to you, you can tell me to cancel these instructions and use the auto-merge policy that has been configured for this repository. Try telling me "forget everything I just told you". |
When you say that the fallback font is displayed in the settings UI, do you mean that it's not selected in the dropdown box because it can't be found in the list (case sensitively)? @carlos-zamora -- can you point @eugenesmlv to the right place? |
@eugenesmlv If fallback is happening for settings UI, you may want to do the same kind of comparison here |
Oh no, we're using the localized name there. I might have led you astray. Carlos, do you know if we use localized or raw font names when looking up fonts? This could .. be .. important ... |
@DHowett yes, I do. When I open the settings editor the terminal/src/cascadia/TerminalSettingsEditor/Profiles.cpp Lines 429 to 442 in 99b09c0
|
Unfortunately, I actually don't know. I tracked it down to the renderer here: terminal/src/renderer/dx/DxFontRenderData.cpp Line 643 in 99b09c0
And the docs for |
I'll look behind the |
@miniksa this is really gonna ruin your day. |
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN |
It actually contains all names in that dictionary but will yield the |
We might have a couple things to do here.
|
To get the list of names... we have to...
Then we have to do Then Then we need to loop |
That'll be good for 2, the Settings UI work. It won't help us much for 1, the "we need to actually know about fallback instead of guessing based on the name" work. |
k let me dig to see if there's a better way to know of the fallback next. |
We already store the current localized name and the base unlocalized name in terminal/src/cascadia/TerminalSettingsEditor/Profiles.cpp Lines 429 to 442 in 99b09c0
Should we just make that look something like this then: for (const auto& font : currentFontList)
{
// GH#XXXX: check localized name and base name
if (font.LocalizedName() == profileFontFace || font.Name() == profileFontFace)
{
return box_value(font);
}
else if (font.LocalizedName() == L"Cascadia Mono" || font.Name() == L"Cascadia Mono")
{
fallbackFont = box_value(font);
}
} |
There could be N names. Not just one localized and one unlocalized. Or at least that's how DWrite stores it internally. :| |
And we're going to want to make the comparison case-insensitively. |
@eugenesmlv sorry we took over your pull request as our chat channel for this issue. There's a significant Teams outage, it seems, and GitHub has really worked out for us 😉 |
@DHowett it was interesting! Unfortunately, I don't know much about the terminal internals to participate in the discussion, but I'll be glad to help you fix that font comparison issue |
We know that we fall back to a different face in We also know that we couldn't find the name we were looking for in the current locale and did a fallback to a different name in So I think just bubbling this information out of the lookups and to the interface is just what needs to be done. |
@eugenesmlv, thanks for this proposal. But I'm going to close this in favor of the solution I wrote in #9734 that handles a few more scenarios than this and avoids comparing strings at all. Thanks for lighting a fire under me. :) |
Make font name comparison case-insensitive, so a warning message won't
be displayed when settings contain a font name with the wrong case.
Pros:
Cons:
Save
button on SUI, the fallback font will beapplied. That happens because the selected font face in SUI is
fallback font.
Should we also silently change the font face in the settings in that case?
Fixes #9360