pub struct FontDesc<'a> { /* private fields */ }
Expand description

Describes a font

Implementations

Create a new font

  • family: The font family name
  • size: The size of the font
  • style: The font variations
  • returns The newly created font description

Create a new font desc with the same font but different size

  • size: The new size to set
  • returns The newly created font descriptor with a new size

Set the style of the font

  • style: The new style
  • returns The new font description with this style applied

Set the font transformation

  • trans: The new transformation
  • returns The new font description with this font transformation applied

Get the font transformation description

Returns a new text style object with the specified color.

Example
use plotters::prelude::*;
let text_style = ("sans-serif", 20).into_font().color(&RED);
let drawing_area = SVGBackend::new("font_desc_color.svg", (200, 100)).into_drawing_area();
drawing_area.fill(&WHITE).unwrap();
drawing_area.draw_text("This is a big red label", &text_style, (10, 50));

The result is a text label colorized accordingly:

See also

IntoTextStyle::with_color()

IntoTextStyle::into_text_style() for a more succinct example

Returns the font family

Get the name of the font

Get the name of the style

Get the size of font

Get the size of the text if rendered in this font

For a TTF type, zero point of the layout box is the left most baseline char of the string Thus the upper bound of the box is most likely be negative

Get the size of the text if rendered in this font. This is similar to layout_box function, but it apply the font transformation and estimate the overall size of the font

Actually draws a font with a drawing function

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts the value into a TextStyle value. Read more

Specifies the color of the text element Read more

Specifies the position of the text anchor relative to the text element Read more

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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Make the font description from the source type

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

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.