-
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
Fix bugs introduced in #16821 (custom font fallback) #16993
Conversation
if (primaryFontName.empty()) | ||
{ | ||
primaryFontName = name; | ||
} |
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.
A temporary hack.
@@ -187,6 +187,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation | |||
UpdateFontList(); | |||
} | |||
const auto& currentFontList{ CompleteFontList() }; | |||
fallbackFont = currentFontList.First().Current(); |
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.
Another temporary hack.
return S_OK; | ||
} | ||
CATCH_RETURN(); | ||
return hr; |
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.
HRESULT makes it simpler to write the if failed and necessary to retry
condition IMO.
fontCollection = _api.s->font->fontCollection; | ||
THROW_IF_FAILED(fontCollection->FindFamilyName(fontName.c_str(), &index, &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.
The fix for the dialog.
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.
okay so now, on the first failed font in the list, we'll fall back to the nearby font collection for all the remaining ones
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.
assuming the instrumentation build passes, of course
// Doing it this way is a bit hacky, but it does have the benefit that we can cache a font collection | ||
// instance across font changes, like when zooming the font size rapidly using the scroll wheel. | ||
try | ||
if (FAILED(hr) && _updateWithNearbyFontCollection()) |
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.
do we technically need this at all anymore? the first failed font will automatically use the nearby collection, down in _resolveFontMetrics
, right?
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 tried that at one point and it didn't work. My current leading theory is that DWrite's internal font cache thinks the font exists, tells us it exists, and only once it actually tries to use the font - for instance when we call GetMetrics()
- it notices that the font doesn't actually exist / is inaccessible, and then it returns a bad HRESULT
.
FindFontWithLocalizedName
is broken (intentionally andtemporarily until Any use of
FindFontWithLocalizedName
is broken and requires refactoring #16943 is fixed) we have to be extra be carefulnot to return a nullptr
Font
.the given font (Cascadia Mono for instance) installed. This requires
us to load the nearby fonts even if there aren't any exceptions.
Validation Steps Performed
src/cascadia/CascadiaResources.build.items
and remove the
Condition
for .ttf filesSettings > Defaults > Appearance
,enter a non-existing font and hit Save