Struct rckive_genpdf::fonts::FontCache
source · pub struct FontCache { /* private fields */ }
Expand description
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§
source§impl FontCache
impl FontCache
sourcepub fn new(default_font_family: FontFamily<FontData>) -> FontCache
pub fn new(default_font_family: FontFamily<FontData>) -> FontCache
Creates a new font cache with the given default font family.
sourcepub fn add_font(&mut self, font_data: FontData) -> Font
pub fn add_font(&mut self, font_data: FontData) -> Font
Adds the given font to the cache and returns a reference to it.
sourcepub fn add_font_family(
&mut self,
family: FontFamily<FontData>
) -> FontFamily<Font>
pub fn add_font_family(
&mut self,
family: FontFamily<FontData>
) -> FontFamily<Font>
Adds the given font family to the cache and returns a reference to it.
sourcepub fn load_pdf_fonts(&mut self, renderer: &Renderer) -> Result<(), Error>
pub fn load_pdf_fonts(&mut self, renderer: &Renderer) -> Result<(), Error>
Embeds all loaded fonts into the document generated by the given renderer and caches a reference to them.
sourcepub fn default_font_family(&self) -> FontFamily<Font>
pub fn default_font_family(&self) -> FontFamily<Font>
Returns the default font family for this font cache.
sourcepub fn get_pdf_font(&self, font: Font) -> Option<&IndirectFontRef>
pub fn get_pdf_font(&self, font: Font) -> Option<&IndirectFontRef>
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.
sourcepub fn get_rt_font(&self, font: Font) -> &Font<'static>
pub fn get_rt_font(&self, font: Font) -> &Font<'static>
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.