Struct macroquad_text::Fonts[][src]

pub struct Fonts { /* fields omitted */ }

Implementations

Creates a new Fonts instance to handle all your fonts with a given ScalingMode

You can also call Fonts::default which defaults to [ScalingMode::Linear]

Examples

With nearest mode

let mut fonts = Fonts::new(ScalingMode::Nearest);

With linear mode

let mut fonts = Fonts::new(ScalingMode::Linear);

Returns an immutable reference to the list of fonts that are currently loaded

Caches a glyph for a given character with a given font size

You don’t really need to call this function since caching happens automatically

Loads font from bytes with a given scale

What Scale does

(copied from FontSettings::scale)

The scale in px the font geometry is optimized for. Fonts rendered at the scale defined here will be the most optimal in terms of looks and performance. Glyphs rendered smaller than this scale will look the same but perform slightly worse, while glyphs rendered larger than this will looks worse but perform slightly better. The units of the scale are pixels per Em unit.

Loads font from bytes with a scale of 100.0

Checks if any fonts supports this character

Looks up glyph index in all fonts until it finds one

Rasterize a character using which ever font that contains that character first

See Font::rasterize or Font::rasterize_indexed

Measures text with a given font size

Example

let dimensions = fonts.measure_text("Some Text", 22);

println!("width: {}, height: {}, offset_y: {}",
  dimensions.width,
  dimensions.height,
  dimensions.offset_y
)

See TextDimensions

Draws text with a given font size, draws from TopLeft

Examples

fonts.draw_text("Some Text", 20.0, 20.0, 22, Color::from_rgba(255, 255, 255, 255));

See Self::draw_text_ex

Draws text with given TextParams

Example

fonts.draw_text_ex(&TextParams {
  text: "Some Text",
  x: 20.0,
  y: 20.0,
  // Default Size
  size: 22,
  // Default Color
  color: Color::from_rgba(255, 255, 255, 255),
  // Default Draw method
  draw: DrawFrom::TopLeft
});

// Does the same as above
fonts.draw_text_ex(&TextParams {
  text: "Some Text",
  x: 20.0,
  y: 20.0,
  ..Default::default()
});

See Self::draw_text

Trait Implementations

Creates a new Fonts instance to handle all your font

Same as calling [Fonts::new(ScalingMode::Linear)]

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.