Font: Reduce internal font loading IO.
Improves startup for games that load sceFont on devices with slow storage.
This commit is contained in:
parent
4db30e7724
commit
6fd2940376
1 changed files with 17 additions and 21 deletions
|
@ -858,7 +858,7 @@ static void __LoadInternalFonts() {
|
||||||
}
|
}
|
||||||
const std::string fontPath = "flash0:/font/";
|
const std::string fontPath = "flash0:/font/";
|
||||||
const std::string fontOverridePath = "ms0:/PSP/flash0/font/";
|
const std::string fontOverridePath = "ms0:/PSP/flash0/font/";
|
||||||
const std::string userfontPath = "disc0:/PSP_GAME/USRDIR/";
|
const std::string gameFontPath = "disc0:/PSP_GAME/USRDIR/";
|
||||||
|
|
||||||
if (!pspFileSystem.GetFileInfo(fontPath).exists) {
|
if (!pspFileSystem.GetFileInfo(fontPath).exists) {
|
||||||
pspFileSystem.MkDir(fontPath);
|
pspFileSystem.MkDir(fontPath);
|
||||||
|
@ -866,14 +866,13 @@ static void __LoadInternalFonts() {
|
||||||
if ((pspFileSystem.GetFileInfo("disc0:/PSP_GAME/USRDIR/zh_gb.pgf").exists) && (pspFileSystem.GetFileInfo("disc0:/PSP_GAME/USRDIR/oldfont.prx").exists)) {
|
if ((pspFileSystem.GetFileInfo("disc0:/PSP_GAME/USRDIR/zh_gb.pgf").exists) && (pspFileSystem.GetFileInfo("disc0:/PSP_GAME/USRDIR/oldfont.prx").exists)) {
|
||||||
for (size_t i = 0; i < ARRAY_SIZE(fontRegistry); i++) {
|
for (size_t i = 0; i < ARRAY_SIZE(fontRegistry); i++) {
|
||||||
const FontRegistryEntry &entry = fontRegistry[i];
|
const FontRegistryEntry &entry = fontRegistry[i];
|
||||||
std::string fontFilename = userfontPath + entry.fileName;
|
std::string fontFilename = gameFontPath + entry.fileName;
|
||||||
PSPFileInfo info = pspFileSystem.GetFileInfo(fontFilename);
|
|
||||||
DEBUG_LOG(SCEFONT, "Loading internal font %s (%i bytes)", fontFilename.c_str(), (int)info.size);
|
|
||||||
std::vector<u8> buffer;
|
std::vector<u8> buffer;
|
||||||
if (pspFileSystem.ReadEntireFile(fontFilename, buffer) < 0) {
|
if (pspFileSystem.ReadEntireFile(fontFilename, buffer) < 0) {
|
||||||
ERROR_LOG(SCEFONT, "Failed opening font");
|
ERROR_LOG(SCEFONT, "Failed opening font %s", fontFilename.c_str());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
DEBUG_LOG(SCEFONT, "Loading internal font %s (%i bytes)", fontFilename.c_str(), (int)buffer.size());
|
||||||
internalFonts.push_back(new Font(buffer, entry));
|
internalFonts.push_back(new Font(buffer, entry));
|
||||||
DEBUG_LOG(SCEFONT, "Loaded font %s", fontFilename.c_str());
|
DEBUG_LOG(SCEFONT, "Loaded font %s", fontFilename.c_str());
|
||||||
return;
|
return;
|
||||||
|
@ -882,29 +881,26 @@ static void __LoadInternalFonts() {
|
||||||
|
|
||||||
for (size_t i = 0; i < ARRAY_SIZE(fontRegistry); i++) {
|
for (size_t i = 0; i < ARRAY_SIZE(fontRegistry); i++) {
|
||||||
const FontRegistryEntry &entry = fontRegistry[i];
|
const FontRegistryEntry &entry = fontRegistry[i];
|
||||||
std::string fontFilename = userfontPath + entry.fileName;
|
std::vector<u8> buffer;
|
||||||
PSPFileInfo info = pspFileSystem.GetFileInfo(fontFilename);
|
bool bufferRead = false;
|
||||||
|
|
||||||
if (!info.exists) {
|
std::string fontFilename = gameFontPath + entry.fileName;
|
||||||
// No user font, let's try override path.
|
bufferRead = pspFileSystem.ReadEntireFile(fontFilename, buffer) >= 0;
|
||||||
|
|
||||||
|
if (!bufferRead) {
|
||||||
|
// No game font, let's try override path.
|
||||||
fontFilename = fontOverridePath + entry.fileName;
|
fontFilename = fontOverridePath + entry.fileName;
|
||||||
info = pspFileSystem.GetFileInfo(fontFilename);
|
bufferRead = pspFileSystem.ReadEntireFile(fontFilename, buffer) >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!info.exists) {
|
if (!bufferRead) {
|
||||||
// No override, let's use the default path.
|
// No override, let's use the default path.
|
||||||
fontFilename = fontPath + entry.fileName;
|
fontFilename = fontPath + entry.fileName;
|
||||||
info = pspFileSystem.GetFileInfo(fontFilename);
|
bufferRead = pspFileSystem.ReadEntireFile(fontFilename, buffer) >= 0;
|
||||||
}
|
|
||||||
|
|
||||||
if (info.exists) {
|
|
||||||
DEBUG_LOG(SCEFONT, "Loading internal font %s (%i bytes)", fontFilename.c_str(), (int)info.size);
|
|
||||||
std::vector<u8> buffer;
|
|
||||||
if (pspFileSystem.ReadEntireFile(fontFilename, buffer) < 0) {
|
|
||||||
ERROR_LOG(SCEFONT, "Failed opening font");
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (bufferRead) {
|
||||||
|
DEBUG_LOG(SCEFONT, "Loading internal font %s (%i bytes)", fontFilename.c_str(), (int)buffer.size());
|
||||||
internalFonts.push_back(new Font(buffer, entry));
|
internalFonts.push_back(new Font(buffer, entry));
|
||||||
|
|
||||||
DEBUG_LOG(SCEFONT, "Loaded font %s", fontFilename.c_str());
|
DEBUG_LOG(SCEFONT, "Loaded font %s", fontFilename.c_str());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue