Skip to main content

Tbox

Struct Tbox 

Source
pub struct Tbox {
    pub text: SymStr,
    pub font: Rc<Font>,
    pub locator: Option<Locator>,
    pub properties: SymHashMap<Stored>,
    pub tokens: Tokens,
    pub empty_marker: bool,
}
Expand description

Box is a Rust keyword, so we use “Tbox” instead, as in “TeX Box”

Fields§

§text: SymStr

plain-text content

§font: Rc<Font>

associated font for text

§locator: Option<Locator>

source location where the box originated (None = unknown)

§properties: SymHashMap<Stored>

misc properties, such as sizing information

§tokens: Tokens

a Tokens list containing the TeX that created (or could have) the Tbox.

§empty_marker: bool

isEmpty, lifted off the property map. The {/} group markers (tex_box.rs) and the no-op primitive box carry exactly one property, isEmpty => true; as a map entry it cost a heap-allocated hashbrown table per marker — 1.24 M tables / 421 MB, 16 % of the Rust-heap peak on pgf-spectra LSE (dhat, 2026-09-20). Tbox::new drains the key into this field, so a text-mode marker’s map stays empty (no allocation); the isEmpty readers below consult the field first.

Implementations§

Source§

impl Tbox

Source

pub fn new( text: SymStr, font_opt: Option<Rc<Font>>, locator_opt: Option<Locator>, tokens_opt: Tokens, properties: HashMap<Stored>, ) -> Self

creates a new Tbox. If font_opt or locator_opt are None, they are obtained from the currently active state? Note that text can be empty, which contributes nothing to the generated document, but does record the TeX code (in the tokens).

Source

pub fn with_tfm_slot(self, code: u32) -> Self

Records the font slot code this character box was typeset from, when its font is measured by its TFM (Font::measuring_tfm): the decoded Unicode character no longer names the slot (witness 2605.02221). A slot the TFM lacks is measured by its decoded character as before (TeX: a missing character, 0pt).

Source

pub fn is_empty(&self) -> bool

checks if the text content is empty

Source

pub fn is_math(&self) -> bool

Whether this box is in math mode. Perl: Box.pm::isMath (L79-81): ($mode || 'restricted_horizontal') =~ /math$/. Matches “math”, “inline_math”, “display_math”.

Source

