Skip to content

Commit 3a9cf21

Browse files
sapiersapier
authored andcommitted
Fix newline not handled to to interpreting it as invisible char
1 parent 1c7cc26 commit 3a9cf21

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

src/cguittfont/CGUITTFont.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -568,32 +568,32 @@ void CGUITTFont::draw(const core::stringw& text, const core::rect<s32>& position
568568
uchar32_t currentChar = *iter;
569569
n = getGlyphIndexByChar(currentChar);
570570
bool visible = (Invisible.findFirst(currentChar) == -1);
571-
if (n > 0 && visible)
571+
bool lineBreak=false;
572+
if (currentChar == L'\r') // Mac or Windows breaks
572573
{
573-
bool lineBreak=false;
574-
if (currentChar == L'\r') // Mac or Windows breaks
575-
{
576-
lineBreak = true;
577-
if (*(iter + 1) == (uchar32_t)'\n') // Windows line breaks.
578-
currentChar = *(++iter);
579-
}
580-
else if (currentChar == (uchar32_t)'\n') // Unix breaks
581-
{
582-
lineBreak = true;
583-
}
574+
lineBreak = true;
575+
if (*(iter + 1) == (uchar32_t)'\n') // Windows line breaks.
576+
currentChar = *(++iter);
577+
}
578+
else if (currentChar == (uchar32_t)'\n') // Unix breaks
579+
{
580+
lineBreak = true;
581+
}
584582

585-
if (lineBreak)
586-
{
587-
previousChar = 0;
588-
offset.Y += font_metrics.ascender / 64;
589-
offset.X = position.UpperLeftCorner.X;
583+
if (lineBreak)
584+
{
585+
previousChar = 0;
586+
offset.Y += font_metrics.ascender / 64;
587+
offset.X = position.UpperLeftCorner.X;
590588

591-
if (hcenter)
592-
offset.X += (position.getWidth() - textDimension.Width) >> 1;
593-
++iter;
594-
continue;
595-
}
589+
if (hcenter)
590+
offset.X += (position.getWidth() - textDimension.Width) >> 1;
591+
++iter;
592+
continue;
593+
}
596594

595+
if (n > 0 && visible)
596+
{
597597
// Calculate the glyph offset.
598598
s32 offx = Glyphs[n-1].offset.X;
599599
s32 offy = (font_metrics.ascender / 64) - Glyphs[n-1].offset.Y;

0 commit comments

Comments
 (0)