pub struct TextLayout { /* private fields */ }Expand description
Represents a multi line text layout.
Implementations§
Source§impl TextLayout
impl TextLayout
Sourcepub fn new(text: &str, typeface: Typeface, options: TextLayoutOptions) -> Self
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.
Sourcepub fn from_utf16(
text: ReadOnlyMemory<u16>,
typeface: Typeface,
options: TextLayoutOptions,
) -> Self
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).
Sourcepub 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
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.
Sourcepub fn line_height(&self) -> f64
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.
Sourcepub fn max_height(&self) -> f64
pub fn max_height(&self) -> f64
Gets the maximum height.
Sourcepub fn letter_spacing(&self) -> f64
pub fn letter_spacing(&self) -> f64
Gets the text spacing.
Sourcepub fn text_lines(&self) -> &[Rc<dyn TextLine>]
pub fn text_lines(&self) -> &[Rc<dyn TextLine>]
Gets the text lines.
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 draw(&self, context: &mut dyn ITextDrawingSink, origin: Point)
pub fn draw(&self, context: &mut dyn ITextDrawingSink, origin: Point)
Draws the text layout.
context— the drawing context.origin— the origin.
Sourcepub fn hit_test_text_position(&self, text_position: i32) -> Rect
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.
Sourcepub fn hit_test_text_range(&self, start: i32, length: i32) -> Vec<Rect>
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.
Sourcepub fn hit_test_point(&self, point: Point) -> TextHitTestResult
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.
Sourcepub fn get_line_index_from_character_index(
&self,
char_index: i32,
trailing_edge: bool,
) -> i32
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.
Auto Trait Implementations§
impl !RefUnwindSafe for TextLayout
impl !Send for TextLayout
impl !Sync for TextLayout
impl !UnwindSafe for TextLayout
impl Freeze for TextLayout
impl Unpin for TextLayout
impl UnsafeUnpin for TextLayout
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