mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-24 13:45:00 +00:00
feature: supports custom fonts (#30)
This commit is contained in:
parent
0e49ad181a
commit
83aa373079
14 changed files with 181 additions and 15 deletions
|
@ -72,7 +72,7 @@
|
|||
BorderThickness="1"
|
||||
Background="{DynamicResource Brush.Contents}"
|
||||
Foreground="{DynamicResource Brush.FG1}"
|
||||
FontFamily="fonts:SourceGit#JetBrains Mono"
|
||||
FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont, Converter={x:Static c:StringConverters.ToFontFamily}}"
|
||||
FontSize="12"
|
||||
BlameData="{Binding Data}"/>
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
<Grid RowDefinitions="24,Auto,Auto,Auto" ColumnDefinitions="96,*">
|
||||
<!-- SHA -->
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" Classes="info_label" Text="{DynamicResource Text.CommitDetail.Info.SHA}" />
|
||||
<SelectableTextBlock Grid.Row="0" Grid.Column="1" Text="{Binding SHA}" Margin="12,0,0,0" FontSize="12" VerticalAlignment="Center" FontFamily="fonts:SourceGit#JetBrains Mono"/>
|
||||
<SelectableTextBlock Grid.Row="0" Grid.Column="1" Text="{Binding SHA}" Margin="12,0,0,0" FontSize="12" VerticalAlignment="Center" FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont, Converter={x:Static c:StringConverters.ToFontFamily}}"/>
|
||||
|
||||
<!-- PARENTS -->
|
||||
<TextBlock Grid.Row="1" Grid.Column="0" Classes="info_label" Text="{DynamicResource Text.CommitDetail.Info.Parents}" IsVisible="{Binding Parents.Count, Converter={x:Static c:IntConverters.IsGreaterThanZero}}"/>
|
||||
|
@ -95,7 +95,7 @@
|
|||
<!-- Messages -->
|
||||
<TextBlock Grid.Row="3" Grid.Column="0" Classes="info_label" Text="{DynamicResource Text.CommitDetail.Info.Message}" VerticalAlignment="Top" Margin="0,4,0,0" />
|
||||
<ScrollViewer Grid.Row="3" Grid.Column="1" Margin="12,5,0,0" MaxHeight="100" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
|
||||
<SelectableTextBlock Text="{Binding FullMessage}" FontSize="12" FontFamily="fonts:SourceGit#JetBrains Mono" TextWrapping="Wrap"/>
|
||||
<SelectableTextBlock Text="{Binding FullMessage}" FontSize="12" FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont, Converter={x:Static c:StringConverters.ToFontFamily}}" TextWrapping="Wrap"/>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@
|
|||
<TabItem.Header>
|
||||
<TextBlock Classes="tab_header" Text="{DynamicResource Text.Preference.General}"/>
|
||||
</TabItem.Header>
|
||||
<Grid Margin="8" RowDefinitions="32,32,32,32,32,32" ColumnDefinitions="Auto,*">
|
||||
<Grid Margin="8" RowDefinitions="32,32,32,32,32,32,32,32" ColumnDefinitions="Auto,*">
|
||||
<TextBlock Grid.Row="0" Grid.Column="0"
|
||||
Text="{DynamicResource Text.Preference.General.Locale}"
|
||||
HorizontalAlignment="Right"
|
||||
|
@ -113,10 +113,48 @@
|
|||
</ComboBox>
|
||||
|
||||
<TextBlock Grid.Row="3" Grid.Column="0"
|
||||
Text="{DynamicResource Text.Preference.General.DefaultFont}"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,16,0"/>
|
||||
<ComboBox Grid.Row="3" Grid.Column="1"
|
||||
MinHeight="28"
|
||||
Padding="8,0"
|
||||
HorizontalAlignment="Stretch"
|
||||
ItemsSource="{Binding #me.InstalledFonts}"
|
||||
SelectedItem="{Binding DefaultFont, Converter={x:Static c:StringConverters.ToFontFamily}, Mode=TwoWay}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate DataType="FontFamily">
|
||||
<Border Height="24">
|
||||
<TextBlock VerticalAlignment="Center" Text="{Binding Name}" FontFamily="{Binding}"/>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
|
||||
<TextBlock Grid.Row="4" Grid.Column="0"
|
||||
Text="{DynamicResource Text.Preference.General.MonospaceFont}"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,16,0"/>
|
||||
<ComboBox Grid.Row="4" Grid.Column="1"
|
||||
MinHeight="28"
|
||||
Padding="8,0"
|
||||
HorizontalAlignment="Stretch"
|
||||
ItemsSource="{Binding #me.InstalledMonospaceFonts}"
|
||||
SelectedItem="{Binding MonospaceFont, Converter={x:Static c:StringConverters.ToFontFamily}, Mode=TwoWay}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate DataType="FontFamily">
|
||||
<Border Height="24">
|
||||
<TextBlock VerticalAlignment="Center" Text="{Binding Name}" FontFamily="{Binding}"/>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
|
||||
<TextBlock Grid.Row="5" Grid.Column="0"
|
||||
Text="{DynamicResource Text.Preference.General.MaxHistoryCommits}"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,16,0"/>
|
||||
<Grid Grid.Row="3" Grid.Column="1" ColumnDefinitions="*,64">
|
||||
<Grid Grid.Row="5" Grid.Column="1" ColumnDefinitions="*,64">
|
||||
<Slider Grid.Column="0"
|
||||
Minimum="20000" Maximum="100000"
|
||||
TickPlacement="BottomRight" TickFrequency="5000"
|
||||
|
@ -140,11 +178,11 @@
|
|||
Text="{Binding MaxHistoryCommits}"/>
|
||||
</Grid>
|
||||
|
||||
<CheckBox Grid.Row="4" Grid.Column="1"
|
||||
<CheckBox Grid.Row="6" Grid.Column="1"
|
||||
Content="{DynamicResource Text.Preference.General.RestoreTabs}"
|
||||
IsChecked="{Binding RestoreTabs, Mode=TwoWay}"/>
|
||||
|
||||
<CheckBox Grid.Row="5" Grid.Column="1"
|
||||
<CheckBox Grid.Row="7" Grid.Column="1"
|
||||
Height="32"
|
||||
Content="{DynamicResource Text.Preference.General.UseFixedTabWidth}"
|
||||
IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=UseFixedTabWidth, Mode=TwoWay}"/>
|
||||
|
|
|
@ -1,15 +1,30 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Platform.Storage;
|
||||
|
||||
namespace SourceGit.Views
|
||||
{
|
||||
public partial class Preference : Window
|
||||
{
|
||||
public List<FontFamily> InstalledFonts
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public List<FontFamily> InstalledMonospaceFonts
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public string DefaultUser
|
||||
{
|
||||
get;
|
||||
|
@ -51,6 +66,37 @@ namespace SourceGit.Views
|
|||
var pref = ViewModels.Preference.Instance;
|
||||
DataContext = pref;
|
||||
|
||||
InstalledFonts = new List<FontFamily>();
|
||||
InstalledFonts.Add(new FontFamily("fonts:SourceGit#JetBrains Mono"));
|
||||
InstalledFonts.AddRange(FontManager.Current.SystemFonts);
|
||||
InstalledFonts.Remove(FontManager.Current.DefaultFontFamily);
|
||||
InstalledFonts.Add(FontManager.Current.DefaultFontFamily);
|
||||
|
||||
InstalledMonospaceFonts = new List<FontFamily>();
|
||||
InstalledMonospaceFonts.Add(new FontFamily("fonts:SourceGit#JetBrains Mono"));
|
||||
foreach (var font in FontManager.Current.SystemFonts)
|
||||
{
|
||||
var typeface = new Typeface(font);
|
||||
var testI = new FormattedText(
|
||||
"i",
|
||||
CultureInfo.CurrentCulture,
|
||||
FlowDirection.LeftToRight,
|
||||
typeface,
|
||||
12,
|
||||
Brushes.White);
|
||||
var testW = new FormattedText(
|
||||
"W",
|
||||
CultureInfo.CurrentCulture,
|
||||
FlowDirection.LeftToRight,
|
||||
typeface,
|
||||
12,
|
||||
Brushes.White);
|
||||
if (testI.Width == testW.Width)
|
||||
{
|
||||
InstalledMonospaceFonts.Add(font);
|
||||
}
|
||||
}
|
||||
|
||||
var ver = string.Empty;
|
||||
if (pref.IsGitConfigured)
|
||||
{
|
||||
|
|
|
@ -89,7 +89,7 @@
|
|||
</DataTemplate>
|
||||
|
||||
<DataTemplate DataType="m:RevisionTextFile">
|
||||
<v:RevisionTextFileView FontFamily="fonts:SourceGit#JetBrains Mono" FontSize="12" Background="{DynamicResource Brush.Contents}"/>
|
||||
<v:RevisionTextFileView FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont, Converter={x:Static c:StringConverters.ToFontFamily}}" FontSize="12" Background="{DynamicResource Brush.Contents}"/>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate DataType="m:RevisionLFSObject">
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
BorderThickness="0"
|
||||
Foreground="{DynamicResource Brush.FG1}"
|
||||
SecondaryFG="{DynamicResource Brush.FG2}"
|
||||
FontFamily="fonts:SourceGit#JetBrains Mono"
|
||||
FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont, Converter={x:Static c:StringConverters.ToFontFamily}}"
|
||||
FontSize="12"
|
||||
DiffData="{Binding}"
|
||||
SyncScrollOffset="{Binding $parent[v:DiffView].DataContext.(vm:DiffContext).SyncScrollOffset, Mode=TwoWay}"
|
||||
|
@ -36,7 +36,7 @@
|
|||
BorderThickness="0"
|
||||
Foreground="{DynamicResource Brush.FG1}"
|
||||
SecondaryFG="{DynamicResource Brush.FG2}"
|
||||
FontFamily="fonts:SourceGit#JetBrains Mono"
|
||||
FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont, Converter={x:Static c:StringConverters.ToFontFamily}}"
|
||||
FontSize="12"
|
||||
DiffData="{Binding}"/>
|
||||
|
||||
|
@ -52,7 +52,7 @@
|
|||
BorderThickness="0"
|
||||
Foreground="{DynamicResource Brush.FG1}"
|
||||
SecondaryFG="{DynamicResource Brush.FG2}"
|
||||
FontFamily="fonts:SourceGit#JetBrains Mono"
|
||||
FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont, Converter={x:Static c:StringConverters.ToFontFamily}}"
|
||||
FontSize="12"
|
||||
DiffData="{Binding}"/>
|
||||
</Grid>
|
||||
|
|
|
@ -160,7 +160,7 @@ namespace SourceGit.Views
|
|||
public LineStyleTransformer(CombinedTextDiffPresenter editor)
|
||||
{
|
||||
_editor = editor;
|
||||
_indicatorTypeface = new Typeface("fonts:SourceGit#JetBrains Mono", FontStyle.Italic);
|
||||
_indicatorTypeface = new Typeface(editor.FontFamily, FontStyle.Italic);
|
||||
}
|
||||
|
||||
protected override void ColorizeLine(DocumentLine line)
|
||||
|
@ -520,7 +520,7 @@ namespace SourceGit.Views
|
|||
public LineStyleTransformer(SingleSideTextDiffPresenter editor)
|
||||
{
|
||||
_editor = editor;
|
||||
_indicatorTypeface = new Typeface("fonts:SourceGit#JetBrains Mono", FontStyle.Italic);
|
||||
_indicatorTypeface = new Typeface(editor.FontFamily, FontStyle.Italic);
|
||||
}
|
||||
|
||||
protected override void ColorizeLine(DocumentLine line)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue