mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-29 09:32:45 +00:00
Avoid overflow when handling output characters (bug #4676)
This commit is contained in:
parent
c45ec9171b
commit
dad0b78901
@ -506,7 +506,7 @@ struct TypesetBookImpl::Typesetter : BookTypesetter
|
||||
while (!stream.eof () && !ucsLineBreak (stream.peek ()) && ucsBreakingSpace (stream.peek ()))
|
||||
{
|
||||
MWGui::GlyphInfo info = GlyphInfo(style->mFont, stream.peek());
|
||||
if (info.codePoint >= 0)
|
||||
if (info.charFound)
|
||||
space_width += static_cast<int>(info.advance + info.bearingX);
|
||||
stream.consume ();
|
||||
}
|
||||
@ -516,7 +516,7 @@ struct TypesetBookImpl::Typesetter : BookTypesetter
|
||||
while (!stream.eof () && !ucsLineBreak (stream.peek ()) && !ucsBreakingSpace (stream.peek ()))
|
||||
{
|
||||
MWGui::GlyphInfo info = GlyphInfo(style->mFont, stream.peek());
|
||||
if (info.codePoint >= 0)
|
||||
if (info.charFound)
|
||||
word_width += static_cast<int>(info.advance + info.bearingX);
|
||||
stream.consume ();
|
||||
}
|
||||
@ -765,7 +765,7 @@ namespace
|
||||
{
|
||||
MWGui::GlyphInfo info = GlyphInfo(mFont, ch);
|
||||
|
||||
if (info.codePoint < 0)
|
||||
if (!info.charFound)
|
||||
return;
|
||||
|
||||
MyGUI::FloatRect vr;
|
||||
@ -787,7 +787,7 @@ namespace
|
||||
{
|
||||
MWGui::GlyphInfo info = GlyphInfo(mFont, ch);
|
||||
|
||||
if (info.codePoint >= 0)
|
||||
if (info.charFound)
|
||||
mCursor.left += static_cast<int>(info.bearingX + info.advance);
|
||||
}
|
||||
|
||||
|
@ -43,6 +43,7 @@ namespace MWGui
|
||||
float advance;
|
||||
float bearingX;
|
||||
float bearingY;
|
||||
bool charFound;
|
||||
MyGUI::FloatRect uvRect;
|
||||
|
||||
GlyphInfo(MyGUI::IFont* font, MyGUI::Char ch)
|
||||
@ -61,15 +62,17 @@ namespace MWGui
|
||||
height = (int) gi->height / scale;
|
||||
advance = (int) gi->advance / scale;
|
||||
uvRect = gi->uvRect;
|
||||
charFound = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
codePoint = -1;
|
||||
codePoint = 0;
|
||||
bearingX = 0;
|
||||
bearingY = 0;
|
||||
width = 0;
|
||||
height = 0;
|
||||
advance = 0;
|
||||
charFound = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user