Skip to main content

TextLayout

Struct TextLayout 

Source
pub struct TextLayout { /* private fields */ }
Expand description

Represents a multi line text layout.

Implementations§

Source§

impl TextLayout

Source

pub fn new(text: &str, typeface: Typeface, options: TextLayoutOptions) -> Self

Initializes a new instance of the TextLayout class.

  • text — the text.
  • typeface — the typeface.
  • options — the remaining (optional) parameters.
Source

pub fn from_utf16( text: ReadOnlyMemory<u16>, typeface: Typeface, options: TextLayoutOptions, ) -> Self

Initializes a new instance of the TextLayout class from UTF-16 text (no transcoding).

Source

pub fn from_text_source( text_source: Rc<dyn ITextSource>, paragraph_properties: Rc<dyn TextParagraphProperties>, text_trimming: Option<Rc<dyn TextTrimming>>, max_width: f64, max_height: f64, max_lines: i32, text_run_cache: Option<Rc<TextRunCache>>, ) -> Self

Initializes a new instance of the TextLayout class.

  • text_source — the text source.
  • paragraph_properties — the default text paragraph properties.
  • text_trimming — the text trimming (upstream default: None).
  • max_width — the maximum width (upstream default: positive infinity).
  • max_height — the maximum height (upstream default: positive infinity).
  • max_lines — the maximum number of text lines (upstream default: 0).
  • text_run_cache — an optional cache for shaped text runs to avoid redundant shaping.
Source

pub fn line_height(&self) -> f64

Gets the height of each line of text.

A value of NaN (equivalent to an attribute value of “Auto”) indicates that the line height is determined automatically from the current font characteristics. The default is NaN.

Source

pub fn max_width(&self) -> f64

Gets the maximum width.

Source

pub fn max_height(&self) -> f64

Gets the maximum height.

Source

pub fn max_lines(&self) -> i32

Gets the maximum number of text lines.

Source

pub fn letter_spacing(&self) -> f64

Gets the text spacing.

Source

pub fn text_lines(&self) -> &[Rc<dyn TextLine>]

Gets the text lines.

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 draw(&self, context: &mut dyn ITextDrawingSink, origin: Point)

Draws the text layout.

  • context — the drawing context.
  • origin — the origin.
Source

pub fn hit_test_text_position(&self, text_position: i32) -> Rect

Get the pixel location relative to the top-left of the layout box given the text position.

  • text_position — the text position.
Source

pub fn hit_test_text_range(&self, start: i32, length: i32) -> Vec<Rect>

Gets the bounding rectangles of a range of text, relative to the top-left of the layout box.

Source

pub fn hit_test_point(&self, point: Point) -> TextHitTestResult

Gets the character hit of a point relative to the top-left of the layout box.

Source

pub fn get_line_index_from_character_index( &self, char_index: i32, trailing_edge: bool, ) -> i32

Gets the index of the line that contains a character index.

Source

pub fn dispose(&self)

Releases the text lines.

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.