Skip to main content

TextRun

Struct TextRun 

Source
pub struct TextRun {
    pub text: String,
    pub position: (f32, f32),
    pub font_name: String,
    pub font_size: f32,
    pub render_mode: TextRenderMode,
    pub text_rise: f32,
}
Expand description

One contiguous text-show output by the content-stream walker.

Position is the text-space origin of the run at the moment the show operator fired (text-matrix e / f). Font size carries the Tf argument verbatim — note that PDF text-space is multiplied by the CTM scaling, so the rendered glyph size on paper is font_size * CTM_scale. Round-22 callers that only need the raw Tf value (e.g. for keyword search) can ignore the CTM; renderers that want physical size should multiply by the CTM extracted from the reader’s group walker.

Fields§

§text: String

Decoded Unicode payload — the result of mapping every encoded byte / CID through the font’s /ToUnicode CMap (or the identity / WinAnsi fallbacks documented above).

§position: (f32, f32)

(x, y) in PDF user space — the origin at which the run’s glyphs begin. This is the text-matrix origin adjusted by the text rise Ts (ISO 32000-1 §9.4.4): per the text-rendering matrix the rise translates the rendering origin by Trise along the text matrix’s vertical basis, so a 4 Ts superscript reports a position shifted up from the surrounding baseline rather than colliding with it. When no Ts is in force the rise is 0 and the position is the bare text-matrix origin.

§font_name: String

The PDF resource name of the font (/F0, /F12, etc.) — the /Tf operand, with the leading / stripped. Empty when the content stream issues a show without a preceding Tf (malformed but tolerated).

§font_size: f32

Font size as supplied to the Tf operator.

§render_mode: TextRenderMode

Text rendering mode in force at the moment of the show — the most recent Tr operand (ISO 32000-1 §9.3.6, Table 106), defaulting to TextRenderMode::Fill when no Tr preceded the show. The load-bearing case for extraction consumers is TextRenderMode::Invisible (3 Tr): the unpainted OCR text layer scanners stack behind a page image. A keyword-search consumer keeps it; a “what the human sees” consumer drops it.

§text_rise: f32

Text rise in force at the moment of the show — the most recent Ts operand (ISO 32000-1 §9.4.4 + §9.3.7, Table 105), expressed in unscaled text-space units, defaulting to 0.0 when no Ts preceded the show. A positive rise raises the baseline (superscript); a negative rise lowers it (subscript). The geometric effect is already folded into Self::position; this raw value lets a layout / accessibility consumer classify a run as super/subscript without reverse-engineering the offset from the position delta.

Trait Implementations§

Source§

impl Clone for TextRun

Source§

fn clone(&self) -> TextRun

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 TextRun

Source§

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

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

impl PartialEq for TextRun

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for TextRun

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = Infallible

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V