FontString
From Multiverse
| User Interface Widgets | |
|
Browser
|
Region
|
A FontString displays text in the user interface. Change the text displayed with the method SetText(). Read the text with the method GetText().
Derived from: LayeredRegion
Contents |
Tag
<FontString hidden=[true|false] inherits=parentWidgetName name=widgetName setAllPoints=[true|false] virtual=[true|false] font=fontFileName justifyV=[ TOP | MIDDLE | BOTTOM ] justifyH=[ LEFT | CENTER | RIGHT ] monochrome=[true|false] nonspacewrap=[true|false] text=textToDisplay > ... </FontString>
Attributes
FontString has the following special attributes:
- font - string specifying the font to use, of the form "fonts/filename", where filename is the name of a TrueType font file in the
Fontsdirectory of your asset repository. - justifyV - vertical justification: "TOP", "MIDDLE", or "BOTTOM".
- justifyH - horizontal justification: "LEFT", "CENTER", or "RIGHT".
- monochrome - Boolean that specifies whether to display the font string in black and white.
- nonspacewrap - whether to wrap the string if there is no more room on the line, and no whitespace.
- text - initial text to display.
All widgets have these attributes that they inherit from Region:
- hidden - Boolean; whether the widget is initially hidden.
- inherits - name of the widget from which to inherit all attribute values. Must be widget of the same type as this widget (or an ancestor type).
- name - name of the widget. The name must be unique across all widgets in the UI.
- setAllPoints - Boolean (Not currently implemented)
- virtual - Boolean; if true, indicates this widget is not actually created, but will be used as a template for other widgets.
Property Elements
FontString can contain these property elements:
All widgets can contain these property elements:
- Anchors - contains one or more Anchor elements that specify the positioning of the widget relative to its parent.
- Size - specifies the size of the widget with an AbsDimension element.
Methods
The following table describes the methods of FontString.
| Method | Description | Parameters |
|---|---|---|
| GetStringWidth() | Returns the width in pixels of the text in the fontstring. | None |
| GetText() | Returns the text of the widget. If the widget's text is editable, returns the text that the user has entered. Otherwise, the text the widget displays. | None |
| SetJustifyH( direction ) | Set the horizontal justification of the widget. | direction - String; valid values are "LEFT", "CENTER", and "RIGHT". |
| SetJustifyV( direction ) | Set the vertical justification of the widget. | direction - String; valid values are "TOP", "MIDDLE", and "BOTTOM". |
| SetText( text ) | Set the text of the widget. | text - a text string. |
| SetTextColor( red, green, blue ) | Set the color of the text. | red: 0 to 1 value green: 0 to 1 value |
| SetTextHeight( height ) | Set the text height. | height - height in pixels
|
| Methods Inherited from LayeredRegion | ||
| GetDrawLayer() | Returns the draw layer of the region. One of the following:
| None |
| SetDrawLayer(layer) | Sets the draw layer for the region. | layer: the draw layer for the region. One of the following:
|
| SetVertexColor(r, g, b) | Sets the vertex color for the region. | r: red value g: green value |
| SetVertexColor(r, g, b, alpha) | Sets the vertex color for the region. | r: red value g: green value |
| Methods Inherited from Region | ||
| ClearAllPoints() | Clears all the anchors for the widget | None |
| GetAlpha() | Returns the opacity (alpha) of the texture object, from 0 to 1. This does not include the effect of the alpha values of the parent widgets. | None |
| GetBottom() | Returns the y coordinate of the bottom edge of the frame. NOTE: This method is available on FontString and Texture widgets only with 1.5. | None |
| GetHeight() | Returns the height of the widget | None |
| GetLeft() | Returns the x coordinate of the left edge of the frame.
NOTE: This method is available on FontString and Texture widgets only with 1.5. | None |
| GetName() | Returns the name of the widget. | None |
| GetParent() | Returns the parent widget of the frame. NOTE: This method is available on FontString and Texture widgets only with 1.5. | None |
| GetRight() | Returns the x coordinate of the right edge of the frame. NOTE: This method is available on FontString and Texture widgets only with 1.5. | None |
| GetTop() | Returns the y coordinate of the top of the frame, but inverted so that 0 is the bottom of the screen. NOTE: This method is available on FontString and Texture widgets only with 1.5. | None |
| GetWidth() | Returns the width of the widget | None |
| Hide() | Mark the widget as hidden. If the widget, or any of the widget's parents are hidden, the widget will not be displayed. | None |
| IsVisible() | Returns true if the widget is visible, false otherwise. If the widget, or any of the widget's parents are hidden, the widget will not be displayed. | None |
| SetAlpha(alpha) | Set the alpha value (opacity) of the widget. | alpha - a measure of opacity: zero (0) means transparent, while one (1) means opaque. |
| SetHeight(height) | Set the height of the widget. | height -height in pixels (integer) |
| SetPoint( point,
relativeTo,
| Set an anchor point for the widget. Valid values for point and relativePoint arguments:
| point - Point on the widget that is anchored.
relativeTo - Name of the widget being achored to.
|
| SetWidth(width) | Set the width of the widget | width - width in pixels(integer) |
| Show() | Mark the widget as visible. If the widget, or any of the widget's parents are hidden, the widget will not be displayed. | None
|
Event handlers
None.
Example
<FontString name="SystemFont" inherits="MasterFont" font="Fonts\FRIZQT__.TTF" virtual="true">
<FontHeight>
<AbsValue val="15"/>
</FontHeight>
<Color r="1.0" g="1.0" b="0"/>
</FontString>
