Skip to content

Commit

Permalink
Fix newline not handled to to interpreting it as invisible char
Browse files Browse the repository at this point in the history
  • Loading branch information
sapier authored and sapier committed Jun 19, 2014
1 parent 1c7cc26 commit 3a9cf21
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions src/cguittfont/CGUITTFont.cpp
Expand Up @@ -568,32 +568,32 @@ void CGUITTFont::draw(const core::stringw& text, const core::rect<s32>& position
uchar32_t currentChar = *iter;
n = getGlyphIndexByChar(currentChar);
bool visible = (Invisible.findFirst(currentChar) == -1);
if (n > 0 && visible)
bool lineBreak=false;
if (currentChar == L'\r') // Mac or Windows breaks
{
bool lineBreak=false;
if (currentChar == L'\r') // Mac or Windows breaks
{
lineBreak = true;
if (*(iter + 1) == (uchar32_t)'\n') // Windows line breaks.
currentChar = *(++iter);
}
else if (currentChar == (uchar32_t)'\n') // Unix breaks
{
lineBreak = true;
}
lineBreak = true;
if (*(iter + 1) == (uchar32_t)'\n') // Windows line breaks.
currentChar = *(++iter);
}
else if (currentChar == (uchar32_t)'\n') // Unix breaks
{
lineBreak = true;
}

if (lineBreak)
{
previousChar = 0;
offset.Y += font_metrics.ascender / 64;
offset.X = position.UpperLeftCorner.X;
if (lineBreak)
{
previousChar = 0;
offset.Y += font_metrics.ascender / 64;
offset.X = position.UpperLeftCorner.X;

if (hcenter)
offset.X += (position.getWidth() - textDimension.Width) >> 1;
++iter;
continue;
}
if (hcenter)
offset.X += (position.getWidth() - textDimension.Width) >> 1;
++iter;
continue;
}

if (n > 0 && visible)
{
// Calculate the glyph offset.
s32 offx = Glyphs[n-1].offset.X;
s32 offy = (font_metrics.ascender / 64) - Glyphs[n-1].offset.Y;
Expand Down

0 comments on commit 3a9cf21

Please sign in to comment.