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>
impl<'a> PdfFont<'a>
Sourcepub fn bindings(&self) -> &'a dyn PdfiumLibraryBindings
pub fn bindings(&self) -> &'a dyn PdfiumLibraryBindings
Returns the PdfiumLibraryBindings used by this PdfFont.
Sourcepub fn weight(&self) -> Result<PdfFontWeight, PdfiumError>
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.
Sourcepub fn italic_angle(&self) -> Result<i32, PdfiumError>
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.
Sourcepub fn ascent(&self, font_size: PdfPoints) -> Result<PdfPoints, PdfiumError>
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.
Sourcepub fn descent(&self, font_size: PdfPoints) -> Result<PdfPoints, PdfiumError>
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.
Sourcepub fn is_fixed_pitch(&self) -> bool
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.
Sourcepub fn is_proportional_pitch(&self) -> bool
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.
Sourcepub fn is_serif(&self) -> bool
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.
Sourcepub fn is_sans_serif(&self) -> bool
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.
Sourcepub fn is_symbolic(&self) -> bool
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.
Sourcepub fn is_non_symbolic(&self) -> bool
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.
Sourcepub fn is_cursive(&self) -> bool
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.
Sourcepub fn is_italic(&self) -> bool
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.
Sourcepub fn is_all_caps(&self) -> bool
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.
Sourcepub fn is_small_caps(&self) -> bool
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.
Sourcepub fn is_bold_reenforced(&self) -> bool
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.
Sourcepub fn is_built_in(&self) -> bool
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.
Sourcepub fn built_in(&self) -> Option<PdfFontBuiltin>
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.
Sourcepub fn is_embedded(&self) -> Result<bool, PdfiumError>
pub fn is_embedded(&self) -> Result<bool, PdfiumError>
Returns true if the data for this PdfFont is embedded in the containing PdfDocument.
Sourcepub fn data(&self) -> Result<Vec<u8>, PdfiumError>
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.
Sourcepub fn glyphs(&self) -> &PdfFontGlyphs<'_>
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> ToPdfFontToken for &'a PdfFont<'a>
impl<'a> ToPdfFontToken for &'a PdfFont<'a>
fn token(&self) -> PdfFontToken
Source§impl<'a> ToPdfFontToken for PdfFont<'a>
impl<'a> ToPdfFontToken for PdfFont<'a>
fn token(&self) -> PdfFontToken
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> 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