Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression font alignment fix #4410

Merged
merged 1 commit into from
Nov 2, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Core/Font/PGF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,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, bool original) {
void PGF::DrawCharacter(const GlyphImage *image, int clipX, int clipY, int clipWidth, int clipHeight, int charCode, int altCharCode, int glyphType, bool packagedFont) {
Glyph glyph;
if (!GetCharGlyph(charCode, glyphType, glyph)) {
// No Glyph available for this charCode, try to use the alternate char.
Expand Down Expand Up @@ -512,8 +512,8 @@ void PGF::DrawCharacter(const GlyphImage *image, int clipX, int clipY, int clipW
int pixelX = x + xx;
int pixelY = y + yy;

// Apply offset by 1px for non-original PSP fonts
if (!original)
// Apply offset by 1px for our packaged PSP fonts
if (packagedFont)
pixelX += 1;

if (pixelX >= clipX && pixelX < clipX + clipWidth && pixelY >= clipY && pixelY < clipY + clipHeight) {
Expand Down
2 changes: 1 addition & 1 deletion Core/Font/PGF.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ class PGF {

bool GetCharInfo(int charCode, PGFCharInfo *ci);
void GetFontInfo(PGFFontInfo *fi);
void DrawCharacter(const GlyphImage *image, int clipX, int clipY, int clipWidth, int clipHeight, int charCode, int altCharCode, int glyphType, bool original = true);
void DrawCharacter(const GlyphImage *image, int clipX, int clipY, int clipWidth, int clipHeight, int charCode, int altCharCode, int glyphType, bool packagedFont);

void DoState(PointerWrap &p);

Expand Down
8 changes: 4 additions & 4 deletions Core/HLE/sceFont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class LoadedFont;
class FontLib;
class Font;
int GetInternalFontIndex(Font *font);
bool original;
bool packagedFont;

// These should not need to be state saved.
static std::vector<Font *> internalFonts;
Expand Down Expand Up @@ -508,7 +508,7 @@ void __LoadInternalFonts() {
// Our provided font of jpn0.pgf has size 4367080 bytes
// This is an ugly hack to workaround incorrect metrics in it.
if (std::string(entry.fileName) == "jpn0.pgf" && (int)info.size == 4367080) {
original = false;
packagedFont = true;
}

pspFileSystem.ReadFile(handle, buffer, info.size);
Expand Down Expand Up @@ -874,7 +874,7 @@ int sceFontGetCharGlyphImage(u32 fontHandle, u32 charCode, u32 glyphImagePtr) {
DEBUG_LOG(SCEFONT, "sceFontGetCharGlyphImage(%x, %x, %x)", fontHandle, charCode, glyphImagePtr);
auto glyph = Memory::GetStruct<const GlyphImage>(glyphImagePtr);
int altCharCode = font->GetFontLib()->GetAltCharCode();
font->GetPGF()->DrawCharacter(glyph, 0, 0, 8192, 8192, charCode, altCharCode, FONT_PGF_CHARGLYPH, original);
font->GetPGF()->DrawCharacter(glyph, 0, 0, 8192, 8192, charCode, altCharCode, FONT_PGF_CHARGLYPH, packagedFont);
return 0;
}

Expand All @@ -892,7 +892,7 @@ int sceFontGetCharGlyphImage_Clip(u32 fontHandle, u32 charCode, u32 glyphImagePt
INFO_LOG(SCEFONT, "sceFontGetCharGlyphImage_Clip(%08x, %i, %08x, %i, %i, %i, %i)", fontHandle, charCode, glyphImagePtr, clipXPos, clipYPos, clipWidth, clipHeight);
auto glyph = Memory::GetStruct<const GlyphImage>(glyphImagePtr);
int altCharCode = font->GetFontLib()->GetAltCharCode();
font->GetPGF()->DrawCharacter(glyph, clipXPos, clipYPos, clipXPos + clipWidth, clipYPos + clipHeight, charCode, altCharCode, FONT_PGF_CHARGLYPH, original);
font->GetPGF()->DrawCharacter(glyph, clipXPos, clipYPos, clipXPos + clipWidth, clipYPos + clipHeight, charCode, altCharCode, FONT_PGF_CHARGLYPH, packagedFont);
return 0;
}

Expand Down