PdfFonts

Struct PdfFonts 

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

A collection of all the PdfFont objects in a PdfDocument.

Implementations§

Source§

impl<'a> PdfFonts<'a>

Source

pub fn bindings(&self) -> &'a dyn PdfiumLibraryBindings

Returns the PdfiumLibraryBindings used by this PdfFonts collection.

Source

pub fn new_built_in(&mut self, font: PdfFontBuiltin) -> PdfFontToken

Returns a reusable PdfFontToken for the given built-in font.

Source

pub fn times_roman(&mut self) -> PdfFontToken

Returns a reusable PdfFontToken for the built-in “Times-Roman” font.

Source

pub fn times_bold(&mut self) -> PdfFontToken

Returns a reusable PdfFontToken for the built-in “Times-Bold” font.

Source

pub fn times_italic(&mut self) -> PdfFontToken

Returns a reusable PdfFontToken for the built-in “Times-Italic” font.

Source

pub fn times_bold_italic(&mut self) -> PdfFontToken

Returns a reusable PdfFontToken for the built-in “Times-BoldItalic” font.

Source

pub fn helvetica(&mut self) -> PdfFontToken

Returns a reusable PdfFontToken for the built-in “Helvetica” font.

Source

pub fn helvetica_bold(&mut self) -> PdfFontToken

Returns a reusable PdfFontToken for the built-in “Helvetica-Bold” font.

Source

pub fn helvetica_oblique(&mut self) -> PdfFontToken

Returns a reusable PdfFontToken for the built-in “Helvetica-Oblique” font.

Source

pub fn helvetica_bold_oblique(&mut self) -> PdfFontToken

Returns a reusable PdfFontToken for the built-in “Helvetica-BoldOblique” font.

Source

pub fn courier(&mut self) -> PdfFontToken

Returns a reusable PdfFontToken for the built-in “Courier” font.

Source

pub fn courier_bold(&mut self) -> PdfFontToken

Returns a reusable PdfFontToken for the built-in “Courier-Bold” font.

Source

pub fn courier_oblique(&mut self) -> PdfFontToken

Returns a reusable PdfFontToken for the built-in “Courier-Oblique” font.

Source

pub fn courier_bold_oblique(&mut self) -> PdfFontToken

Returns a reusable PdfFontToken for the built-in “Courier-BoldOblique” font.

Source

pub fn symbol(&mut self) -> PdfFontToken

Returns a reusable PdfFontToken for the built-in “Symbol” font.

Source

pub fn zapf_dingbats(&mut self) -> PdfFontToken

Returns a reusable PdfFontToken for the built-in “ZapfDingbats” font.

Source

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.
Source

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.

Source

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.

Source

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.

Source

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.

Source

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 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_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.
Source

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.

Source

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.

Source

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.

Source

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.

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.