TextLine
Holds a line of text.
TextLine.swift:11class TextLine
Abstraction over TextServer
for handling a single line of text.
Superclasses
class RefCounted
Base class for reference-counted objects.
Citizens in SwiftGodot
Conformances
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol Identifiable<ID>
A class of types whose instances hold the value of an entity with stable identity.
protocol VariantRepresentable
Types that conform to VariantRepresentable can be stored directly in
Variant
with no conversion. These include all of the Variant types from Godot (for exampleGString
,Rect
,Plane
), Godot objects (those that subclass SwiftGodot.Object) as well as the built-in Swift types UInt8, Int64 and Double.protocol VariantStorable
Types that conform to VariantStorable can be stored in a Variant and can be extracted back out of a Variant.
Type members
Instance members
var alignment: HorizontalAlignment
Sets text alignment within the line as if the line was horizontal.
var direction: TextServer.Direction
Text writing direction.
var flags: TextServer.JustificationFlag
Line alignment rules. For more info see
TextServer
.var orientation: TextServer.Orientation
Text orientation.
var preserveControl: Bool
If set to
true
text will display control characters.var preserveInvalid: Bool
If set to
true
text will display invalid characters.var textOverrunBehavior: TextServer.OverrunBehavior
Sets the clipping behavior when the text exceeds the text line’s set width. See
TextServer.OverrunBehavior
for a description of all modes.var width: Double
Text line width.
func addObject(key: Variant, size: Vector2, inlineAlign: InlineAlignment, length: Int32, baseline: Double
) -> Bool Adds inline object to the text buffer,
key
must be unique. In the text, object is represented aslength
object replacement characters.func addString(text: String, font: Font?, fontSize: Int32, language: String, meta: Variant
) -> Bool Adds text span and font to draw it.
func clear(
) Clears text line (removes text and inline objects).
func draw(canvas: RID, pos: Vector2, color: Color
) Draw text into a canvas item at a given position, with
color
.pos
specifies the top left corner of the bounding box.func drawOutline(canvas: RID, pos: Vector2, outlineSize: Int32, color: Color
) Draw text into a canvas item at a given position, with
color
.pos
specifies the top left corner of the bounding box.func getLineAscent(
) -> Double Returns the text ascent (number of pixels above the baseline for horizontal layout or to the left of baseline for vertical).
func getLineDescent(
) -> Double Returns the text descent (number of pixels below the baseline for horizontal layout or to the right of baseline for vertical).
func getLineUnderlinePosition(
) -> Double Returns pixel offset of the underline below the baseline.
func getLineUnderlineThickness(
) -> Double Returns thickness of the underline.
func getLineWidth(
) -> Double Returns width (for horizontal layout) or height (for vertical) of the text.
func getObjectRect(key: Variant
) -> Rect2 Returns bounding rectangle of the inline object.
func getObjects(
) -> GArray Returns array of inline objects.
func getRid(
) -> RID Returns TextServer buffer RID.
func getSize(
) -> Vector2 Returns size of the bounding box of the text.
func hitTest(coords: Double
) -> Int32 Returns caret character offset at the specified pixel offset at the baseline. This function always returns a valid position.
func resizeObject(key: Variant, size: Vector2, inlineAlign: InlineAlignment, baseline: Double
) -> Bool Sets new size and alignment of embedded object.
func setBidiOverride(GArray
) Overrides BiDi for the structured text.
func tabAlign(tabStops: PackedFloat32Array
) Aligns text to the given tab-stops.