Skip to main content

TextSpan

Struct TextSpan 

Source
pub struct TextSpan {
Show 19 fields pub text: String, pub x: f32, pub y: f32, pub end_x: f32, pub size: f32, pub font: String, pub font_name: String, pub page: usize, pub bbox: Rect, pub bold: bool, pub italic: bool, pub monospace: bool, pub serif: bool, pub rise: f32, pub vertical: bool, pub invisible: bool, pub color: Option<(f32, f32, f32)>, pub underline: bool, pub strikethrough: bool,
}
Expand description

A positioned run of extracted text.

Fields§

§text: String

The decoded text.

§x: f32

Device-space x coordinate of the span origin.

§y: f32

Device-space y coordinate of the span baseline.

§end_x: f32

Device-space x after the last glyph’s advance.

§size: f32

Effective font size.

§font: String

Font resource name.

§font_name: String

The font’s /BaseFont name verbatim — subset prefix included — falling back to the FontDescriptor’s /FontName; empty when the file names the font nowhere (a missing font resource included).

§page: usize

0-based index of the page the span came from.

§bbox: Rect

Device-space box: origin to advance horizontally, the font’s /Descent../Ascent (per-mille of the effective size) vertically. Exact for unrotated horizontal text, an approximation under rotated matrices; vertical writing takes the advance as its vertical extent and half the size to each side of the baseline.

§bold: bool

Whether the font that produced this span is bold: FontDescriptor /FontWeight >= 600, /Flags ForceBold, or a /StemV in bold stem-width territory, else a Bold substring in /BaseFont (ISO 32000-1 Table 123).

§italic: bool

Whether the font that produced this span is italic: FontDescriptor /Flags Italic or a nonzero /ItalicAngle, else an Italic or Oblique substring in /BaseFont (ISO 32000-1 Table 123).

§monospace: bool

FontDescriptor /Flags FixedPitch (ISO 32000-1 Table 123 bit 1).

§serif: bool

FontDescriptor /Flags Serif (ISO 32000-1 Table 123 bit 2).

§rise: f32

The text rise (Ts) the span was shown under, in unscaled text space: positive above the baseline — a superscript/subscript signal. The origin already includes the shift.

§vertical: bool

Writing mode 1: the text advances downward and bbox takes the advance as its vertical extent.

§invisible: bool

Shown under render mode 3 or 7 (ISO 32000-1 Table 106), which paint nothing — the shape of an OCR text layer under a scanned image.

§color: Option<(f32, f32, f32)>

The fill color the span was shown with, as RGB in [0, 1]. Device gray/RGB/CMYK convert exactly; other spaces’ components are read by count (1 gray, 3 RGB, 4 CMYK) without running the space’s transform. None for pattern fills, which have no single color.

§underline: bool

A drawn ruling sits just below the baseline and covers most of the span. PDF has no underline attribute — this is read from the page’s geometry, so a table border hugging a cell’s text can read as one.

§strikethrough: bool

A drawn ruling crosses the span’s x-height band — geometry-read, like underline.

Trait Implementations§

Source§

impl Clone for TextSpan

Source§

fn clone(&self) -> TextSpan

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 Debug for TextSpan

Source§

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

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

impl PartialEq for TextSpan

Source§

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

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, <T as TryFrom<U>>::Error>

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.