The Richtext Tags¶
For an introduction to our richtext system including a code example, see The Widelands Rich Text System.
Rich Text – <rt>¶
The main wrapper that will signal to the font renderer to go into richtext mode. This tag surrounds your whole text, and is allowed only once. You can also set some options here what will affect your whole text.
Attributes¶
padding: The rectangle of this tag is shrunk so leave a gap on its outside, on all four outer edges.
padding_r: Padding on the right-hand side
padding_l: Padding on the left-hand side
padding_b: Padding on the bottom
padding_t: Padding on the top
background: Give this tag’s rectangle a background color as a hex value.
keep_spaces: Do now trim away trailing and double spaces. Use this where the user is editing text.
db_show_spaces: Highlight all blank spaces for debugging purposes.
Sub-tags¶
Division – <div>¶
This tag defines a rectangle and can be used as a layout control.
Attributes¶
The same attributes as Rich Text – <rt>, plus the following:
margin: Shrink all contents to leave a margin towards the outer edge of this tag’s rectangle.
float: Make text float around this div. Allowed values are
left
,right
. The structure has to be something like:div("width=100%", div("float=left padding_r=6", p(img(imagepath))) .. p(text))
, with the first embedded div being the floating one.valign: Align the contents vertically. Allowed values are
top
(default),center
ormiddle
,bottom
.width: The width of this element, as a pixel amount, or as a percentage. The last
div
in a row can be expanded automatically by using*
.
Sub-tags¶
Line Break – <br>¶
A single line break. Use sparingly for things like poetry stanzas. If you are starting a new paragraph, use Paragraph – <p> instead.
Horizontal Space – <space>¶
Inserts a horizontal gap between the previous and the following text. This space can be filled with a character of your choice.
Attributes¶
gap: The size of the gap as a pixel amount
fill: A character to fill the gap with
Vertical Space – <vspace>¶
Inserts a vertical gap between the previous and the following text.
Attributes¶
gap: The size of the gap as a pixel amount
Paragraph – <p>¶
This tag encloses a text paragraph.
Attributes¶
indent: Adds an indent to the first line of the paragraph
align: The horizontal alignment for the paragraph’s text. Allowed values are
left
(default),center
ormiddle
,right
.valign: See Division – <div>
spacing: Vertical line spacing as a pixel value
Sub-tags¶
Font – <font>¶
This tag defines the font style for the enclosed text.
Attributes¶
size: The font size as a pixel value
face: The font face. Allowed values are
sans
(default),serif
andcondensed
.color: The font color as a hex value
bold: Make the text bold
italic: Make the text italic
underline: Underline the text
shadow: Add a background shadow
ref: To be implemented
Sub-tags¶
Link – <link>¶
This tag defines a clickable hyperlink.
Attributes¶
type: Mandatory. What kind of link. Can be “url” or “ui”.
target: Mandatory. The URL to open or the UI widget to reference.
action: Mandatory for UI links: the action to perform. Not allowed for URLs.
mouseover: Optional. The mouseover text to show.
Sub-tags¶
Image – <img>¶
Displays an image with your text.
Attributes¶
src: The path to the image, relative to the
data
directory.object: Show the representative image of a map object instead of using
src
.ref: To be implemented
color: Player color for the image as a hex value
width: Maximum width of the image as a pixel amount. The corresponding height will be matched automatically. The image may only be scaled down, never up. Not supported in conjunction with the
object
parameter.