diff --git a/ChatTwo/ChatTwo.csproj b/ChatTwo/ChatTwo.csproj index 4a2ba93..2443349 100755 --- a/ChatTwo/ChatTwo.csproj +++ b/ChatTwo/ChatTwo.csproj @@ -43,6 +43,20 @@ + HellionStrings..resx) is picked up automatically by the SDK default include. Designer.cs is hand-maintained, no auto-gen needed. --> + + + + HellionFont.ttf + + + HellionFont-OFL.txt + + + diff --git a/ChatTwo/Configuration.cs b/ChatTwo/Configuration.cs index aabfaeb..74210e8 100755 --- a/ChatTwo/Configuration.cs +++ b/ChatTwo/Configuration.cs @@ -75,6 +75,12 @@ public class Configuration : IPluginConfiguration // panes more glass-like so the game shines through. Default ~92%. public float HellionThemeWindowOpacity = 0.92f; + // Use the bundled Exo 2 font (OFL-1.1) for the regular plugin font + // instead of whatever GlobalFontV2.FontId points at. Default ON so a + // fresh install gets the Hellion typography out-of-the-box; flip OFF + // to fall back to the user's chosen system or Dalamud font. + public bool UseHellionFont = true; + public int GetRetentionDays(ChatType type) { if (RetentionPerChannelDays.TryGetValue(type, out var userOverride)) @@ -255,6 +261,7 @@ public class Configuration : IPluginConfiguration FirstRunCompleted = other.FirstRunCompleted; HellionThemeEnabled = other.HellionThemeEnabled; HellionThemeWindowOpacity = other.HellionThemeWindowOpacity; + UseHellionFont = other.UseHellionFont; } } diff --git a/ChatTwo/FontManager.cs b/ChatTwo/FontManager.cs index 3f9c2e2..aa3f25f 100644 --- a/ChatTwo/FontManager.cs +++ b/ChatTwo/FontManager.cs @@ -49,6 +49,27 @@ public class FontManager } } + /// + /// Backing bytes for the bundled Hellion font (Exo 2, OFL-1.1). Lazily + /// extracted from the assembly's manifest resources on first use; the + /// load happens inside the font atlas build callback so we keep the + /// allocation off the plugin constructor's hot path. + /// + private static byte[]? HellionFontBytes; + + private static byte[] GetHellionFontBytes() + { + if (HellionFontBytes is not null) + return HellionFontBytes; + + using var stream = typeof(FontManager).Assembly.GetManifestResourceStream("HellionFont.ttf") + ?? throw new FileNotFoundException("Hellion font resource not embedded in the assembly"); + using var ms = new MemoryStream(); + stream.CopyTo(ms); + HellionFontBytes = ms.ToArray(); + return HellionFontBytes; + } + private unsafe void SetUpRanges() { ushort[] BuildRange(IReadOnlyList? chars, params nint[] ranges) @@ -121,7 +142,9 @@ public class FontManager tk => { var config = new SafeFontConfig {SizePt = Plugin.Config.GlobalFontV2.SizePt, GlyphRanges = Ranges}; - config.MergeFont = AddFontWithFallback(tk, Plugin.Config.GlobalFontV2.FontId, config, "global"); + config.MergeFont = Plugin.Config.UseHellionFont + ? tk.AddFontFromMemory(GetHellionFontBytes(), config, "Hellion-Exo2") + : AddFontWithFallback(tk, Plugin.Config.GlobalFontV2.FontId, config, "global"); config.SizePt = Plugin.Config.JapaneseFontV2.SizePt; config.GlyphRanges = JpRange; diff --git a/ChatTwo/Resources/HellionFont-OFL.txt b/ChatTwo/Resources/HellionFont-OFL.txt new file mode 100755 index 0000000..2c3a6df --- /dev/null +++ b/ChatTwo/Resources/HellionFont-OFL.txt @@ -0,0 +1,93 @@ +Copyright 2013 The Exo 2 Project Authors (https://github.com/googlefonts/Exo-2.0) + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +https://openfontlicense.org + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/ChatTwo/Resources/HellionFont.ttf b/ChatTwo/Resources/HellionFont.ttf new file mode 100755 index 0000000..2170b15 Binary files /dev/null and b/ChatTwo/Resources/HellionFont.ttf differ diff --git a/ChatTwo/Resources/HellionStrings.Designer.cs b/ChatTwo/Resources/HellionStrings.Designer.cs index b073de7..717f1c1 100644 --- a/ChatTwo/Resources/HellionStrings.Designer.cs +++ b/ChatTwo/Resources/HellionStrings.Designer.cs @@ -136,4 +136,6 @@ internal class HellionStrings internal static string Theme_Enabled_Description => Get(nameof(Theme_Enabled_Description)); internal static string Theme_WindowOpacity_Label => Get(nameof(Theme_WindowOpacity_Label)); internal static string Theme_WindowOpacity_Help => Get(nameof(Theme_WindowOpacity_Help)); + internal static string Theme_UseHellionFont_Name => Get(nameof(Theme_UseHellionFont_Name)); + internal static string Theme_UseHellionFont_Description => Get(nameof(Theme_UseHellionFont_Description)); } diff --git a/ChatTwo/Resources/HellionStrings.de.resx b/ChatTwo/Resources/HellionStrings.de.resx index 735846d..f293e5c 100644 --- a/ChatTwo/Resources/HellionStrings.de.resx +++ b/ChatTwo/Resources/HellionStrings.de.resx @@ -279,4 +279,10 @@ Wie deckend die Plugin-Fenster sind. Niedrigere Werte lassen das Spiel durchscheinen, Form-Felder und Dialoge bleiben oben drauf deckend und gut lesbar. + + Mitgelieferte Hellion-Schrift (Exo 2) verwenden + + + Rendert Chat und UI in Exo 2 (SIL Open Font License 1.1), die mit dem Plugin ausgeliefert wird. Deaktivieren, um auf die unter Einstellungen → Schrift gewählte Schriftart zurückzufallen. + diff --git a/ChatTwo/Resources/HellionStrings.resx b/ChatTwo/Resources/HellionStrings.resx index 1e2547a..37c6ad0 100644 --- a/ChatTwo/Resources/HellionStrings.resx +++ b/ChatTwo/Resources/HellionStrings.resx @@ -279,4 +279,10 @@ How opaque the plugin panes are. Lower values let the game shine through; form fields and dialogs stay opaque on top so they remain readable. + + Use the bundled Hellion font (Exo 2) + + + Renders chat and UI in Exo 2 (SIL Open Font License 1.1) which ships with the plugin. Disable to fall back to whatever font you picked under Settings → Fonts. + diff --git a/ChatTwo/Ui/Settings.cs b/ChatTwo/Ui/Settings.cs index 7976682..eed5b75 100755 --- a/ChatTwo/Ui/Settings.cs +++ b/ChatTwo/Ui/Settings.cs @@ -156,7 +156,8 @@ public sealed class SettingsWindow : Window var fontChanged = Mutable.GlobalFontV2 != Plugin.Config.GlobalFontV2 || Mutable.JapaneseFontV2 != Plugin.Config.JapaneseFontV2 || Mutable.ItalicFontV2 != Plugin.Config.ItalicFontV2 - || Mutable.ExtraGlyphRanges != Plugin.Config.ExtraGlyphRanges; + || Mutable.ExtraGlyphRanges != Plugin.Config.ExtraGlyphRanges + || Mutable.UseHellionFont != Plugin.Config.UseHellionFont; var fontSizeChanged = Math.Abs(Mutable.SymbolsFontSizeV2 - Plugin.Config.SymbolsFontSizeV2) > 0.001 || Math.Abs(Mutable.FontSizeV2 - Plugin.Config.FontSizeV2) > 0.001; var italicStateChanged = Mutable.ItalicEnabled != Plugin.Config.ItalicEnabled; diff --git a/ChatTwo/Ui/SettingsTabs/Privacy.cs b/ChatTwo/Ui/SettingsTabs/Privacy.cs index 8f5058a..aa2e226 100644 --- a/ChatTwo/Ui/SettingsTabs/Privacy.cs +++ b/ChatTwo/Ui/SettingsTabs/Privacy.cs @@ -86,6 +86,13 @@ internal sealed class Privacy : ISettingsTab Mutable.HellionThemeWindowOpacity = Math.Clamp(opacity, 0.5f, 1.0f); ImGuiUtil.HelpText(HellionStrings.Theme_WindowOpacity_Help); } + + ImGui.Spacing(); + + ImGuiUtil.OptionCheckbox( + ref Mutable.UseHellionFont, + HellionStrings.Theme_UseHellionFont_Name, + HellionStrings.Theme_UseHellionFont_Description); } ImGui.Spacing(); diff --git a/ChatTwo/images/icon.png b/ChatTwo/images/icon.png index 539f99e..c129caf 100644 Binary files a/ChatTwo/images/icon.png and b/ChatTwo/images/icon.png differ