Page 1 of 1

Formatting with the ReneredStringParser-tags

Posted: Wed May 12, 2010 17:39
by r0br0y
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

Re: Formatting with the ReneredStringParser-tags

Posted: Wed May 12, 2010 18:27
by agamemnus
Huh, doesn't seem like it lets me do more than one "colour" statement, here. Everything after the second statement is ignored.

Re: Formatting with the ReneredStringParser-tags

Posted: Thu May 13, 2010 09:01
by CrazyEddie
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

Re: Formatting with the ReneredStringParser-tags

Posted: Thu May 13, 2010 17:27
by r0br0y
thanks,

that really clears things up - cool feature!

Re: Formatting with the ReneredStringParser-tags

Posted: Fri May 14, 2010 15:24
by r0br0y
How do I use the padding-tag or how to define a Rect-Poperty as string?
Same for image-size

thanks

Re: Formatting with the ReneredStringParser-tags

Posted: Sat May 15, 2010 16:12
by CrazyEddie
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

Re: Formatting with the ReneredStringParser-tags

Posted: Sat May 15, 2010 20:51
by agamemnus
Hmmm, working now... I dunno what I did to make more than one colour tag not work. :?

Re: Formatting with the ReneredStringParser-tags

Posted: Mon May 31, 2010 15:49
by r0br0y
r0br0y wrote:thanks,

that really clears things up - cool feature!

:D