diff --git a/app/src/main/cpp/GakumasLocalify/Hook.cpp b/app/src/main/cpp/GakumasLocalify/Hook.cpp index 8645ace..47c44b8 100644 --- a/app/src/main/cpp/GakumasLocalify/Hook.cpp +++ b/app/src/main/cpp/GakumasLocalify/Hook.cpp @@ -288,30 +288,6 @@ namespace GakumasLocal::HookMain { } } - void* fontCache = nullptr; - void* GetReplaceFont() { - static auto CreateFontFromPath = reinterpret_cast( - Il2cppUtils::il2cpp_resolve_icall("UnityEngine.Font::Internal_CreateFontFromPath(UnityEngine.Font,System.String)") - ); - static auto Font_klass = Il2cppUtils::GetClass("UnityEngine.TextRenderingModule.dll", - "UnityEngine", "Font"); - static auto Font_ctor = Il2cppUtils::GetMethod("UnityEngine.TextRenderingModule.dll", - "UnityEngine", "Font", ".ctor"); - if (fontCache) { - if (IsNativeObjectAlive(fontCache)) { - return fontCache; - } - } - - const auto newFont = Font_klass->New(); - Font_ctor->Invoke(newFont); - - static std::string fontName = Local::GetBasePath() / "local-files" / "gkamsZHFontMIX.otf"; - CreateFontFromPath(newFont, Il2cppString::New(fontName)); - fontCache = newFont; - return newFont; - } - std::unordered_set updatedFontPtrs{}; void UpdateFont(void* TMP_Text_this) { static auto get_font = Il2cppUtils::GetMethod("Unity.TextMeshPro.dll", @@ -325,13 +301,10 @@ namespace GakumasLocal::HookMain { "TMP_FontAsset", "UpdateFontAssetData"); auto fontAsset = get_font->Invoke(TMP_Text_this); - auto newFont = GetReplaceFont(); - if (fontAsset && newFont) { - set_sourceFontFile->Invoke(fontAsset, newFont); - if (!updatedFontPtrs.contains(fontAsset)) { - updatedFontPtrs.emplace(fontAsset); - UpdateFontAssetData->Invoke(fontAsset); - } + + if (!updatedFontPtrs.contains(fontAsset)) { + updatedFontPtrs.emplace(fontAsset); + UpdateFontAssetData->Invoke(fontAsset); } set_font->Invoke(TMP_Text_this, fontAsset); }