Skip to content

TextLine

eduardgushchin edited this page Oct 22, 2026 · 1 revision

Home | API by Category | Complete API Index | API Status

Field Value
Full name Electron2D.TextLine
Namespace Electron2D
Kind class
Category API Rendering

Overview

Authors, shapes, measures and draws a retained single line with borrowed fonts and inline objects.

Syntax

public sealed class Electron2D.TextLine

Remarks

The creating thread owns access. Typed span metadata, object keys and font resources remain borrowed; duplicates copy authored state and own separate buffers. Prepared queries and drawing reuse layout storage. Size/width describe the trimmed display; carets and inline geometry retain the complete shaped buffer. Authoring is bounded to 1,048,576 Unicode scalars and 64 MiB UTF-16 text. This transient object is not serialized.

Inherits: ElectronObject

Detailed engine reference

Members

Member Kind Summary
public TextLine() constructor Creates an empty thread-owned shaped-text buffer with the default line policies.
public System.Boolean AddObject(Electron2D.TextObjectKey key, Electron2D.Vector2 size, Electron2D.InlineAlignment inlineAlign = Center, System.Int32 length = 1, System.Single baseline = 0f) method Appends one inline object represented by the requested number of replacement scalars.
public System.Boolean AddString(System.String text, Electron2D.Font font, System.Int32 fontSize, System.String language = "") method Appends one copied text segment with its borrowed font and language.
public System.Boolean AddString<T>(System.String text, Electron2D.Font font, System.Int32 fontSize, System.String language, T metadata) method Appends a segment retaining metadata under its exact original type.
public System.Void Clear() method Removes content, objects and BIDI contexts while preserving RID, tabs and line policies.
protected override System.Void Dispose(System.Boolean disposing) method
public System.Void Draw(Electron2D.CanvasItem canvas, Electron2D.Vector2 position, System.Nullable<Electron2D.Color> color = null, System.Single oversampling = 0f) method Draws the trimmed line from its top-left origin into a recording canvas.
public System.Void DrawOutline(Electron2D.CanvasItem canvas, Electron2D.Vector2 position, System.Int32 outlineSize = 1, System.Nullable<Electron2D.Color> color = null, System.Single oversampling = 0f) method Draws the trimmed glyph outline from its top-left origin.
public Electron2D.TextLine Duplicate() method Copies authored state and every line policy into an independent thread-owned buffer.
public Electron2D.TextDirection GetInferredDirection() method Returns the inferred first-paragraph writing direction.
public System.Single GetLineAscent() method Returns the complete shaped line ascent.
public System.Single GetLineDescent() method Returns the complete shaped line descent.
public System.Single GetLineUnderlinePosition() method Returns maximum authored-font underline offset below the baseline.
public System.Single GetLineUnderlineThickness() method Returns maximum authored-font underline thickness.
public System.Single GetLineWidth() method Returns the ceiled advance-axis width of the trimmed display.
public Electron2D.Rect2 GetObjectRect(Electron2D.TextObjectKey key) method Returns an inline rectangle in line-top-left coordinates, including display alignment.
public Electron2D.TextObjectKey[] GetObjects() method Returns inline tokens in authored order as a caller-owned snapshot.
protected override System.Collections.Generic.IEnumerable<Electron2D.PropertyDescriptor> GetPropertyDescriptors() method
public Electron2D.RID GetRID() method Returns the stable borrowed identity of this line's live shaped buffer.
public Electron2D.Vector2 GetSize() method Returns the ceiled trimmed bounding size.
public System.Boolean HasObject(Electron2D.TextObjectKey key) method Reports whether the exact inline token is authored in this line.
public System.Int32 HitTest(System.Single coords) method Returns a valid complete-buffer scalar caret position near the baseline offset.
public System.Boolean ResizeObject(Electron2D.TextObjectKey key, Electron2D.Vector2 size, Electron2D.InlineAlignment inlineAlign = Center, System.Single baseline = 0f) method Changes an existing inline object's size/alignment/baseline without changing its source range.
public System.Void SetBIDIOverride(System.ReadOnlySpan<Electron2D.TextBIDIRange> ranges) method Replaces BIDI contexts with copied contiguous ranges covering the current scalar buffer.
public System.Void TabAlign(System.ReadOnlySpan<System.Single> tabStops) method Replaces repeating tab interval lengths.
public System.Boolean TryGetSpanMetadata<T>(System.Int32 spanIndex, out T metadata) method Reads a segment's exact typed metadata without conversion.
protected override System.Void ValidateDisposal() method
protected override System.Void ValidateMutation() method
public Electron2D.HorizontalAlignment Alignment { get; set; } property Gets or sets advance-axis alignment; initially Left.
public Electron2D.TextDirection Direction { get; set; } property Gets or sets writing direction; initially Auto.
public System.String EllipsisChar { get; set; } property Gets or sets the custom ellipsis text; its first Unicode scalar is used, or the default ellipsis for empty text.
public Electron2D.TextJustificationFlags Flags { get; set; } property Gets or sets Fill justification flags; initially Kashida and WordBound.
public Electron2D.TextOrientation Orientation { get; set; } property Gets or sets the drawing advance axis; initially Horizontal.
public System.Boolean PreserveControl { get; set; } property Gets or sets whether otherwise nonprinting controls are displayed; initially false.
public System.Boolean PreserveInvalid { get; set; } property Gets or sets whether missing characters display hexadecimal glyph boxes; initially true.
public System.Int32 SpanCount { get; } property Gets the number of authored text segments, excluding inline objects and empty additions.
public Electron2D.TextOverrunBehavior TextOverrunBehavior { get; set; } property Gets or sets the display trimming policy; initially TrimEllipsis.
public System.Single Width { get; set; } property Gets or sets available advance-axis width; initially minus one.

