Browse Source

Optimization on wctob() calls, and check that even the ascii index is valid

tickets/19/19/1
rarified 4 years ago
parent
commit
6546d39c31
  1. 20
      Sources/Plasma/PubUtilLib/plGImage/plFont.cpp

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

@ -290,8 +290,9 @@ void plFont::IRenderString( plMipmap *mip, UInt16 x, UInt16 y, const wchar_t *st
{ {
plCharacter& ch = fCharacters[(UInt16)L' ' - fFirstChar]; plCharacter& ch = fCharacters[(UInt16)L' ' - fFirstChar];
if (fCharacters.Count() <= ((UInt16)string[0] - fFirstChar)) { if (fCharacters.Count() <= ((UInt16)string[0] - fFirstChar)) {
if (wctob(string[0]) != EOF) UInt16 w = wctob(string[0]);
ch = (fCharacters[(UInt16)wctob(string[0]) - fFirstChar]); if (w != EOF && (w - fFirstChar) <= fCharacters.Count())
ch = (fCharacters[w - fFirstChar]);
} else { } else {
ch = (fCharacters[(UInt16)string[0] - fFirstChar]); ch = (fCharacters[(UInt16)string[0] - fFirstChar]);
} }
@ -396,8 +397,9 @@ void plFont::IRenderString( plMipmap *mip, UInt16 x, UInt16 y, const wchar_t *st
// 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]; plCharacter& ch = fCharacters[(UInt16)L' ' - fFirstChar];
if (fCharacters.Count() <= ((UInt16)string[0] - fFirstChar)) { if (fCharacters.Count() <= ((UInt16)string[0] - fFirstChar)) {
if (wctob(string[0]) != EOF) UInt16 w = wctob(string[0]);
ch = (fCharacters[(UInt16)wctob(string[0]) - fFirstChar]); if (w != EOF && (w - fFirstChar) <= fCharacters.Count())
ch = (fCharacters[w - fFirstChar]);
} else { } else {
ch = (fCharacters[(UInt16)string[0] - fFirstChar]); ch = (fCharacters[(UInt16)string[0] - fFirstChar]);
} }
@ -466,8 +468,9 @@ 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]); plCharacter* charToDraw = &(fCharacters[(UInt16)L' ' - fFirstChar]);
if (fCharacters.Count() <= ((UInt16)string[i] - fFirstChar)) { if (fCharacters.Count() <= ((UInt16)string[i] - fFirstChar)) {
if (wctob(string[i]) != EOF) UInt16 w = wctob(string[0]);
charToDraw = &(fCharacters[(UInt16)wctob(string[i]) - fFirstChar]); if (w != EOF && (w - fFirstChar) <= fCharacters.Count())
ch = (fCharacters[w - fFirstChar]);
} else { } else {
charToDraw = &(fCharacters[(UInt16)string[i] - fFirstChar]); charToDraw = &(fCharacters[(UInt16)string[i] - fFirstChar]);
} }
@ -602,8 +605,9 @@ void plFont::IRenderString( plMipmap *mip, UInt16 x, UInt16 y, const wchar_t *st
plCharacter& ch = fCharacters[(UInt16)L' ' - fFirstChar]; plCharacter& ch = fCharacters[(UInt16)L' ' - fFirstChar];
if (fCharacters.Count() <= ((UInt16)string[0] - fFirstChar)) { if (fCharacters.Count() <= ((UInt16)string[0] - fFirstChar)) {
if (wctob(string[0]) != EOF) UInt16 w = wctob(string[0]);
ch = (fCharacters[(UInt16)wctob(string[0]) - fFirstChar]); if (w != EOF && (w - fFirstChar) <= fCharacters.Count())
ch = (fCharacters[w - fFirstChar]);
} else { } else {
ch = (fCharacters[(UInt16)string[0] - fFirstChar]); ch = (fCharacters[(UInt16)string[0] - fFirstChar]);
} }

Loading…
Cancel
Save