text_formatting
module · ferroui-base · v0.5.0
module text_formatting
Text formatting: shaping, line breaking, bidi reordering and text layout.
Index unit: UTF-16 code units
Every index and length in this subsystem — CharacterHit, text source
indices, TextRun::length, glyph clusters, text ranges, caret positions —
counts UTF-16 code units, exactly as upstream, whose text is
ReadOnlyMemory<char>. Text is stored as
ReadOnlyMemory<u16> (a shared
Rc<[u16]> plus a range), so slicing a run or splitting a line never
copies text and indices need no translation anywhere inside the formatter.
This keeps positions identical to upstream (XAML SelectionStart,
CaretIndex, hit testing and the text shaper's clusters all agree) and
keeps the bidi, line break and grapheme algorithms literal ports.
The cost is at the boundary: a Rust String/&str is transcoded once
into UTF-16 when it becomes text of a run (ReadOnlyMemory::<u16>::from_str,
one allocation of 2 bytes per code unit), and callers that keep text as
UTF-8 convert positions with utf16_index_to_utf8 / utf8_index_to_utf16
(O(n) scans; controls that edit text should keep their buffer in UTF-16 or
cache the mapping).
Contents
unicode— moduleDrawableTextRun— traitGenericTextParagraphProperties— structGenericTextRunProperties— structGlyphInfo— structITextDrawingSink— traitITextSource— traitFormattedTextSource— structFontFamilyLineMetrics— structFormattingObjectPool— structListPool— structRentedList— type aliasBidiReorderer— structIndexedTextRun— structLogicalTextRunEnumerator— structInterWordJustification— structJustificationProperties— traitLogicalDirection— enumShapedBuffer— structShapedTextRun— structSplitResult— structTextBounds— structTextCharacters— structTextCollapsingProperties— traitTextEndOfLine— structTextEndOfParagraph— structTextFormatter— traitutf16_index_to_utf8— functionutf8_index_to_utf16— functionTextLayout— structTextLayoutOptions— structTextLeadingPrefixCharacterEllipsis— structTextLine— traitTextLineBreak— structTextLineMetrics— structTextLineMetricsMode— enumTextMetrics— structTextParagraphProperties— traitTextParagraphStyle— structTextParagraphStyles— type aliasTextRun— traitDEFAULT_TEXT_SOURCE_LENGTH— constantTextRunBounds— structTextRunCache— structTextRunProperties— traitTextShaper— structTextShaperOptions— structTabAlignment— enumTabLeader— enumTextTabError— enumTextTabStop— structTextTabStops— structTextTrailingCharacterEllipsis— structTextTrailingWordEllipsis— structUnshapedTextRun— structWrappingTextLineBreak— struct
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.