Removed font replacement function
This commit is contained in:
parent
8c1df4b2b6
commit
312a580568
@ -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{};
|
std::unordered_set<void*> updatedFontPtrs{};
|
||||||
void UpdateFont(void* TMP_Text_this) {
|
void UpdateFont(void* TMP_Text_this) {
|
||||||
static auto get_font = Il2cppUtils::GetMethod("Unity.TextMeshPro.dll",
|
static auto get_font = Il2cppUtils::GetMethod("Unity.TextMeshPro.dll",
|
||||||
@ -325,13 +301,10 @@ namespace GakumasLocal::HookMain {
|
|||||||
"TMP_FontAsset", "UpdateFontAssetData");
|
"TMP_FontAsset", "UpdateFontAssetData");
|
||||||
|
|
||||||
auto fontAsset = get_font->Invoke<void*>(TMP_Text_this);
|
auto fontAsset = get_font->Invoke<void*>(TMP_Text_this);
|
||||||
auto newFont = GetReplaceFont();
|
|
||||||
if (fontAsset && newFont) {
|
if (!updatedFontPtrs.contains(fontAsset)) {
|
||||||
set_sourceFontFile->Invoke<void>(fontAsset, newFont);
|
updatedFontPtrs.emplace(fontAsset);
|
||||||
if (!updatedFontPtrs.contains(fontAsset)) {
|
UpdateFontAssetData->Invoke<void>(fontAsset);
|
||||||
updatedFontPtrs.emplace(fontAsset);
|
|
||||||
UpdateFontAssetData->Invoke<void>(fontAsset);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
set_font->Invoke<void>(TMP_Text_this, fontAsset);
|
set_font->Invoke<void>(TMP_Text_this, fontAsset);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user