mirror of
https://github.com/libretro/ppsspp.git
synced 2025-01-20 23:54:48 +00:00
Support replacement chars in sceFontGetCharInfo().
This commit is contained in:
parent
d955d9b303
commit
8f6315e375
@ -307,13 +307,18 @@ int PGF::GetCharIndex(int charCode, const std::vector<int> &charmapCompressed) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool PGF::GetCharInfo(int charCode, PGFCharInfo *charInfo) {
|
||||
bool PGF::GetCharInfo(int charCode, PGFCharInfo *charInfo, int altCharCode) {
|
||||
Glyph glyph;
|
||||
memset(charInfo, 0, sizeof(*charInfo));
|
||||
|
||||
if (!GetCharGlyph(charCode, FONT_PGF_CHARGLYPH, glyph)) {
|
||||
// Character not in font, return zeroed charInfo as on real PSP.
|
||||
return false;
|
||||
if (charCode < firstGlyph) {
|
||||
// Character not in font, return zeroed charInfo as on real PSP.
|
||||
return false;
|
||||
}
|
||||
if (!GetCharGlyph(altCharCode, FONT_PGF_CHARGLYPH, glyph)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
charInfo->bitmapWidth = glyph.w;
|
||||
|
@ -263,7 +263,7 @@ public:
|
||||
|
||||
void ReadPtr(const u8 *ptr, size_t dataSize);
|
||||
|
||||
bool GetCharInfo(int charCode, PGFCharInfo *ci);
|
||||
bool GetCharInfo(int charCode, PGFCharInfo *ci, int altCharCode);
|
||||
void GetFontInfo(PGFFontInfo *fi);
|
||||
void DrawCharacter(const GlyphImage *image, int clipX, int clipY, int clipWidth, int clipHeight, int charCode, int altCharCode, int glyphType, bool packagedFont);
|
||||
|
||||
|
@ -338,6 +338,7 @@ public:
|
||||
}
|
||||
}
|
||||
u32 args[2] = { params_.userDataAddr, (u32)handle_ };
|
||||
// TODO: The return value of this is leaking.
|
||||
__KernelDirectMipsCall(params_.freeFuncAddr, 0, args, 2, false);
|
||||
handle_ = 0;
|
||||
fonts_.clear();
|
||||
@ -825,8 +826,10 @@ int sceFontGetCharInfo(u32 fontHandle, u32 charCode, u32 charInfoPtr) {
|
||||
}
|
||||
|
||||
DEBUG_LOG(SCEFONT, "sceFontGetCharInfo(%08x, %i, %08x)", fontHandle, charCode, charInfoPtr);
|
||||
auto fontLib = font->GetFontLib();
|
||||
int altCharCode = fontLib == NULL ? -1 : fontLib->GetAltCharCode();
|
||||
auto charInfo = Memory::GetStruct<PGFCharInfo>(charInfoPtr);
|
||||
font->GetPGF()->GetCharInfo(charCode, charInfo);
|
||||
font->GetPGF()->GetCharInfo(charCode, charInfo, altCharCode);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -842,11 +845,13 @@ int sceFontGetCharImageRect(u32 fontHandle, u32 charCode, u32 charRectPtr) {
|
||||
DEBUG_LOG(SCEFONT, "sceFontGetCharImageRect(%08x, %i, %08x)", fontHandle, charCode, charRectPtr);
|
||||
if (!Memory::IsValidAddress(charRectPtr))
|
||||
return -1;
|
||||
|
||||
|
||||
PGFCharInfo charInfo;
|
||||
LoadedFont *font = GetLoadedFont(fontHandle, false);
|
||||
auto fontLib = font->GetFontLib();
|
||||
int altCharCode = fontLib == NULL ? -1 : fontLib->GetAltCharCode();
|
||||
if (font) {
|
||||
font->GetPGF()->GetCharInfo(charCode, &charInfo);
|
||||
font->GetPGF()->GetCharInfo(charCode, &charInfo, altCharCode);
|
||||
Memory::Write_U16(charInfo.bitmapWidth, charRectPtr); // character bitmap width in pixels
|
||||
Memory::Write_U16(charInfo.bitmapHeight, charRectPtr + 2); // character bitmap height in pixels
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user