RichTextKit v0.4

TextBlock Class

Assembly: Topten.RichTextKit.dll
Namespace: Topten.RichTextKit

Represents a block of formatted, laid out and measurable text

public class TextBlock : StyledText

Inheritance

TextBlock → StyledTextobject

Constructors

TextBlock()

Constructor

Properties

Alignment

Sets the left, right or center alignment of the text block.

BaseDirection

The base directionality of this text block (whether text is laid out left to right, or right to left)

CaretIndicies

Retrieves a list of all valid caret positions

EllipsisEnabled

Controls the rendering of an ellipsis (...) character, when the line has been truncated because of MaxWidth/MaxHeight/MaxLines.

FontMapper

Gets or sets the font mapper to be used by this TextBlock instance

FontRuns

Get all font runs for this text block

LineCount

The number of lines in the text

LineIndicies

Retrieves a list of the indicies of the first code point in each line

Lines

Get all the lines for this text block

MaxHeight

The maximum height of the TextBlock after which lines will be truncated and the final line will be appended with an ellipsis (...) character.

MaxLines

The maximum number of lines after which lines will be truncated and the final line will be appended with an ellipsis (...) character.

MaxWidth

The max width property sets the maximum width of a line, after which the line will be wrapped onto the next line.

MeasuredHeight

The total height of all lines.

MeasuredLength

The length of the displayed text (in code points)

MeasuredOverhang

Gets the actual measured overhang in each direction based on the fonts used, and the supplied text.

MeasuredPadding

Gets the size of any unused space around the text.

MeasuredWidth

The width of the widest line of text.

RenderWidth

This property is only used for text alignment when word wrapping is disabled (MaxWidth == null). When set it will be used for text alignment.

Truncated

Indicates if the text was truncated due to max height or max lines constraints

WordBoundaryIndicies

Retrieves a list of all valid caret positions

Methods

AddEllipsis()

Appends an ellipsis to this text block

Copy(int, int)

Split this text block at the specified code point index

FindFontRunForCodePointIndex(int)

Find the font run holding a code point index

GetCaretInfo(CaretPosition)

Calculates useful information for displaying a caret

HitTest(float, float)

Hit test this block of text

HitTestLine(int, float)

Hit test this block of text

Layout()

Updates the internal layout of the text block

LookupCaretIndex(int)

Given a code point index, find the index in the CaretIndicies

Paint(SkiaSharp.SKCanvas, TextPaintOptions)

Paint this text block

Paint(SkiaSharp.SKCanvas, SkiaSharp.SKPoint, TextPaintOptions)

Paint this text block

ResetPooledMemory()

Resets and internal object and memory pools.

Overridden & Inherited

_codePoints

All code points as supplied by user, accumulated into a single buffer

_hasTextDirectionOverrides

Set to true if any style runs have a directionality override.

_styleRuns

A list of style runs, as supplied by user

AddText(StyledText)

Add all the text from another text block to this text block

AddText(ReadOnlySpan<char>, IStyle)

Add text to this text block

AddText(Utils.Slice<int>, IStyle)

Add text to this paragraph

AddText(string, IStyle)

Add text to this text block

ApplyStyle(int, int, IStyle)

Overwrites the styles of existing text in the text block

CharacterToCodePointIndex(int)

Converts a character index to a code point index

Clear()

Clear the content of this text block

CodePoints

Get the code points of this text block

CodePointToCharacterIndex(int)

Converts a code point index to a character index

DeleteText(int, int)

Deletes text from this text block

Extract(int, int)

Extract text from this styled text block

GetStyleAtOffset(int)

Gets the style of the text at a specified offset

InsertText(int, StyledText)

Add all the text from another text block to this text block

InsertText(int, Utils.Slice<int>, IStyle)

Add text to this text block

InsertText(int, ReadOnlySpan<char>, IStyle)

Add text to this text block

InsertText(int, string, IStyle)

Add text to this text block

Length

The length of the added text in code points

OnChanged()

Called whenever the content of this styled text block changes

StyleRuns

Get the text runs as added by AddText

ToString()