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: StringDecoded 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: StringThe 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: f32Font size as supplied to the Tf operator.
render_mode: TextRenderModeText 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: f32Text 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.