[Bug]Blank line in wrapped rendered string cannot display

If you found a bug in our library or on our website, please report it in this section. In this forum you can also make concrete suggestions or feature requests.

Moderators: CEGUI MVP, CEGUI Team

zyjhbgd
Just popping in
Just popping in
Posts: 2
Joined: Tue Mar 01, 2011 11:10

[Bug]Blank line in wrapped rendered string cannot display

Postby zyjhbgd » 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:

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. :pint:

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: [Bug]Blank line in wrapped rendered string cannot displa

Postby CrazyEddie » Mon Mar 14, 2011 09:26

Thanks for the heads up, I will add a ticket for this and look into it some time soon.

CE

zyjhbgd
Just popping in
Just popping in
Posts: 2
Joined: Tue Mar 01, 2011 11:10

Re: [Bug]Blank line in wrapped rendered string cannot displa

Postby zyjhbgd » Wed Mar 16, 2011 02:21

I found another way for the issue that we can push the '\n' into string rather than drop it.

But I was confused with rendered string's logic to '\n':
1. '\n' is trimed when parsing.
2. There are "LineBreak"s appended into rendered string when parsing, meaning new line.
3. Some fommat characters like \n\t are trimed in split method.


Return to “Bug Reports, Suggestions, Feature Requests”

Who is online

Users browsing this forum: No registered users and 8 guests