« Go back


class Text: Dgame.Graphic.Transformable.Transformable, Dgame.Graphic.Drawable.Drawable;
Text defines a graphical 2D text, that can be drawn on screen.

Randy Schuett (rswhite4@googlemail.com)

Color4b foreground;
The foreground color. Default is Color4b.Black.

Color4b background;
The background color. Default is Color4b.White.

The background color is ignored if your mode is not Font.Mode.Shaded

Font.Mode mode;
The Font mode which is default Font.Mode.Solid.

final pure nothrow @nogc this(ref Font fnt, string str = null);

final nothrow @nogc void update();
Update the Texture and redraw the text, if necessary. This method is called automatically if the Text is drawn onto the Window. But if you need specific informations (e.g. width/height) before the draw call, you can call the method by yourself.

final const pure nothrow @nogc @property uint width();
Returns the width

final const pure nothrow @nogc @property uint height();
Returns the height

final inout pure nothrow @nogc inout(Texture*) getTexture();
Returns the used Texture which contains the last rendered Text

pure void format(Args...)(string text, Args args);
Format a given string by using std.string.format. Therefore the formating pattern is identical.

pure nothrow void setData(T)(T data);
Set or reset the current text by using std.conv.to!(string) if the data is not a string

pure nothrow Text opBinary(string op)(string text) if (op == "~" || op == "+");
Concatenate the current string with another.

Font fnt = new Font("samples/font/arial.ttf", 12);
Text t = new Text(font);
t.setData("My new string");
t ~= "is great!"; // t draws now 'My new string is great' on screen.
The example above is the same as if you do:
t += "is great!";
Both operators (~ and +) are allowed.

final const pure nothrow @nogc string getText();
Returns the current text

final pure nothrow @nogc void setFont(ref Font fnt);
Set or reset the current Font

final inout pure nothrow @nogc inout(Font*) getFont();
Returns a pointer to the current Font

Page generated by Ddoc.

» Dgame.Graphic.Text on Github


« Go back