Trait sixtyfps_corelib::graphics::FontMetrics[][src]

pub trait FontMetrics {
    fn text_size(&self, text: &str, max_width: Option<f32>) -> Size;
fn line_height(&self) -> f32;
fn text_offset_for_x_position<'a>(&self, text: &'a str, x: f32) -> usize; }
Expand description

The FontMetrics trait is constructed from a FontRequest by the graphics backend and supplied to text related items in order to measure text.

Required methods

Returns the size of the given string in logical pixels. When set, max_width means that one need to wrap the text so it does not go further than that

Returns the height of a line of text.

Returns the (UTF-8) byte offset in the given text that refers to the character that contributed to the glyph cluster that’s visually nearest to the given x coordinate. This is used for hit-testing, for example when receiving a mouse click into a text field. Then this function returns the “cursor” position.

Implementors