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: f64Current font size (Tf’s second operand).
char_spacing: f64Character spacing (Tc).
word_spacing: f64Word spacing (Tw), applied only to single-byte code 32 by the caller.
horizontal_scale: f64Horizontal scaling (Tz), stored as a fraction (Tz operand / 100); PDF default 1.0.
leading: f64Leading (TL), used by T*/TD.
text_rise: f64Text rise (Ts).
render_mode: TextRenderModeImplementations§
Source§impl TextState
impl TextState
pub fn new() -> TextState
Sourcepub fn begin_text(&mut self)
pub fn begin_text(&mut self)
BT: both text matrices reset to identity (PDF spec 9.4.1).
Sourcepub fn move_line(&mut self, tx: f64, ty: f64)
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.
Sourcepub fn origin(&self) -> (f64, f64)
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.
Sourcepub fn glyph_quad(
&self,
glyph: &DecodedGlyph,
text_matrix: Matrix,
) -> Result<[f64; 8], PdfEditError>
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§
Auto Trait Implementations§
impl !RefUnwindSafe for TextState
impl !Send for TextState
impl !Sync for TextState
impl !UnwindSafe for TextState
impl Freeze for TextState
impl Unpin for TextState
impl UnsafeUnpin for TextState
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
Source§fn to_owned_obj(&self, data: FontData<'_>) -> U
fn to_owned_obj(&self, data: FontData<'_>) -> U
T, using the provided data to resolve any offsets.