Skip to main content

Crate cranpose_text

Crate cranpose_text 

Source
Expand description

§Cranpose Text

cranpose-text holds the values text is described with, as Compose’s ui-text does: TextStyle with its SpanStyle and ParagraphStyle parts, AnnotatedString with spans, links and string annotations, font families, weights and styles, text units, decorations and shadows, line boxes, and the options that limit lines and choose the overflow behavior. Application code reaches them through cranpose::prelude and cranpose_ui::text.

use cranpose_text::{AnnotatedString, FontWeight, SpanStyle, TextStyle, TextUnit};

let style = TextStyle {
    span_style: SpanStyle {
        font_size: TextUnit::Sp(16.0),
        font_weight: Some(FontWeight::BOLD),
        ..SpanStyle::default()
    },
    ..TextStyle::default()
};
let text = AnnotatedString::new("Hello".to_owned());
assert_eq!(text.text, "Hello");
let _ = style;

Re-exports§

pub use annotated_string::AnnotatedString;
pub use annotated_string::LinkAnnotation;
pub use annotated_string::LinkKey;
pub use annotated_string::RangeStyle;
pub use annotated_string::RenderString;
pub use annotated_string::SpanBoundaries;
pub use annotated_string::StringAnnotation;
pub use bidi_level::BidiLevel;
pub use decoration::Shadow;
pub use decoration::TextDecoration;
pub use font::FileBackedFontFamily;
pub use font::FontFamily;
pub use font::FontFile;
pub use font::FontStyle;
pub use font::FontSynthesis;
pub use font::FontWeight;
pub use font::LoadedTypefacePath;
pub use font_family_resolver::FontFamilyResolver;
pub use font_family_resolver::FontRequest;
pub use font_feature::FontFeature;
pub use font_feature::FontFeatureSettings;
pub use font_feature::font_feature_settings;
pub use glyph_id::GlyphId;
pub use glyph_outline::GlyphOutline;
pub use glyph_outline::OutlineSegment;
pub use glyph_outline::OutlineTransform;
pub use hyphenator::HyphenationError;
pub use hyphenator::Hyphenator;
pub use itemizer::Itemizer;
pub use itemizer::TextItem;
pub use layout_input::LayoutInput;
pub use layout_input::ParagraphLengths;
pub use layout_options::TextLayoutOptions;
pub use layout_options::TextOptions;
pub use layout_options::TextOverflow;
pub use line_box::FontExtent;
pub use line_box::LineBox;
pub use line_box::line_box;
pub use line_box::paragraph_line_box;
pub use paragraph::Hyphens;
pub use paragraph::LineBreak;
pub use paragraph::ResolvedTextDirection;
pub use paragraph::TextAlign;
pub use paragraph::TextDirection;
pub use paragraph::TextIndent;
pub use paragraph::resolve_text_direction;
pub use script::Script;
pub use shaper::Shaper;
pub use shaping_span::ShapingSpan;
pub use style::BaselineShift;
pub use style::LocaleList;
pub use style::ParagraphStyle;
pub use style::PlatformParagraphStyle;
pub use style::PlatformSpanStyle;
pub use style::PlatformTextStyle;
pub use style::SpanStyle;
pub use style::TextDrawStyle;
pub use style::TextGeometricTransform;
pub use style::TextMotion;
pub use style::TextShaping;
pub use style::TextStyle;
pub use synthesized_style::SynthesizedStyle;
pub use text_layout::CaretDirection;
pub use text_layout::GlyphRun;
pub use text_layout::PositionedGlyph;
pub use text_layout::TextLayout;
pub use text_layouter::TextLayouter;
pub use typeface::DecorationMetrics;
pub use typeface::FontBytes;
pub use typeface::FontFamilyKey;
pub use typeface::LineMetrics;
pub use typeface::Synthesis;
pub use typeface::Typeface;
pub use typeface::TypefaceError;
pub use unit::TextUnit;
pub use word_boundary::word_boundary;

Modules§

annotated_string
Styled text: spans, links and string annotations.
bidi_level
The embedding levels of the Unicode bidirectional algorithm.
decoration
Text decorations (underline, line through) and text shadows.
font
Font weight, style, family and synthesis settings.
font_family_resolver
Which typeface draws each part of a text: Compose’s FontFamily.Resolver with Android’s fallback rules.
font_feature
OpenType feature settings, Compose’s fontFeatureSettings.
glyph_id
Glyph indices.
glyph_outline
Glyph outlines drawn as coverage.
hyphenator
itemizer
Splitting text into the items a shaper takes.
layout_input
A paragraph to lay out and the lengths of its style.
layout_options
Options that limit lines, control wrapping and choose the overflow behavior.
line_box
Where a line of text sits inside the height it was given, and what a paragraph gives back at its edges.
paragraph
Paragraph settings: alignment, direction, line breaking, hyphenation and indent.
script
Writing systems and the script runs of text.
shaper
Shaping text items into glyphs with HarfRust.
shaping_span
The stretches of a paragraph that shape alike.
style
Text styles: SpanStyle, ParagraphStyle and TextStyle.
synthesized_style
The bold and the italic a layout’s glyphs ask of faces that lack them. The bold and the italic a layout’s glyphs ask of faces that lack them.
text_layout
A paragraph laid out in lines, and Compose’s TextLayoutResult queries.
text_layouter
Laying paragraphs out in lines.
typeface
A font loaded for text: Compose’s Typeface.
unit
Text size units: scaled pixels and multiples of the font size.
word_boundary
The words of a text.

Structs§

GlyphOffset
How far right of the pen and up from the baseline a glyph draws, in design units.
LineHeightStyle
The line-height policy lives with the drawing-side text types, because a DrawScope has to be able to name it too: a run drawn through a canvas and a Text composable on the same screen must resolve their line boxes by the same rule, and the only style a draw scope can carry is the flat one from cranpose-ui-graphics. How a line of text sits inside the height it was given, and what a paragraph gives back at its edges.
ParagraphIntrinsics
The widths of a paragraph that do not depend on the width it is laid out at: Compose’s ParagraphIntrinsics. Each includes the indent of the line it is measured on.
ShapedGlyph
A glyph shaping placed: its id, the text offset of its cluster and how far it moves the pen. Where it draws from the pen stands apart, in ShapedGlyphs, since most glyphs draw at the pen.
ShapedGlyphs
Glyphs in the order shaping placed them, with where each draws from the pen.

Enums§

LineHeightAlignment
The line-height policy lives with the drawing-side text types, because a DrawScope has to be able to name it too: a run drawn through a canvas and a Text composable on the same screen must resolve their line boxes by the same rule, and the only style a draw scope can carry is the flat one from cranpose-ui-graphics. Where the leading — the difference between a line’s box and the font’s own ascent-plus-descent extent — is spent.
LineHeightMode
The line-height policy lives with the drawing-side text types, because a DrawScope has to be able to name it too: a run drawn through a canvas and a Text composable on the same screen must resolve their line boxes by the same rule, and the only style a draw scope can carry is the flat one from cranpose-ui-graphics. What a requested line height means when the font does not fit inside it.
LineHeightTrim
The line-height policy lives with the drawing-side text types, because a DrawScope has to be able to name it too: a run drawn through a canvas and a Text composable on the same screen must resolve their line boxes by the same rule, and the only style a draw scope can carry is the flat one from cranpose-ui-graphics. Which edges of a text block give their leading back.