本文整理汇总了C++中FontLib::OpenFont方法的典型用法代码示例。如果您正苦于以下问题:C++ FontLib::OpenFont方法的具体用法?C++ FontLib::OpenFont怎么用?C++ FontLib::OpenFont使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FontLib
的用法示例。
在下文中一共展示了FontLib::OpenFont方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sceFontOpenUserFile
// 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;
}
}
示例2: sceFontOpen
// 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;
}
}
示例3: sceFontOpenUserMemory
// 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;
}
}