FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    FormattedText

    struct · ferroui-base · v0.5.0

    struct FormattedText
    

    The FormattedText class is targeted at programmers needing to add some simple text to a visual.

    All character indices and counts are UTF-16 code units of the text.

    View source

    Members

    DEFAULT_REAL_TO_IDEAL

    const DEFAULT_REAL_TO_IDEAL: f64
    

    Source

    DEFAULT_IDEAL_TO_REAL

    const DEFAULT_IDEAL_TO_REAL: f64
    

    Source

    IDEAL_INFINITE_WIDTH

    const IDEAL_INFINITE_WIDTH: i32
    

    Source

    REAL_INFINITE_WIDTH

    const REAL_INFINITE_WIDTH: f64
    

    Source

    GREATEST_MULTIPLIER_OF_EM

    const GREATEST_MULTIPLIER_OF_EM: f64
    

    Source

    new

    fn new(text_to_format: &str, culture: Locale, flow_direction: FlowDirection, typeface: Typeface, em_size: f64, foreground: Option<Rc<dyn IBrush>>) -> Self
    

    Construct a FormattedText object.

    • text_to_format — string of text to be displayed.
    • culture — culture of text.
    • flow_direction — flow direction of text.
    • typeface — type face used to display text.
    • em_size — font em size in visual units (1/96 of an inch).
    • foreground — foreground brush used to render text.

    Panics when the em size is not a positive number or is too large.

    Source

    set_foreground_brush

    fn set_foreground_brush(self: &Self, foreground_brush: Rc<dyn IBrush>)
    

    Sets foreground brush used for drawing text.

    • foreground_brush — foreground brush

    Source

    set_foreground_brush_range

    fn set_foreground_brush_range(self: &Self, foreground_brush: Option<Rc<dyn IBrush>>, start_index: i32, count: i32)
    

    Sets foreground brush used for drawing text.

    • foreground_brush — foreground brush
    • start_index — the start index of initial character to apply the change to.
    • count — the number of characters the change should be applied to.

    Source

    set_font_features

    fn set_font_features(self: &Self, font_features: Option<FontFeatureCollection>)
    

    Sets or changes the font features for the text object.

    • font_features — feature collection

    Source

    set_font_features_range

    fn set_font_features_range(self: &Self, font_features: Option<FontFeatureCollection>, start_index: i32, count: i32)
    

    Sets or changes the font features for the text object.

    • font_features — feature collection
    • start_index — the start index of initial character to apply the change to.
    • count — the number of characters the change should be applied to.

    Source

    set_font_family_name

    fn set_font_family_name(self: &Self, font_family: &str)
    

    Sets or changes the font family for the text object.

    • font_family — font family name

    Source

    set_font_family_name_range

    fn set_font_family_name_range(self: &Self, font_family: &str, start_index: i32, count: i32)
    

    Sets or changes the font family for the text object.

    • font_family — font family name
    • start_index — the start index of initial character to apply the change to.
    • count — the number of characters the change should be applied to.

    Source

    set_font_family

    fn set_font_family(self: &Self, font_family: FontFamily)
    

    Sets or changes the font family for the text object.

    • font_family — font family

    Source

    set_font_family_range

    fn set_font_family_range(self: &Self, font_family: FontFamily, start_index: i32, count: i32)
    

    Sets or changes the font family for the text object.

    • font_family — font family
    • start_index — the start index of initial character to apply the change to.
    • count — the number of characters the change should be applied to.

    Source

    set_font_size

    fn set_font_size(self: &Self, em_size: f64)
    

    Sets or changes the font em size measured in device independent units.

    • em_size — font em size

    Source

    set_font_size_range

    fn set_font_size_range(self: &Self, em_size: f64, start_index: i32, count: i32)
    

    Sets or changes the font em size measured in device independent units.

    • em_size — font em size
    • start_index — the start index of initial character to apply the change to.
    • count — the number of characters the change should be applied to.

    Source

    set_culture

    fn set_culture(self: &Self, culture: Locale)
    

    Sets or changes the culture for the text object.

    • culture — the new culture for the text object.

    Source

    set_culture_range

    fn set_culture_range(self: &Self, culture: Locale, start_index: i32, count: i32)
    

    Sets or changes the culture for the text object.

    • culture — the new culture for the text object.
    • start_index — the start index of initial character to apply the change to.
    • count — the number of characters the change should be applied to.

    Source

    set_font_weight

    fn set_font_weight(self: &Self, weight: FontWeight)
    

    Sets or changes the font weight.

    • weight — font weight

    Source

    set_font_weight_range

    fn set_font_weight_range(self: &Self, weight: FontWeight, start_index: i32, count: i32)
    

    Sets or changes the font weight.

    • weight — font weight
    • start_index — the start index of initial character to apply the change to.
    • count — the number of characters the change should be applied to.

    Source

    set_font_style

    fn set_font_style(self: &Self, style: FontStyle)
    

    Sets or changes the font style.

    • style — font style

    Source

    set_font_style_range

    fn set_font_style_range(self: &Self, style: FontStyle, start_index: i32, count: i32)
    

    Sets or changes the font style.

    • style — font style
    • start_index — the start index of initial character to apply the change to.
    • count — the number of characters the change should be applied to.

    Source

    set_font_typeface

    fn set_font_typeface(self: &Self, typeface: Typeface)
    

    Sets or changes the type face.

    • typeface — typeface

    Source

    set_font_typeface_range

    fn set_font_typeface_range(self: &Self, typeface: Typeface, start_index: i32, count: i32)
    

    Sets or changes the type face.

    • typeface — typeface
    • start_index — the start index of initial character to apply the change to.
    • count — the number of characters the change should be applied to.

    Source

    set_text_decorations

    fn set_text_decorations(self: &Self, text_decorations: TextDecorationCollection)
    

    Sets or changes the text decorations.

    • text_decorations — text decorations

    Source

    set_text_decorations_range

    fn set_text_decorations_range(self: &Self, text_decorations: TextDecorationCollection, start_index: i32, count: i32)
    

    Sets or changes the text decorations.

    • text_decorations — text decorations
    • start_index — the start index of initial character to apply the change to.
    • count — the number of characters the change should be applied to.

    Source

    flow_direction

    fn flow_direction(self: &Self) -> FlowDirection
    

    Defines the flow direction.

    Source

    set_flow_direction

    fn set_flow_direction(self: &Self, value: FlowDirection)
    

    Defines the flow direction.

    Source

    text_alignment

    fn text_alignment(self: &Self) -> TextAlignment
    

    Defines the alignment of text within the column.

    Source

    set_text_alignment

    fn set_text_alignment(self: &Self, value: TextAlignment)
    

    Defines the alignment of text within the column.

    Source

    line_height

    fn line_height(self: &Self) -> f64
    

    Gets the height of, or the spacing between, each line where zero represents the default line height.

    Source

    set_line_height

    fn set_line_height(self: &Self, value: f64)
    

    Sets the height of, or the spacing between, each line where zero represents the default line height.

    Panics when the value is negative.

    Source

    max_text_width

    fn max_text_width(self: &Self) -> f64
    

    The MaxTextWidth property defines the alignment edges for the FormattedText. For example, left aligned text is wrapped such that the leftmost glyph alignment point on each line falls exactly on the left edge of the rectangle. Note that for many fonts, especially in italic style, some glyph strokes may extend beyond the edges of the alignment rectangle. For this reason, it is recommended that clients draw text with at least 1/6 em (i.e of the font size) unused margin space either side. Zero value of MaxTextWidth is equivalent to the maximum possible paragraph width.

    Source

    set_max_text_width

    fn set_max_text_width(self: &Self, value: f64)
    

    Sets the maximum text width. Panics when the value is negative.

    Source

    set_max_text_widths

    fn set_max_text_widths(self: &Self, max_text_widths: &[f64])
    

    Sets the array of lengths, which will be applied to each line of text in turn. If the text covers more lines than there are entries in the length array, the last entry is reused as many times as required. The max text widths array overrides the MaxTextWidth property.

    Panics when the array is empty.

    • max_text_widths — the max text width array

    Source

    get_max_text_widths

    fn get_max_text_widths(self: &Self) -> Vec<f64>
    

    Obtains a copy of the array of lengths, which will be applied to each line of text in turn. If the text covers more lines than there are entries in the length array, the last entry is reused as many times as required. The max text widths array overrides the MaxTextWidth property.

    Source

    max_text_height

    fn max_text_height(self: &Self) -> f64
    

    Gets the maximum length of a column of text. The last line of text displayed is the last whole line that will fit within this limit, or the nth line as specified by MaxLineCount, whichever occurs first. Use the Trimming property to control how the omission of text is indicated.

    Source

    set_max_text_height

    fn set_max_text_height(self: &Self, value: f64)
    

    Sets the maximum length of a column of text. Panics when the value is not greater than zero or is NaN.

    Source

    max_line_count

    fn max_line_count(self: &Self) -> i32
    

    Defines the maximum number of lines to display. The last line of text displayed is the lineCount-1'th line, or the last whole line that will fit within the count set by MaxTextHeight, whichever occurs first. Use the Trimming property to control how the omission of text is indicated.

    Source

    set_max_line_count

    fn set_max_line_count(self: &Self, value: i32)
    

    Sets the maximum number of lines to display. Panics when the value is not greater than zero.

    Source

    trimming

    fn trimming(self: &Self) -> Rc<dyn TextTrimming>
    

    Defines how omission of text is indicated. CharacterEllipsis trimming allows partial words to be displayed, while WordEllipsis removes whole words to fit. Both guarantee to include an ellipsis ('...') at the end of the lines where text has been trimmed as a result of line and column limits.

    Source

    set_trimming

    fn set_trimming(self: &Self, value: Rc<dyn TextTrimming>)
    

    Defines how omission of text is indicated.

    Source

    height

    fn height(self: &Self) -> f64
    

    The distance from the top of the first line to the bottom of the last line.

    Source

    extent

    fn extent(self: &Self) -> f64
    

    The distance from the topmost black pixel of the first line to the bottommost black pixel of the last line.

    Source

    baseline

    fn baseline(self: &Self) -> f64
    

    The distance from the top of the first line to the baseline of the first line.

    Source

    overhang_after

    fn overhang_after(self: &Self) -> f64
    

    The distance from the bottom of the last line to the extent bottom.

    Source

    overhang_leading

    fn overhang_leading(self: &Self) -> f64
    

    The maximum distance from the leading black pixel to the leading alignment point of a line.

    Source

    overhang_trailing

    fn overhang_trailing(self: &Self) -> f64
    

    The maximum distance from the trailing black pixel to the trailing alignment point of a line.

    Source

    width

    fn width(self: &Self) -> f64
    

    The maximum advance width between the leading and trailing alignment points of a line, excluding the width of whitespace characters at the end of the line.

    Source

    width_including_trailing_whitespace

    fn width_including_trailing_whitespace(self: &Self) -> f64
    

    The maximum advance width between the leading and trailing alignment points of a line, including the width of whitespace characters at the end of the line.

    Source

    build_geometry

    fn build_geometry(self: &Self, origin: Point) -> Option<Ref<Geometry>>
    

    Obtains geometry for the text, including underlines and strikethroughs.

    • origin — the left top origin of the resulting geometry.

    Returns the geometry object containing the outline of the formatted text: the union of all of the glyphs, underlines and strikethroughs that represent the formatted text.

    Source

    build_highlight_geometry

    fn build_highlight_geometry(self: &Self, origin: Point) -> Option<Ref<Geometry>>
    

    Builds a highlight geometry object.

    • origin — the origin of the highlight region

    Returns geometry that surrounds the text.

    Source

    build_highlight_geometry_range

    fn build_highlight_geometry_range(self: &Self, origin: Point, start_index: i32, count: i32) -> Option<Ref<Geometry>>
    

    Builds a highlight geometry object for a given character range.

    • origin — the origin of the highlight region.
    • start_index — the start index of initial character the bounds should be obtained for.
    • count — the number of characters the bounds should be obtained for.

    Returns geometry that surrounds the specified character range.

    Source

    Trait implementations

    • Send
    • Sync
    • Freeze
    • UnsafeUnpin
    • Unpin
    • UnwindSafe
    • RefUnwindSafe
    • ClassDefaults
    • Borrow<T>
    • BorrowMut<T>
    • Into<U>
    • From<T>
    • TryInto<U>
    • TryFrom<U>
    • Any
    • ErasedDestructor
    • IntoEither

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.