pub struct PdfFonts<'a> { /* private fields */ }Expand description
A collection of all the PdfFont objects in a PdfDocument.
Implementations§
Source§impl<'a> PdfFonts<'a>
impl<'a> PdfFonts<'a>
Sourcepub fn bindings(&self) -> &'a dyn PdfiumLibraryBindings
pub fn bindings(&self) -> &'a dyn PdfiumLibraryBindings
Returns the PdfiumLibraryBindings used by this PdfFonts collection.
Sourcepub fn new_built_in(&mut self, font: PdfFontBuiltin) -> PdfFontToken
pub fn new_built_in(&mut self, font: PdfFontBuiltin) -> PdfFontToken
Returns a reusable PdfFontToken for the given built-in font.
Sourcepub fn times_roman(&mut self) -> PdfFontToken
pub fn times_roman(&mut self) -> PdfFontToken
Returns a reusable PdfFontToken for the built-in “Times-Roman” font.
Sourcepub fn times_bold(&mut self) -> PdfFontToken
pub fn times_bold(&mut self) -> PdfFontToken
Returns a reusable PdfFontToken for the built-in “Times-Bold” font.
Sourcepub fn times_italic(&mut self) -> PdfFontToken
pub fn times_italic(&mut self) -> PdfFontToken
Returns a reusable PdfFontToken for the built-in “Times-Italic” font.
Sourcepub fn times_bold_italic(&mut self) -> PdfFontToken
pub fn times_bold_italic(&mut self) -> PdfFontToken
Returns a reusable PdfFontToken for the built-in “Times-BoldItalic” font.
Sourcepub fn helvetica(&mut self) -> PdfFontToken
pub fn helvetica(&mut self) -> PdfFontToken
Returns a reusable PdfFontToken for the built-in “Helvetica” font.
Sourcepub fn helvetica_bold(&mut self) -> PdfFontToken
pub fn helvetica_bold(&mut self) -> PdfFontToken
Returns a reusable PdfFontToken for the built-in “Helvetica-Bold” font.
Sourcepub fn helvetica_oblique(&mut self) -> PdfFontToken
pub fn helvetica_oblique(&mut self) -> PdfFontToken
Returns a reusable PdfFontToken for the built-in “Helvetica-Oblique” font.
Sourcepub fn helvetica_bold_oblique(&mut self) -> PdfFontToken
pub fn helvetica_bold_oblique(&mut self) -> PdfFontToken
Returns a reusable PdfFontToken for the built-in “Helvetica-BoldOblique” font.
Sourcepub fn courier(&mut self) -> PdfFontToken
pub fn courier(&mut self) -> PdfFontToken
Returns a reusable PdfFontToken for the built-in “Courier” font.
Sourcepub fn courier_bold(&mut self) -> PdfFontToken
pub fn courier_bold(&mut self) -> PdfFontToken
Returns a reusable PdfFontToken for the built-in “Courier-Bold” font.
Sourcepub fn courier_oblique(&mut self) -> PdfFontToken
pub fn courier_oblique(&mut self) -> PdfFontToken
Returns a reusable PdfFontToken for the built-in “Courier-Oblique” font.
Sourcepub fn courier_bold_oblique(&mut self) -> PdfFontToken
pub fn courier_bold_oblique(&mut self) -> PdfFontToken
Returns a reusable PdfFontToken for the built-in “Courier-BoldOblique” font.
Sourcepub fn symbol(&mut self) -> PdfFontToken
pub fn symbol(&mut self) -> PdfFontToken
Returns a reusable PdfFontToken for the built-in “Symbol” font.
Sourcepub fn zapf_dingbats(&mut self) -> PdfFontToken
pub fn zapf_dingbats(&mut self) -> PdfFontToken
Returns a reusable PdfFontToken for the built-in “ZapfDingbats” font.
Sourcepub fn load_type1_from_file(
&mut self,
path: &(impl AsRef<Path> + ?Sized),
is_cid_font: bool,
) -> Result<PdfFontToken, PdfiumError>
pub fn load_type1_from_file( &mut self, path: &(impl AsRef<Path> + ?Sized), is_cid_font: bool, ) -> Result<PdfFontToken, PdfiumError>
Attempts to load a Type 1 font file from the given file path, returning a reusable PdfFontToken if the font was successfully loaded.
Set the is_cid_font parameter to true if the given font is keyed by
16-bit character ID (CID), indicating that it supports an extended glyphset of
65,535 glyphs. This is typically the case with fonts that support Asian character sets
or right-to-left languages.
This function is not available when compiling to WASM. You have several options for loading font data in WASM:
- Use the PdfFont::load_type1_from_fetch() function to download font data from a
URL using the browser’s built-in
fetch()API. This function is only available when compiling to WASM. - Use the PdfFont::load_type1_from_blob() function to load font data from a
Javascript File or Blob object (such as a File object returned from an HTML
<input type="file">element). This function is only available when compiling to WASM. - Use the PdfFont::load_type1_from_reader() function to load font data from any valid Rust reader.
- Use another method to retrieve the bytes of the target font over the network, then load those bytes into Pdfium using the PdfFont::new_type1_from_bytes() function.
- Embed the bytes of the desired font directly into the compiled WASM module
using the
include_bytes!()macro.
Sourcepub fn load_type1_from_reader(
&mut self,
reader: impl Read,
is_cid_font: bool,
) -> Result<PdfFontToken, PdfiumError>
pub fn load_type1_from_reader( &mut self, reader: impl Read, is_cid_font: bool, ) -> Result<PdfFontToken, PdfiumError>
Attempts to load a Type 1 font file from the given reader, returning a reusable PdfFontToken if the font was successfully loaded.
Set the is_cid_font parameter to true if the given font is keyed by
16-bit character ID (CID), indicating that it supports an extended glyphset of
65,535 glyphs. This is typically the case with fonts that support Asian character sets
or right-to-left languages.
Sourcepub async fn load_type1_from_fetch(
&mut self,
url: impl ToString,
is_cid_font: bool,
) -> Result<PdfFontToken, PdfiumError>
pub async fn load_type1_from_fetch( &mut self, url: impl ToString, is_cid_font: bool, ) -> Result<PdfFontToken, PdfiumError>
Attempts to load a Type 1 font file from the given URL, returning a reusable PdfFontToken if the font was successfully loaded.
The Javascript fetch() API is used to download data over the network.
Set the is_cid_font parameter to true if the given font is keyed by
16-bit character ID (CID), indicating that it supports an extended glyphset of
65,535 glyphs. This is typically the case with fonts that support Asian character sets
or right-to-left languages.
This function is only available when compiling to WASM.
Sourcepub async fn load_type1_from_blob(
&mut self,
blob: Blob,
is_cid_font: bool,
) -> Result<PdfFontToken, PdfiumError>
pub async fn load_type1_from_blob( &mut self, blob: Blob, is_cid_font: bool, ) -> Result<PdfFontToken, PdfiumError>
Attempts to load a Type 1 font from the given Blob, returning a reusable PdfFontToken if the font was successfully loaded.
A File object returned from a FileList is a suitable Blob:
<input id="filePicker" type="file">
const file = document.getElementById('filePicker').files[0];Set the is_cid_font parameter to true if the given font is keyed by
16-bit character ID (CID), indicating that it supports an extended glyphset of
65,535 glyphs. This is typically the case with fonts that support Asian character sets
or right-to-left languages.
This function is only available when compiling to WASM.
Sourcepub fn load_type1_from_bytes(
&mut self,
font_data: &[u8],
is_cid_font: bool,
) -> Result<PdfFontToken, PdfiumError>
pub fn load_type1_from_bytes( &mut self, font_data: &[u8], is_cid_font: bool, ) -> Result<PdfFontToken, PdfiumError>
Attempts to load the given byte data as a Type 1 font file, returning a reusable PdfFontToken if the font was successfully loaded.
Set the is_cid_font parameter to true if the given font is keyed by
16-bit character ID (CID), indicating that it supports an extended glyphset of
65,535 glyphs. This is typically the case with fonts that support Asian character sets
or right-to-left languages.
Sourcepub fn load_true_type_from_file(
&mut self,
path: &(impl AsRef<Path> + ?Sized),
is_cid_font: bool,
) -> Result<PdfFontToken, PdfiumError>
pub fn load_true_type_from_file( &mut self, path: &(impl AsRef<Path> + ?Sized), is_cid_font: bool, ) -> Result<PdfFontToken, PdfiumError>
Attempts to load a TrueType font file from the given file path, returning a reusable PdfFontToken if the font was successfully loaded.
Set the is_cid_font parameter to true if the given font is keyed by
16-bit character ID (CID), indicating that it supports an extended glyphset of
65,535 glyphs. This is typically the case with fonts that support Asian character sets
or right-to-left languages.
This function is not available when compiling to WASM. You have several options for loading font data in WASM:
- Use the PdfFont::load_true_type_from_fetch() function to download font data from a
URL using the browser’s built-in
fetch()API. This function is only available when compiling to WASM. - Use the PdfFont::load_true_type_from_blob() function to load font data from a
Javascript
FileorBlobobject (such as aFileobject returned from an HTML<input type="file">element). This function is only available when compiling to WASM. - Use the PdfFont::load_true_type_from_reader() function to load font data from any valid Rust reader.
- Use another method to retrieve the bytes of the target font over the network, then load those bytes into Pdfium using the PdfFont::new_true_type_from_bytes() function.
- Embed the bytes of the desired font directly into the compiled WASM module
using the
include_bytes!()macro.
Sourcepub fn load_true_type_from_reader(
&mut self,
reader: impl Read,
is_cid_font: bool,
) -> Result<PdfFontToken, PdfiumError>
pub fn load_true_type_from_reader( &mut self, reader: impl Read, is_cid_font: bool, ) -> Result<PdfFontToken, PdfiumError>
Attempts to load a TrueType font file from the given reader, returning a reusable PdfFontToken if the font was successfully loaded.
Set the is_cid_font parameter to true if the given font is keyed by
16-bit character ID (CID), indicating that it supports an extended glyphset of
65,535 glyphs. This is typically the case with fonts that support Asian character sets
or right-to-left languages.
Sourcepub async fn load_true_type_from_fetch(
&mut self,
url: impl ToString,
is_cid_font: bool,
) -> Result<PdfFontToken, PdfiumError>
pub async fn load_true_type_from_fetch( &mut self, url: impl ToString, is_cid_font: bool, ) -> Result<PdfFontToken, PdfiumError>
Attempts to load a TrueType font file from the given URL, returning a reusable PdfFontToken if the font was successfully loaded.
The Javascript fetch() API is used to download data over the network.
Set the is_cid_font parameter to true if the given font is keyed by
16-bit character ID (CID), indicating that it supports an extended glyphset of
65,535 glyphs. This is typically the case with fonts that support Asian character sets
or right-to-left languages.
This function is only available when compiling to WASM.
Sourcepub async fn load_true_type_from_blob(
&mut self,
blob: Blob,
is_cid_font: bool,
) -> Result<PdfFontToken, PdfiumError>
pub async fn load_true_type_from_blob( &mut self, blob: Blob, is_cid_font: bool, ) -> Result<PdfFontToken, PdfiumError>
Attempts to load a TrueType font from the given Blob, returning a reusable
PdfFontToken if the font was successfully loaded.
A File object returned from a FileList is a suitable Blob:
<input id="filePicker" type="file">
const file = document.getElementById('filePicker').files[0];Set the is_cid_font parameter to true if the given font is keyed by
16-bit character ID (CID), indicating that it supports an extended glyphset of
65,535 glyphs. This is typically the case with fonts that support Asian character sets
or right-to-left languages.
This function is only available when compiling to WASM.
Sourcepub fn load_true_type_from_bytes(
&mut self,
font_data: &[u8],
is_cid_font: bool,
) -> Result<PdfFontToken, PdfiumError>
pub fn load_true_type_from_bytes( &mut self, font_data: &[u8], is_cid_font: bool, ) -> Result<PdfFontToken, PdfiumError>
Attempts to load the given byte data as a TrueType font file, returning a reusable PdfFontToken if the font was successfully loaded.
Set the is_cid_font parameter to true if the given font is keyed by
16-bit character ID (CID), indicating that it supports an extended glyphset of
65,535 glyphs. This is typically the case with fonts that support Asian character sets
or right-to-left languages.
Sourcepub fn get(&self, token: PdfFontToken) -> Option<&PdfFont<'_>>
pub fn get(&self, token: PdfFontToken) -> Option<&PdfFont<'_>>
Returns a reference to the PdfFont associated with the given PdfFontToken, if any.
Auto Trait Implementations§
impl<'a> Freeze for PdfFonts<'a>
impl<'a> !RefUnwindSafe for PdfFonts<'a>
impl<'a> !Send for PdfFonts<'a>
impl<'a> !Sync for PdfFonts<'a>
impl<'a> Unpin for PdfFonts<'a>
impl<'a> !UnwindSafe for PdfFonts<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more