pub struct LayoutCtx<'a> { /* private fields */ }Expand description
Borrowed text system used by layout code to shape and measure text.
Measurements are not cached here; the underlying TextSystem owns any
caching that may occur.
Implementations§
Source§impl<'a> LayoutCtx<'a>
impl<'a> LayoutCtx<'a>
Sourcepub fn new(text: &'a mut TextSystem, default_font_size: f32) -> LayoutCtx<'a>
pub fn new(text: &'a mut TextSystem, default_font_size: f32) -> LayoutCtx<'a>
Creates a context that borrows text and uses default_font_size for
callers that do not specify a size.
Sourcepub fn default_font_size(&self) -> f32
pub fn default_font_size(&self) -> f32
Returns the default font size for this layout pass.
Sourcepub fn text_width(&mut self, text: &str, size: f32) -> f32
pub fn text_width(&mut self, text: &str, size: f32) -> f32
Measures the width of a single line of text.
Sourcepub fn text_width_weighted(
&mut self,
text: &str,
size: f32,
weight: FontWeight,
) -> f32
pub fn text_width_weighted( &mut self, text: &str, size: f32, weight: FontWeight, ) -> f32
Measures the width of a single line using the given font weight.
Sourcepub fn text_width_spaced(&mut self, text: &str, size: f32, spacing: f32) -> f32
pub fn text_width_spaced(&mut self, text: &str, size: f32, spacing: f32) -> f32
Measures the width of a single line with letter spacing.
Sourcepub fn text_width_weighted_spaced(
&mut self,
text: &str,
size: f32,
weight: FontWeight,
spacing: f32,
) -> f32
pub fn text_width_weighted_spaced( &mut self, text: &str, size: f32, weight: FontWeight, spacing: f32, ) -> f32
Measures the width of a single line with weight and letter spacing.
Sourcepub fn text_width_styled_spaced(
&mut self,
text: &str,
size: f32,
weight: FontWeight,
spacing: f32,
family: Option<&str>,
style: FontStyle,
) -> f32
pub fn text_width_styled_spaced( &mut self, text: &str, size: f32, weight: FontWeight, spacing: f32, family: Option<&str>, style: FontStyle, ) -> f32
Measures the width of a single line with weight, spacing, family, and style.
Sourcepub fn caret_positions(
&mut self,
text: &str,
size: f32,
weight: FontWeight,
) -> Vec<f32>
pub fn caret_positions( &mut self, text: &str, size: f32, weight: FontWeight, ) -> Vec<f32>
Returns caret positions along a single line of text.
Sourcepub fn caret_positions_spaced(
&mut self,
text: &str,
size: f32,
weight: FontWeight,
spacing: f32,
) -> Vec<f32>
pub fn caret_positions_spaced( &mut self, text: &str, size: f32, weight: FontWeight, spacing: f32, ) -> Vec<f32>
Returns caret positions along a single line with letter spacing.
Sourcepub fn text_wrapped_size(
&mut self,
text: &str,
size: f32,
weight: FontWeight,
width: f32,
mode: WrapMode,
) -> Size
pub fn text_wrapped_size( &mut self, text: &str, size: f32, weight: FontWeight, width: f32, mode: WrapMode, ) -> Size
Measures wrapped text within width, returning its size.
Sourcepub fn text_wrapped_size_spaced(
&mut self,
text: &str,
size: f32,
weight: FontWeight,
width: f32,
mode: WrapMode,
spacing: f32,
) -> Size
pub fn text_wrapped_size_spaced( &mut self, text: &str, size: f32, weight: FontWeight, width: f32, mode: WrapMode, spacing: f32, ) -> Size
Measures wrapped text within width with letter spacing.
Sourcepub fn text_wrapped_size_styled_spaced(
&mut self,
text: &str,
size: f32,
weight: FontWeight,
width: f32,
mode: WrapMode,
spacing: f32,
family: Option<&str>,
style: FontStyle,
) -> Size
pub fn text_wrapped_size_styled_spaced( &mut self, text: &str, size: f32, weight: FontWeight, width: f32, mode: WrapMode, spacing: f32, family: Option<&str>, style: FontStyle, ) -> Size
Measures wrapped text with weight, spacing, family, and style.
Sourcepub fn text_elided_size(
&mut self,
text: &str,
size: f32,
weight: FontWeight,
max_width: f32,
mode: ElideMode,
) -> Size
pub fn text_elided_size( &mut self, text: &str, size: f32, weight: FontWeight, max_width: f32, mode: ElideMode, ) -> Size
Measures text elided to max_width with the given elision mode.
Sourcepub fn text_elided_size_spaced(
&mut self,
text: &str,
size: f32,
weight: FontWeight,
max_width: f32,
mode: ElideMode,
spacing: f32,
) -> Size
pub fn text_elided_size_spaced( &mut self, text: &str, size: f32, weight: FontWeight, max_width: f32, mode: ElideMode, spacing: f32, ) -> Size
Measures elided text with letter spacing.
Sourcepub fn text_elided_size_styled_spaced(
&mut self,
text: &str,
size: f32,
weight: FontWeight,
max_width: f32,
mode: ElideMode,
spacing: f32,
family: Option<&str>,
style: FontStyle,
) -> Size
pub fn text_elided_size_styled_spaced( &mut self, text: &str, size: f32, weight: FontWeight, max_width: f32, mode: ElideMode, spacing: f32, family: Option<&str>, style: FontStyle, ) -> Size
Measures elided text with weight, spacing, family, and style.
Sourcepub fn text_line_height(size: f32) -> f32
pub fn text_line_height(size: f32) -> f32
Returns the line height used for a font size.