Member Details

TextLine()

Kind: constructor

public TextLine()

Summary

Creates an empty thread-owned shaped-text buffer with the default line policies.

AddObject(Electron2D.TextObjectKey, Electron2D.Vector2, Electron2D.InlineAlignment, System.Int32, System.Single)

Kind: method

public System.Boolean AddObject(Electron2D.TextObjectKey key, Electron2D.Vector2 size, Electron2D.InlineAlignment inlineAlign = Center, System.Int32 length = 1, System.Single baseline = 0f)

Summary

Appends one inline object represented by the requested number of replacement scalars.

Returns

False for an already present token, otherwise true.

Parameters

  • key: Unique borrowed reference token.
  • size: Finite nonnegative dimensions.
  • inlineAlign: Two-axis alignment mask.
  • length: Positive scalar length; one initially.
  • baseline: Finite explicit baseline offset, including negative offsets.

AddString(System.String, Electron2D.Font, System.Int32, System.String)

Kind: method

public System.Boolean AddString(System.String text, Electron2D.Font font, System.Int32 fontSize, System.String language = "")

Summary

Appends one copied text segment with its borrowed font and language.

Returns

True after successful authoring.

Parameters

  • text: Text; empty is a successful no-op. Unpaired UTF-16 units become replacement scalars.
  • font: Live borrowed font.
  • fontSize: Positive supported logical size.
  • language: Language tag, or empty for automatic script inference.

Exceptions

  • T:System.ArgumentNullException: Text, font or language is null.
  • T:System.ArgumentException: Text exceeds the preparation limits.
  • T:System.InvalidOperationException: Explicit BIDI contexts are active, access is off-owner or native work is active.

AddString(System.String, Electron2D.Font, System.Int32, System.String, T)

Kind: method

public System.Boolean AddString<T>(System.String text, Electron2D.Font font, System.Int32 fontSize, System.String language, T metadata)

Summary

Appends a segment retaining metadata under its exact original type.

Returns

True after successful authoring.

Parameters

  • text: Copied source text.
  • font: Live borrowed font.
  • fontSize: Logical font size.
  • language: Language tag.
  • metadata: Value retained by ordinary C# assignment.

Clear()

Kind: method

public System.Void Clear()

Summary

Removes content, objects and BIDI contexts while preserving RID, tabs and line policies.

Dispose(System.Boolean)

Kind: method

protected override System.Void Dispose(System.Boolean disposing)

Draw(Electron2D.CanvasItem, Electron2D.Vector2, System.Nullable<Electron2D.Color>, System.Single)

