Struct rusttype::Scale [] [src]

pub struct Scale(_, _);

An opaque struct representing a common format for font scaling. You typically won't use this struct directly, instead using Pixels or PixelsXY and the Into trait to pass them to functions.

You can however implement your own scales for use with functions that accept S: Into<Scale>. As a simplified example, if you want to write scales in a different unit, like inches, and you know that there are 96 pixels in an inch in your use case, you can create a struct like the following:

use rusttype::{Pixels, Scale};

struct Inches(f32);
impl From<Inches> for Scale {
    fn from(i: Inches) -> Scale {
        Pixels(i.0 * 96.0).into()
    }
}

You can then use Inches wherever you could use Pixels or PixelsXY before.

Trait Implementations

impl Clone for Scale
[src]

fn clone(&self) -> Scale

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)
1.0.0

Performs copy-assignment from source. Read more

impl Copy for Scale
[src]

impl From<Pixels> for Scale
[src]

fn from(p: Pixels) -> Scale

Performs the conversion.

impl From<PixelsXY> for Scale
[src]

fn from(p: PixelsXY) -> Scale

Performs the conversion.