feat: add japanese system fonts
This commit is contained in:
+2
-4
@@ -168,11 +168,9 @@ internal sealed class PluginUi : IDisposable {
|
|||||||
null
|
null
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
jpFontData = Fonts.GetFont(this.Plugin.Config.JapaneseFont, false);
|
||||||
}
|
}
|
||||||
// else {
|
|
||||||
// jpFontData = Fonts.GetFont(this.Plugin.Config.JapaneseFont, false, CharacterSet.SHIFTJIS_CHARSET);
|
|
||||||
// PluginLog.Log($"data.Regular.Length: {jpFontData?.Regular.Length}");
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (jpFontData == null) {
|
if (jpFontData == null) {
|
||||||
this.Plugin.Config.JapaneseFont = Fonts.JapaneseFonts[0].Item1;
|
this.Plugin.Config.JapaneseFont = Fonts.JapaneseFonts[0].Item1;
|
||||||
|
|||||||
+25
-10
@@ -45,7 +45,7 @@ internal static class Fonts {
|
|||||||
var anyItalic = false;
|
var anyItalic = false;
|
||||||
for (var j = 0; j < family.FontCount; j++) {
|
for (var j = 0; j < family.FontCount; j++) {
|
||||||
using var font = family.GetFont(j);
|
using var font = family.GetFont(j);
|
||||||
if (font.Style is not (FontStyle.Italic or FontStyle.Oblique)) {
|
if (font.IsSymbolFont || font.Style is not (FontStyle.Italic or FontStyle.Oblique)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,16 +67,31 @@ internal static class Fonts {
|
|||||||
|
|
||||||
internal static List<string> GetJpFonts() {
|
internal static List<string> GetJpFonts() {
|
||||||
var fonts = new List<string>();
|
var fonts = new List<string>();
|
||||||
// using var g = Graphics.FromImage(new Bitmap(1, 1));
|
|
||||||
// foreach (var (lpelfe, _, fontType) in Gdi32.EnumFontFamiliesEx(g.GetHdc(), CharacterSet.SHIFTJIS_CHARSET)) {
|
|
||||||
// var name = lpelfe.elfEnumLogfontEx.elfLogFont.lfFaceName;
|
|
||||||
// if (name.StartsWith("@")) {
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// fonts.Add(name);
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
using var factory = new Factory();
|
||||||
|
using var collection = factory.GetSystemFontCollection(false);
|
||||||
|
for (var i = 0; i < collection.FontFamilyCount; i++) {
|
||||||
|
using var family = collection.GetFontFamily(i);
|
||||||
|
var probablyJp = false;
|
||||||
|
for (var j = 0; j < family.FontCount; j++) {
|
||||||
|
using var font = family.GetFont(j);
|
||||||
|
if (!font.HasCharacter('日') || font.IsSymbolFont) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
probablyJp = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!probablyJp) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var name = family.FamilyNames.GetString(0);
|
||||||
|
fonts.Add(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
fonts.Sort();
|
||||||
return fonts;
|
return fonts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,17 +69,17 @@ public class Fonts : ISettingsTab {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ImGui.Separator();
|
ImGui.Separator();
|
||||||
//
|
|
||||||
// foreach (var family in this.JpFonts) {
|
foreach (var family in this.JpFonts) {
|
||||||
// if (ImGui.Selectable(family, this.Mutable.JapaneseFont == family)) {
|
if (ImGui.Selectable(family, this.Mutable.JapaneseFont == family)) {
|
||||||
// this.Mutable.JapaneseFont = family;
|
this.Mutable.JapaneseFont = family;
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// if (ImGui.IsWindowAppearing() && this.Mutable.JapaneseFont == family) {
|
if (ImGui.IsWindowAppearing() && this.Mutable.JapaneseFont == family) {
|
||||||
// ImGui.SetScrollHereY(0.5f);
|
ImGui.SetScrollHereY(0.5f);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
ImGui.EndCombo();
|
ImGui.EndCombo();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user