Kind: method

public System.Void Draw(Electron2D.CanvasItem canvas, Electron2D.Vector2 position, System.Nullable<Electron2D.Color> color = null, System.Single oversampling = 0f)

Summary

Draws the trimmed line from its top-left origin into a recording canvas.

Parameters

  • canvas: Live recording canvas item.
  • position: Finite top-left position.
  • color: Finite modulation, or white.
  • oversampling: Finite positive raster scale, or nonpositive for automatic scale.

DrawOutline(Electron2D.CanvasItem, Electron2D.Vector2, System.Int32, System.Nullable<Electron2D.Color>, System.Single)

Kind: method

public System.Void DrawOutline(Electron2D.CanvasItem canvas, Electron2D.Vector2 position, System.Int32 outlineSize = 1, System.Nullable<Electron2D.Color> color = null, System.Single oversampling = 0f)

Summary

Draws the trimmed glyph outline from its top-left origin.

Parameters

  • canvas: Live recording canvas.
  • position: Finite top-left.
  • outlineSize: Nonpositive draws the unexpanded glyph.
  • color: Finite modulation, or white.
  • oversampling: Raster scale, or nonpositive automatic scale.

Duplicate()

Kind: method

public Electron2D.TextLine Duplicate()

Summary

Copies authored state and every line policy into an independent thread-owned buffer.

Returns

A caller-owned duplicate sharing borrowed fonts/keys/payload values.

GetInferredDirection()

Kind: method

public Electron2D.TextDirection GetInferredDirection()

Summary

Returns the inferred first-paragraph writing direction.

Returns

LTR for an empty automatic buffer.

GetLineAscent()

Kind: method

public System.Single GetLineAscent()

Summary

Returns the complete shaped line ascent.

Returns

Fractional pixels, or zero for empty text.

GetLineDescent()

Kind: method

public System.Single GetLineDescent()

Summary

Returns the complete shaped line descent.

Returns

Fractional pixels, or zero for empty text.

GetLineUnderlinePosition()

Kind: method

public System.Single GetLineUnderlinePosition()

Summary

Returns maximum authored-font underline offset below the baseline.

Returns

Zero for no font spans.

GetLineUnderlineThickness()

Kind: method

public System.Single GetLineUnderlineThickness()

Summary

Returns maximum authored-font underline thickness.

Returns

Zero for no font spans.

GetLineWidth()

Kind: method

public System.Single GetLineWidth()

Summary

Returns the ceiled advance-axis width of the trimmed display.

Returns

Zero for empty text.

GetObjectRect(Electron2D.TextObjectKey)

Kind: method

public Electron2D.Rect2 GetObjectRect(Electron2D.TextObjectKey key)

Summary

Returns an inline rectangle in line-top-left coordinates, including display alignment.

Returns

Zero for an absent token; full geometry for a trimmed object.

Parameters

  • key: Borrowed token.

GetObjects()

Kind: method

public Electron2D.TextObjectKey[] GetObjects()

Summary

Returns inline tokens in authored order as a caller-owned snapshot.

Returns

Borrowed tokens, including trimmed objects.

GetPropertyDescriptors()

Kind: method

protected override System.Collections.Generic.IEnumerable<Electron2D.PropertyDescriptor> GetPropertyDescriptors()

GetRID()

Kind: method

public Electron2D.RID GetRID()

Summary

Returns the stable borrowed identity of this line's live shaped buffer.

Returns

A distinct nonempty identity; Clear preserves it and duplicates have their own identity.

GetSize()

Kind: method

public Electron2D.Vector2 GetSize()

Summary

Returns the ceiled trimmed bounding size.

Returns

Width/height follow Orientation.

HasObject(Electron2D.TextObjectKey)

Kind: method

public System.Boolean HasObject(Electron2D.TextObjectKey key)

Summary

Reports whether the exact inline token is authored in this line.

Returns

Presence in the complete buffer.

Parameters

  • key: Borrowed token.

HitTest(System.Single)

Kind: method

public System.Int32 HitTest(System.Single coords)

Summary

Returns a valid complete-buffer scalar caret position near the baseline offset.

Returns

Unicode scalar index with grapheme-boundary preference.

