Skip to main content

FontFlags

Struct FontFlags 

Source
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

Source

pub const FIXED_PITCH: Self

All glyphs have the same width.

Source

pub const SERIF: Self

Glyphs have serifs.

Source

pub const SYMBOLIC: Self

The font uses its own built-in encoding rather than a standard one.

Source

pub const SCRIPT: Self

Glyphs resemble cursive handwriting.

Source

pub const NON_SYMBOLIC: Self

The font uses the Adobe standard Latin character set.

Source

pub const ITALIC: Self

Glyphs have dominant vertical strokes that are slanted.

Source

pub const ALL_CAP: Self

No lowercase letters.

Source

pub const SMALL_CAP: Self

Lowercase letters have the shapes of uppercase ones at reduced size.

Source

pub const FORCE_BOLD: Self

Bold glyphs are painted with extra pixels at small sizes.

Source

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.

Source

pub const NONE: Self

No bit set.

Source

pub const DEFAULT: Self = Self::NON_SYMBOLIC

The default when a font has no /FontDescriptor at all.

Source

pub const fn bits(self) -> u32

The raw /Flags word, including any bit this type does not name.

Source

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.

Source

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.

Source

pub const fn union(self, other: Self) -> Self

Both sets of bits.

Source

pub const fn with(self, other: Self) -> Self

A copy with other’s bits set. An alias for FontFlags::union.

Source

pub const fn without(self, other: Self) -> Self

The bits of self that are not in other.

Source

pub const fn is_empty(self) -> bool

Whether no bit at all is set.

Source

pub const fn is_symbolic(self) -> bool

Symbolic fonts use their own encoding vector.

Source

pub const fn is_non_symbolic(self) -> bool

Non-symbolic fonts use the Adobe standard Latin set.

Source

pub const fn is_italic(self) -> bool

Italic, per the descriptor’s own flag rather than its /ItalicAngle.

Source

pub const fn is_fixed_pitch(self) -> bool

Every glyph the same width.

Source

pub const fn uses_extern_attr(self) -> bool

The descriptor’s metrics are complete enough to trust.

Source

pub const fn is_all_cap(self) -> bool

No lowercase letters — triggers the all-caps glyph aliasing of the former working note.

Trait Implementations§

Source§

impl BitOr for FontFlags

Source§

type Output = FontFlags

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Self) -> Self

Performs the | operation. Read more
Source§

impl Clone for FontFlags

Source§

fn clone(&self) -> FontFlags

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for FontFlags

Source§

impl Debug for FontFlags

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for FontFlags

Source§

fn default() -> FontFlags

Returns the “default value” for a type. Read more
Source§

impl Eq for FontFlags

Source§

impl Hash for FontFlags

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for FontFlags

Source§

fn eq(&self, other: &FontFlags) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for FontFlags

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.