pub struct TextSpan {Show 20 fields
pub text: String,
pub x: f64,
pub y: f64,
pub width: f64,
pub height: f64,
pub font_size: f64,
pub complete_run: bool,
pub font_name: Option<String>,
pub is_bold: bool,
pub is_italic: bool,
pub color: Option<[u8; 4]>,
pub width_source: WidthSource,
pub char_bounds: Vec<[f64; 4]>,
pub transform: Option<[f64; 6]>,
pub font_weight: Option<u16>,
pub is_serif: Option<bool>,
pub is_monospace: Option<bool>,
pub render_mode: Option<u8>,
pub is_ocr_layer: bool,
pub font_metrics: Option<FontMetrics>,
/* private fields */
}Expand description
A single text span at a specific position.
Fields§
§text: StringThe extracted text.
x: f64X position in user space.
y: f64Y position in user space.
width: f64Approximate bounding-box width in user space.
height: f64Approximate bounding-box height in user space.
font_size: f64Font size (approximate, from transform).
complete_run: boolWhether a content run ends after this span: a consumer joining same-style spans must not merge past it (#643). Only set on the raw path; the default path leaves every span open, as before.
font_name: Option<String>PostScript name of the font, with any 6-character subset prefix stripped
(e.g. Helvetica-Bold, TimesNewRomanPS-BoldMT). None for Type1
standard-14 fonts and Type3 fonts where no embedded font data is
available through the public pdf-interpret API.
is_bold: boolInferred bold style: weight >= 700 or PostScript name suggests bold
(“bold”, “demi”, “semibold”, “heavy”, “black”). Defaults false when
no descriptor data is reachable.
is_italic: boolInferred italic style: FontDescriptor /Italic flag set or PostScript
name suggests italic/oblique/slant. Defaults false when no descriptor
data is reachable.
color: Option<[u8; 4]>Fill color as sRGB RGBA, derived from Paint::Color(c).to_rgba().to_rgba8()
at the moment of glyph paint. None for Paint::Pattern (tiling /
shading) — the editor falls back to “auto” in that case.
width_source: WidthSourceWhether glyph widths were measured from real font advance data or estimated.
char_bounds: Vec<[f64; 4]>Per-glyph bounding boxes in user-space, one entry per source glyph.
[x0, y0, x1, y1] with y0 < y1 (PDF coordinate frame).
transform: Option<[f64; 6]>Full affine transform of the span’s first glyph in user space,
[a, b, c, d, e, f] (kurbo coeffs of CTM × text-matrix). Captures
rotation and shear that (x, y, font_size) discards. Text placed by a
rectangle rather than drawn by a glyph (a form field’s value with no
appearance stream, #549) carries the placement in the same form.
None for spans built from neither (e.g. synthetic markers).
font_weight: Option<u16>Numeric font weight (~100–900) from the embedded font’s OS/2 table when
available. None for non-embedded / standard-14 fonts.
is_serif: Option<bool>Whether the font is serif, when determinable from embedded font data.
None when no embedded descriptor is reachable.
is_monospace: Option<bool>Whether the font is monospace, when determinable from embedded font data.
None when no embedded descriptor is reachable.
render_mode: Option<u8>Coarse PDF text render mode: 0 fill, 1 stroke, 3 invisible — the
only three values the renderer’s GlyphDrawMode expresses (the
fill+stroke / clip modes 2 and 4–7 are not distinguished). Reflects the
span’s first glyph, and 0 for text placed by a rectangle rather than
drawn (#549). None for spans built from neither.
is_ocr_layer: boolWhether the span was set in the engine’s own OCR layer resource
(pdf_ocr::pipeline::OCR_FONT_NAME). The hidden-text drop keeps
these spans while author-hidden text goes, because the layer is the
engine’s own voice, not ink the author hid.
font_metrics: Option<FontMetrics>Vertical font metrics (ascent/descent, optional cap/x-height) in /1000
em from the embedded font binary. None for non-embedded fonts.
Implementations§
Trait Implementations§
Source§impl From<&TextSpan> for TextSpanInfo
impl From<&TextSpan> for TextSpanInfo
Source§impl From<TextSpan> for TextSpanInfo
impl From<TextSpan> for TextSpanInfo
Auto Trait Implementations§
impl Freeze for TextSpan
impl RefUnwindSafe for TextSpan
impl Send for TextSpan
impl Sync for TextSpan
impl Unpin for TextSpan
impl UnsafeUnpin for TextSpan
impl UnwindSafe for TextSpan
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneAny for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().