pub type Paragraph = RefHandle<skia_textlayout_Paragraph>;
Aliased Type§
struct Paragraph(/* private fields */);
Implementations§
Source§impl Paragraph
impl Paragraph
pub fn max_width(&self) -> scalar
pub fn height(&self) -> scalar
pub fn min_intrinsic_width(&self) -> scalar
pub fn max_intrinsic_width(&self) -> scalar
pub fn alphabetic_baseline(&self) -> scalar
pub fn ideographic_baseline(&self) -> scalar
pub fn longest_line(&self) -> scalar
pub fn did_exceed_max_lines(&self) -> bool
pub fn layout(&mut self, width: scalar)
pub fn paint(&self, canvas: &Canvas, p: impl Into<Point>)
Sourcepub fn get_rects_for_range(
&self,
range: Range<usize>,
rect_height_style: RectHeightStyle,
rect_width_style: RectWidthStyle,
) -> Vec<TextBox>
pub fn get_rects_for_range( &self, range: Range<usize>, rect_height_style: RectHeightStyle, rect_width_style: RectWidthStyle, ) -> Vec<TextBox>
Returns a vector of bounding boxes that enclose all text between start and end glyph indexes, including start and excluding end
pub fn get_rects_for_placeholders(&self) -> Vec<TextBox>
Sourcepub fn get_glyph_position_at_coordinate(
&self,
p: impl Into<Point>,
) -> PositionWithAffinity
pub fn get_glyph_position_at_coordinate( &self, p: impl Into<Point>, ) -> PositionWithAffinity
Returns the index of the glyph that corresponds to the provided coordinate, with the top left corner as the origin, and +y direction as down
Sourcepub fn get_word_boundary(&self, offset: u32) -> Range<usize> ⓘ
pub fn get_word_boundary(&self, offset: u32) -> Range<usize> ⓘ
Finds the first and last glyphs that define a word containing the glyph at index offset
pub fn get_line_metrics(&self) -> Vec<LineMetrics<'_>>
pub fn line_number(&self) -> usize
pub fn mark_dirty(&mut self)
Sourcepub fn unresolved_glyphs(&mut self) -> Option<usize>
pub fn unresolved_glyphs(&mut self) -> Option<usize>
This function will return the number of unresolved glyphs or
None
if not applicable (has not been shaped yet - valid case)
pub fn unresolved_codepoints(&mut self) -> Vec<Unichar>
pub fn visit<'a, F>(&mut self, visitor: F)
pub fn extended_visit<'a, F>(&mut self, visitor: F)
Sourcepub fn get_path_at(&mut self, line_number: usize) -> (usize, Path)
pub fn get_path_at(&mut self, line_number: usize) -> (usize, Path)
Returns path for a given line
line_number
- a line numberdest
- a resulting path
Returns: a number glyphs that could not be converted to path
Sourcepub fn get_path(text_blob: &mut TextBlob) -> Path
pub fn get_path(text_blob: &mut TextBlob) -> Path
Returns path for a text blob
text_blob
- a text blob
Returns: a path
Sourcepub fn contains_emoji(&mut self, text_blob: &mut TextBlob) -> bool
pub fn contains_emoji(&mut self, text_blob: &mut TextBlob) -> bool
Checks if a given text blob contains glyph with emoji
text_blob
- a text blob
Returns: true
if there is such a glyph
Sourcepub fn contains_color_font_or_bitmap(
&mut self,
text_blob: &mut TextBlob,
) -> bool
pub fn contains_color_font_or_bitmap( &mut self, text_blob: &mut TextBlob, ) -> bool
Checks if a given text blob contains colored font or bitmap
text_blob
- a text blob
Returns: true
if there is such a glyph
Sourcepub fn get_line_number_at(&self, code_unit_index: TextIndex) -> Option<usize>
pub fn get_line_number_at(&self, code_unit_index: TextIndex) -> Option<usize>
Finds the line number of the line that contains the given UTF-8 index.
index
- a UTF-8 TextIndex into the paragraph
Returns: the line number the glyph that corresponds to the
given code_unit_index
is in, or -1 if the code_unit_index
is out of bounds, or when the glyph is truncated or
ellipsized away.
Sourcepub fn get_line_number_at_utf16_offset(
&self,
code_unit_index: TextIndex,
) -> Option<usize>
pub fn get_line_number_at_utf16_offset( &self, code_unit_index: TextIndex, ) -> Option<usize>
Finds the line number of the line that contains the given UTF-16 index.
index
- a UTF-16 offset into the paragraph
Returns: the line number the glyph that corresponds to the
given code_unit_index
is in, or -1 if the code_unit_index
is out of bounds, or when the glyph is truncated or
ellipsized away.
Sourcepub fn get_line_metrics_at(&self, line_number: usize) -> Option<LineMetrics<'_>>
pub fn get_line_metrics_at(&self, line_number: usize) -> Option<LineMetrics<'_>>
Returns line metrics info for the line
line_number
- a line numberline_metrics
- an address to return the info (in case of null just skipped)
Returns: true
if the line is found; false
if not
Sourcepub fn get_actual_text_range(
&self,
line_number: usize,
include_spaces: bool,
) -> TextRange
pub fn get_actual_text_range( &self, line_number: usize, include_spaces: bool, ) -> TextRange
Returns the visible text on the line (excluding a possible ellipsis)
line_number
- a line numberinclude_spaces
- indicates if the whitespaces should be included
Returns: the range of the text that is shown in the line
Sourcepub fn get_glyph_cluster_at(
&self,
code_unit_index: TextIndex,
) -> Option<GlyphClusterInfo>
pub fn get_glyph_cluster_at( &self, code_unit_index: TextIndex, ) -> Option<GlyphClusterInfo>
Finds a glyph cluster for text index
code_unit_index
- a text indexglyph_info
- a glyph cluster info filled if not null
Returns: true
if glyph cluster was found; false
if not
Sourcepub fn get_closest_glyph_cluster_at(
&self,
d: impl Into<Point>,
) -> Option<GlyphClusterInfo>
pub fn get_closest_glyph_cluster_at( &self, d: impl Into<Point>, ) -> Option<GlyphClusterInfo>
Finds the closest glyph cluster for a visual text position
dx
- x coordinatedy
- y coordinateglyph_info
- a glyph cluster info filled if not null
Returns: true
if glyph cluster was found; false
if not
(which usually means the paragraph is empty)
Sourcepub fn get_glyph_info_at_utf16_offset(
&mut self,
code_unit_index: usize,
) -> Option<GlyphInfo>
pub fn get_glyph_info_at_utf16_offset( &mut self, code_unit_index: usize, ) -> Option<GlyphInfo>
Retrieves the information associated with the glyph located at the given
code_unit_index
.
code_unit_index
- a UTF-16 offset into the paragraphglyph_info
- an optional GlyphInfo struct to hold the information associated with the glyph found at the given index
Returns: false
only if the offset is out of bounds
Sourcepub fn get_closest_utf16_glyph_info_at(
&mut self,
d: impl Into<Point>,
) -> Option<GlyphInfo>
pub fn get_closest_utf16_glyph_info_at( &mut self, d: impl Into<Point>, ) -> Option<GlyphInfo>
Finds the information associated with the closest glyph to the given paragraph coordinates.
d
- x/y coordinateglyph_info
- an optional GlyphInfo struct to hold the information associated with the glyph found. The text indices and text ranges are described using UTF-16 offsets
Returns: true
if a grapheme cluster was found; false
if not
(which usually means the paragraph is empty)
Sourcepub fn get_font_at(&self, code_unit_index: TextIndex) -> Font
pub fn get_font_at(&self, code_unit_index: TextIndex) -> Font
Returns the font that is used to shape the text at the position
code_unit_index
- text index
Returns: font info or an empty font info if the text is not found
Sourcepub fn get_font_at_utf16_offset(&mut self, code_unit_index: usize) -> Font
pub fn get_font_at_utf16_offset(&mut self, code_unit_index: usize) -> Font
Returns the font used to shape the text at the given UTF-16 offset.
code_unit_index
- a UTF-16 offset in the paragraph
Returns: font info or an empty font info if the text is not found