Browse Source

Fixes incorrect assert for age sequence prefix and unicode character rendering

Prefixes can be in the 1<<15 space, not 1<<8 space.

Rendering journal book text (usually Unicode) did not check to see if the font
actually had characters present for a text character under consideration while rendering.

Put in checks that will fall back on a wctob() mapped character if available,
otherwise render a space (L' ') character.
tickets/19/19/1
rarified 4 years ago
parent
commit
a045a8d5fa
  1. 3
      Sources/Plasma/FeatureLib/pfJournalBook/pfJournalBook.cpp
  2. 4
      Sources/Plasma/PubUtilLib/plAgeDescription/plAgeDescription.cpp
  3. 34
      Sources/Plasma/PubUtilLib/plGImage/plFont.cpp

3
Sources/Plasma/FeatureLib/pfJournalBook/pfJournalBook.cpp

@ -2682,7 +2682,8 @@ void pfJournalBook::IRenderPage( UInt32 page, UInt32 whichDTMap, hsBool suppress
idx--;
break;
}
if( chunk->fText[ lastChar ] != 0 )
// careful here! We're switching between wchar_t[] indicies and std::string indicies
if( chunk->fText.c_str()[ lastChar ] != 0 )
{
// Didn't get to render the whole paragraph in this go, so we're going to cheat
// and split the paragraph up into two so that we can handle it properly. Note:

4
Sources/Plasma/PubUtilLib/plAgeDescription/plAgeDescription.cpp

@ -316,7 +316,7 @@ plLocation plAgeDescription::CalcPageLocation( const char *page ) const
{
// Combine our sequence # together
Int32 combined;
hsAssert(abs(fSeqPrefix) < 0xFF, "Age sequence prefex is out of range!"); // sequence prefix can NOT be larger or equal to 1-byte max value
hsAssert(abs(fSeqPrefix) < 0x7FFF, "Age sequence prefex is out of range!"); // sequence prefix can NOT be larger or equal to 2-byte max value
UInt32 suffix = ap->GetSeqSuffix();
hsAssert(suffix <= 0xFFFF, "Page sequence number is out of range!"); // page sequence number can NOT be larger then 2-byte max value
if( fSeqPrefix < 0 ) // we are a global age
@ -562,4 +562,4 @@ bool plAgeDescription::FindLocation(const plLocation& loc) const
return true;
}
return false;
}
}

34
Sources/Plasma/PubUtilLib/plGImage/plFont.cpp

@ -288,7 +288,14 @@ void plFont::IRenderString( plMipmap *mip, UInt16 x, UInt16 y, const wchar_t *st
if( justCalc )
{
plCharacter &ch = fCharacters[ (UInt16)string[ 0 ] - fFirstChar ];
plCharacter& ch = fCharacters[fFirstChar];
if (fCharacters.Count() <= ((UInt16)string[0] - fFirstChar))
if (wctob(string[0]) != EOF)
ch = (fCharacters[(UInt16)wctob(string[0])]);
else
ch = (fCharacters[(UInt16)L' ' - fFirstChar]);
else
ch = (fCharacters[(UInt16)string[0] - fFirstChar]);
fRenderInfo.fX = fRenderInfo.fFarthestX = x - (Int16)ch.fLeftKern;
if( fRenderInfo.fX < 0 )
fRenderInfo.fX = 0;
@ -387,7 +394,14 @@ void plFont::IRenderString( plMipmap *mip, UInt16 x, UInt16 y, const wchar_t *st
// Just calculating, no wrapping, so the max is as far as we can go
// Note: 32767 isn't quite right, since we'll be adding the left kern in before we
// calc the first character, so adjust so we make sure we don't underflow
plCharacter &ch = fCharacters[ (UInt16)(UInt8)string[ 0 ] - fFirstChar ];
plCharacter& ch = fCharacters[fFirstChar];
if (fCharacters.Count() <= ((UInt16)string[0] - fFirstChar))
if (wctob(string[0]) != EOF)
ch = (fCharacters[(UInt16)wctob(string[0])]);
else
ch = (fCharacters[(UInt16)L' ' - fFirstChar]);
else
ch = (fCharacters[(UInt16)string[0] - fFirstChar]);
fRenderInfo.fMaxHeight = (Int16)fMaxCharHeight;
fRenderInfo.fMaxWidth = (Int16)32767 + (Int16)ch.fLeftKern;
@ -453,7 +467,10 @@ void plFont::IRenderString( plMipmap *mip, UInt16 x, UInt16 y, const wchar_t *st
// handle invalid chars discretely
plCharacter* charToDraw = NULL;
if (fCharacters.Count() <= ((UInt16)string[i] - fFirstChar))
charToDraw = &(fCharacters[(UInt16)L' ' - fFirstChar]);
if (wctob(string[i]) != EOF)
charToDraw = &(fCharacters[(UInt16)wctob(string[i])]);
else
charToDraw = &(fCharacters[(UInt16)L' ' - fFirstChar]);
else
charToDraw = &(fCharacters[(UInt16)string[i] - fFirstChar]);
@ -584,8 +601,15 @@ void plFont::IRenderString( plMipmap *mip, UInt16 x, UInt16 y, const wchar_t *st
else if( ( fRenderInfo.fFlags & kRenderJustXMask ) == kRenderJustXForceLeft )
{
Int16 baseX = fRenderInfo.fX;
plCharacter &ch = fCharacters[ (UInt16)string[ 0 ] - fFirstChar ];
plCharacter& ch = fCharacters[fFirstChar];
if (fCharacters.Count() <= ((UInt16)string[0] - fFirstChar))
if (wctob(string[0]) != EOF)
ch = (fCharacters[(UInt16)wctob(string[0])]);
else
ch = (fCharacters[(UInt16)L' ' - fFirstChar]);
else
ch = (fCharacters[(UInt16)string[0] - fFirstChar]);
fRenderInfo.fX -= (Int16)ch.fLeftKern;
fRenderInfo.fDestPtr -= (Int16)ch.fLeftKern * fRenderInfo.fDestBPP;

Loading…
Cancel
Save