pub struct FontFlags(/* private fields */);Expand description
The /FontDescriptor /Flags bit set (ISO 32000-1 table 123), plus
PDFium’s own USE_EXTERN_ATTR bit.
A hand-rolled newtype rather than a bitflags dependency, for the reason
bitflags would get wrong: unknown bits round-trip. Files set reserved
bits, and SYMBOLIC and NON_SYMBOLIC co-occur in the wild, so
FontFlags::from_bits keeps the whole word and FontFlags::bits
hands it back unchanged.
use pdfrum_font::FontFlags;
let f = FontFlags::SERIF | FontFlags::ITALIC;
assert!(f.contains(FontFlags::SERIF));
assert!(!f.without(FontFlags::SERIF).contains(FontFlags::SERIF));
// A reserved bit survives the trip.
assert_eq!(FontFlags::from_bits(1 << 30).bits(), 1 << 30);Implementations§
Source§impl FontFlags
impl FontFlags
Sourcepub const FIXED_PITCH: Self
pub const FIXED_PITCH: Self
All glyphs have the same width.
Sourcepub const NON_SYMBOLIC: Self
pub const NON_SYMBOLIC: Self
The font uses the Adobe standard Latin character set.
Sourcepub const FORCE_BOLD: Self
pub const FORCE_BOLD: Self
Bold glyphs are painted with extra pixels at small sizes.
Sourcepub const USE_EXTERN_ATTR: Self
pub const USE_EXTERN_ATTR: Self
Not a PDF flag. PDFium sets this bit when the descriptor carried a complete enough metric set to be trusted, and the substitution ladder discards the caller’s weight and slant entirely when it is absent.
Sourcepub const DEFAULT: Self = Self::NON_SYMBOLIC
pub const DEFAULT: Self = Self::NON_SYMBOLIC
The default when a font has no /FontDescriptor at all.
Sourcepub const fn from_bits(bits: u32) -> Self
pub const fn from_bits(bits: u32) -> Self
The word as written in the file. Unknown bits are retained: a reserved bit a damaged file sets is kept, not dropped.
Sourcepub const fn contains(self, other: Self) -> bool
pub const fn contains(self, other: Self) -> bool
Whether every bit of other is set here.
FontFlags::NONE is contained in everything, so contains is the
wrong question to ask about “no flags at all” — use == FontFlags::NONE.
Sourcepub const fn with(self, other: Self) -> Self
pub const fn with(self, other: Self) -> Self
A copy with other’s bits set. An alias for FontFlags::union.
Sourcepub const fn is_symbolic(self) -> bool
pub const fn is_symbolic(self) -> bool
Symbolic fonts use their own encoding vector.
Sourcepub const fn is_non_symbolic(self) -> bool
pub const fn is_non_symbolic(self) -> bool
Non-symbolic fonts use the Adobe standard Latin set.
Sourcepub const fn is_italic(self) -> bool
pub const fn is_italic(self) -> bool
Italic, per the descriptor’s own flag rather than its /ItalicAngle.
Sourcepub const fn is_fixed_pitch(self) -> bool
pub const fn is_fixed_pitch(self) -> bool
Every glyph the same width.
Sourcepub const fn uses_extern_attr(self) -> bool
pub const fn uses_extern_attr(self) -> bool
The descriptor’s metrics are complete enough to trust.
Sourcepub const fn is_all_cap(self) -> bool
pub const fn is_all_cap(self) -> bool
No lowercase letters — triggers the all-caps glyph aliasing of the former working note.