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: CharTypeWhere this character came from.
unicode: u32The --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: PointThe baseline origin, already transformed into page space.
char_box: RectThe tight glyph box in page space. Zero-area for a generated character, by construction.
loose_char_box: RectThe 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: AffineThe 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: f32The font size in force, or 1.0 for a character with no text object —
which is every generated one.
angle: f32atan2(matrix.c, matrix.a) normalized to [0, 2π).
Implementations§
Source§impl CharBox
impl CharBox
Sourcepub fn is_normal(&self) -> bool
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.
Sourcepub fn is_control(&self) -> bool
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.
Sourcepub fn is_generated(&self) -> bool
pub fn is_generated(&self) -> bool
Whether the extractor invented this character.