[−][src]Struct genpdf::fonts::FontCache
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]
default_dir: impl AsRef<Path>,
default_name: &str
) -> Result<FontCache, Error>
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]
&mut self,
dir: impl AsRef<Path>,
name: &str
) -> Result<FontFamily, Error>
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
Auto Trait Implementations
impl RefUnwindSafe for FontCache
impl Send for FontCache
impl Sync for FontCache
impl Unpin for FontCache
impl UnwindSafe for FontCache
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,