From ea6428ae05206c15ce004425b0f2e7936c78e458 Mon Sep 17 00:00:00 2001 From: chinosk <2248589280@qq.com> Date: Thu, 21 Dec 2023 16:17:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86=E6=83=85?= =?UTF-8?q?=E5=86=B5=E4=B8=8B=E5=AD=97=E4=BD=93=E6=B8=B2=E6=9F=93=E5=8D=A1?= =?UTF-8?q?=E9=A1=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hook.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/hook.cpp b/src/hook.cpp index e2429cd..991c6e0 100644 --- a/src/hook.cpp +++ b/src/hook.cpp @@ -402,7 +402,8 @@ namespace void* (*TMP_FontAsset_CreateFontAsset)(void* font); void (*TMP_Text_set_font)(void* _this, void* fontAsset); void* (*TMP_Text_get_font)(void* _this); - void* lastUpdateFontPtr = nullptr; + // void* lastUpdateFontPtr = nullptr; + std::unordered_set updatedFontPtrs{}; void* UITextMeshProUGUI_Awake_orig; void UITextMeshProUGUI_Awake_hook(void* _this) { @@ -453,10 +454,15 @@ namespace if (replaceFont) { auto origFont = TMP_Text_get_font(_this); set_sourceFontFile(origFont, replaceFont); + if (!updatedFontPtrs.contains(origFont)) { + updatedFontPtrs.emplace(origFont); + UpdateFontAssetData(origFont); + } + /* if (origFont != lastUpdateFontPtr) { UpdateFontAssetData(origFont); lastUpdateFontPtr = origFont; - } + }*/ } reinterpret_cast(UITextMeshProUGUI_Awake_orig)(_this); }