Parameters

  • coords: Finite advance-axis pixels, including positions outside the line.

ResizeObject(Electron2D.TextObjectKey, Electron2D.Vector2, Electron2D.InlineAlignment, System.Single)

Kind: method

public System.Boolean ResizeObject(Electron2D.TextObjectKey key, Electron2D.Vector2 size, Electron2D.InlineAlignment inlineAlign = Center, System.Single baseline = 0f)

Summary

Changes an existing inline object's size/alignment/baseline without changing its source range.

Returns

False for an absent token.

Parameters

  • key: Existing borrowed token.
  • size: Finite nonnegative dimensions.
  • inlineAlign: Two-axis mask.
  • baseline: Finite explicit offset.

SetBIDIOverride(System.ReadOnlySpan<Electron2D.TextBIDIRange>)

Kind: method

public System.Void SetBIDIOverride(System.ReadOnlySpan<Electron2D.TextBIDIRange> ranges)

Summary

Replaces BIDI contexts with copied contiguous ranges covering the current scalar buffer.

Parameters

  • ranges: Defined directions and full nonoverlapping scalar ranges; empty clears overrides.

Exceptions

  • T:System.ArgumentException: Ranges do not cover the buffer contiguously.

TabAlign(System.ReadOnlySpan<System.Single>)

Kind: method

public System.Void TabAlign(System.ReadOnlySpan<System.Single> tabStops)

Summary

Replaces repeating tab interval lengths.

Parameters

  • tabStops: Copied finite positive intervals; empty restores the backend default.

TryGetSpanMetadata(System.Int32, ref T)

Kind: method

public System.Boolean TryGetSpanMetadata<T>(System.Int32 spanIndex, out T metadata)

Summary

Reads a segment's exact typed metadata without conversion.

Returns

Whether the exact type matches.

Parameters

  • spanIndex: Zero-based successful nonempty AddString index.
  • metadata: Borrowed value, or default.

Exceptions

  • T:System.ArgumentOutOfRangeException: The text span does not exist.

ValidateDisposal()

Kind: method

protected override System.Void ValidateDisposal()

ValidateMutation()

Kind: method

protected override System.Void ValidateMutation()

Alignment

Kind: property

public Electron2D.HorizontalAlignment Alignment { get; set; }

Summary

Gets or sets advance-axis alignment; initially Left.

Value

Left, Center, Right or Fill.

Direction

Kind: property

public Electron2D.TextDirection Direction { get; set; }

Summary

Gets or sets writing direction; initially Auto.

Value

A defined text direction.

EllipsisChar

Kind: property

public System.String EllipsisChar { get; set; }

Summary

Gets or sets the custom ellipsis text; its first Unicode scalar is used, or the default ellipsis for empty text.

Value

The ellipsis character initially.

Flags

Kind: property

public Electron2D.TextJustificationFlags Flags { get; set; }

Summary

Gets or sets Fill justification flags; initially Kashida and WordBound.

Value

Defined flag bits.

Orientation

Kind: property

public Electron2D.TextOrientation Orientation { get; set; }

Summary

Gets or sets the drawing advance axis; initially Horizontal.

Value

A defined text orientation.

PreserveControl

Kind: property

public System.Boolean PreserveControl { get; set; }

Summary

Gets or sets whether otherwise nonprinting controls are displayed; initially false.

Value

The real control-glyph policy.

PreserveInvalid

Kind: property

public System.Boolean PreserveInvalid { get; set; }

Summary

Gets or sets whether missing characters display hexadecimal glyph boxes; initially true.

Value

The real missing-glyph policy.

SpanCount

Kind: property

public System.Int32 SpanCount { get;  }

Summary

Gets the number of authored text segments, excluding inline objects and empty additions.

Value

Zero initially.

TextOverrunBehavior

Kind: property

public Electron2D.TextOverrunBehavior TextOverrunBehavior { get; set; }

Summary

Gets or sets the display trimming policy; initially TrimEllipsis.

Value

A defined overrun policy.

Width

Kind: property

public System.Single Width { get; set; }

Summary

Gets or sets available advance-axis width; initially minus one.

Value

A finite value; nonpositive values do not trim or align.

Clone this wiki locally