Skip to main content

TextState

Struct TextState 

Source
pub struct TextState {
    pub ctm: Matrix,
    pub text_matrix: Matrix,
    pub text_line_matrix: Matrix,
    pub font: Option<Rc<dyn TextStateFont>>,
    pub font_size: f64,
    pub char_spacing: f64,
    pub word_spacing: f64,
    pub horizontal_scale: f64,
    pub leading: f64,
    pub text_rise: f64,
    pub render_mode: TextRenderMode,
}
Expand description

Running text-object state for one page’s content-stream scan: the CTM, text matrix/text-line matrix, and the spacing/scale/leading/rise/render-mode parameters §5.2 requires tracking across q/Q/cm; BT/ET; Tm/Td/TD/T*; Tf/Tz/Tc/Tw/TL/Ts/Tr.

Fields§

§ctm: Matrix§text_matrix: Matrix§text_line_matrix: Matrix§font: Option<Rc<dyn TextStateFont>>§font_size: f64

Current font size (Tf’s second operand).

§char_spacing: f64

Character spacing (Tc).

§word_spacing: f64

Word spacing (Tw), applied only to single-byte code 32 by the caller.

§horizontal_scale: f64

Horizontal scaling (Tz), stored as a fraction (Tz operand / 100); PDF default 1.0.

§leading: f64

Leading (TL), used by T*/TD.

§text_rise: f64

Text rise (Ts).

§render_mode: TextRenderMode

Implementations§

Source§

impl TextState

Source

pub fn new() -> TextState

Source

pub fn begin_text(&mut self)

BT: both text matrices reset to identity (PDF spec 9.4.1).

Source

pub fn set_tm(&mut self, m: Matrix)

Tm a b c d e f: both matrices are set directly.

Source

pub fn move_line(&mut self, tx: f64, ty: f64)

Td/the translation half of TD: Tlm = [1 0 0 1 tx ty] x Tlm_old; Tm = Tlm.

Source

pub fn next_line(&mut self)

T*: equivalent to 0 -TL Td.

Source

pub fn origin(&self) -> (f64, f64)

Device-space origin a Tj/TJ at the current text matrix would render at — where pdf_inspect.rs’s visit_text_show records each glyph’s origin.

Source

pub fn glyph_quad( &self, glyph: &DecodedGlyph, text_matrix: Matrix, ) -> Result<[f64; 8], PdfEditError>

Device-space glyph quad for glyph shown at text_matrix under this state’s ctm. Uses glyph.bbox when the font decoder supplied one; otherwise approximates an em-box from this state’s font size and the font’s advance width for glyph.cid — a placeholder good enough for construction/serialization tests, refined by pdf_inspect.rs (B1) once real font metrics (§7.2) are threaded through.

Trait Implementations§

Source§

impl Clone for TextState

Source§

fn clone(&self) -> Self

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 TextState

Source§

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

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

impl Default for TextState

Source§

fn default() -> Self

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

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> 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> 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> 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<U, T> ToOwnedObj<U> for T
where U: FromObjRef<T>,

Source§

fn to_owned_obj(&self, data: FontData<'_>) -> U

Convert this type into T, using the provided data to resolve any offsets.
Source§

impl<U, T> ToOwnedTable<U> for T
where U: FromTableRef<T>,

Source§

fn to_owned_table(&self) -> U

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, !>

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.