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.
Members
DEFAULT_REAL_TO_IDEALDEFAULT_IDEAL_TO_REALIDEAL_INFINITE_WIDTHREAL_INFINITE_WIDTHGREATEST_MULTIPLIER_OF_EMnewset_foreground_brushset_foreground_brush_rangeset_font_featuresset_font_features_rangeset_font_family_nameset_font_family_name_rangeset_font_familyset_font_family_rangeset_font_sizeset_font_size_rangeset_cultureset_culture_rangeset_font_weightset_font_weight_rangeset_font_styleset_font_style_rangeset_font_typefaceset_font_typeface_rangeset_text_decorationsset_text_decorations_rangeflow_directionset_flow_directiontext_alignmentset_text_alignmentline_heightset_line_heightmax_text_widthset_max_text_widthset_max_text_widthsget_max_text_widthsmax_text_heightset_max_text_heightmax_line_countset_max_line_counttrimmingset_trimmingheightextentbaselineoverhang_afteroverhang_leadingoverhang_trailingwidthwidth_including_trailing_whitespacebuild_geometrybuild_highlight_geometrybuild_highlight_geometry_range
DEFAULT_REAL_TO_IDEAL
const DEFAULT_REAL_TO_IDEAL: f64
DEFAULT_IDEAL_TO_REAL
const DEFAULT_IDEAL_TO_REAL: f64
IDEAL_INFINITE_WIDTH
const IDEAL_INFINITE_WIDTH: i32
REAL_INFINITE_WIDTH
const REAL_INFINITE_WIDTH: f64
GREATEST_MULTIPLIER_OF_EM
const GREATEST_MULTIPLIER_OF_EM: f64
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.
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
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 brushstart_index— the start index of initial character to apply the change to.count— the number of characters the change should be applied to.
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
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 collectionstart_index— the start index of initial character to apply the change to.count— the number of characters the change should be applied to.
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
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 namestart_index— the start index of initial character to apply the change to.count— the number of characters the change should be applied to.
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
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 familystart_index— the start index of initial character to apply the change to.count— the number of characters the change should be applied to.
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
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 sizestart_index— the start index of initial character to apply the change to.count— the number of characters the change should be applied to.
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.
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.
set_font_weight
fn set_font_weight(self: &Self, weight: FontWeight)
Sets or changes the font weight.
weight— font weight
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 weightstart_index— the start index of initial character to apply the change to.count— the number of characters the change should be applied to.
set_font_style
fn set_font_style(self: &Self, style: FontStyle)
Sets or changes the font style.
style— font style
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 stylestart_index— the start index of initial character to apply the change to.count— the number of characters the change should be applied to.
set_font_typeface
fn set_font_typeface(self: &Self, typeface: Typeface)
Sets or changes the type face.
typeface— typeface
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— typefacestart_index— the start index of initial character to apply the change to.count— the number of characters the change should be applied to.
set_text_decorations
fn set_text_decorations(self: &Self, text_decorations: TextDecorationCollection)
Sets or changes the text decorations.
text_decorations— text decorations
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 decorationsstart_index— the start index of initial character to apply the change to.count— the number of characters the change should be applied to.
flow_direction
fn flow_direction(self: &Self) -> FlowDirection
Defines the flow direction.
set_flow_direction
fn set_flow_direction(self: &Self, value: FlowDirection)
Defines the flow direction.
text_alignment
fn text_alignment(self: &Self) -> TextAlignment
Defines the alignment of text within the column.
set_text_alignment
fn set_text_alignment(self: &Self, value: TextAlignment)
Defines the alignment of text within the column.
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.
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.
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.
set_max_text_width
fn set_max_text_width(self: &Self, value: f64)
Sets the maximum text width. Panics when the value is negative.
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
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.
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.
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.
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.
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.
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.
set_trimming
fn set_trimming(self: &Self, value: Rc<dyn TextTrimming>)
Defines how omission of text is indicated.
height
fn height(self: &Self) -> f64
The distance from the top of the first line to the bottom of the last line.
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.
baseline
fn baseline(self: &Self) -> f64
The distance from the top of the first line to the baseline of the first line.
overhang_after
fn overhang_after(self: &Self) -> f64
The distance from the bottom of the last line to the extent bottom.
overhang_leading
fn overhang_leading(self: &Self) -> f64
The maximum distance from the leading black pixel to the leading alignment point of a line.
overhang_trailing
fn overhang_trailing(self: &Self) -> f64
The maximum distance from the trailing black pixel to the trailing alignment point of a line.
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.
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.
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.
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.
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.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeClassDefaultsBorrow<T>BorrowMut<T>Into<U>From<T>TryInto<U>TryFrom<U>AnyErasedDestructorIntoEither
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.