MongolTextPainter class

An object that paints a Mongolian TextSpan tree into a Canvas.

To use a MongolTextPainter, follow these steps:

  1. Create a TextSpan tree and pass it to the MongolTextPainter constructor.

  2. Call layout to prepare the paragraph.

  3. Call paint as often as desired to paint the paragraph.

  4. Call dispose when the object will no longer be accessed to release native resources. For MongolTextPainter objects that are used repeatedly and stored on a State or RenderObject, call dispose from State.dispose or RenderObject.dispose or similar. For MongolTextPainter objects that are only used ephemerally, it is safe to immediately dispose them after the last call to methods or properties on the object.

If the height of the area into which the text is being painted changes, return to step 2. If the text to be painted changes, return to step 1.

The default text style is white. To change the color of the text, pass a TextStyle object to the TextSpan in text.

Constructors

MongolTextPainter({TextSpan? text, MongolTextAlign textAlign = MongolTextAlign.top, @Deprecated('Use textScaler instead. ' 'Use of textScaleFactor was deprecated in preparation for the upcoming nonlinear text scaling support. ' 'This feature was deprecated after v3.12.0-2.0.pre.') double textScaleFactor = 1.0, TextScaler textScaler = TextScaler.noScaling, int? maxLines, String? ellipsis, TextHeightBasis textHeightBasis = TextHeightBasis.parent})
Creates a text painter that paints the given text.

Properties

debugDisposed bool
Whether this object has been disposed or not.
no setter
didExceedMaxLines bool
Whether any text was truncated or ellipsized.
no setter
ellipsis String?
The string used to ellipsize overflowing text. Setting this to a non-empty string will cause this string to be substituted for the remaining text if the text can not fit within the specified maximum height.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
height double
The vertical space required to paint this text.
no setter
maxIntrinsicHeight double
The height at which increasing the height of the text no longer decreases the width.
no setter
maxLines int?
An optional maximum number of lines for the text to span, wrapping if necessary.
getter/setter pair
minIntrinsicHeight double
The height at which decreasing the height of the text would prevent it from painting itself completely within its bounds.
no setter
plainText String
Returns a plain text version of the text to paint.
no setter
preferredLineWidth double
The width of a space in text in logical pixels.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
size Size
The amount of space required to paint this text.
no setter
text TextSpan?
The (potentially styled) text to paint.
getter/setter pair
textAlign MongolTextAlign
How the text should be aligned vertically.
getter/setter pair
textHeightBasis TextHeightBasis
Defines how to measure the height of the rendered text.
getter/setter pair
textScaleFactor double
Deprecated. Will be removed in a future version of Flutter. Use textScaler instead.
getter/setter pair
textScaler TextScaler
The font scaling strategy to use when laying out and rendering the text.
getter/setter pair
width double
The horizontal space required to paint this text.
no setter
wordBoundaries MongolWordBoundary
Returns a TextBoundary that can be used to perform word boundary analysis on the current text.
no setter

Methods

computeDistanceToActualBaseline(TextBaseline baseline) double
Even though the text is rotated, it is still useful to have a baseline along which to layout objects. (For example in the MongolInputDecorator.)
computeLineMetrics() List<MongolLineMetrics>
Returns the full list of MongolLineMetrics that describe in detail the various metrics of each laid out line.
dispose() → void
Releases the resources associated with this painter.
getBoxesForSelection(TextSelection selection) List<Rect>
Returns a list of rects that bound the given selection.
getFullWidthForCaret(TextPosition position, Rect caretPrototype) double?
Returns the strut bounded width of the glyph at the given position.
getLineBoundary(TextPosition position) TextRange
Returns the text range of the line at the given offset.
getOffsetAfter(int offset) int?
Returns the closest offset after offset at which the input cursor can be positioned.
getOffsetBefore(int offset) int?
Returns the closest offset before offset at which the input cursor can be positioned.
getOffsetForCaret(TextPosition position, Rect caretPrototype) Offset
Returns the offset at which to paint the caret.
getPositionForOffset(Offset offset) TextPosition
Returns the position within the text for the given pixel offset.
getWordBoundary(TextPosition position) TextRange
Returns the text range of the word at the given offset. Characters not part of a word, such as spaces, symbols, and punctuation, have word breaks on both sides. In such cases, this method will return a text range that contains the given text position.
layout({double minHeight = 0.0, double maxHeight = double.infinity}) → void
Computes the visual position of the glyphs for painting the text.
markNeedsLayout() → void
Marks this text painter's layout information as dirty and removes cached information.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
paint(Canvas canvas, Offset offset) → void
Paints the text onto the given canvas at the given offset.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

computeHeight({required TextSpan text, MongolTextAlign textAlign = MongolTextAlign.top, double textScaleFactor = 1.0, TextScaler textScaler = TextScaler.noScaling, int? maxLines, String? ellipsis, TextHeightBasis textHeightBasis = TextHeightBasis.parent, double minHeight = 0.0, double maxHeight = double.infinity}) double
Computes the height of a configured MongolTextPainter.
computeMaxIntrinsicHeight({required TextSpan text, MongolTextAlign textAlign = MongolTextAlign.top, double textScaleFactor = 1.0, TextScaler textScaler = TextScaler.noScaling, int? maxLines, String? ellipsis, TextHeightBasis textHeightBasis = TextHeightBasis.parent, double minHeight = 0.0, double maxHeight = double.infinity}) double
Computes the max intrinsic height of a configured MongolTextPainter.
isHighSurrogate(int value) bool
Returns true iff the given value is a valid UTF-16 high (first) surrogate. The value must be a UTF-16 code unit, meaning it must be in the range 0x0000-0xFFFF.
isLowSurrogate(int value) bool
Returns true iff the given value is a valid UTF-16 low (second) surrogate. The value must be a UTF-16 code unit, meaning it must be in the range 0x0000-0xFFFF.