Seperate matcher from font manager.

This commit is contained in:
2023-02-05 15:53:30 +08:00
parent 6d0fd0f9ec
commit 84b7a6d183
5 changed files with 351 additions and 196 deletions

View File

@@ -11,17 +11,17 @@ namespace Cryville.Common.Unity.UI {
[RequireComponent(typeof(TextMeshProUGUI))]
public class TMPAutoFont : MonoBehaviour {
public static Shader DefaultShader;
public static FontManager FontManager;
public static FontMatcher FontMatcher;
static FontAsset _font;
TextMeshProUGUI _text;
[SerializeField]
Shader m_shader;
void Awake() {
if (FontManager == null) return;
if (FontMatcher == null) return;
_text = GetComponent<TextMeshProUGUI>();
if (_font == null) {
foreach (var typeface in FontManager.MatchScript()) {
foreach (var typeface in FontMatcher.MatchScript(null, true)) {
try {
var _ifont = new IFont(typeface.File.FullName);
_font = (FontAsset)typeof(FontAsset).GetMethod("CreateFontAsset", BindingFlags.Static | BindingFlags.NonPublic, null, new Type[] { typeof(IFont), typeof(int), typeof(int), typeof(int), typeof(GlyphRenderMode), typeof(int), typeof(int), typeof(AtlasPopulationMode), typeof(bool) },