pub struct FormattedText { /* private fields */ }Expand description
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.
Implementations§
Source§impl FormattedText
impl FormattedText
pub const DEFAULT_REAL_TO_IDEAL: f64
pub const DEFAULT_IDEAL_TO_REAL: f64
pub const IDEAL_INFINITE_WIDTH: i32 = 0x3FFFFFFE
pub const REAL_INFINITE_WIDTH: f64
pub const GREATEST_MULTIPLIER_OF_EM: f64 = 100.0
Sourcepub fn new(
text_to_format: &str,
culture: CultureInfo,
flow_direction: FlowDirection,
typeface: Typeface,
em_size: f64,
foreground: Option<Rc<dyn IBrush>>,
) -> Self
pub fn new( text_to_format: &str, culture: CultureInfo, 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.
Sourcepub fn set_foreground_brush(&self, foreground_brush: Rc<dyn IBrush>)
pub fn set_foreground_brush(&self, foreground_brush: Rc<dyn IBrush>)
Sets foreground brush used for drawing text.
foreground_brush— foreground brush
Sourcepub fn set_foreground_brush_range(
&self,
foreground_brush: Option<Rc<dyn IBrush>>,
start_index: i32,
count: i32,
)
pub fn set_foreground_brush_range( &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.
Sourcepub fn set_font_features(&self, font_features: Option<FontFeatureCollection>)
pub fn set_font_features(&self, font_features: Option<FontFeatureCollection>)
Sets or changes the font features for the text object.
font_features— feature collection
Sourcepub fn set_font_features_range(
&self,
font_features: Option<FontFeatureCollection>,
start_index: i32,
count: i32,
)
pub fn set_font_features_range( &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.
Sourcepub fn set_font_family_name(&self, font_family: &str)
pub fn set_font_family_name(&self, font_family: &str)
Sets or changes the font family for the text object.
font_family— font family name
Sourcepub fn set_font_family_name_range(
&self,
font_family: &str,
start_index: i32,
count: i32,
)
pub fn set_font_family_name_range( &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.
Sourcepub fn set_font_family(&self, font_family: FontFamily)
pub fn set_font_family(&self, font_family: FontFamily)
Sets or changes the font family for the text object.
font_family— font family
Sourcepub fn set_font_family_range(
&self,
font_family: FontFamily,
start_index: i32,
count: i32,
)
pub fn set_font_family_range( &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.
Sourcepub fn set_font_size(&self, em_size: f64)
pub fn set_font_size(&self, em_size: f64)
Sets or changes the font em size measured in device independent units.
em_size— font em size
Sourcepub fn set_font_size_range(&self, em_size: f64, start_index: i32, count: i32)
pub fn set_font_size_range(&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.
Sourcepub fn set_culture(&self, culture: CultureInfo)
pub fn set_culture(&self, culture: CultureInfo)
Sets or changes the culture for the text object.
culture— the new culture for the text object.
Sourcepub fn set_culture_range(
&self,
culture: CultureInfo,
start_index: i32,
count: i32,
)
pub fn set_culture_range( &self, culture: CultureInfo, 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.
Sourcepub fn set_font_weight(&self, weight: FontWeight)
pub fn set_font_weight(&self, weight: FontWeight)
Sets or changes the font weight.
weight— font weight
Sourcepub fn set_font_weight_range(
&self,
weight: FontWeight,
start_index: i32,
count: i32,
)
pub fn set_font_weight_range( &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.
Sourcepub fn set_font_style(&self, style: FontStyle)
pub fn set_font_style(&self, style: FontStyle)
Sets or changes the font style.
style— font style
Sourcepub fn set_font_style_range(
&self,
style: FontStyle,
start_index: i32,
count: i32,
)
pub fn set_font_style_range( &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.
Sourcepub fn set_font_typeface(&self, typeface: Typeface)
pub fn set_font_typeface(&self, typeface: Typeface)
Sets or changes the type face.
typeface— typeface
Sourcepub fn set_font_typeface_range(
&self,
typeface: Typeface,
start_index: i32,
count: i32,
)
pub fn set_font_typeface_range( &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.
Sourcepub fn set_text_decorations(&self, text_decorations: TextDecorationCollection)
pub fn set_text_decorations(&self, text_decorations: TextDecorationCollection)
Sets or changes the text decorations.
text_decorations— text decorations
Sourcepub fn set_text_decorations_range(
&self,
text_decorations: TextDecorationCollection,
start_index: i32,
count: i32,
)
pub fn set_text_decorations_range( &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.
Sourcepub fn flow_direction(&self) -> FlowDirection
pub fn flow_direction(&self) -> FlowDirection
Defines the flow direction.
Sourcepub fn set_flow_direction(&self, value: FlowDirection)
pub fn set_flow_direction(&self, value: FlowDirection)
Defines the flow direction.
Sourcepub fn text_alignment(&self) -> TextAlignment
pub fn text_alignment(&self) -> TextAlignment
Defines the alignment of text within the column.
Sourcepub fn set_text_alignment(&self, value: TextAlignment)
pub fn set_text_alignment(&self, value: TextAlignment)
Defines the alignment of text within the column.
Sourcepub fn line_height(&self) -> f64
pub fn line_height(&self) -> f64
Gets the height of, or the spacing between, each line where zero represents the default line height.
Sourcepub fn set_line_height(&self, value: f64)
pub fn set_line_height(&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.
Sourcepub fn max_text_width(&self) -> f64
pub fn max_text_width(&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.
Sourcepub fn set_max_text_width(&self, value: f64)
pub fn set_max_text_width(&self, value: f64)
Sets the maximum text width. Panics when the value is negative.
Sourcepub fn set_max_text_widths(&self, max_text_widths: &[f64])
pub fn set_max_text_widths(&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
Sourcepub fn get_max_text_widths(&self) -> Vec<f64>
pub fn get_max_text_widths(&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.
Sourcepub fn max_text_height(&self) -> f64
pub fn max_text_height(&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.
Sourcepub fn set_max_text_height(&self, value: f64)
pub fn set_max_text_height(&self, value: f64)
Sets the maximum length of a column of text. Panics when the value is not greater than zero or is NaN.
Sourcepub fn max_line_count(&self) -> i32
pub fn max_line_count(&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.
Sourcepub fn set_max_line_count(&self, value: i32)
pub fn set_max_line_count(&self, value: i32)
Sets the maximum number of lines to display. Panics when the value is not greater than zero.
Sourcepub fn trimming(&self) -> Rc<dyn TextTrimming>
pub fn trimming(&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.
Sourcepub fn set_trimming(&self, value: Rc<dyn TextTrimming>)
pub fn set_trimming(&self, value: Rc<dyn TextTrimming>)
Defines how omission of text is indicated.
Sourcepub fn height(&self) -> f64
pub fn height(&self) -> f64
The distance from the top of the first line to the bottom of the last line.
Sourcepub fn extent(&self) -> f64
pub fn extent(&self) -> f64
The distance from the topmost black pixel of the first line to the bottommost black pixel of the last line.
Sourcepub fn baseline(&self) -> f64
pub fn baseline(&self) -> f64
The distance from the top of the first line to the baseline of the first line.
Sourcepub fn overhang_after(&self) -> f64
pub fn overhang_after(&self) -> f64
The distance from the bottom of the last line to the extent bottom.
Sourcepub fn overhang_leading(&self) -> f64
pub fn overhang_leading(&self) -> f64
The maximum distance from the leading black pixel to the leading alignment point of a line.
Sourcepub fn overhang_trailing(&self) -> f64
pub fn overhang_trailing(&self) -> f64
The maximum distance from the trailing black pixel to the trailing alignment point of a line.
Sourcepub fn width(&self) -> f64
pub fn width(&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.
Sourcepub fn width_including_trailing_whitespace(&self) -> f64
pub fn width_including_trailing_whitespace(&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.
Sourcepub fn build_geometry(&self, origin: Point) -> Option<Ref<Geometry>>
pub fn build_geometry(&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.
Sourcepub fn build_highlight_geometry(&self, origin: Point) -> Option<Ref<Geometry>>
pub fn build_highlight_geometry(&self, origin: Point) -> Option<Ref<Geometry>>
Builds a highlight geometry object.
origin— the origin of the highlight region
Returns geometry that surrounds the text.
Sourcepub fn build_highlight_geometry_range(
&self,
origin: Point,
start_index: i32,
count: i32,
) -> Option<Ref<Geometry>>
pub fn build_highlight_geometry_range( &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.
Auto Trait Implementations§
impl !Freeze for FormattedText
impl !RefUnwindSafe for FormattedText
impl !Send for FormattedText
impl !Sync for FormattedText
impl !UnwindSafe for FormattedText
impl Unpin for FormattedText
impl UnsafeUnpin for FormattedText
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> ClassDefaults for Twhere
T: ?Sized,
impl<T> ClassDefaults for Twhere
T: ?Sized,
Source§fn static_constructor()
fn static_constructor()
affects_render, metadata
overrides). Read more