PdfFont

Struct PdfFont 

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

A single font used to render text in a PdfDocument.

The PDF specification defines 14 built-in fonts that can be used in any PDF file without font embedding. Additionally, custom fonts can be directly embedded into any PDF file as a data stream.

Implementations§

Source§

impl<'a> PdfFont<'a>

Source

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

Returns the PdfiumLibraryBindings used by this PdfFont.

Source

pub fn name(&self) -> String

Returns the name of this PdfFont.

Source

pub fn family(&self) -> String

Returns the family of this PdfFont.

Source

pub fn weight(&self) -> Result<PdfFontWeight, PdfiumError>

Returns the weight of this PdfFont.

Pdfium may not reliably return the correct value of this property for built-in fonts.

Source

pub fn italic_angle(&self) -> Result<i32, PdfiumError>

Returns the italic angle of this PdfFont. The italic angle is the angle, expressed in degrees counter-clockwise from the vertical, of the dominant vertical strokes of the font. The value is zero for non-italic fonts, and negative for fonts that slope to the right (as almost all italic fonts do).

Pdfium may not reliably return the correct value of this property for built-in fonts.

Source

pub fn ascent(&self, font_size: PdfPoints) -> Result<PdfPoints, PdfiumError>

Returns the ascent of this PdfFont for the given font size. The ascent is the maximum height above the baseline reached by glyphs in this font, excluding the height of glyphs for accented characters.

Source

pub fn descent(&self, font_size: PdfPoints) -> Result<PdfPoints, PdfiumError>

Returns the descent of this PdfFont for the given font size. The descent is the maximum distance below the baseline reached by glyphs in this font, expressed as a negative points value.

Source

pub fn is_fixed_pitch(&self) -> bool

Returns true if all the glyphs in this PdfFont have the same width.

Pdfium may not reliably return the correct value of this flag for built-in fonts.

Source

pub fn is_proportional_pitch(&self) -> bool

Returns true if the glyphs in this PdfFont have variable widths.

Pdfium may not reliably return the correct value of this flag for built-in fonts.

Source

pub fn is_serif(&self) -> bool

Returns true if one or more glyphs in this PdfFont have serifs - short strokes drawn at an angle on the top or bottom of glyph stems to decorate the glyphs. For example, Times New Roman is a serif font.

Pdfium may not reliably return the correct value of this flag for built-in fonts.

Source

pub fn is_sans_serif(&self) -> bool

Returns true if no glyphs in this PdfFont have serifs - short strokes drawn at an angle on the top or bottom of glyph stems to decorate the glyphs. For example, Helvetica is a sans-serif font.

Pdfium may not reliably return the correct value of this flag for built-in fonts.

Source

pub fn is_symbolic(&self) -> bool

Returns true if this PdfFont contains glyphs outside the Adobe standard Latin character set.

This classification of non-symbolic and symbolic fonts is peculiar to PDF. A font may contain additional characters that are used in Latin writing systems but are outside the Adobe standard Latin character set; PDF considers such a font to be symbolic.

Pdfium may not reliably return the correct value of this flag for built-in fonts.

Source

pub fn is_non_symbolic(&self) -> bool

Returns true if this PdfFont does not contain glyphs outside the Adobe standard Latin character set.

This classification of non-symbolic and symbolic fonts is peculiar to PDF. A font may contain additional characters that are used in Latin writing systems but are outside the Adobe standard Latin character set; PDF considers such a font to be symbolic.

Pdfium may not reliably return the correct value of this flag for built-in fonts.

Source

pub fn is_cursive(&self) -> bool

Returns true if the glyphs in this PdfFont are designed to resemble cursive handwriting.

Pdfium may not reliably return the correct value of this flag for built-in fonts.

Source

pub fn is_italic(&self) -> bool

Returns true if the glyphs in this PdfFont include dominant vertical strokes that are slanted.

The designed vertical stroke angle can be retrieved using the PdfFont::italic_angle() function.

Pdfium may not reliably return the correct value of this flag for built-in fonts.

Source

pub fn is_all_caps(&self) -> bool

Returns true if this PdfFont contains no lowercase letters by design.

Pdfium may not reliably return the correct value of this flag for built-in fonts.

Source

pub fn is_small_caps(&self) -> bool

Returns true if the lowercase letters in this PdfFont have the same shapes as the corresponding uppercase letters but are sized proportionally so they have the same size and stroke weight as lowercase glyphs in the same typeface family.

Pdfium may not reliably return the correct value of this flag for built-in fonts.

Source

pub fn is_bold_reenforced(&self) -> bool

Returns true if bold glyphs in this PdfFont are painted with extra pixels at very small font sizes.

Typically when glyphs are painted at small sizes on low-resolution devices, individual strokes of bold glyphs may appear only one pixel wide. Because this is the minimum width of a pixel based device, individual strokes of non-bold glyphs may also appear as one pixel wide and therefore cannot be distinguished from bold glyphs. If this flag is set, individual strokes of bold glyphs may be thickened at small font sizes.

Pdfium may not reliably return the correct value of this flag for built-in fonts.

Source

pub fn is_built_in(&self) -> bool

Returns true if this PdfFont is an instance of one of the 14 built-in fonts provided as part of the PDF specification.

Source

pub fn built_in(&self) -> Option<PdfFontBuiltin>

Returns the PdfFontBuiltin type of this built-in font, or None if this font is not one of the 14 built-in fonts provided as part of the PDF specification.

Source

pub fn is_embedded(&self) -> Result<bool, PdfiumError>

Returns true if the data for this PdfFont is embedded in the containing PdfDocument.

Source

pub fn data(&self) -> Result<Vec<u8>, PdfiumError>

Writes this PdfFont to a new byte buffer, returning the byte buffer.

If this PdfFont is not embedded in the containing PdfDocument, then the data returned will be for the substitution font instead.

Source

pub fn glyphs(&self) -> &PdfFontGlyphs<'_>

Returns a collection of all the PdfFontGlyphs defined for this PdfFont in the containing PdfDocument.

Note that documents typically include only the specific glyphs they need from any given font, not the entire font glyphset. This is a PDF feature known as font subsetting. The collection of glyphs returned by this function may therefore not cover the entire font glyphset.

Trait Implementations§

Source§

impl<'a> Drop for PdfFont<'a>

Source§

fn drop(&mut self)

Closes this PdfFont, releasing held memory.

Source§

impl<'a> ToPdfFontToken for &'a PdfFont<'a>

Source§

impl<'a> ToPdfFontToken for PdfFont<'a>

Auto Trait Implementations§

§

impl<'a> !Freeze for PdfFont<'a>

§

impl<'a> !RefUnwindSafe for PdfFont<'a>

§

impl<'a> !Send for PdfFont<'a>

§

impl<'a> !Sync for PdfFont<'a>

§

impl<'a> Unpin for PdfFont<'a>

§

impl<'a> !UnwindSafe for PdfFont<'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.