Skip to main content

CharBox

Struct CharBox 

Source
pub struct CharBox {
    pub char_type: CharType,
    pub unicode: u32,
    pub code: Option<CharCode>,
    pub origin: Point,
    pub char_box: Rect,
    pub loose_char_box: Rect,
    pub matrix: Affine,
    pub object: Option<ObjectIndex>,
    pub font_size: f32,
    pub angle: f32,
}
Expand description

One extracted character, with its metrics and page geometry.

unicode is a u32, not a char: the character-code passthrough (CharType::NotUnicode) emits raw codes that need not be Unicode scalar values, and 0 is a legal and observed value.

Fields§

§char_type: CharType

Where this character came from.

§unicode: u32

The --txt code unit.

§code: Option<CharCode>

The PDF character code, or None where the C++ uses its invalid-code sentinel — which is every generated and /ActualText character.

§origin: Point

The baseline origin, already transformed into page space.

§char_box: Rect

The tight glyph box in page space. Zero-area for a generated character, by construction.

§loose_char_box: Rect

The font-uniform box: the glyph’s advance width by the font’s ascent and descent, so two characters of one font share a box height whatever their glyphs do. Always contains char_box.

§matrix: Affine

The composed text × form matrix for a real character; the bare form matrix — usually the identity — for a generated one.

§object: Option<ObjectIndex>

Which of Page::objects produced it, in content order counting into form XObjects. None for a character no text object produced.

§font_size: f32

The font size in force, or 1.0 for a character with no text object — which is every generated one.

§angle: f32

atan2(matrix.c, matrix.a) normalized to [0, 2π).

Implementations§

Source§

impl CharBox

Source

pub fn is_normal(&self) -> bool

Whether this character is one search_text keeps.

A character with a unicode is normal unless it is one of the eight control code points; a character without one is normal exactly when its character code is non-zero. So the charcode-0 passthrough — which carries unicode == 0 — is not normal: it lands in chars as a NUL and never reaches the text.

Source

pub fn is_control(&self) -> bool

Whether this is one of the control code points search_text drops.

A CharType::Hyphen is exempt, which is why its 0x0002 survives into chars.

Source

pub fn is_generated(&self) -> bool

Whether the extractor invented this character.

Trait Implementations§

Source§

impl Clone for CharBox

Source§

fn clone(&self) -> CharBox

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 CharBox

Source§

impl Debug for CharBox

Source§

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

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

impl PartialEq for CharBox

Source§

fn eq(&self, other: &CharBox) -> 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 CharBox

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.