generated from karashiiro/DalamudPluginProjectTemplate
-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathUiFontHandler.cs
67 lines (54 loc) · 2.38 KB
/
UiFontHandler.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// <copyright file="UiFontHandler.cs" company="lokinmodar">
// Copyright (c) lokinmodar. All rights reserved.
// Licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License license.
// </copyright>
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using ImGuiNET;
namespace Echoglossian;
public partial class Echoglossian
{
public ImFontPtr ConfigUiFont;
public static readonly string FontFileName = "NotoSans-Medium.ttf";
public bool FontLoaded;
public bool FontLoadFailed;
public GCHandle? GlyphRangeConfigText;
public GCHandle? GlyphRangeMainText;
public bool LanguageComboFontLoaded;
public bool LanguageComboFontLoadFailed;
public static string SpecialFontFileName = string.Empty;
public ImFontPtr UiFont;
private static void AdjustLanguageForFontBuild()
{
#if DEBUG
PluginLog.Debug("Inside AdjustLanguageForFontBuild method");
#endif
var lang = SelectedLanguage;
SpecialFontFileName = lang.FontName;
ScriptCharList = lang.ExclusiveCharsToAdd;
PluginLog.Debug("Lang:\n " + lang + "\nSpecialFontFileName:\n " + SpecialFontFileName + "\nScriptCharList:\n " + ScriptCharList);
}
public static void MountFontPaths()
{
AdjustLanguageForFontBuild();
SpecialFontFilePath = $@"{PluginInterface.AssemblyLocation.DirectoryName}{Path.DirectorySeparatorChar}Font{Path.DirectorySeparatorChar}{SpecialFontFileName}";
FontFilePath =
$@"{PluginInterface.AssemblyLocation.DirectoryName}{Path.DirectorySeparatorChar}Font{Path.DirectorySeparatorChar}{FontFileName}";
SymbolsFontFilePath =
$@"{PluginInterface.AssemblyLocation.DirectoryName}{Path.DirectorySeparatorChar}Font{Path.DirectorySeparatorChar}symbols.ttf";
DummyFontFilePath =
$@"{PluginInterface.AssemblyLocation.DirectoryName}{Path.DirectorySeparatorChar}Font{Path.DirectorySeparatorChar}NotoSans-Regular.ttf";
LangComboFontFilePath =
$@"{PluginInterface.AssemblyLocation.DirectoryName}{Path.DirectorySeparatorChar}Font{Path.DirectorySeparatorChar}NotoSans-Medium-Custom2.otf";
PluginLog.Debug("Fonts paths:\n " + SpecialFontFilePath + "\n " + FontFilePath + "\n " + SymbolsFontFilePath + "\n " + DummyFontFilePath);
}
private unsafe void AddCharsFromIntPtr(List<ushort> chars, ushort* ptr)
{
while (*ptr != 0)
{
chars.Add(*ptr);
ptr++;
}
}
}