mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-23 13:14:59 +00:00
refactor: setup fonts based on operating system
This commit is contained in:
parent
267c955c88
commit
2182d39e5f
6 changed files with 50 additions and 28 deletions
|
@ -1,10 +1,17 @@
|
|||
using System.Diagnostics;
|
||||
using Avalonia;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace SourceGit.Native {
|
||||
[SupportedOSPlatform("linux")]
|
||||
internal class Linux : OS.IBackend {
|
||||
public void SetupFonts(AppBuilder builder) {
|
||||
#if USE_FONT_INTER
|
||||
builder.WithInterFont();
|
||||
#endif
|
||||
}
|
||||
|
||||
public string FindGitExecutable() {
|
||||
if (File.Exists("/usr/bin/git")) return "/usr/bin/git";
|
||||
return string.Empty;
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using System.Diagnostics;
|
||||
using Avalonia;
|
||||
using Avalonia.Media;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Runtime.Versioning;
|
||||
using System.Text;
|
||||
|
@ -6,6 +8,15 @@ using System.Text;
|
|||
namespace SourceGit.Native {
|
||||
[SupportedOSPlatform("macOS")]
|
||||
internal class MacOS : OS.IBackend {
|
||||
public void SetupFonts(AppBuilder builder) {
|
||||
builder.With(new FontManagerOptions() {
|
||||
DefaultFamilyName = "PingFang SC",
|
||||
FontFallbacks = [
|
||||
new FontFallback { FontFamily = new FontFamily("PingFang SC") }
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
public string FindGitExecutable() {
|
||||
if (File.Exists("/usr/bin/git")) return "/usr/bin/git";
|
||||
return string.Empty;
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
using System;
|
||||
using Avalonia;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace SourceGit.Native {
|
||||
public static class OS {
|
||||
public interface IBackend {
|
||||
void SetupFonts(AppBuilder builder);
|
||||
|
||||
string FindGitExecutable();
|
||||
string FindVSCode();
|
||||
|
||||
|
@ -38,6 +41,10 @@ namespace SourceGit.Native {
|
|||
}
|
||||
}
|
||||
|
||||
public static void SetupFonts(AppBuilder builder) {
|
||||
_backend?.SetupFonts(builder);
|
||||
}
|
||||
|
||||
public static string FindGitExecutable() {
|
||||
return _backend?.FindGitExecutable();
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using System;
|
||||
using Avalonia;
|
||||
using Avalonia.Media;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
|
@ -11,6 +13,15 @@ namespace SourceGit.Native {
|
|||
[DllImport("shlwapi.dll", CharSet = CharSet.Unicode, SetLastError = false)]
|
||||
private static extern bool PathFindOnPath([In, Out] StringBuilder pszFile, [In] string[] ppszOtherDirs);
|
||||
|
||||
public void SetupFonts(AppBuilder builder) {
|
||||
builder.With(new FontManagerOptions() {
|
||||
DefaultFamilyName = "Microsoft YaHei UI",
|
||||
FontFallbacks = [
|
||||
new FontFallback { FontFamily = new FontFamily("Microsoft YaHei UI") }
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
public string FindGitExecutable() {
|
||||
var reg = Microsoft.Win32.RegistryKey.OpenBaseKey(
|
||||
Microsoft.Win32.RegistryHive.LocalMachine,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue