pub struct Font {Show 22 fields
pub family: Option<Cow<'static, str>>,
pub series: Option<Cow<'static, str>>,
pub shape: Option<Cow<'static, str>>,
pub size: Option<f64>,
pub color: Option<Color>,
pub bg: Option<Color>,
pub opacity: Option<Cow<'static, str>>,
pub encoding: Option<Cow<'static, str>>,
pub language: Option<Cow<'static, str>>,
pub mathstyle: Option<Cow<'static, str>>,
pub mathstylestep: Option<i32>,
pub name: Option<Cow<'static, str>>,
pub nfss_font: Option<Arc<Font>>,
pub emph: Option<bool>,
pub scripted: Option<bool>,
pub fraction: Option<bool>,
pub forceseries: Option<bool>,
pub forcefamily: Option<bool>,
pub forceshape: Option<bool>,
pub forcebold: Option<bool>,
pub scale: Option<f64>,
pub flags: Option<u8>,
}Expand description
A data structure containing Font information, but also related textual properties (such as color)
This struct is a little interesting, as we want to pass overrides that partially modify (via a merge) the current font, in each definitional binding. To accommodate that with this struct, every single field needs to be an Option, in order to unambiguously tell the “intend” of override (Some) vs no intent (None).
Fields§
§family: Option<Cow<'static, str>>§series: Option<Cow<'static, str>>§shape: Option<Cow<'static, str>>§size: Option<f64>§color: Option<Color>§bg: Option<Color>§opacity: Option<Cow<'static, str>>§encoding: Option<Cow<'static, str>>§language: Option<Cow<'static, str>>§mathstyle: Option<Cow<'static, str>>§mathstylestep: Option<i32>§name: Option<Cow<'static, str>>§nfss_font: Option<Arc<Font>>While a font selected by \font (name) is in force, the font it replaced: NFSS’s
\f@encoding/\f@family/\f@series/\f@shape/\f@size, which a \font identifier never
changes (tex.web §1217) and the next font selection returns to (merge_ref). Set where a
\font identifier is selected (content::merge_font_ref), so it — not name, which a box
font also carries from its \textfont — marks a raw font in force. Not part of the font’s
identity (Hash, PartialEq): it changes nothing until a selection, and the dump does not
carry it.
emph: Option<bool>§scripted: Option<bool>§fraction: Option<bool>§forceseries: Option<bool>§forcefamily: Option<bool>§forceshape: Option<bool>§forcebold: Option<bool>§scale: Option<f64>§flags: Option<u8>Implementations§
Source§impl Font
impl Font
Sourcepub fn perl_equals(&self, other: &Font) -> bool
pub fn perl_equals(&self, other: &Font) -> bool
Perl Font::equals (Font.pm:333-337): the eleven slots of Perl’s font array — family,
series, shape, size, color, background, opacity, encoding, language, mathstyle and flags — and
none of the Rust-only fields (name, mathstylestep, scale, …) PartialEq also compares,
which a font merged from a mathchar’s fontinfo carries ($2\mathrm{KL}$’s digit, whose
name and OT1 encoding are the fontinfo’s). Colors compare by value (OXIDIZED_DESIGN #20);
unset flags are 0, and an unset encoding is Perl’s default OT1 — Rust’s math default leaves
it unset where Perl’s mathDefault has 'OT1' (Font.pm:280-283), so the current font of
\mathrm letters compares equal to a digit’s fontinfo font as in Perl. Used by the letters
and number ligatures (base_xmath.rs); witness 2605.31599.
Source§impl Font
impl Font
pub fn text_default() -> Self
pub fn math_default() -> Self
pub fn to_hashable(&self) -> u64
Sourcepub fn stringify(&self) -> String
pub fn stringify(&self) -> String
Condensed string showing only non-default components. Perl: stringify
Sourcepub fn font_match(&self, other: &Font) -> bool
pub fn font_match(&self, other: &Font) -> bool
Wildcard font matching: if any components are defined in both fonts, they must be equal. Perl: match
Sourcepub fn make_concrete(&self, concrete: &Font) -> Self
pub fn make_concrete(&self, concrete: &Font) -> Self
Fill in undefined fields from a concrete font. Perl: makeConcrete
Sourcepub fn merge_purestyle(&self, changes: &Font) -> Self
pub fn merge_purestyle(&self, changes: &Font) -> Self
Apply pure style changes (from purestyleChanges) to this font. Perl: mergePurestyle
Sourcepub fn math_bearing(&self, thisbox: &Digested, prevbox: &Digested) -> f64
pub fn math_bearing(&self, thisbox: &Digested, prevbox: &Digested) -> f64
Compute math bearing (inter-atom spacing) between two boxes. Perl: math_bearing
pub fn is_sticky(&self) -> bool
pub fn get_family(&self) -> Option<&Cow<'_, str>>
pub fn get_series(&self) -> Option<&Cow<'_, str>>
pub fn get_shape(&self) -> Option<&Cow<'_, str>>
pub fn get_size(&self) -> Option<f64>
pub fn get_color(&self) -> Option<&Color>
pub fn get_background(&self) -> Option<&Color>
pub fn get_opacity(&self) -> Option<&Cow<'_, str>>
pub fn get_encoding(&self) -> Option<&Cow<'_, str>>
pub fn get_language(&self) -> Option<&Cow<'_, str>>
pub fn get_mathstyle(&self) -> Option<&Cow<'_, str>>
pub fn get_flags(&self) -> Option<u8>
pub fn merge(&self, other: Font) -> Self
Sourcepub fn merge_ref(&self, other: &Font) -> Self
pub fn merge_ref(&self, other: &Font) -> Self
Like merge but borrows other to avoid requiring callers to own or
clone a Font just to pass into merge. Clones only the retained fields
from other (cheap — Option<Cow<’static,str>> clones are free for
Borrowed variants, and most Font fields are None in typical uses).
Sourcepub fn specialize(&self, text: &str) -> Self
pub fn specialize(&self, text: &str) -> Self
Instanciate the font for a particular class of symbols. NOTE: This works in `normal’ latex, but probably needs some tunability. Depending on the fonts being used, the allowable combinations may be different. Getting the font right is important, since the author probably thinks of the identity of the symbols according to what they SEE in the printed document. Even though the markup might seem to indicate something else…
Use Unicode properties to determine font merging.
Sourcepub fn specialize_letters(&self, text: &str, class: LettersClass) -> Self
pub fn specialize_letters(&self, text: &str, class: LettersClass) -> Self
specialize for a glyph \DeclareMathSymbol‘d from the math italic symbol font, letters (OML cmm/m/it,
fontmath.ltx:60): a capital Greek letter takes the rule of the fontmath.ltx glyphs of the same class, which
Perl’s specialize encodes — a \mathalpha (class 7, variable family) one the Latin letters’ (fontmath.ltx:87-138
\DeclareMathSymbol{a}{\mathalpha}{letters}{a}): italic unless a math alphabet is in force (\mathrm, \mathbfupright;\boldmath, \boldsymbol, \bmbold italic), as TeX's class 7 takes\fam(tex.web §1151); a\mathord(class 0) one the lowercase Greek letters' (fontmath.ltx:175-203\DeclareMathSymbol{\alpha}
{\mathord}{letters}{“0B}): italic whatever the alphabet. The capitals follow an alphabet to the same letter because OT1, the alphabets' encoding, holds them at OML's slots "00-"0A; lowercase Greek has no OT1 slot (an alphabet prints a ligature there), so every other glyph keeps specialize's own rule. llncs.cls:379-389, svmult.cls:971-981, svjour3.cls:147-157, fixmath.sty:27-37, amsmath.sty:384-395 (\varGamma, class 0). Witnesses 2606.09074 (llncs), 2101.03721 (svjour3), 0812.2480 (svmult), 1002.2350 (fixmath), 2508.05134 (newpxmath slantedGreek), 1701.03426 and 2407.01655 (amsmath \var…`).
pub fn distance(&self, other: &Font) -> i8
Sourcepub fn font_attribute_string(&self) -> String
pub fn font_attribute_string(&self) -> String
This method compares 2 fonts, returning the differences between them. Returns the font attribute string (family/series/shape components that differ from text defaults), joined by spaces. E.g., “italic” for a math font. Used by cancel.sty to capture font state for XML attributes.
Sourcepub fn relative_to(&self, other: &Font) -> HashMap<String, (String, Font)>
pub fn relative_to(&self, other: &Font) -> HashMap<String, (String, Font)>
Noting that the font-related attributes in the schema distill the font properties into fewer attributes (font,fontsize,color,background,opacity), the return value encodes both the attribute changes that would be needed to effect the font change, along with the font properties that differed Namely, the result is a hash keyed on the attribute name and whose value is a FontDiff value => “new_attribute_value” properties => { %fontproperties } or (String, Font)
pub fn purestyle_changes(&self, other: &Font) -> Font
Sourcepub fn measuring_tfm(&self) -> Option<Rc<Tfm>>
pub fn measuring_tfm(&self) -> Option<Rc<Tfm>>
The TFM a character of this font is measured from: a font loaded by name (\font) whose
family has no standard metric, while it is still that font’s family and encoding (a later
font selection ends it, merge_ref). Fonts with a standard metric keep Perl’s metric
(get_metric; KPE #408, witness 2605.02221).
Sourcepub fn get_metric(&self, c_opt: Option<char>) -> &MetricData
pub fn get_metric(&self, c_opt: Option<char>) -> &MetricData
Find a Font Metric corresponding to this font’s family_series_shape_size
that contains the given char, if given.
Try to find a fallback metric if char is not in the current Font.
Perl: getMetric
pub fn get_em_width(&self) -> i64
pub fn get_ex_height(&self) -> i64
pub fn get_mu_width(&self) -> i64
pub fn compute_string_size( &self, text: &str, _options: SymHashMap<Stored>, ) -> (Dimension, Dimension, Dimension)
Sourcepub fn get_nominal_size(&self) -> (Dimension, Dimension, Dimension)
pub fn get_nominal_size(&self) -> (Dimension, Dimension, Dimension)
Get nominal width, height base ? Probably should be using data from FontMetric ???
Sourcepub fn compute_boxes_size(
&self,
boxes: &[Digested],
options: SymHashMap<Stored>,
) -> Result<(Dimension, Dimension, Dimension)>
pub fn compute_boxes_size( &self, boxes: &[Digested], options: SymHashMap<Stored>, ) -> Result<(Dimension, Dimension, Dimension)>
Perl: Font.pm sub computeBoxesSize (L635-680) Compute the size of a List of boxes, dispatching to helpers based on layout mode.