Struct lux::font::ContainedText [] [src]

#[must_use = "text references just contains a drawing context, and must be drawn with `draw()`"]
pub struct ContainedText<'a, C: 'a + HasDisplay + HasFontCache + Canvas, S: 'a + AsRef<str>> {
    // some fields omitted
}

A context that contains information about the text that can be drawn to the screen.

Methods

impl<'a, C: 'a + HasDisplay + HasFontCache + Canvas, S: 'a + AsRef<str>> ContainedText<'a, C, S>

fn size(&mut self, size: u16) -> &mut ContainedText<'a, C, S>

Sets the size of the font.

fn font<A: Into<String>>(&mut self, font_family: A) -> &mut ContainedText<'a, C, S>

Sets the font to be used.

fn draw(&mut self) -> LuxResult<()>

Draws the font to the screen.

fn line_height(&mut self) -> LuxResult<u32>

Returns the height of one line of text with the selected font.

fn max_advance(&mut self) -> LuxResult<u32>

Returns the maximum horizontal distance that a character can move the pen while drawing.

fn absolute_positions(&mut self) -> LuxResult<Vec<OutputPosition>>

Returns an iterator containing each character in the input text along with the position and the size.

These positions are absolute, and are not relative to the position that the text will be drawn on the screen. (they start at position (0, 0))

fn positions(&mut self) -> LuxResult<Vec<(char, (Float, Float), (Float, Float))>>

Returns an iterator containing each character in the input text along with the position and the size.

These positions are relative to the providex (x, y) coordinates that the text will be drawn at.

fn bounding_box(&mut self) -> LuxResult<((Float, Float), (Float, Float))>

Returns the bounding box around this text.

((start_x, start_y), (width, height))

start_x and start_y are oriented to the top-left of the screen.

width and height are pointing down and to the right.

fn get_length(&mut self) -> LuxResult<u32>

Returns the length in pixels of the rendered string.

Trait Implementations

impl<'a, A, B: AsRef<str>> Transform for ContainedText<'a, A, B> where A: HasDisplay + HasFontCache + Canvas

fn current_matrix(&self) -> &[[Float; 4]; 4]

fn current_matrix_mut(&mut self) -> &mut [[Float; 4]; 4]

fn apply_matrix(&mut self, other: [[Float; 4]; 4]) -> &mut Self

fn translate(&mut self, dx: Float, dy: Float) -> &mut Self

fn scale(&mut self, sx: Float, sy: Float) -> &mut Self

fn shear(&mut self, sx: Float, sy: Float) -> &mut Self

fn rotate(&mut self, theta: Float) -> &mut Self

fn rotate_around(&mut self, point: (Float, Float), theta: Float) -> &mut Self

fn with_matrix<F, R>(&mut self, f: F) -> R where F: FnOnce(&mut Self) -> R

fn with_rotation<F, R>(&mut self, rotation: Float, f: F) -> R where F: FnOnce(&mut Self) -> R

fn with_translate<F, R>(&mut self, dx: Float, dy: Float, f: F) -> R where F: FnOnce(&mut Self) -> R

fn with_scale<F, R>(&mut self, scale_x: Float, scale_y: Float, f: F) -> R where F: FnOnce(&mut Self) -> R

fn with_shear<F, R>(&mut self, sx: Float, sy: Float, f: F) -> R where F: FnOnce(&mut Self) -> R

fn with_rotate_around<F, R>(&mut self, point: (Float, Float), theta: Float, f: F) -> R where F: FnOnce(&mut Self) -> R

impl<'a, A, B: AsRef<str>> Colored for ContainedText<'a, A, B> where A: HasDisplay + HasFontCache + Canvas

fn get_color(&self) -> [Float; 4]

fn color<C: Color>(&mut self, color: C) -> &mut Self

fn with_color<F, C: Color>(&mut self, color: C, f: F) where F: FnOnce(&mut Self)