diff --git a/ChatTwo/Configuration.cs b/ChatTwo/Configuration.cs index fd9cd78..3ba9400 100755 --- a/ChatTwo/Configuration.cs +++ b/ChatTwo/Configuration.cs @@ -85,7 +85,8 @@ internal class Configuration : IPluginConfiguration public float SymbolsFontSizeV2 = 12.75f; public SingleFontSpec GlobalFontV2 = new() { - FontId = new DalamudAssetFontAndFamilyId(DalamudAsset.NotoSansKrRegular), // dalamud only ships KR as regular, which chat2 used previously for global fonts + // dalamud only ships KR as regular, which chat2 used previously for global fonts + FontId = new DalamudAssetFontAndFamilyId(DalamudAsset.NotoSansKrRegular), SizePt = 12.75f, }; public SingleFontSpec JapaneseFontV2 = new() @@ -93,6 +94,12 @@ internal class Configuration : IPluginConfiguration FontId = new DalamudAssetFontAndFamilyId(DalamudAsset.NotoSansJpMedium), SizePt = 12.75f, }; + public bool ItalicEnabled = false; + public SingleFontSpec ItalicFontV2 = new() + { + FontId = new DalamudAssetFontAndFamilyId(DalamudAsset.NotoSansKrRegular), + SizePt = 12.75f, + }; // TODO Remove after 24.08 public float FontSize = 17f; @@ -159,10 +166,12 @@ internal class Configuration : IPluginConfiguration ShowEmotes = other.ShowEmotes; BlockedEmotes = other.BlockedEmotes; FontsEnabled = other.FontsEnabled; + ItalicEnabled = other.ItalicEnabled; ExtraGlyphRanges = other.ExtraGlyphRanges; FontSizeV2 = other.FontSizeV2; GlobalFontV2 = other.GlobalFontV2; JapaneseFontV2 = other.JapaneseFontV2; + ItalicFontV2 = other.ItalicFontV2; SymbolsFontSizeV2 = other.SymbolsFontSizeV2; TooltipOffset = other.TooltipOffset; WindowAlpha = other.WindowAlpha; diff --git a/ChatTwo/FontManager.cs b/ChatTwo/FontManager.cs index a05597d..88877ba 100644 --- a/ChatTwo/FontManager.cs +++ b/ChatTwo/FontManager.cs @@ -130,27 +130,31 @@ public class FontManager } )); - // load italic version if it exists, else default to regular - ItalicFont = Plugin.Interface.UiBuilder.FontAtlas.NewDelegateFontHandle( - e => e.OnPreBuild( - tk => - { - var italicVersion = Plugin.Config.GlobalFontV2.FontId.Family.Fonts.FirstOrDefault(f => f.EnglishName.Contains("Italic")); + if (Plugin.Config.ItalicEnabled) + { + ItalicFont = Plugin.Interface.UiBuilder.FontAtlas.NewDelegateFontHandle( + e => e.OnPreBuild( + tk => + { + var config = new SafeFontConfig {SizePt = Plugin.Config.GlobalFontV2.SizePt, GlyphRanges = Ranges}; + config.MergeFont = Plugin.Config.ItalicFontV2.FontId.AddToBuildToolkit(tk, config); - var config = new SafeFontConfig {SizePt = Plugin.Config.GlobalFontV2.SizePt, GlyphRanges = Ranges}; - config.MergeFont = italicVersion?.AddToBuildToolkit(tk, config) ?? Plugin.Config.GlobalFontV2.FontId.AddToBuildToolkit(tk, config); + config.SizePt = Plugin.Config.JapaneseFontV2.SizePt; + config.GlyphRanges = JpRange; + Plugin.Config.JapaneseFontV2.FontId.AddToBuildToolkit(tk, config); - config.SizePt = Plugin.Config.JapaneseFontV2.SizePt; - config.GlyphRanges = JpRange; - Plugin.Config.JapaneseFontV2.FontId.AddToBuildToolkit(tk, config); + config.SizePt = Plugin.Config.SymbolsFontSizeV2; + config.GlyphRanges = SymRange; + tk.AddFontFromMemory(GameSymFont, config, "ChatTwo2 Sym Font"); - config.SizePt = Plugin.Config.SymbolsFontSizeV2; - config.GlyphRanges = SymRange; - tk.AddFontFromMemory(GameSymFont, config, "ChatTwo2 Sym Font"); - - tk.Font = config.MergeFont; - } - )); + tk.Font = config.MergeFont; + } + )); + } + else + { + ItalicFont = null; + } } public static float SizeInPt(float px) => (float) (px * 3.0 / 4.0); diff --git a/ChatTwo/Resources/Language.Designer.cs b/ChatTwo/Resources/Language.Designer.cs index d1336b9..ef0a905 100755 --- a/ChatTwo/Resources/Language.Designer.cs +++ b/ChatTwo/Resources/Language.Designer.cs @@ -2615,6 +2615,33 @@ namespace ChatTwo.Resources { } } + /// + /// Looks up a localized string similar to If enabled, uses the italic font in {0}, else it will use the ingame italic font.. + /// + internal static string Options_Italic_Description { + get { + return ResourceManager.GetString("Options_Italic_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Use italic font. + /// + internal static string Options_ItalicEnabled { + get { + return ResourceManager.GetString("Options_ItalicEnabled", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Italic font. + /// + internal static string Options_ItalicFont_Name { + get { + return ResourceManager.GetString("Options_ItalicFont_Name", resourceCulture); + } + } + /// /// Looks up a localized string similar to The font {0} will use to display Japanese text.. /// diff --git a/ChatTwo/Resources/Language.resx b/ChatTwo/Resources/Language.resx index 4a457e4..6b2f386 100644 --- a/ChatTwo/Resources/Language.resx +++ b/ChatTwo/Resources/Language.resx @@ -340,6 +340,12 @@ The font {0} will use to display Japanese text. + + Italic font + + + If enabled, uses the italic font in {0}, else it will use the ingame italic font. + Special @@ -523,6 +529,9 @@ Enable custom fonts + + Use italic font + Search Auto Translate... diff --git a/ChatTwo/Ui/SettingsTabs/Fonts.cs b/ChatTwo/Ui/SettingsTabs/Fonts.cs index 7cbd869..910e4e7 100755 --- a/ChatTwo/Ui/SettingsTabs/Fonts.cs +++ b/ChatTwo/Ui/SettingsTabs/Fonts.cs @@ -31,7 +31,7 @@ public class Fonts : ISettingsTab } else { - var globalChooser = ImGuiUtil.FontChooser(Language.Options_Font_Name, Mutable.GlobalFontV2); + var globalChooser = ImGuiUtil.FontChooser(Language.Options_Font_Name, Mutable.GlobalFontV2, false, ref _); globalChooser?.ResultTask.ContinueWith(r => { if (r.IsCompletedSuccessfully) @@ -47,7 +47,7 @@ public class Fonts : ISettingsTab ImGui.Spacing(); // LocaleNames being null means it is likely a game font which all support JP symbols - var japaneseChooser = ImGuiUtil.FontChooser(Language.Options_JapaneseFont_Name, Mutable.JapaneseFontV2, id => !id.LocaleNames?.ContainsKey("ja-jp") ?? false, "いろはにほへと ちりぬるを"); + var japaneseChooser = ImGuiUtil.FontChooser(Language.Options_JapaneseFont_Name, Mutable.JapaneseFontV2, false, ref _, id => !id.LocaleNames?.ContainsKey("ja-jp") ?? false, "いろはにほへと ちりぬるを"); japaneseChooser?.ResultTask.ContinueWith(r => { if (r.IsCompletedSuccessfully) @@ -61,6 +61,19 @@ public class Fonts : ISettingsTab ImGuiUtil.HelpText(string.Format(Language.Options_JapaneseFont_Description, Plugin.PluginName)); ImGui.Spacing(); + var italicChooser = ImGuiUtil.FontChooser(Language.Options_ItalicFont_Name, Mutable.ItalicFontV2, true, ref Mutable.ItalicEnabled); + italicChooser?.ResultTask.ContinueWith(r => + { + if (r.IsCompletedSuccessfully) + Mutable.ItalicFontV2 = r.Result; + }); + ImGui.SameLine(); + if (ImGui.Button("Reset##italic")) + Mutable.ItalicFontV2 = new SingleFontSpec{ FontId = new DalamudAssetFontAndFamilyId(DalamudAsset.NotoSansKrRegular), SizePt = 12.75f }; + + ImGuiUtil.HelpText(string.Format(Language.Options_Italic_Description, Plugin.PluginName)); + ImGui.Spacing(); + if (ImGui.CollapsingHeader(Language.Options_ExtraGlyphs_Name)) { ImGuiUtil.HelpText(string.Format(Language.Options_ExtraGlyphs_Description, Plugin.PluginName)); diff --git a/ChatTwo/Util/ImGuiUtil.cs b/ChatTwo/Util/ImGuiUtil.cs index 2d6ce14..30a261c 100755 --- a/ChatTwo/Util/ImGuiUtil.cs +++ b/ChatTwo/Util/ImGuiUtil.cs @@ -268,11 +268,17 @@ internal static class ImGuiUtil return r; } - public static SingleFontChooserDialog? FontChooser(string label, SingleFontSpec font, Predicate? exclusion = null, string? preview = null) + public static SingleFontChooserDialog? FontChooser(string label, SingleFontSpec font, bool checkbox, ref bool checkboxValue, Predicate? exclusion = null, string? preview = null) { using var id = ImRaii.PushId(label); ImGui.TextUnformatted(label); + if (checkbox) + { + ImGui.Checkbox("##enabled", ref checkboxValue); + ImGui.SameLine(); + } + var fontFamily = font.FontId.Family.EnglishName; var fontStyle = font.FontId.EnglishName; fontStyle = fontStyle.Equals(fontFamily) ? "" : $" - {fontStyle}";