API reference

aster_blueprint::rich_text

Pre-1.0: signatures are not frozen. Generated from rustdoc JSON of the compiled crate; rustdoc JSON format version 60. Only public items are listed.

Rich text: the inline runs of one paragraph, and the font fallback chain.

A rich paragraph is one text node with several runs: every run has its own face, size and colour, but they are laid out as one paragraph. The lines break across the run boundaries (with the break rules and the wrap modes of [crate::text_wrap]), the runs of a line share one baseline, and the height of a line is the max of its runs (an explicit line height wins, as in a plain text).

The font fallback chain is the other half: a face that has no glyph for a cluster hands that cluster to the next face of the chain (the primary face first, then the fallbacks of the text, then the default chain of the typesetter). The runs split where the face changes, and each face-run is shaped on its own (the width of a line is the sum of its face-runs).

Structs

structaster_blueprint::rich_text::Deco

pub struct Deco { /* see fields */ }

The decoration of a run: lines drawn in the run's colour and a background, none of which touches the layout.

Public fields

fieldtype
underlinebool
strikebool
bgOption<[u8; 4]>The background behind the run (sRGB, straight alpha).

Methods

  • fn is_none(&self) -> bool

Trait implementations: Clone, Copy, Debug, Default, PartialEq, StructuralPartialEq

structaster_blueprint::rich_text::Piece

pub struct Piece { /* see fields */ }

One face-run of a rich line: the text of one face, with its size and colour.

Public fields

fieldtype
textStringThe text of the piece.
fontStringThe face of the piece.
sizef64The size of the piece.
colorOption<[u8; 4]>The colour of the piece (the element's own colour when it is none).
levelu8The resolved bidi level of the piece (odd is shaped right to left).
isou32The isolate span the piece belongs to (0: none) and the level of the text around that isolate: the visual order never mixes an isolate with its surroundings.
outeru8
wf64The measured width of the piece.
hf64The height of the face (ascent + descent + gap).
ascentf64The ascent of the face: the baseline is this far below the top.
decoDecoThe lines and background drawn with the piece.

Methods

  • fn dir(&self) -> Direction — The direction the piece is shaped in.

Trait implementations: Clone, Debug, PartialEq, StructuralPartialEq

structaster_blueprint::rich_text::Rich

pub struct Rich { /* see fields */ }

A laid-out rich paragraph.

Public fields

fieldtype
linesVec<RichLine>The lines of the paragraph.
widthf64The width of the widest line.
heightf64The height of the paragraph (the sum of its line heights).
textStringThe plain text of the paragraph (what a screen reader reads).

Trait implementations: Clone, Debug, PartialEq, StructuralPartialEq

structaster_blueprint::rich_text::RichLine

pub struct RichLine { /* see fields */ }

One line of a rich paragraph.

Public fields

fieldtype
piecesVec<Piece>The face-runs of the line, in order.
wf64The width of the line (the sum of its pieces).
hf64The height of the line: the max of its runs, or the node's explicit pitch when it has one.
baselinef64The baseline of the line, from the top of the line.

Trait implementations: Clone, Debug, Default, PartialEq, StructuralPartialEq

structaster_blueprint::rich_text::Span

pub struct Span { /* see fields */ }

One inline run of a rich paragraph.

Public fields

fieldtype
textStringThe text of the run.
fontStringThe face of the run (the node's own face when it is empty).
sizef64The size of the run (the node's own size when it is zero).
colorOption<[u8; 4]>The colour of the run (the node's own colour when it is none).
dirOption<layout::Direction>The run is a directional isolate of this direction (None: it reads in the paragraph's flow).
decoDecoThe lines and background drawn with the run.

Methods

  • fn new(text: impl Into<String>) -> Span — A run of text in the node's own face, size and colour.
  • fn deco(self, deco: Deco) -> Span — Draw the run underlined, struck through or on a background.
  • fn dir(self, dir: Direction) -> Span — Make the run a directional isolate (UAX #9 LRI / RLI): it is resolved in dir on its own, as one neutral object of the paragraph around it, so a Hebrew name in an English sentence (or the other way round) does not pull the punctuation next to it into its direction.
  • fn font(self, f: impl Into<String>) -> Span — The face of the run (the node's own face when it is empty; "bold" is the bold face of the UI theme).
  • fn bold(self) -> Span — The bold face of the run.
  • fn size(self, s: f64) -> Span — The size of the run (px).
  • fn color(self, c: [u8; 4]) -> Span — The colour of the run (sRGB, straight alpha).

Trait implementations: Clone, Debug, PartialEq, StructuralPartialEq

Functions

fnaster_blueprint::rich_text::span

pub fn span(text: impl Into<String>) -> Span

A run of text in the node's own face, size and colour.