fix: make MonospaceFont fallback to DefaultFont (#366)

This commit is contained in:
Gadfly 2024-08-19 15:10:44 +08:00
parent 24dde77548
commit ad53d874a2
No known key found for this signature in database
8 changed files with 30 additions and 13 deletions

View file

@ -85,25 +85,38 @@ namespace SourceGit.ViewModels
get => _defaultFont;
set
{
if (SetProperty(ref _defaultFont, value) && _onlyUseMonoFontInEditor)
if (SetProperty(ref _defaultFont, value))
{
MonospaceFontWithFallbackDefault = new FontFamily($"{_monospaceFont}, {_defaultFont}");
OnPropertyChanged(nameof(PrimaryFont));
}
}
}
public FontFamily MonospaceFont
{
get => _monospaceFont;
set
{
if (SetProperty(ref _monospaceFont, value) && !_onlyUseMonoFontInEditor)
if (SetProperty(ref _monospaceFont, value))
{
MonospaceFontWithFallbackDefault = new FontFamily($"{_monospaceFont}, {_defaultFont}");
OnPropertyChanged(nameof(PrimaryFont));
}
}
}
[JsonIgnore]
public FontFamily MonospaceFontWithFallbackDefault
{
get => _monospaceFontWithFallbackDefault;
set => SetProperty(ref _monospaceFontWithFallbackDefault, value);
}
[JsonIgnore]
public FontFamily PrimaryFont
{
get => _onlyUseMonoFontInEditor ? _defaultFont : _monospaceFont;
get => _onlyUseMonoFontInEditor ? _defaultFont : _monospaceFontWithFallbackDefault;
}
public bool OnlyUseMonoFontInEditor
@ -112,9 +125,12 @@ namespace SourceGit.ViewModels
set
{
if (SetProperty(ref _onlyUseMonoFontInEditor, value))
{
MonospaceFontWithFallbackDefault = new FontFamily($"{_monospaceFont}, {_defaultFont}");
OnPropertyChanged(nameof(PrimaryFont));
}
}
}
public double DefaultFontSize
{
@ -501,6 +517,7 @@ namespace SourceGit.ViewModels
private string _themeOverrides = string.Empty;
private FontFamily _defaultFont = null;
private FontFamily _monospaceFont = null;
private FontFamily _monospaceFontWithFallbackDefault = null;
private bool _onlyUseMonoFontInEditor = false;
private double _defaultFontSize = 13;
private LayoutInfo _layout = new LayoutInfo();

View file

@ -58,7 +58,7 @@
BorderThickness="1"
Background="{DynamicResource Brush.Contents}"
Foreground="{DynamicResource Brush.FG1}"
FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont}"
FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFontWithFallbackDefault}"
BlameData="{Binding Data}"/>
<!-- Not supported mask (for binary files) -->

View file

@ -86,7 +86,7 @@
<v:BranchTreeNodeTrackStatusPresenter Grid.Column="2"
Margin="8,0"
VerticalAlignment="Center"
FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont}"
FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFontWithFallbackDefault}"
FontSize="10"
Foreground="{DynamicResource Brush.BadgeFG}"
Background="{DynamicResource Brush.Badge}"/>

View file

@ -96,7 +96,7 @@
BranchNameBackground="{DynamicResource Brush.DecoratorBranch}"
TagNameBackground="{DynamicResource Brush.DecoratorTag}"
LabelForeground="{DynamicResource Brush.DecoratorFG}"
FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont}"
FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFontWithFallbackDefault}"
FontSize="10"
VerticalAlignment="Center"/>
</Border>

View file

@ -73,7 +73,7 @@
BranchNameBackground="{DynamicResource Brush.DecoratorBranch}"
TagNameBackground="{DynamicResource Brush.DecoratorTag}"
LabelForeground="{DynamicResource Brush.DecoratorFG}"
FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont}"
FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFontWithFallbackDefault}"
FontSize="10"
VerticalAlignment="Center"/>

View file

@ -95,7 +95,7 @@
Margin="6,0"
VerticalAlignment="Center"
Count="{Binding LocalChangesCount}"
FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont}"
FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFontWithFallbackDefault}"
FontSize="10"
Foreground="{DynamicResource Brush.BadgeFG}"
Background="{DynamicResource Brush.Badge}"/>
@ -110,7 +110,7 @@
Margin="6,0"
VerticalAlignment="Center"
Count="{Binding StashesCount}"
FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont}"
FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFontWithFallbackDefault}"
FontSize="10"
Foreground="{DynamicResource Brush.BadgeFG}"
Background="{DynamicResource Brush.Badge}"/>

View file

@ -42,7 +42,7 @@
</DataTemplate>
<DataTemplate DataType="m:RevisionTextFile">
<v:RevisionTextFileView FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont}" Background="{DynamicResource Brush.Contents}"/>
<v:RevisionTextFileView FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFontWithFallbackDefault}" Background="{DynamicResource Brush.Contents}"/>
</DataTemplate>
<DataTemplate DataType="m:RevisionImageFile">

View file

@ -22,7 +22,7 @@
AddedHighlightBrush="{DynamicResource Brush.Diff.AddedHighlight}"
DeletedHighlightBrush="{DynamicResource Brush.Diff.DeletedHighlight}"
IndicatorForeground="{DynamicResource Brush.FG2}"
FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont}"
FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFontWithFallbackDefault}"
UseSyntaxHighlighting="{Binding Source={x:Static vm:Preference.Instance}, Path=UseSyntaxHighlighting}"
WordWrap="{Binding Source={x:Static vm:Preference.Instance}, Path=EnableDiffViewWordWrap}"
ShowHiddenSymbols="{Binding Source={x:Static vm:Preference.Instance}, Path=ShowHiddenSymbolsInDiffView}"
@ -43,7 +43,7 @@
AddedHighlightBrush="{DynamicResource Brush.Diff.AddedHighlight}"
DeletedHighlightBrush="{DynamicResource Brush.Diff.DeletedHighlight}"
IndicatorForeground="{DynamicResource Brush.FG2}"
FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont}"
FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFontWithFallbackDefault}"
UseSyntaxHighlighting="{Binding Source={x:Static vm:Preference.Instance}, Path=UseSyntaxHighlighting}"
WordWrap="{Binding Source={x:Static vm:Preference.Instance}, Path=EnableDiffViewWordWrap}"
ShowHiddenSymbols="{Binding Source={x:Static vm:Preference.Instance}, Path=ShowHiddenSymbolsInDiffView}"
@ -63,7 +63,7 @@
AddedHighlightBrush="{DynamicResource Brush.Diff.AddedHighlight}"
DeletedHighlightBrush="{DynamicResource Brush.Diff.DeletedHighlight}"
IndicatorForeground="{DynamicResource Brush.FG2}"
FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont}"
FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFontWithFallbackDefault}"
UseSyntaxHighlighting="{Binding Source={x:Static vm:Preference.Instance}, Path=UseSyntaxHighlighting}"
WordWrap="{Binding Source={x:Static vm:Preference.Instance}, Path=EnableDiffViewWordWrap}"
ShowHiddenSymbols="{Binding Source={x:Static vm:Preference.Instance}, Path=ShowHiddenSymbolsInDiffView}"