[][src]Struct genpdf::fonts::FontCache

pub struct FontCache { /* fields omitted */ }

Stores font data that can be referenced by a Font or FontFamily.

If you use the high-level interface provided by Document, you don’t have to access this type. See the module documentation for details on the internals.

Implementations

impl FontCache[src]

pub fn new(
    default_dir: impl AsRef<Path>,
    default_name: &str
) -> Result<FontCache, Error>
[src]

Creates a new font cache, loads the font family at the given path and with the given name and sets that font family as the default.

pub fn load_font(&mut self, path: impl AsRef<Path>) -> Result<Font, Error>[src]

Loads the font at the given path.

pub fn load_font_family(
    &mut self,
    dir: impl AsRef<Path>,
    name: &str
) -> Result<FontFamily, Error>
[src]

Loads the font family at the given path with the given name.

This method assumes that at the given path, these files exist and are valid font files:

  • {name}-Regular.ttf
  • {name}-Bold.ttf
  • {name}-Italic.ttf
  • {name}-BoldItalic.ttf

pub fn load_pdf_fonts(&mut self, renderer: &Renderer) -> Result<(), Error>[src]

Embeds all loaded fonts into the document generated by the given renderer and caches a reference to them.

pub fn default_font_family(&self) -> FontFamily[src]

Returns the default font family for this font cache.

pub fn get_pdf_font(&self, font: Font) -> Option<&IndirectFontRef>[src]

Returns a reference to the emebdded PDF font for the given font, if available.

This method may only be called with Font instances that have been created by this font cache. PDF fonts are only avaiable if load_pdf_fonts has been called.

pub fn get_rt_font(&self, font: Font) -> &Font<'static>[src]

Returns a reference to the Rusttype font for the given font, if available.

This method may only be called with Font instances that have been created by this font cache.

Trait Implementations

impl Debug for FontCache[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.