mirror of
https://github.com/moparisthebest/minetest
synced 2024-12-23 08:08:47 -05:00
Fix newline not handled to to interpreting it as invisible char
This commit is contained in:
parent
1c7cc2665b
commit
3a9cf21664
@ -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);
|
||||
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;
|
||||
}
|
||||
|
||||
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 (n > 0 && visible)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// Calculate the glyph offset.
|
||||
s32 offx = Glyphs[n-1].offset.X;
|
||||
s32 offy = (font_metrics.ascender / 64) - Glyphs[n-1].offset.Y;
|
||||
|
Loading…
Reference in New Issue
Block a user