Repository navigation
Represent font face as a combo box in SUI - #9275
13 commits merged into
Conversation
This comment has been minimized.
This comment has been minimized.
IMO, if the user has |
Mike Griese (zadjii-msft)
left a comment
There was a problem hiding this comment.
blocking over the memory leak. I think Michael Niksa (@miniksa) should review the "collect all the fonts" bit, since he's the dwrite expert.
| <TextBox Text="{x:Bind State.Profile.FontFace, Mode=TwoWay}" | ||
| Style="{StaticResource TextBoxSettingStyle}"/> | ||
| <ComboBox ItemsSource="{x:Bind FontList, Mode=OneWay}" | ||
| SelectedItem="{x:Bind CurrentFontFace, Mode=TwoWay}" |
There was a problem hiding this comment.
What happens if CurrentFontFace is something that's not an installed font? Like if I set my fontFace to asdf, what happens then?
There was a problem hiding this comment.
So, there's a two fold approach (it's more developed in the upcoming commit):
- We have 2 lists: all installed fonts and monospace fonts. If we find that the current font face is not in the list of monospace fonts, assume that it's in the list of all fonts. So we update the UI to force the user to look at all of the installed fonts.
- If the user still selected a font that doesn't exist,
CurrentFontFace()returnsCascadia Mono. This has to be valid since it is shipped with Windows Terminal.
There was a problem hiding this comment.
I'd rather there be an error or warning instead of a whole "it automatically edits the setting if I look at the settings page" :/
There was a problem hiding this comment.
Huh, I think we might be ok, but let me run through it out loud to double check.
- JSON - invalid font face in settings.json --> show "Cascadia Mono" in SUI:

- SUI - limited to autogenerated list
So the only way to get an invalid font is if you modified the JSON. That said, if you then go to SUI, the change won't go into effect until you click on the combo box.
Maybe the behavior should be that we add another "font" called "Invalid Font"? But I feel like this case is fairly rare, and this is more of a request for input validation in SUI. So I'm inclined to say we should punt on this one or throw it in the backlog? Whatcha think?
|
@msftbot make sure Michael Niksa (@miniksa) signs off |
|
Hello Carlos Zamora (@carlos-zamora)! 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". |
| <data name="Profile_FontFaceShowAllFonts.Content" xml:space="preserve"> | ||
| <value>Show all fonts</value> | ||
| </data> | ||
| <data name="Profile_FontFaceShowAllFonts.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve"> | ||
| <value>If checked, show all installed fonts in the list above. Otherwise, only show the list of monospace fonts.</value> | ||
| </data> |
There was a problem hiding this comment.
Kayla Cinnamon (@cinnamon-msft) (or others) feel free to suggest changes for this part.
| </DataTemplate> | ||
|
|
||
| <DataTemplate x:DataType="x:String" x:Key="FontFaceComboBoxItemTemplate"> | ||
| <TextBlock Text="{x:Bind}" FontFamily="{x:Bind}"/> |
There was a problem hiding this comment.
Did you double check that this is fine receiving the localized name on other languages? I know you're keeping the localized name in the list for sorting and presentation.... but I have no idea what code TextBlock is calling to turn that localized string into its display font. I just want to make sure you double checked this on at least one non-English scenario.
There was a problem hiding this comment.
I don't know how to test this, but I have a feeling that this is definitely going to fail. Working on a solution rn.
Michael Niksa (miniksa)
left a comment
There was a problem hiding this comment.
Good with the DWrite stuff. A few odds and ends comments, but I'll let the other blocks be the definitive ones.
This comment has been minimized.
This comment has been minimized.
|
If it were an Editable ComboBox, that makes it the best of both worlds. You could also present a text warning, if the FontName read from the JSON, does not match a font available to use. |
My concern with it being editable is that you could choose a font that doesn't exist. Yeah, we could present a warning, but if the list fully encompasses the accepted fonts, I think this is fine? That said, making it editable would be "the cherry on top", so I'm gonna open a follow-up task for somebody to do that (most of the work would be creating the warning and validation after this PR). |
Mike Griese (zadjii-msft)
left a comment
There was a problem hiding this comment.
Uhg I feel conflicted - these feel like nits, but there's enough that I'm gonna block.
Generally looks good to me though
| // generate the font list, if we don't have one | ||
| if (!_State.Profile().CompleteFontList() || !_State.Profile().MonospaceFontList()) | ||
| { | ||
| ProfileViewModel::UpdateFontList(); |
There was a problem hiding this comment.
Should we do this here, or should we instead have the font lists initialized in the ProfileViewModel ctor?
There was a problem hiding this comment.
actually wait this is done in the ctor. So is this ever hit?
There was a problem hiding this comment.
I only have this here in case loading the fonts fails for some reason. The one in the constructor is hit when the Settings UI is opened, but then we check if we have it when we navigate to the profiles page.
| _ShowAllFonts = value; | ||
| _NotifyChanges(L"ShowAllFonts"); | ||
| } | ||
| } |
There was a problem hiding this comment.
an aside: almost starting to feel like PVM warrants its own file
There was a problem hiding this comment.
agreed. I think this'll be a part of #9207.
| monospaceFontList.emplace_back(fontEntry); | ||
| } | ||
| } | ||
| CATCH_LOG(); |
There was a problem hiding this comment.
This isn't gonna log 100 warnings as we iterate over all the fonts, is it?
There was a problem hiding this comment.
switched from .as to .try_as. So I think the only one we are really logging here is GetFirstMatchingFont. I think that's fair because we'd want to know which fonts we can't get the IDWriteFont version of?
|
Hello Mike Griese (@zadjii-msft)! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
|
🎉 Handy links: |
| </data> | ||
|
|
||
| There are any number of "resheader" rows that contain simple | ||
There was a problem hiding this comment.
Trailing whitespaces...
There was a problem hiding this comment.
Yep. Turns out that Visual Studio will automatically add those trailing spaces to a .resw file pretty much always. That's why every other commit in this repo removes them, then adds them back, depending on what editor the author is using. It really doesn't matter in the end though.
There was a problem hiding this comment.
(thanks for the review though? :P)
Summary of the Pull Request
This replaces the Profiles > Font Face text box with a combo box.
References
#6800 - Settings UI Epic
Detailed Description of the Pull Request / Additional comments
Profileskeeps a reference to the current value. We use that as a way to update the settings model. If an invalid value is used, we fallback toCascadia Mono.Demo