Class TextParagraph
- Namespace
- Godot
- Assembly
- GodotSharp.dll
Abstraction over TextServer for handling a single paragraph of text.
public class TextParagraph : RefCounted, IDisposable
- Inheritance
-
TextParagraph
- Implements
- Inherited Members
Constructors
TextParagraph()
public TextParagraph()
Properties
Alignment
Paragraph horizontal alignment.
public HorizontalAlignment Alignment { get; set; }
Property Value
BreakFlags
Line breaking rules. For more info see TextServer.
public TextServer.LineBreakFlag BreakFlags { get; set; }
Property Value
CustomPunctuation
Custom punctuation character list, used for word breaking. If set to empty string, server defaults are used.
public string CustomPunctuation { get; set; }
Property Value
Direction
Text writing direction.
public TextServer.Direction Direction { get; set; }
Property Value
EllipsisChar
Ellipsis character used for text clipping.
public string EllipsisChar { get; set; }
Property Value
JustificationFlags
Line fill alignment rules. For more info see TextServer.JustificationFlag.
public TextServer.JustificationFlag JustificationFlags { get; set; }
Property Value
MaxLinesVisible
Limits the lines of text shown.
public int MaxLinesVisible { 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 paragraph's set width. See TextServer.OverrunBehavior for a description of all modes.
public TextServer.OverrunBehavior TextOverrunBehavior { get; set; }
Property Value
Width
Paragraph 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 paragraph (removes text and inline objects).
public void Clear()
ClearDropcap()
Removes dropcap.
public void ClearDropcap()
Draw(Rid, Vector2, Color?, Color?)
Draw all lines of the text and drop cap 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, Color? dcColor = null)
Parameters
canvas
Ridpos
Vector2color
Color?If the parameter is null, then the default value is
new Color(1, 1, 1, 1)
.dcColor
Color?If the parameter is null, then the default value is
new Color(1, 1, 1, 1)
.
DrawDropcap(Rid, Vector2, Color?)
Draw drop cap into a canvas item at a given position, with color
. pos
specifies the top left corner of the bounding box.
public void DrawDropcap(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)
.
DrawDropcapOutline(Rid, Vector2, int, Color?)
Draw drop cap outline into a canvas item at a given position, with color
. pos
specifies the top left corner of the bounding box.
public void DrawDropcapOutline(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)
.
DrawLine(Rid, Vector2, int, Color?)
Draw single line of text into a canvas item at a given position, with color
. pos
specifies the top left corner of the bounding box.
public void DrawLine(Rid canvas, Vector2 pos, int line, Color? color = null)
Parameters
canvas
Ridpos
Vector2line
intcolor
Color?If the parameter is null, then the default value is
new Color(1, 1, 1, 1)
.
DrawLineOutline(Rid, Vector2, int, int, Color?)
Draw outline of the single line of text into a canvas item at a given position, with color
. pos
specifies the top left corner of the bounding box.
public void DrawLineOutline(Rid canvas, Vector2 pos, int line, int outlineSize = 1, Color? color = null)
Parameters
canvas
Ridpos
Vector2line
intoutlineSize
intcolor
Color?If the parameter is null, then the default value is
new Color(1, 1, 1, 1)
.
DrawOutline(Rid, Vector2, int, Color?, Color?)
Draw outlines of all lines of the text and drop cap 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, Color? dcColor = null)
Parameters
canvas
Ridpos
Vector2outlineSize
intcolor
Color?If the parameter is null, then the default value is
new Color(1, 1, 1, 1)
.dcColor
Color?If the parameter is null, then the default value is
new Color(1, 1, 1, 1)
.
GetDropcapLines()
Returns number of lines used by dropcap.
public int GetDropcapLines()
Returns
GetDropcapRid()
Returns drop cap text buffer RID.
public Rid GetDropcapRid()
Returns
GetDropcapSize()
Returns drop cap bounding box size.
public Vector2 GetDropcapSize()
Returns
GetLineAscent(int)
Returns the text line ascent (number of pixels above the baseline for horizontal layout or to the left of baseline for vertical).
public float GetLineAscent(int line)
Parameters
line
int
Returns
GetLineCount()
Returns number of lines in the paragraph.
public int GetLineCount()
Returns
GetLineDescent(int)
Returns the text line descent (number of pixels below the baseline for horizontal layout or to the right of baseline for vertical).
public float GetLineDescent(int line)
Parameters
line
int
Returns
GetLineObjectRect(int, Variant)
Returns bounding rectangle of the inline object.
public Rect2 GetLineObjectRect(int line, Variant key)
Parameters
Returns
GetLineObjects(int)
Returns array of inline objects in the line.
public Array GetLineObjects(int line)
Parameters
line
int
Returns
GetLineRange(int)
Returns character range of the line.
public Vector2I GetLineRange(int line)
Parameters
line
int
Returns
GetLineRid(int)
Returns TextServer line buffer RID.
public Rid GetLineRid(int line)
Parameters
line
int
Returns
GetLineSize(int)
Returns size of the bounding box of the line of text. Returned size is rounded up.
public Vector2 GetLineSize(int line)
Parameters
line
int
Returns
GetLineUnderlinePosition(int)
Returns pixel offset of the underline below the baseline.
public float GetLineUnderlinePosition(int line)
Parameters
line
int
Returns
GetLineUnderlineThickness(int)
Returns thickness of the underline.
public float GetLineUnderlineThickness(int line)
Parameters
line
int
Returns
GetLineWidth(int)
Returns width (for horizontal layout) or height (for vertical) of the line of text.
public float GetLineWidth(int line)
Parameters
line
int
Returns
GetNonWrappedSize()
Returns the size of the bounding box of the paragraph, without line breaks.
public Vector2 GetNonWrappedSize()
Returns
GetRid()
Returns TextServer full string buffer RID.
public Rid GetRid()
Returns
GetSize()
Returns the size of the bounding box of the paragraph.
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(Vector2)
Returns caret character offset at the specified coordinates. This function always returns a valid position.
public int HitTest(Vector2 coords)
Parameters
coords
Vector2
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
SetDropcap(string, Font, int, Rect2?, string)
Sets drop cap, overrides previously set drop cap. Drop cap (dropped capital) is a decorative element at the beginning of a paragraph that is larger than the rest of the text.
public bool SetDropcap(string text, Font font, int fontSize, Rect2? dropcapMargins = null, string language = "")
Parameters
text
stringfont
FontfontSize
intdropcapMargins
Rect2?If the parameter is null, then the default value is
new Rect2(new Vector2(0, 0), new Vector2(0, 0))
.language
string
Returns
TabAlign(float[])
Aligns paragraph to the given tab-stops.
public void TabAlign(float[] tabStops)
Parameters
tabStops
float[]