Make italic font chooseable
This commit is contained in:
@@ -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;
|
||||
|
||||
+22
-18
@@ -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);
|
||||
|
||||
Generated
+27
@@ -2615,6 +2615,33 @@ namespace ChatTwo.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to If enabled, uses the italic font in {0}, else it will use the ingame italic font..
|
||||
/// </summary>
|
||||
internal static string Options_Italic_Description {
|
||||
get {
|
||||
return ResourceManager.GetString("Options_Italic_Description", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Use italic font.
|
||||
/// </summary>
|
||||
internal static string Options_ItalicEnabled {
|
||||
get {
|
||||
return ResourceManager.GetString("Options_ItalicEnabled", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Italic font.
|
||||
/// </summary>
|
||||
internal static string Options_ItalicFont_Name {
|
||||
get {
|
||||
return ResourceManager.GetString("Options_ItalicFont_Name", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The font {0} will use to display Japanese text..
|
||||
/// </summary>
|
||||
|
||||
@@ -340,6 +340,12 @@
|
||||
<data name="Options_JapaneseFont_Description">
|
||||
<value>The font {0} will use to display Japanese text.</value>
|
||||
</data>
|
||||
<data name="Options_ItalicFont_Name">
|
||||
<value>Italic font</value>
|
||||
</data>
|
||||
<data name="Options_Italic_Description">
|
||||
<value>If enabled, uses the italic font in {0}, else it will use the ingame italic font.</value>
|
||||
</data>
|
||||
<data name="Options_Tabs_ChannelTypes_Special">
|
||||
<value>Special</value>
|
||||
</data>
|
||||
@@ -523,6 +529,9 @@
|
||||
<data name="Options_FontsEnabled">
|
||||
<value>Enable custom fonts</value>
|
||||
</data>
|
||||
<data name="Options_ItalicEnabled">
|
||||
<value>Use italic font</value>
|
||||
</data>
|
||||
<data name="AutoTranslate_Search_Hint">
|
||||
<value>Search Auto Translate...</value>
|
||||
</data>
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -268,11 +268,17 @@ internal static class ImGuiUtil
|
||||
return r;
|
||||
}
|
||||
|
||||
public static SingleFontChooserDialog? FontChooser(string label, SingleFontSpec font, Predicate<IFontFamilyId>? exclusion = null, string? preview = null)
|
||||
public static SingleFontChooserDialog? FontChooser(string label, SingleFontSpec font, bool checkbox, ref bool checkboxValue, Predicate<IFontFamilyId>? 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}";
|
||||
|
||||
Reference in New Issue
Block a user