Check for non-indexed glyph advance values.

This change from JPCSP:
http://code.google.com/p/jpcsp/source/detail?r=3350
This commit is contained in:
Unknown W. Brackets 2013-11-16 18:35:15 -08:00
parent 2d7741a433
commit e77b8bc5b5
2 changed files with 17 additions and 6 deletions

View File

@ -335,7 +335,7 @@ bool PGF::GetGlyph(const u8 *fontdata, size_t charPtr, int glyphType, Glyph &gly
glyph.flags = getBits(6, fontdata, charPtr);
charPtr += 6;
if (glyph.flags & FONT_PGF_CHARGLYPH) {
if (glyphType == FONT_PGF_CHARGLYPH) {
// Skip magic number
charPtr += 7;
@ -419,12 +419,22 @@ bool PGF::GetGlyph(const u8 *fontdata, size_t charPtr, int glyphType, Glyph &gly
charPtr += 32;
}
int advanceIndex = getBits(8, fontdata, charPtr);
charPtr += 8;
if ((glyph.flags & FONT_PGF_METRIC_ADVANCE_INDEX) == FONT_PGF_METRIC_ADVANCE_INDEX)
{
int advanceIndex = getBits(8, fontdata, charPtr);
charPtr += 8;
if (advanceIndex < header.advanceTableLength) {
glyph.advanceH = advanceTable[0][advanceIndex];
glyph.advanceV = advanceTable[1][advanceIndex];
if (advanceIndex < header.advanceTableLength) {
glyph.advanceH = advanceTable[0][advanceIndex];
glyph.advanceV = advanceTable[1][advanceIndex];
}
}
else
{
glyph.advanceH = getBits(32, fontdata, charPtr);
charPtr += 32;
glyph.advanceV = getBits(32, fontdata, charPtr);
charPtr += 32;
}
} else {
glyph.shadowID = 65535;

View File

@ -39,6 +39,7 @@ enum {
FONT_PGF_METRIC_DIMENSION_INDEX = 0x04,
FONT_PGF_METRIC_BEARING_X_INDEX = 0x08,
FONT_PGF_METRIC_BEARING_Y_INDEX = 0x10,
FONT_PGF_METRIC_ADVANCE_INDEX = 0x20,
FONT_PGF_CHARGLYPH = 0x20,
FONT_PGF_SHADOWGLYPH = 0x40,
};