1
0

Removed font replacement function

This commit is contained in:
Natsu 2024-06-14 06:10:57 +07:00
parent 8c1df4b2b6
commit 312a580568
Signed by: NatsumeLS
GPG Key ID: 6DB67FB460CF46C6

View File

@ -288,30 +288,6 @@ namespace GakumasLocal::HookMain {
}
}
void* fontCache = nullptr;
void* GetReplaceFont() {
static auto CreateFontFromPath = reinterpret_cast<void (*)(void* self, Il2cppString* path)>(
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<void*>();
Font_ctor->Invoke<void>(newFont);
static std::string fontName = Local::GetBasePath() / "local-files" / "gkamsZHFontMIX.otf";
CreateFontFromPath(newFont, Il2cppString::New(fontName));
fontCache = newFont;
return newFont;
}
std::unordered_set<void*> updatedFontPtrs{};
void UpdateFont(void* TMP_Text_this) {
static auto get_font = Il2cppUtils::GetMethod("Unity.TextMeshPro.dll",
@ -325,14 +301,11 @@ namespace GakumasLocal::HookMain {
"TMP_FontAsset", "UpdateFontAssetData");
auto fontAsset = get_font->Invoke<void*>(TMP_Text_this);
auto newFont = GetReplaceFont();
if (fontAsset && newFont) {
set_sourceFontFile->Invoke<void>(fontAsset, newFont);
if (!updatedFontPtrs.contains(fontAsset)) {
updatedFontPtrs.emplace(fontAsset);
UpdateFontAssetData->Invoke<void>(fontAsset);
}
}
set_font->Invoke<void>(TMP_Text_this, fontAsset);
}