diff --git a/Core/Font/PGF.cpp b/Core/Font/PGF.cpp index d7e926dab..23db5391e 100644 --- a/Core/Font/PGF.cpp +++ b/Core/Font/PGF.cpp @@ -323,7 +323,7 @@ int PGF::GetCharIndex(int charCode, const std::vector &charmapCompressed) { return -1; } -bool PGF::GetCharInfo(int charCode, PGFCharInfo *charInfo, int altCharCode) { +bool PGF::GetCharInfo(int charCode, PGFCharInfo *charInfo, int altCharCode) const { Glyph glyph; memset(charInfo, 0, sizeof(*charInfo)); @@ -357,7 +357,7 @@ bool PGF::GetCharInfo(int charCode, PGFCharInfo *charInfo, int altCharCode) { return true; } -void PGF::GetFontInfo(PGFFontInfo *fi) { +void PGF::GetFontInfo(PGFFontInfo *fi) const { fi->maxGlyphWidthI = header.maxSize[0]; fi->maxGlyphHeightI = header.maxSize[1]; fi->maxGlyphAscenderI = header.maxAscender; @@ -511,7 +511,7 @@ bool PGF::GetGlyph(const u8 *fontdata, size_t charPtr, int glyphType, Glyph &gly return true; } -bool PGF::GetCharGlyph(int charCode, int glyphType, Glyph &glyph) { +bool PGF::GetCharGlyph(int charCode, int glyphType, Glyph &glyph) const { if (charCode < firstGlyph) return false; charCode -= firstGlyph; @@ -530,7 +530,7 @@ bool PGF::GetCharGlyph(int charCode, int glyphType, Glyph &glyph) { return true; } -void PGF::DrawCharacter(const GlyphImage *image, int clipX, int clipY, int clipWidth, int clipHeight, int charCode, int altCharCode, int glyphType) { +void PGF::DrawCharacter(const GlyphImage *image, int clipX, int clipY, int clipWidth, int clipHeight, int charCode, int altCharCode, int glyphType) const { Glyph glyph; if (!GetCharGlyph(charCode, glyphType, glyph)) { // No Glyph available for this charCode, try to use the alternate char. @@ -556,6 +556,12 @@ void PGF::DrawCharacter(const GlyphImage *image, int clipX, int clipY, int clipW int x = image->xPos64 >> 6; int y = image->yPos64 >> 6; + // Negative means don't clip on that side. + if (clipWidth < 0) + clipWidth = glyph.w; + if (clipHeight < 0) + clipHeight = glyph.h; + while (pixelIndex < numberPixels && bitPtr + 8 < fontDataSize * 8) { // This is some kind of nibble based RLE compression. int nibble = consumeBits(4, fontData, bitPtr); @@ -624,7 +630,7 @@ void PGF::DrawCharacter(const GlyphImage *image, int clipX, int clipY, int clipW gpu->InvalidateCache(image->bufferPtr, image->bytesPerLine * image->bufHeight, GPU_INVALIDATE_SAFE); } -void PGF::SetFontPixel(u32 base, int bpl, int bufWidth, int bufHeight, int x, int y, int pixelColor, int pixelformat) { +void PGF::SetFontPixel(u32 base, int bpl, int bufWidth, int bufHeight, int x, int y, int pixelColor, int pixelformat) const { if (x < 0 || x >= bufWidth || y < 0 || y >= bufHeight) { return; } diff --git a/Core/Font/PGF.h b/Core/Font/PGF.h index c4d177b9d..4fd224c81 100644 --- a/Core/Font/PGF.h +++ b/Core/Font/PGF.h @@ -264,9 +264,9 @@ public: bool ReadPtr(const u8 *ptr, size_t dataSize); - 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 GetCharInfo(int charCode, PGFCharInfo *ci, int altCharCode) const; + void GetFontInfo(PGFFontInfo *fi) const; + void DrawCharacter(const GlyphImage *image, int clipX, int clipY, int clipWidth, int clipHeight, int charCode, int altCharCode, int glyphType) const; void DoState(PointerWrap &p); @@ -274,12 +274,12 @@ public: private: bool GetGlyph(const u8 *fontdata, size_t charPtr, int glyphType, Glyph &glyph); - bool GetCharGlyph(int charCode, int glyphType, Glyph &glyph); + bool GetCharGlyph(int charCode, int glyphType, Glyph &glyph) const; // Unused int GetCharIndex(int charCode, const std::vector &charmapCompressed); - void SetFontPixel(u32 base, int bpl, int bufWidth, int bufHeight, int x, int y, int pixelColor, int pixelformat); + void SetFontPixel(u32 base, int bpl, int bufWidth, int bufHeight, int x, int y, int pixelColor, int pixelformat) const; PGFHeaderRev3Extra rev3extra; diff --git a/Core/HLE/sceFont.cpp b/Core/HLE/sceFont.cpp index 3e2d4a076..b1eb4a4cd 100644 --- a/Core/HLE/sceFont.cpp +++ b/Core/HLE/sceFont.cpp @@ -1074,10 +1074,10 @@ int sceFontGetCharGlyphImage_Clip(u32 fontHandle, u32 charCode, u32 glyphImagePt return ERROR_FONT_INVALID_PARAMETER; } - INFO_LOG(SCEFONT, "sceFontGetCharGlyphImage_Clip(%08x, %i, %08x, %i, %i, %i, %i)", fontHandle, charCode, glyphImagePtr, clipXPos, clipYPos, clipWidth, clipHeight); + DEBUG_LOG(SCEFONT, "sceFontGetCharGlyphImage_Clip(%08x, %i, %08x, %i, %i, %i, %i)", fontHandle, charCode, glyphImagePtr, clipXPos, clipYPos, clipWidth, clipHeight); auto glyph = Memory::GetStruct(glyphImagePtr); int altCharCode = font->GetFontLib()->GetAltCharCode(); - font->GetPGF()->DrawCharacter(glyph, clipXPos, clipYPos, clipXPos + clipWidth, clipYPos + clipHeight, charCode, altCharCode, FONT_PGF_CHARGLYPH); + font->GetPGF()->DrawCharacter(glyph, clipXPos, clipYPos, clipWidth, clipHeight, charCode, altCharCode, FONT_PGF_CHARGLYPH); return 0; }