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 Types§

source

type Font: Default + Clone

The font type used.

Required Associated Constants§

source

const ICON_FONT: Self::Font

The icon font of the backend.

source

const CHECKMARK_ICON: char

The char representing a ✔ icon in the ICON_FONT.

source

const ARROW_DOWN_ICON: char

The char representing a ▼ icon in the built-in ICON_FONT.

Required Methods§

source

fn default_size(&self) -> f32

Returns the default size of Text.

source

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.

source

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.

source

fn fill_text(&mut self, text: Text<'_, Self::Font>)

Draws the given Text.

Provided Methods§

source

fn measure_width(&self, content: &str, size: f32, font: Self::Font) -> f32

Measures the width of the text as if it were laid out in a single line.

Implementors§

source§

impl Renderer for Null

§

type Font = Font

source§

const ICON_FONT: Font = Font::Default

source§

const CHECKMARK_ICON: char = '0'

source§

const ARROW_DOWN_ICON: char = '0'