[Bug]Blank line in wrapped rendered string cannot display
Posted: Thu Mar 10, 2011 05:41
Crazy Eddie and CEGUI team:
I' ve taken advantage from your awesome work for a period. It' s great. And I found a small problem with BasicRenderedStringParser::appendRenderedText.
For example, when text parsing enabled, text like:
"\n\nabc"
should be displayed with two blank line and then a line "abc", but I only got the last line displayed without the two blank lines.
Soon I found this occured not only in wrapped rendered string but in all rendered string, so the title is not exactly correct.
I think it comes from BasicRenderedStringParser::appendRenderedText, as followed:
The condition (len > 0) in the code above ignores blank lines. I tried to fix it by (len >= 0) and it works.
I don't know whether it's a considered design(blank lines should be ignored) or not. I only raise it. But I found that DefaultRenderedStringParser::parse didn't ignore blank lines.
With best regards.
I' ve taken advantage from your awesome work for a period. It' s great. And I found a small problem with BasicRenderedStringParser::appendRenderedText.
For example, when text parsing enabled, text like:
"\n\nabc"
should be displayed with two blank line and then a line "abc", but I only got the last line displayed without the two blank lines.
Soon I found this occured not only in wrapped rendered string but in all rendered string, so the title is not exactly correct.
I think it comes from BasicRenderedStringParser::appendRenderedText, as followed:
Code: Select all
void BasicRenderedStringParser::appendRenderedText(RenderedString& rs,
const String& text) const
{
size_t cpos = 0;
// split the given string into lines based upon the newline character
while (text.length() > cpos)
{
// find next newline
const size_t nlpos = text.find('\n', cpos);
// calculate length of this substring
const size_t len =
((nlpos != String::npos) ? nlpos : text.length()) - cpos;
// construct new text component and append it.
if (len > 0)//here is it
{
RenderedStringTextComponent rtc(text.substr(cpos, len), d_fontName);
rtc.setPadding(d_padding);
rtc.setColours(d_colours);
rtc.setVerticalFormatting(d_vertAlignment);
rtc.setAspectLock(d_aspectLock);
rs.appendComponent(rtc);
}
// break line if needed
if (nlpos != String::npos)
rs.appendLineBreak();
// advance current position. +1 to skip the \n char
cpos += len + 1;
}
}
The condition (len > 0) in the code above ignores blank lines. I tried to fix it by (len >= 0) and it works.
I don't know whether it's a considered design(blank lines should be ignored) or not. I only raise it. But I found that DefaultRenderedStringParser::parse didn't ignore blank lines.
With best regards.