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: SymStrplain-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: Tokensa Tokens list containing the TeX that created (or could have) the Tbox.
empty_marker: boolisEmpty, 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
impl Tbox
Sourcepub fn new(
text: SymStr,
font_opt: Option<Rc<Font>>,
locator_opt: Option<Locator>,
tokens_opt: Tokens,
properties: HashMap<Stored>,
) -> Self
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).
Sourcepub fn with_tfm_slot(self, code: u32) -> Self
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).
Sourcepub fn is_math(&self) -> bool
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”.
Sourcepub fn set_properties<I>(&mut self, entries: I)
pub fn set_properties<I>(&mut self, entries: I)
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).
Sourcepub fn total_height(&self) -> Dimension
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
impl BoxOps for Tbox
Source§fn get_tokens(&self) -> Option<&Tokens>
fn get_tokens(&self) -> Option<&Tokens>
Source§fn get_properties(&self) -> &HashMap<Stored>
fn get_properties(&self) -> &HashMap<Stored>
with_properties instead.Source§fn get_property(&self, key: &str) -> Option<Cow<'_, Stored>>
fn get_property(&self, key: &str) -> Option<Cow<'_, Stored>>
Source§fn with_properties<R, FnR>(&self, caller: FnR) -> R
fn with_properties<R, FnR>(&self, caller: FnR) -> R
Source§fn get_properties_mut(&mut self) -> &mut HashMap<Stored>
fn get_properties_mut(&mut self) -> &mut HashMap<Stored>
Source§fn has_property(&self, key: &str) -> bool
fn has_property(&self, key: &str) -> bool
Source§fn get_property_bool(&self, key: &str) -> bool
fn get_property_bool(&self, key: &str) -> bool
Stored::Bool)Source§fn get_string(&self) -> Result<Cow<'_, str>>
fn get_string(&self) -> Result<Cow<'_, str>>
Source§fn be_absorbed(&self, document: &mut Document) -> Result<Vec<Node>>
fn be_absorbed(&self, document: &mut Document) -> Result<Vec<Node>>
Document XML - returning the corresponding nodesSource§fn compute_size(
&self,
options: HashMap<Stored>,
) -> Result<(Dimension, Dimension, Dimension)>
fn compute_size( &self, options: HashMap<Stored>, ) -> Result<(Dimension, Dimension, Dimension)>
Source§fn unlist(&self) -> Vec<Digested>
fn unlist(&self) -> Vec<Digested>
fn unlist_ref(&self) -> Vec<Cow<'_, Digested>>
Source§fn be_absorbed_mut(&mut self, _document: &mut Document) -> Result<Vec<Node>>
fn be_absorbed_mut(&mut self, _document: &mut Document) -> Result<Vec<Node>>
Alignment only)Source§fn set_property<T: Into<Stored>>(&mut self, key: &str, value: T)
fn set_property<T: Into<Stored>>(&mut self, key: &str, value: T)
Stored types for values)Source§fn set_memo_property<T: Into<Stored>>(&mut self, key: &str, value: T)
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.fn get_property_string(&self, key: &str) -> String
Source§fn get_property_mut(&mut self, key: &str) -> Option<&mut Stored>
fn get_property_mut(&mut self, key: &str) -> Option<&mut Stored>
Source§fn get_body(&self) -> Result<Option<Digested>>
fn get_body(&self) -> Result<Option<Digested>>
Source§fn get_width(
&self,
options: Option<HashMap<Stored>>,
) -> Result<Option<RegisterValue>>
fn get_width( &self, options: Option<HashMap<Stored>>, ) -> Result<Option<RegisterValue>>
Source§fn set_height<T: Into<Stored>>(&mut self, width: T)
fn set_height<T: Into<Stored>>(&mut self, width: T)
Source§fn get_height(&self) -> Option<RegisterValue>
fn get_height(&self) -> Option<RegisterValue>
Source§fn get_depth(&self) -> Option<RegisterValue>
fn get_depth(&self) -> Option<RegisterValue>
Source§fn get_size(
&mut self,
options: Option<HashMap<Stored>>,
) -> Result<(Dimension, Dimension, Dimension, Dimension, Dimension, Dimension)>
fn get_size( &mut self, options: Option<HashMap<Stored>>, ) -> Result<(Dimension, Dimension, Dimension, Dimension, Dimension, Dimension)>
Digested::get_size for a variant with interior mutability which caches the box sizeSource§fn compute_size_and_cache(
&mut self,
options: HashMap<Stored>,
) -> Result<(Dimension, Dimension, Dimension)>
fn compute_size_and_cache( &mut self, options: HashMap<Stored>, ) -> Result<(Dimension, Dimension, Dimension)>
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 Object for Tbox
impl Object for Tbox
Source§fn get_locator(&self) -> Option<Locator>
fn get_locator(&self) -> Option<Locator>
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>
fn revert(&self) -> Result<Tokens>
fn stringify(&self) -> String
fn isa_box(&self) -> bool
fn is_expandable(&self) -> bool
fn is_definition(&self) -> bool
fn is_comment(&self) -> bool
fn be_digested(self) -> Result<Digested>
Source§fn get_origin(&self) -> DefinitionOrigin
fn get_origin(&self) -> DefinitionOrigin
definition::origin). The
default is Unknown, which counts as LaTeXML’s own.