Skip to main content

FormattedText

Struct FormattedText 

Source
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

Source

pub const DEFAULT_REAL_TO_IDEAL: f64

Source

pub const DEFAULT_IDEAL_TO_REAL: f64

Source

pub const IDEAL_INFINITE_WIDTH: i32 = 0x3FFFFFFE

Source

pub const REAL_INFINITE_WIDTH: f64

Source

pub const GREATEST_MULTIPLIER_OF_EM: f64 = 100.0

Source

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.

Source

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

Sets foreground brush used for drawing text.

  • foreground_brush — foreground brush
Source

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 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

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

Sets or changes the font features for the text object.

  • font_features — feature collection
Source

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 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

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
Source

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 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

pub fn set_font_family(&self, font_family: FontFamily)

Sets or changes the font family for the text object.

  • font_family — font family
Source

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 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

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
Source

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 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

pub fn set_culture(&self, culture: CultureInfo)

Sets or changes the culture for the text object.

  • culture — the new culture for the text object.
Source

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.
Source

pub fn set_font_weight(&self, weight: FontWeight)

Sets or changes the font weight.

  • weight — font weight
Source

pub fn set_font_weight_range( &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

pub fn set_font_style(&self, style: FontStyle)

Sets or changes the font style.

  • style — font style
Source

pub fn set_font_style_range( &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

pub fn set_font_typeface(&self, typeface: Typeface)

Sets or changes the type face.

  • typeface — typeface
Source

pub fn set_font_typeface_range( &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

pub fn set_text_decorations(&self, text_decorations: TextDecorationCollection)

Sets or changes the text decorations.

  • text_decorations — text decorations
Source

pub fn set_text_decorations_range( &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

pub fn flow_direction(&self) -> FlowDirection

Defines the flow direction.

Source

pub fn set_flow_direction(&self, value: FlowDirection)

Defines the flow direction.

Source

pub fn text_alignment(&self) -> TextAlignment

Defines the alignment of text within the column.

Source

pub fn set_text_alignment(&self, value: TextAlignment)

Defines the alignment of text within the column.

Source

pub fn line_height(&self) -> f64

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

Source

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.

Source

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.

Source

pub fn set_max_text_width(&self, value: f64)

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

Source

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
Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Defines how omission of text is indicated.

Source

pub fn height(&self) -> f64

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

Source

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.

Source

pub fn baseline(&self) -> f64

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

Source

pub fn overhang_after(&self) -> f64

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

Source

pub fn overhang_leading(&self) -> f64

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

Source

pub fn overhang_trailing(&self) -> f64

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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ClassDefaults for T
where T: ?Sized,

Source§

fn static_constructor()

The static constructor of a type: work done once per thread, after the properties of the type are registered and before its first instance exists (class handlers, affects_render, metadata overrides). Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.