Browse Source

Refactor font index changes; VS2010 can't handle multiple array refs

in the single block.
tickets/19/19/1
rarified 4 years ago
parent
commit
29948a230b
  1. 47
      Sources/Plasma/PubUtilLib/plGImage/plFont.cpp

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

@ -288,15 +288,16 @@ void plFont::IRenderString( plMipmap *mip, UInt16 x, UInt16 y, const wchar_t *st
if( justCalc ) if( justCalc )
{ {
plCharacter& ch = fCharacters[(UInt16)L' ' - fFirstChar]; UInt16 ixFC = (UInt16)L' ' - fFirstChar;
if (fCharacters.Count() <= ((UInt16)string[0] - fFirstChar)) { if (fCharacters.Count() <= ((UInt16)string[0] - fFirstChar)) {
UInt16 w = wctob(string[0]); UInt16 w = wctob((UInt16)string[0]);
if (w != EOF && (w - fFirstChar) <= fCharacters.Count()) if ((w != EOF) && (fCharacters.Count() > (w - fFirstChar)))
ch = (fCharacters[w - fFirstChar]); ixFC = w - fFirstChar;
} else { } else {
ch = (fCharacters[(UInt16)string[0] - fFirstChar]); ixFC = (UInt16)string[0] - fFirstChar;
} }
plCharacter &ch = fCharacters[ixFC];
fRenderInfo.fX = fRenderInfo.fFarthestX = x - (Int16)ch.fLeftKern; fRenderInfo.fX = fRenderInfo.fFarthestX = x - (Int16)ch.fLeftKern;
if( fRenderInfo.fX < 0 ) if( fRenderInfo.fX < 0 )
fRenderInfo.fX = 0; fRenderInfo.fX = 0;
@ -395,15 +396,17 @@ 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 // 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 // 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 // calc the first character, so adjust so we make sure we don't underflow
plCharacter& ch = fCharacters[(UInt16)L' ' - fFirstChar]; UInt16 ixFC = (UInt16)L' ' - fFirstChar;
if (fCharacters.Count() <= ((UInt16)string[0] - fFirstChar)) { if (fCharacters.Count() <= ((UInt16)string[0] - fFirstChar)) {
UInt16 w = wctob(string[0]); UInt16 w = wctob((UInt16)string[0]);
if (w != EOF && (w - fFirstChar) <= fCharacters.Count()) if ((w != EOF) && (fCharacters.Count() > (w - fFirstChar)))
ch = (fCharacters[w - fFirstChar]); ixFC = w - fFirstChar;
} else { } else {
ch = (fCharacters[(UInt16)string[0] - fFirstChar]); ixFC = (UInt16)string[0] - fFirstChar;
} }
plCharacter &ch = fCharacters[ixFC];
fRenderInfo.fMaxHeight = (Int16)fMaxCharHeight; fRenderInfo.fMaxHeight = (Int16)fMaxCharHeight;
fRenderInfo.fMaxWidth = (Int16)32767 + (Int16)ch.fLeftKern; fRenderInfo.fMaxWidth = (Int16)32767 + (Int16)ch.fLeftKern;
} }
@ -466,15 +469,17 @@ void plFont::IRenderString( plMipmap *mip, UInt16 x, UInt16 y, const wchar_t *st
} }
// handle invalid chars discretely // handle invalid chars discretely
plCharacter* charToDraw = &(fCharacters[(UInt16)L' ' - fFirstChar]); UInt16 ixFC = (UInt16)L' ' - fFirstChar;
if (fCharacters.Count() <= ((UInt16)string[i] - fFirstChar)) { if (fCharacters.Count() <= ((UInt16)string[i] - fFirstChar)) {
UInt16 w = wctob(string[i]); UInt16 w = wctob((UInt16)string[i]);
if (w != EOF && (w - fFirstChar) <= fCharacters.Count()) if ((w != EOF) && (fCharacters.Count() > (w - fFirstChar)))
charToDraw = &(fCharacters[w - fFirstChar]); ixFC = w - fFirstChar;
} else { } else {
charToDraw = &(fCharacters[(UInt16)string[i] - fFirstChar]); ixFC = (UInt16)string[i] - fFirstChar;
} }
plCharacter* charToDraw = &(fCharacters[ixFC]);
Int16 leftKern = (Int16)charToDraw->fLeftKern; Int16 leftKern = (Int16)charToDraw->fLeftKern;
if( fRenderInfo.fFlags & kRenderScaleAA ) if( fRenderInfo.fFlags & kRenderScaleAA )
x += leftKern / 2; x += leftKern / 2;
@ -603,15 +608,17 @@ void plFont::IRenderString( plMipmap *mip, UInt16 x, UInt16 y, const wchar_t *st
{ {
Int16 baseX = fRenderInfo.fX; Int16 baseX = fRenderInfo.fX;
plCharacter& ch = fCharacters[(UInt16)L' ' - fFirstChar]; UInt16 ixFC = (UInt16)L' ' - fFirstChar;
if (fCharacters.Count() <= ((UInt16)string[0] - fFirstChar)) { if (fCharacters.Count() <= ((UInt16)string[0] - fFirstChar)) {
UInt16 w = wctob(string[0]); UInt16 w = wctob((UInt16)string[0]);
if (w != EOF && (w - fFirstChar) <= fCharacters.Count()) if ((w != EOF) && (fCharacters.Count() > (w - fFirstChar)))
ch = (fCharacters[w - fFirstChar]); ixFC = w - fFirstChar;
} else { } else {
ch = (fCharacters[(UInt16)string[0] - fFirstChar]); ixFC = (UInt16)string[0] - fFirstChar;
} }
plCharacter &ch = fCharacters[ixFC];
fRenderInfo.fX -= (Int16)ch.fLeftKern; fRenderInfo.fX -= (Int16)ch.fLeftKern;
fRenderInfo.fDestPtr -= (Int16)ch.fLeftKern * fRenderInfo.fDestBPP; fRenderInfo.fDestPtr -= (Int16)ch.fLeftKern * fRenderInfo.fDestBPP;

Loading…
Cancel
Save