ShapedText class
Text shaped once, as one straight line, by Flutter's own paragraph engine, then drawn one grapheme cluster at a time into an atlas.
Shaping the whole run at once keeps every script right: Arabic letters take their joining forms, Devanagari and Bengali their conjuncts and vowel signs. Each cluster is then drawn alone, with the rest of the run transparent, so it keeps the exact shape and place it had in the run (an overhanging tail and all) and can be moved on its own.
The flat run's coordinates are the paragraph's: x to the right, y down from the top of the line.
Properties
- atlas → TextAtlas
-
Every cluster drawn alone, each in its own cell, at scale texels per logical pixel. It's also what the run's
joins are found from; drawAtlas draws others, at the density a zoomed view needs.
final
- band → ConnectionBand?
-
The rows the script's letters join on: the Arabic baseline, the Indic headline. Null when nothing joins.
final
- baseline → double
-
The flat run's width, height and baseline.
final
- fontSize → double
-
The font size.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- height → double
-
The flat run's width, height and baseline.
final
-
neighbours
→ List<
UnitPair> -
Each pair of clusters side by side in the run, left to right, and whether they join.
final
- paragraph → Paragraph
-
The run, laid out straight: for finding positions and words in it, as selection does.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scale → double
-
The atlas's texels per logical pixel.
no setter
- style → TextStyle
-
The style it was shaped in.
final
- text → String
-
The text, as given.
final
- textDirection → TextDirection
-
The run's direction.
final
-
units
→ List<
TextUnit> -
The run's clusters with ink, left to right as they're seen.
final
- width → double
-
The flat run's width, height and baseline.
final
Methods
-
coverage(
TextUnit unit, double x, double y) → double -
How much of
unit's ink covers the flat point (x,y), from 0 to 1. -
dispose(
) → void - Frees the atlas and the paragraph.
-
drawAtlas(
double density) → Future< TextAtlas> -
Draws every cluster again, alone in a cell cropped to its ink, at
densitytexels per logical pixel. -
drawnRect(
TextUnit unit) → Rect -
The flat rectangle round
unit's ink that's drawn: its ink and a pixel more, for the edges' antialiasing. -
inkSamples(
TextUnit unit, {double spacing = 0.5}) → Iterable< (double, double, double)> -
Points across
unit's ink, aboutspacinglogical pixels apart, with their coverage:(x, y, coverage). -
isolated(
TextRange range) → Paragraph -
text laid out again with only
rangevisible: the rest of the run transparent, so the visible part keeps the shape and place the whole run gives it. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
texelsAt(
double density) → int -
How many texels an atlas drawn at
densityholds. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
layout(
String text, TextStyle style, {TextDirection? textDirection, double scale = 2, ConnectionLine connection = const ConnectionLine.auto()}) → Future< ShapedText> -
Shapes
textinstyleand draws its clusters into an atlas atscaletexels per logical pixel (or fewer, if that atlas wouldn't fit one texture of at most maxTextureSide a side and 16M texels in all).
Constants
- maxTextureSide → const int
- The longest side an atlas may have: what GPUs reliably take.