pub fn set_properties<I>(&mut self, entries: I)
where I: IntoIterator<Item = (&'static str, Stored)>,

Batch-insert properties. Equivalent to calling set_property for each entry, but avoids re-looking up the properties map per call. Perl: Box.pm::setProperties (L171-175).

Source

pub fn total_height(&self) -> Dimension

height + depth of this box (the TeX “total height”). Returns Dimension::default() (0pt) when either component is absent. Perl: Box.pm::getTotalHeight (L202-210).

Trait Implementations§

Source§

impl BoxOps for Tbox

Source§

fn get_tokens(&self) -> Option<&Tokens>

get the underlying tokens (preceding digestion)
Source§

fn get_properties(&self) -> &HashMap<Stored>

deprecated: get the map of named properties. This can not be usable as long as we have any data behind a RefCell wrapper. Use with_properties instead.
Source§

fn get_property(&self, key: &str) -> Option<Cow<'_, Stored>>

get a single named property (with special “isSpace” check)
Source§

fn with_properties<R, FnR>(&self, caller: FnR) -> R
where FnR: FnOnce(&HashMap<Stored>) -> R,

execute a function using this object’s named properties
Source§

fn get_properties_mut(&mut self) -> &mut HashMap<Stored>

get a mutable reference to the map of named properties
Source§

fn has_property(&self, key: &str) -> bool

checks if a property key has been set
Source§

fn get_property_bool(&self, key: &str) -> bool

obtains a boolean property value (false unless Stored::Bool)
Source§

fn get_string(&self) -> Result<Cow<'_, str>>

build a string representation of the underlying digested data
Source§

fn be_absorbed(&self, document: &mut Document) -> Result<Vec<Node>>

absorb the current object into the Document XML - returning the corresponding nodes
Source§

fn get_font(&self) -> Result<Option<Rc<Font>>>

gets the associated font, if any
Source§

fn compute_size( &self, options: HashMap<Stored>, ) -> Result<(Dimension, Dimension, Dimension)>

computes and returns the size of a box-like object
Source§

fn unlist(&self) -> Vec<Digested>

If composite, unwrap into the contained digested objects (or return self)
Source§

fn unlist_ref(&self) -> Vec<Cow<'_, Digested>>

Source§

fn be_absorbed_mut(&mut self, _document: &mut Document) -> Result<Vec<Node>>

be_absorbed but with allowed side-effects on the carrier (for Alignment only)
Source§

fn set_property<T: Into<Stored>>(&mut self, key: &str, value: T)

set a named property (allows all Stored types for values)
Source§

fn set_memo_property<T: Into<Stored>>(&mut self, key: &str, value: T)

BoxOps::set_property for a memo — a value the box can compute again — which a box busy elsewhere (being absorbed) does without, where Perl’s plain hash store (Box.pm:294-296) always lands.
Source§

fn get_property_string(&self, key: &str) -> String

Source§

fn get_property_mut(&mut self, key: &str) -> Option<&mut Stored>

get a mutable reference to a single named property (does NOT have the “isSpace” check)
Source§

fn get_body(&self) -> Result<Option<Digested>>

obtains the “body” of a digested object which captured it
Source§

fn set_font(&mut self, _font: Rc<Font>)

sets an associated font
Source§

fn set_width<T: Into<Stored>>(&mut self, width: T)

sets a “width” property, for sizing
Source§

fn get_width( &self, options: Option<HashMap<Stored>>, ) -> Result<Option<RegisterValue>>

gets the “width” property value, if any
Source§

fn set_height<T: Into<Stored>>(&mut self, width: T)

sets a “height” property value, for sizing
Source§

fn get_height(&self) -> Option<RegisterValue>

gets the “height” property value, if any. Checks “height”, then “cached_height”, then computes from font if needed.
Source§

fn set_depth<T: Into<Stored>>(&mut self, width: T)

sets a “depth” property value, for sizing
Source§

fn get_depth(&self) -> Option<RegisterValue>

gets the “depth” property value, if any. Checks “depth”, then “cached_depth”, then computes from font if needed.
Source§

fn get_size( &mut self, options: Option<HashMap<Stored>>, ) -> Result<(Dimension, Dimension, Dimension, Dimension, Dimension, Dimension)>

gets the box size as a triple of (width, height, depth) the generic implementation is immutable and will recompute the size on each call see Digested::get_size for a variant with interior mutability which caches the box size
Source§

fn compute_size_and_cache( &mut self, options: HashMap<Stored>, ) -> Result<(Dimension, Dimension, Dimension)>

computes and caches (via named properties) the size of a box-like object, Perl’s computeSizeStore (Box.pm:266-297). A box whose size is completely specified keeps that size, and its contents are not measured (:275-281): width, height and depth all given, a space’s width, or a vertical space’s height or depth. A pgf picture declares its size, and sizing a box that holds one walked every drawing box of it (pgf-spectraPreviewDataLSE, 56kq). Perl #2798 (S5, padding slice): the size then takes any requested pad{top,bottom,left,right} (display math \abovedisplayskip/\belowdisplayskip, \overline/\underline 2pt, items/equations). Not ported: a partly specified size keeping its given parts over the computed ones, and isEmpty — a mechanical port of those regressed (Rust boxes don’t use width/height/depth uniformly as “requested box size”; docs/archive/UPSTREAM_SYNC_2767_to_2833_2026-06-26.md, U2 and slice S5); tracked with K18 in docs/SYNC_STATUS.md.
Source§

impl Clone for Tbox

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 Tbox

Source§

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

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

impl Default for Tbox

Source§

fn default() -> Self

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

impl Display for Tbox

Source§

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

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

impl From<Tbox> for Digested

Source§

fn from(value: Tbox) -> Digested

Converts to this type from the input type.
Source§

impl From<Tbox> for Result<Vec<Digested>>

Source§

fn from(tbox: Tbox) -> Result<Vec<Digested>>

Converts to this type from the input type.
Source§

impl From<Tbox> for Option<Digested>

Source§

fn from(tbox: Tbox) -> Option<Digested>

Converts to this type from the input type.
Source§

impl IntoDigestedResult<Result<Vec<Digested>, Error>> for Tbox

Source§

fn into_digested_result(self) -> Result<Vec<Digested>>

Performs the conversion, used for DefPrimitive return values etc
Source§

impl Object for Tbox

Source§

fn get_locator(&self) -> Option<Locator>

The object’s stored source locator, if it has one. None is the honest “no recorded source position” (replacing the old Locator::default() file!()/line!() sentinel). For “where the parser is now” (error reporting, box creation), use the free fn gullet::get_locator().
Source§

fn revert(&self) -> Result<Tokens>

each concrete object needs to provide its own path back to tokens
Source§

fn stringify(&self) -> String

Source§

fn isa_box(&self) -> bool

Source§

fn is_expandable(&self) -> bool

Source§

fn is_definition(&self) -> bool

Source§

fn is_comment(&self) -> bool

Source§

fn be_digested(self) -> Result<Digested>
where Self: Sized + Debug,

Source§

fn get_origin(&self) -> DefinitionOrigin

Who made this definition (K1 provenance, definition::origin). The default is Unknown, which counts as LaTeXML’s own.
Source§

impl PartialEq for Tbox

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Tbox

§

impl !Send for Tbox

§

impl !Sync for Tbox

§

impl !UnwindSafe for Tbox

§

impl Freeze for Tbox

§

impl Unpin for Tbox

§

impl UnsafeUnpin for Tbox

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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.