mirror of https://github.com/2dust/v2rayN
change fonts folder
parent
a704a30242
commit
238086942e
|
@ -15,8 +15,8 @@ namespace v2rayN.Converters
|
||||||
var fontFamily = LazyConfig.Instance.GetConfig().uiItem.currentFontFamily;
|
var fontFamily = LazyConfig.Instance.GetConfig().uiItem.currentFontFamily;
|
||||||
if (!string.IsNullOrEmpty(fontFamily))
|
if (!string.IsNullOrEmpty(fontFamily))
|
||||||
{
|
{
|
||||||
var fontPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Resources\Fonts\");
|
var fontPath = Utils.GetFontsPath();
|
||||||
MyFont = new FontFamily(new Uri($"file:///{fontPath}"), $"./#{fontFamily}");
|
MyFont = new FontFamily(new Uri(@$"file:///{fontPath}\"), $"./#{fontFamily}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
|
|
Binary file not shown.
|
@ -2402,7 +2402,7 @@ namespace v2rayN.Resx {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找类似 Copy the font TTF file to the directory Resources\Fonts, restart the settings 的本地化字符串。
|
/// 查找类似 Copy the font TTF file to the directory guiFonts, restart the settings 的本地化字符串。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string TbSettingsCurrentFontFamilyTip {
|
public static string TbSettingsCurrentFontFamilyTip {
|
||||||
get {
|
get {
|
||||||
|
|
|
@ -1097,7 +1097,7 @@
|
||||||
<value>FontFamily(Require restart)</value>
|
<value>FontFamily(Require restart)</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbSettingsCurrentFontFamilyTip" xml:space="preserve">
|
<data name="TbSettingsCurrentFontFamilyTip" xml:space="preserve">
|
||||||
<value>Copy the font TTF file to the directory Resources\Fonts, restart the settings</value>
|
<value>Copy the font TTF file to the directory guiFonts, restart the settings</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbSettingsSocksPortTip" xml:space="preserve">
|
<data name="TbSettingsSocksPortTip" xml:space="preserve">
|
||||||
<value>http port=socks port+1</value>
|
<value>http port=socks port+1</value>
|
||||||
|
|
|
@ -1097,7 +1097,7 @@
|
||||||
<value>当前字体(需重启)</value>
|
<value>当前字体(需重启)</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbSettingsCurrentFontFamilyTip" xml:space="preserve">
|
<data name="TbSettingsCurrentFontFamilyTip" xml:space="preserve">
|
||||||
<value>拷贝字体TTF文件到目录Resources\Fonts,重启设置</value>
|
<value>拷贝字体TTF文件到目录guiFonts,重启设置</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbSettingsSocksPortTip" xml:space="preserve">
|
<data name="TbSettingsSocksPortTip" xml:space="preserve">
|
||||||
<value>http端口=socks端口+1</value>
|
<value>http端口=socks端口+1</value>
|
||||||
|
|
|
@ -1135,6 +1135,22 @@ namespace v2rayN
|
||||||
return Path.Combine(_tempPath, filename);
|
return Path.Combine(_tempPath, filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static string GetFontsPath(string filename = "")
|
||||||
|
{
|
||||||
|
string _tempPath = Path.Combine(StartupPath(), "guiFonts");
|
||||||
|
if (!Directory.Exists(_tempPath))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(_tempPath);
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(filename))
|
||||||
|
{
|
||||||
|
return _tempPath;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Path.Combine(_tempPath, filename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
|
@ -66,23 +66,32 @@ namespace v2rayN.Views
|
||||||
//fill fonts
|
//fill fonts
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var dir = new DirectoryInfo(Utils.GetPath(@"Resources\Fonts"));
|
var dir = new DirectoryInfo(Utils.GetFontsPath());
|
||||||
var files = dir.GetFiles("*.ttf");
|
var files = dir.GetFiles("*.ttf");
|
||||||
var culture = _config.uiItem.currentLanguage.Equals(Global.Languages[0]) ? "zh-cn" : "en-us";
|
var culture = _config.uiItem.currentLanguage.Equals(Global.Languages[0]) ? "zh-cn" : "en-us";
|
||||||
foreach (var it in files)
|
foreach (var it in files)
|
||||||
{
|
{
|
||||||
var glyphTypeface = new GlyphTypeface(new Uri(Utils.GetPath(@$"Resources\Fonts\{it.Name}")));
|
var families = Fonts.GetFontFamilies(Utils.GetFontsPath(it.Name));
|
||||||
var fontFace = glyphTypeface.Win32FaceNames[new CultureInfo("en-us")];
|
foreach (FontFamily family in families)
|
||||||
if (!fontFace.Equals("Regular") && !fontFace.Equals("Normal"))
|
|
||||||
{
|
{
|
||||||
continue;
|
var typefaces = family.GetTypefaces();
|
||||||
|
foreach (Typeface typeface in typefaces)
|
||||||
|
{
|
||||||
|
typeface.TryGetGlyphTypeface(out GlyphTypeface glyph);
|
||||||
|
var fontFace = glyph.Win32FaceNames[new CultureInfo("en-us")];
|
||||||
|
if (!fontFace.Equals("Regular") && !fontFace.Equals("Normal"))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
var fontFamily = glyph.Win32FamilyNames[new CultureInfo(culture)];
|
||||||
|
if (Utils.IsNullOrEmpty(fontFamily))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
cmbcurrentFontFamily.Items.Add(fontFamily);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
var fontFamily = glyphTypeface.Win32FamilyNames[new CultureInfo(culture)];
|
|
||||||
if (Utils.IsNullOrEmpty(fontFamily))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
cmbcurrentFontFamily.Items.Add(fontFamily);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
|
@ -101,13 +101,4 @@
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Update="Resources\Fonts\SourceHanSansCN-Regular.ttf">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
<None Update="Resources\Fonts\微软雅黑.ttf">
|
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
Loading…
Reference in New Issue