Formatting with the ReneredStringParser-tags

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

r0br0y
Not too shy to talk
Not too shy to talk
Posts: 26
Joined: Thu Apr 08, 2010 09:36

Formatting with the ReneredStringParser-tags

Postby r0br0y » Wed May 12, 2010 17:39

Hi,

is it possible to mix different font-styles/formats inside a single text with the format-tags? E.g. a text with some bold or colored words?


thanks
rob

agamemnus
Just can't stay away
Just can't stay away
Posts: 185
Joined: Sun Mar 14, 2010 04:21

Re: Formatting with the ReneredStringParser-tags

Postby agamemnus » Wed May 12, 2010 18:27

Huh, doesn't seem like it lets me do more than one "colour" statement, here. Everything after the second statement is ignored.

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

Re: Formatting with the ReneredStringParser-tags

Postby CrazyEddie » Thu May 13, 2010 09:01

Hi,
r0br0y wrote:is it possible to mix different font-styles/formats inside a single text with the format-tags? E.g. a text with some bold or colored words?

Yes, this is perfectly possible. One key thing to be aware of is that each font size or style (i.e. bold, standard, italic) requires a separate font specification. Once you have those you can happily use any font and any colours via the formatting tags within in a string.

For example, if you have DejaVuSans-10 and DejaVuSansBold-10 as your fonts, you could set the following:

Code: Select all

"[colour='FFFF0000"][font='DejaVuSans-10']This is Red DejaVuSans font, and [colour='FF00FF00']this is green.  [colour='FF0000FF'][font='DejaVuSansBold-10']This is a different font in blue!"

and get, something similar to:
This is Red DejaVuSans font, and this is green. This is a different font in blue!


CE

r0br0y
Not too shy to talk
Not too shy to talk
Posts: 26
Joined: Thu Apr 08, 2010 09:36

Re: Formatting with the ReneredStringParser-tags

Postby r0br0y » Thu May 13, 2010 17:27

thanks,

that really clears things up - cool feature!

r0br0y
Not too shy to talk
Not too shy to talk
Posts: 26
Joined: Thu Apr 08, 2010 09:36

Re: Formatting with the ReneredStringParser-tags

Postby r0br0y » Fri May 14, 2010 15:24

How do I use the padding-tag or how to define a Rect-Poperty as string?
Same for image-size

thanks

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

Re: Formatting with the ReneredStringParser-tags

Postby CrazyEddie » Sat May 15, 2010 16:12

Ok. To recap on some of the basics of this :)

The RenderedString system as provided should be thought of as a state machine - so tags do not affect one part of the text, but rather they set some state(s) that stay in effect until either the end of the string or until some other tag changes the state.

All tags are in the form:
[tag-name='value']

value is always in single quotes.

To print a [ in the string you have to escape it with backslash. There is no need to escape the ending ]. If you're putting such things in C/C++ strings, don't forget to additionally escape the backslash character:

Code: Select all

const char* c_string = "This is escaped \\[not_a_tag]"


And, to answer your actual questions:
Generally values are in the same format as for xml / script properties.

A Rect looks like:

Code: Select all

l:<left_edge> t:<top_edge> r:<right_edge> b:<bottom_edge>

so that's l (ell), t, r and b to specify the left, top, right and bottom edges. They have to be in this order.

A Size is:

Code: Select all

w:<width> h:<height>

so, w for width and h for height. Again, the order is important.

All values are floats.

HTH

CE

agamemnus
Just can't stay away
Just can't stay away
Posts: 185
Joined: Sun Mar 14, 2010 04:21

Re: Formatting with the ReneredStringParser-tags

Postby agamemnus » Sat May 15, 2010 20:51

Hmmm, working now... I dunno what I did to make more than one colour tag not work. :?

r0br0y
Not too shy to talk
Not too shy to talk
Posts: 26
Joined: Thu Apr 08, 2010 09:36

Re: Formatting with the ReneredStringParser-tags

Postby r0br0y » Mon May 31, 2010 15:49

r0br0y wrote:thanks,

that really clears things up - cool feature!

:D


Return to “Help”

Who is online

Users browsing this forum: No registered users and 12 guests