Skip to main content

TextSpan

Struct TextSpan 

Source
pub struct TextSpan {
Show 18 fields pub text: String, pub x: f64, pub y: f64, pub width: f64, pub height: f64, pub font_size: f64, 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 font_metrics: Option<FontMetrics>, /* private fields */
}
Expand description

A single text span at a specific position.

Fields§

§text: String

The extracted text.

§x: f64

X position in user space.

§y: f64

Y position in user space.

§width: f64

Approximate bounding-box width in user space.

§height: f64

Approximate bounding-box height in user space.

§font_size: f64

Font size (approximate, from transform).

§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: bool

Inferred bold style: weight >= 700 or PostScript name suggests bold (“bold”, “demi”, “semibold”, “heavy”, “black”). Defaults false when no descriptor data is reachable.

§is_italic: bool

Inferred 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: WidthSource

Whether 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. None for spans not built from a glyph (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. None for spans not built from a glyph.

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

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

Source§

fn default() -> TextSpan

Returns the “default value” for a type. Read more
Source§

impl From<&TextSpan> for TextSpanInfo

Source§

fn from(s: &TextSpan) -> Self

Build the canonical wire form from a borrowed TextSpan (clones).

Source§

impl From<TextSpan> for TextSpanInfo

Source§

fn from(s: TextSpan) -> Self

Build the canonical wire form from an owned engine TextSpan.

Centralises the conversions that previously lived in each binding: the ½-em width fallback, the RGBA-u8 → RGB-f32 colour normalisation, and the height-reports-font-size contract.

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> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> ParallelSend for T

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(value: T, _simd: S) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

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

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more