pub trait Renderer: Renderer {
type Font: Default + Clone;
const ICON_FONT: Self::Font;
const CHECKMARK_ICON: char;
const ARROW_DOWN_ICON: char;
// Required methods
fn default_size(&self) -> f32;
fn measure(
&self,
content: &str,
size: f32,
font: Self::Font,
bounds: Size,
) -> (f32, f32);
fn hit_test(
&self,
contents: &str,
size: f32,
font: Self::Font,
bounds: Size,
point: Point,
nearest_only: bool,
) -> Option<Hit>;
fn fill_text(&mut self, text: Text<'_, Self::Font>);
// Provided method
fn measure_width(&self, content: &str, size: f32, font: Self::Font) -> f32 { ... }
}Expand description
A renderer capable of measuring and drawing Text.
Required Associated Constants§
Sourceconst CHECKMARK_ICON: char
const CHECKMARK_ICON: char
The char representing a ✔ icon in the ICON_FONT.
Sourceconst ARROW_DOWN_ICON: char
const ARROW_DOWN_ICON: char
The char representing a ▼ icon in the built-in ICON_FONT.
Required Associated Types§
Required Methods§
Sourcefn default_size(&self) -> f32
fn default_size(&self) -> f32
Returns the default size of Text.
Sourcefn measure(
&self,
content: &str,
size: f32,
font: Self::Font,
bounds: Size,
) -> (f32, f32)
fn measure( &self, content: &str, size: f32, font: Self::Font, bounds: Size, ) -> (f32, f32)
Measures the text in the given bounds and returns the minimum boundaries that can fit the contents.
Sourcefn hit_test(
&self,
contents: &str,
size: f32,
font: Self::Font,
bounds: Size,
point: Point,
nearest_only: bool,
) -> Option<Hit>
fn hit_test( &self, contents: &str, size: f32, font: Self::Font, bounds: Size, point: Point, nearest_only: bool, ) -> Option<Hit>
Tests whether the provided point is within the boundaries of text laid out with the given parameters, returning information about the nearest character.
If nearest_only is true, the hit test does not consider whether the
the point is interior to any glyph bounds, returning only the character
with the nearest centeroid.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.