Class TextLine
- Namespace
- Godot
- Assembly
- GodotSharp.dll
Abstraction over TextServer for handling a single line of text.
public class TextLine : RefCounted, IDisposable
- Inheritance
-
TextLine
- Implements
- Inherited Members
Constructors
TextLine()
public TextLine()
Properties
Alignment
Sets text alignment within the line as if the line was horizontal.
public HorizontalAlignment Alignment { get; set; }
Property Value
Direction
Text writing direction.
public TextServer.Direction Direction { get; set; }
Property Value
Flags
Line alignment rules. For more info see TextServer.
public TextServer.JustificationFlag Flags { get; set; }
Property Value
Orientation
Text orientation.
public TextServer.Orientation Orientation { get; set; }
Property Value
PreserveControl
If set to true
text will display control characters.
public bool PreserveControl { get; set; }
Property Value
PreserveInvalid
If set to true
text will display invalid characters.
public bool PreserveInvalid { get; set; }
Property Value
TextOverrunBehavior
Sets the clipping behavior when the text exceeds the text line's set width. See TextServer.OverrunBehavior for a description of all modes.
public TextServer.OverrunBehavior TextOverrunBehavior { get; set; }
Property Value
Width
Text line width.
public float Width { get; set; }
Property Value
Methods
AddObject(Variant, Vector2, InlineAlignment, int, float)
Adds inline object to the text buffer, key
must be unique. In the text, object is represented as length
object replacement characters.
public bool AddObject(Variant key, Vector2 size, InlineAlignment inlineAlign = InlineAlignment.Center, int length = 1, float baseline = 0)
Parameters
key
Variantsize
Vector2inlineAlign
InlineAlignmentlength
intbaseline
float
Returns
AddString(string, Font, int, string, Variant)
Adds text span and font to draw it.
public bool AddString(string text, Font font, int fontSize, string language = "", Variant meta = default)
Parameters
Returns
Clear()
Clears text line (removes text and inline objects).
public void Clear()
Draw(Rid, Vector2, Color?)
Draw text into a canvas item at a given position, with color
. pos
specifies the top left corner of the bounding box.
public void Draw(Rid canvas, Vector2 pos, Color? color = null)
Parameters
canvas
Ridpos
Vector2color
Color?If the parameter is null, then the default value is
new Color(1, 1, 1, 1)
.
DrawOutline(Rid, Vector2, int, Color?)
Draw text into a canvas item at a given position, with color
. pos
specifies the top left corner of the bounding box.
public void DrawOutline(Rid canvas, Vector2 pos, int outlineSize = 1, Color? color = null)
Parameters
canvas
Ridpos
Vector2outlineSize
intcolor
Color?If the parameter is null, then the default value is
new Color(1, 1, 1, 1)
.
GetLineAscent()
Returns the text ascent (number of pixels above the baseline for horizontal layout or to the left of baseline for vertical).
public float GetLineAscent()
Returns
GetLineDescent()
Returns the text descent (number of pixels below the baseline for horizontal layout or to the right of baseline for vertical).
public float GetLineDescent()
Returns
GetLineUnderlinePosition()
Returns pixel offset of the underline below the baseline.
public float GetLineUnderlinePosition()
Returns
GetLineUnderlineThickness()
Returns thickness of the underline.
public float GetLineUnderlineThickness()
Returns
GetLineWidth()
Returns width (for horizontal layout) or height (for vertical) of the text.
public float GetLineWidth()
Returns
GetObjectRect(Variant)
Returns bounding rectangle of the inline object.
public Rect2 GetObjectRect(Variant key)
Parameters
key
Variant
Returns
GetObjects()
Returns array of inline objects.
public Array GetObjects()
Returns
GetRid()
Returns TextServer buffer RID.
public Rid GetRid()
Returns
GetSize()
Returns size of the bounding box of the text.
public Vector2 GetSize()
Returns
HasGodotClassMethod(in godot_string_name)
Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.
protected override bool HasGodotClassMethod(in godot_string_name method)
Parameters
method
godot_string_nameName of the method to check for.
Returns
HasGodotClassSignal(in godot_string_name)
Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.
protected override bool HasGodotClassSignal(in godot_string_name signal)
Parameters
signal
godot_string_nameName of the signal to check for.
Returns
HitTest(float)
Returns caret character offset at the specified pixel offset at the baseline. This function always returns a valid position.
public int HitTest(float coords)
Parameters
coords
float
Returns
InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)
Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.
protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)
Parameters
method
godot_string_nameName of the method to invoke.
args
NativeVariantPtrArgsArguments to use with the invoked method.
ret
godot_variantValue returned by the invoked method.
Returns
ResizeObject(Variant, Vector2, InlineAlignment, float)
Sets new size and alignment of embedded object.
public bool ResizeObject(Variant key, Vector2 size, InlineAlignment inlineAlign = InlineAlignment.Center, float baseline = 0)
Parameters
key
Variantsize
Vector2inlineAlign
InlineAlignmentbaseline
float
Returns
SetBidiOverride(Array)
Overrides BiDi for the structured text.
Override ranges should cover full source text without overlaps. BiDi algorithm will be used on each range separately.
public void SetBidiOverride(Array @override)
Parameters
override
Array
TabAlign(float[])
Aligns text to the given tab-stops.
public void TabAlign(float[] tabStops)
Parameters
tabStops
float[]