pub struct SoftwareTextMeasurer { /* private fields */ }Implementations§
Source§impl SoftwareTextMeasurer
impl SoftwareTextMeasurer
pub fn new(font: SoftwareTextFont, cache_capacity: usize) -> Self
pub fn from_font_set(fonts: SoftwareTextFontSet, cache_capacity: usize) -> Self
pub fn from_fonts_or_default( fonts: &[&'static [u8]], cache_capacity: usize, ) -> Self
pub fn register_hyphenation_dictionary_path( &self, locale: &str, path: impl AsRef<Path>, ) -> Result<(), HyphenationDictionaryError>
pub fn register_hyphenation_dictionary_reader( &self, locale: &str, reader: &mut impl Read, ) -> Result<(), HyphenationDictionaryError>
Trait Implementations§
Source§impl TextMeasurer for SoftwareTextMeasurer
impl TextMeasurer for SoftwareTextMeasurer
fn measure(&self, text: &AnnotatedString, style: &TextStyle) -> TextMetrics
Source§fn begin_layout_pass(&self)
fn begin_layout_pass(&self)
Called as each layout pass starts. A measurer that caches
measurements can age them by passes and drop the ones recent passes
did not use.
fn measure_subsequence( &self, text: &AnnotatedString, range: Range<usize>, style: &TextStyle, ) -> TextMetrics
Source§fn measure_line_prefix_widths(
&self,
text: &AnnotatedString,
line_range: Range<usize>,
style: &TextStyle,
) -> Option<TextLinePrefixWidths>
fn measure_line_prefix_widths( &self, text: &AnnotatedString, line_range: Range<usize>, style: &TextStyle, ) -> Option<TextLinePrefixWidths>
The widths of every prefix of one line.
fn measure_line_width( &self, text: &AnnotatedString, line_range: Range<usize>, style: &TextStyle, ) -> Option<f32>
fn line_height(&self, text: &AnnotatedString, style: &TextStyle) -> f32
Source§fn glyph_line_box(&self, style: &TextStyle) -> Option<(f32, f32)>
fn glyph_line_box(&self, style: &TextStyle) -> Option<(f32, f32)>
The tight glyph box of a text line inside its
line_height slot:
(top_offset, height) in logical units, where height is the font’s
natural ascent+descent extent and top_offset positions it within the
slot (glyph rows are vertically centered). Selection chrome — the
highlight, the caret and the finger handles — anchors to THIS box,
not the full slot: with a paragraph line height above the natural one
the reference shows gaps between highlighted lines and handles riding
the glyphs. None means the box fills the slot.Source§fn first_baseline(&self, style: &TextStyle) -> Option<f32>
fn first_baseline(&self, style: &TextStyle) -> Option<f32>
Distance from the top of a line slot down to that line’s baseline, in
logical units — the number the rasterizer places glyph origins at. Read more
Source§fn line_box(&self, style: &TextStyle) -> Option<LineBox>
fn line_box(&self, style: &TextStyle) -> Option<LineBox>
One line’s whole box for a style: its advance, its baseline and what a
paragraph of it gives back at its edges, with no string to measure. Read more
Source§fn line_box_and_height(
&self,
_node_id: Option<NodeId>,
text: &AnnotatedString,
style: &TextStyle,
) -> (Option<LineBox>, f32)
fn line_box_and_height( &self, _node_id: Option<NodeId>, text: &AnnotatedString, style: &TextStyle, ) -> (Option<LineBox>, f32)
TextMeasurer::line_box of style and
TextMeasurer::line_height_for_node of text in it, together: a
measurer that finds both in one font lookup answers them at once.Source§fn visit_line_boxes(
&self,
text: &AnnotatedString,
style: &TextStyle,
visit: &mut dyn FnMut(LineBox),
) -> Option<()>
fn visit_line_boxes( &self, text: &AnnotatedString, style: &TextStyle, visit: &mut dyn FnMut(LineBox), ) -> Option<()>
Visits each displayed line’s resolved font box, including styled spans.
The text must already contain its wrapping newlines. Returns
None when
the measurer does not provide these metrics; no callbacks run in that case.
The default handles plain text and defers annotated spans to line_height.fn get_offset_for_position( &self, text: &AnnotatedString, style: &TextStyle, x: f32, y: f32, ) -> usize
fn get_cursor_x_for_offset( &self, text: &AnnotatedString, style: &TextStyle, offset: usize, ) -> f32
fn layout(&self, text: &AnnotatedString, style: &TextStyle) -> TextLayoutResult
Source§fn choose_auto_hyphen_break(
&self,
line: &str,
style: &TextStyle,
segment_start_char: usize,
measured_break_char: usize,
) -> Option<usize>
fn choose_auto_hyphen_break( &self, line: &str, style: &TextStyle, segment_start_char: usize, measured_break_char: usize, ) -> Option<usize>
Returns an alternate break boundary for
Hyphens::Auto when a greedy break
split lands in the middle of a word. Read morefn measure_for_node( &self, node_id: Option<usize>, text: &AnnotatedString, style: &TextStyle, ) -> TextMetrics
fn measure_subsequence_for_node( &self, node_id: Option<usize>, text: &AnnotatedString, range: Range<usize>, style: &TextStyle, ) -> TextMetrics
fn line_height_for_node( &self, node_id: Option<usize>, text: &AnnotatedString, style: &TextStyle, ) -> f32
fn measure_with_options( &self, text: &AnnotatedString, style: &TextStyle, options: TextLayoutOptions, max_width: Option<f32>, ) -> TextMetrics
fn measure_with_options_for_node( &self, node_id: Option<usize>, text: &AnnotatedString, style: &TextStyle, options: TextLayoutOptions, max_width: Option<f32>, ) -> TextMetrics
fn prepare_with_options( &self, text: &AnnotatedString, style: &TextStyle, options: TextLayoutOptions, max_width: Option<f32>, ) -> PreparedTextLayout
Source§fn prepare_with_options_for_node(
&self,
node_id: Option<usize>,
text: &Rc<AnnotatedString>,
style: &Arc<TextStyle>,
options: TextLayoutOptions,
max_width: Option<f32>,
) -> PreparedTextLayout
fn prepare_with_options_for_node( &self, node_id: Option<usize>, text: &Rc<AnnotatedString>, style: &Arc<TextStyle>, options: TextLayoutOptions, max_width: Option<f32>, ) -> PreparedTextLayout
Lays
text out in style for a node that holds both: a layout that
leaves them as they are shares them instead of copying them.fn prepare_with_options_fallback( &self, text: &AnnotatedString, style: &TextStyle, options: TextLayoutOptions, max_width: Option<f32>, ) -> PreparedTextLayout
Auto Trait Implementations§
impl !Freeze for SoftwareTextMeasurer
impl !RefUnwindSafe for SoftwareTextMeasurer
impl !Send for SoftwareTextMeasurer
impl !Sync for SoftwareTextMeasurer
impl !UnwindSafe for SoftwareTextMeasurer
impl Unpin for SoftwareTextMeasurer
impl UnsafeUnpin for SoftwareTextMeasurer
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
Mutably borrows from an owned value. Read more