// Open a user font in a file into a FontLib u32 sceFontOpenUserFile(u32 libHandle, const char *fileName, u32 mode, u32 errorCodePtr) { INFO_LOG(HLE, "sceFontOpenUserFile(%08x, %s, %08x, %08x)", libHandle, fileName, mode, errorCodePtr); if (!Memory::IsValidAddress(errorCodePtr)) return ERROR_FONT_INVALID_PARAMETER; PSPFileInfo info = pspFileSystem.GetFileInfo(fileName); if (!info.exists) { Memory::Write_U32(ERROR_FONT_INVALID_PARAMETER, errorCodePtr); return 0; } FontLib *fontLib = GetFontLib(libHandle); if (!fontLib) { Memory::Write_U32(ERROR_FONT_INVALID_PARAMETER, errorCodePtr); return 0; } u8 *buffer = new u8[(size_t)info.size]; u32 fileHandle = pspFileSystem.OpenFile(fileName, FILEACCESS_READ); pspFileSystem.ReadFile(fileHandle, buffer, info.size); pspFileSystem.CloseFile(fileHandle); LoadedFont *font = fontLib->OpenFont(new Font(buffer, (size_t)info.size)); if (font) { fontMap[font->Handle()] = font; Memory::Write_U32(0, errorCodePtr); return font->Handle(); } else { Memory::Write_U32(ERROR_FONT_TOO_MANY_OPEN_FONTS, errorCodePtr); return 0; } }
// Open internal font into a FontLib u32 sceFontOpen(u32 libHandle, u32 index, u32 mode, u32 errorCodePtr) { if (!Memory::IsValidAddress(errorCodePtr)) { // Would crash on the PSP. ERROR_LOG(HLE, "sceFontOpen(%x, %x, %x, %x): invalid pointer", libHandle, index, mode, errorCodePtr); return 0; } INFO_LOG(HLE, "sceFontOpen(%x, %x, %x, %x)", libHandle, index, mode, errorCodePtr); FontLib *fontLib = GetFontLib(libHandle); if (fontLib == NULL) { Memory::Write_U32(ERROR_FONT_INVALID_LIBID, errorCodePtr); return 0; } if (index >= internalFonts.size()) { Memory::Write_U32(ERROR_FONT_INVALID_PARAMETER, errorCodePtr); return 0; } LoadedFont *font = fontLib->OpenFont(internalFonts[index]); if (font) { fontMap[font->Handle()] = font; Memory::Write_U32(0, errorCodePtr); return font->Handle(); } else { Memory::Write_U32(ERROR_FONT_TOO_MANY_OPEN_FONTS, errorCodePtr); return 0; } }
int sceFontSetResolution(u32 fontLibHandle, float hRes, float vRes) { INFO_LOG(HLE, "sceFontSetResolution(%08x, %f, %f)", fontLibHandle, hRes, vRes); FontLib *fl = GetFontLib(fontLibHandle); if (fl) { fl->SetResolution(hRes, vRes); } return 0; }
int sceFontSetAltCharacterCode(u32 fontLibHandle, u32 charCode) { INFO_LOG(HLE, "sceFontSetAltCharacterCode(%08x) (%08x)", fontLibHandle, charCode); FontLib *fl = GetFontLib(fontLibHandle); if (fl) { fl->SetAltCharCode(charCode); } return 0; }
int sceFontDoneLib(u32 fontLibHandle) { INFO_LOG(HLE, "sceFontDoneLib(%08x)", fontLibHandle); FontLib *fl = GetFontLib(fontLibHandle); if (fl) { fl->Done(); } return 0; }
float sceFontPointToPixelV(int fontLibHandle, float fontPointsV, u32 errorCodePtr) { DEBUG_LOG(HLE, "sceFontPointToPixelV(%08x, %f, %08x)", fontLibHandle, fontPointsV, errorCodePtr); if (Memory::IsValidAddress(errorCodePtr)) Memory::Write_U32(0, errorCodePtr); FontLib *fl = GetFontLib(fontLibHandle); if (fl) { return fontPointsV * fl->FontVRes() / pointDPI; } return 0; }
float sceFontPixelToPointH(int fontLibHandle, float fontPixelsH, u32 errorCodePtr) { DEBUG_LOG(HLE, "sceFontPixelToPointH(%08x, %f, %08x)", fontLibHandle, fontPixelsH, errorCodePtr); if (Memory::IsValidAddress(errorCodePtr)) Memory::Write_U32(0, errorCodePtr); FontLib *fl = GetFontLib(fontLibHandle); if (fl) { return fontPixelsH * pointDPI / fl->FontHRes(); } return 0; }
float sceFontPointToPixelH(int fontLibHandle, float fontPointsH, u32 errorCodePtr) { INFO_LOG(HLE, "UNIMPL sceFontPointToPixelH(%08x, %f, %08x)", fontLibHandle, fontPointsH, errorCodePtr); if (Memory::IsValidAddress(errorCodePtr)) Memory::Write_U32(0, errorCodePtr); FontLib *fl = GetFontLib(fontLibHandle); if (fl) { return fontPointsH * fl->FontHRes() / pointDPI; } return 0; }
float sceFontPixelToPointV(int fontLibHandle, float fontPixelsV, u32 errorCodePtr) { INFO_LOG(HLE, "UNIMPL sceFontPixelToPointV(%08x, %f, %08x)", fontLibHandle, fontPixelsV, errorCodePtr); if (Memory::IsValidAddress(errorCodePtr)) Memory::Write_U32(0, errorCodePtr); FontLib *fl = GetFontLib(fontLibHandle); if (fl) { return fontPixelsV * pointDPI / fl->FontVRes(); } return 0; }
// Open a user font in RAM into a FontLib u32 sceFontOpenUserMemory(u32 libHandle, u32 memoryFontAddrPtr, u32 memoryFontLength, u32 errorCodePtr) { INFO_LOG(HLE, "sceFontOpenUserMemory %x, %x, %x, %x", libHandle, memoryFontAddrPtr, memoryFontLength, errorCodePtr); if (!Memory::IsValidAddress(errorCodePtr) || !Memory::IsValidAddress(memoryFontAddrPtr)) { Memory::Write_U32(ERROR_FONT_INVALID_PARAMETER, errorCodePtr); return 0; } FontLib *fontLib = GetFontLib(libHandle); if (!fontLib) { Memory::Write_U32(ERROR_FONT_INVALID_PARAMETER, errorCodePtr); return 0; } const u8 *fontData = Memory::GetPointer(memoryFontAddrPtr); LoadedFont *font = fontLib->OpenFont(new Font(fontData, memoryFontLength)); if (font) { fontMap[font->Handle()] = font; Memory::Write_U32(0, errorCodePtr); return font->Handle(); } else { Memory::Write_U32(ERROR_FONT_TOO_MANY_OPEN_FONTS, errorCodePtr); return 0; } }
int sceFontGetFontInfoByIndexNumber(u32 libHandle, u32 fontInfoPtr, u32 unknown, u32 fontIndex) { DEBUG_LOG(HLE, "sceFontGetFontInfoByIndexNumber(%x, %x, %i, %i)", libHandle, fontInfoPtr, unknown, fontIndex); FontLib *fl = GetFontLib(libHandle); u32 fontHandle = fl->GetFontHandle(fontIndex); return sceFontGetFontInfo(fontHandle, fontInfoPtr); }