pub struct Font {Show 21 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 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>>§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
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.
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 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.