Skip to main content

Font

Struct Font 

Source
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

Source

pub fn text_default() -> Self

Source

pub fn math_default() -> Self

Source

pub fn to_hashable(&self) -> u64

Source

pub fn stringify(&self) -> String

Condensed string showing only non-default components. Perl: stringify

Source

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

Source

pub fn make_concrete(&self, concrete: &Font) -> Self

Fill in undefined fields from a concrete font. Perl: makeConcrete

Source

pub fn merge_purestyle(&self, changes: &Font) -> Self

Apply pure style changes (from purestyleChanges) to this font. Perl: mergePurestyle

Source

pub fn math_bearing(&self, thisbox: &Digested, prevbox: &Digested) -> f64

Compute math bearing (inter-atom spacing) between two boxes. Perl: math_bearing

Source

pub fn is_sticky(&self) -> bool

Source

pub fn get_family(&self) -> Option<&Cow<'_, str>>

Source

pub fn get_series(&self) -> Option<&Cow<'_, str>>

Source

pub fn get_shape(&self) -> Option<&Cow<'_, str>>

Source

pub fn get_size(&self) -> Option<f64>

Source

pub fn get_color(&self) -> Option<&Color>

Source

pub fn get_background(&self) -> Option<&Color>

Source

pub fn get_opacity(&self) -> Option<&Cow<'_, str>>

Source

pub fn get_encoding(&self) -> Option<&Cow<'_, str>>

Source

pub fn get_language(&self) -> Option<&Cow<'_, str>>

Source

pub fn get_mathstyle(&self) -> Option<&Cow<'_, str>>

Source

pub fn get_flags(&self) -> Option<u8>

Source

pub fn merge(&self, other: Font) -> Self

Source

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).

Source

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.

Source

pub fn distance(&self, other: &Font) -> i8

Source

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.

Source

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)

Source

pub fn purestyle_changes(&self, other: &Font) -> Font

Source

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

Source

pub fn get_em_width(&self) -> i64

Source

pub fn get_ex_height(&self) -> i64

Source

pub fn get_mu_width(&self) -> i64

Source

pub fn compute_string_size( &self, text: &str, _options: SymHashMap<Stored>, ) -> (Dimension, Dimension, Dimension)

Source

pub fn get_nominal_size(&self) -> (Dimension, Dimension, Dimension)

Get nominal width, height base ? Probably should be using data from FontMetric ???

Source

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.

Trait Implementations§

Source§

impl Clone for Font

Source§

fn clone(&self) -> Font

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 Font

Source§

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

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

impl Default for Font

Source§

fn default() -> Font

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

impl Display for Font

Source§

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

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

impl Eq for Font

Source§

impl From<Font> for Stored

Source§

fn from(value: Font) -> Self

Converts to this type from the input type.
Source§

impl From<Font> for FontDirective

Source§

fn from(f: Font) -> Self

Converts to this type from the input type.
Source§

impl Hash for Font

Source§

fn hash<H: Hasher>(&self, hasher: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Font

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 Freeze for Font

§

impl RefUnwindSafe for Font

§

impl Send for Font

§

impl Sync for Font

§

impl Unpin for Font

§

impl UnsafeUnpin for Font

§

impl UnwindSafe for Font

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
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.