i_slint_core

Module textlayout

Source
Expand description

module for basic text layout

The basic algorithm for breaking text into multiple lines:

  1. First we determine the boundaries for text shaping. As shaping happens based on a single font and we know that different fonts cater different writing systems, we split up the text into chunks that maximize our chances of finding a font that covers all glyphs in the chunk. This way for example arabic text can be covered by a font that has excellent arabic coverage while latin text is rendered using a different font. Shaping boundaries are always also grapheme boundaries.
  2. Then we shape the text at shaping boundaries, to determine the metrics of glyphs and glyph clusters
  3. Loop over all glyph clusters as well as the line break opportunities produced by the unicode line break algorithm: Sum up the width of all glyph clusters until the next line break opportunity (encapsulated in FragmentIterator), record separately the width of trailing space within the fragment. If the width of the current line (including trailing whitespace) and the new fragment of glyph clusters (without trailing whitespace) is less or equal to the available width: Add fragment of glyph clusters to the current line Else: Emit current line as new line If encountering a mandatory line break opportunity: Emit current line as new line

Structs§

Traits§

  • This trait defines the interface between the text layout and the platform specific mapping of text to glyphs. An implementation of the TextShaper trait must provide metric types (Length, LengthPrimitive), which is used for the line breaking calculation and glyph positioning, as well as an opaque platform specific glyph data type.