From cb5954c9e31010edc5fa08f7ea8b4ccf73971a10 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 7 Aug 2021 17:36:29 -0700 Subject: [PATCH] Font: Delay only on first open of internal font. --- Core/HLE/sceFont.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Core/HLE/sceFont.cpp b/Core/HLE/sceFont.cpp index f6dfa4631d..80b4a716b3 100644 --- a/Core/HLE/sceFont.cpp +++ b/Core/HLE/sceFont.cpp @@ -579,6 +579,13 @@ public: return fonts_[index]; } + int GetFontRefCount(Font *font) const { + int foundFontIndex = FindExistingIndex(font); + if (foundFontIndex >= 0) + return fontRefCount_.at(foundFontIndex); + return 0; + } + // For FONT_OPEN_USER* modes, the font will automatically be freed. LoadedFont *OpenFont(Font *font, FontOpenMode mode, int &error) { // TODO: Do something with mode, possibly save it where the PSP does in the struct. @@ -1033,10 +1040,12 @@ static u32 sceFontOpen(u32 libHandle, u32 index, u32 mode, u32 errorCodePtr) { LoadedFont *font = fontLib->OpenFont(internalFonts[index], openMode, *errorCode); if (font) { *errorCode = 0; - return hleDelayResult(font->Handle(), "font open", 10000); - } else { - return 0; + // Delay only on the first open. + if (fontLib->GetFontRefCount(internalFonts[index]) == 1) + return hleDelayResult(font->Handle(), "font open", 10000); + return font->Handle(); } + return 0; } // Open a user font in RAM into a FontLib