Skip to main content

GlyphCatalog

Struct GlyphCatalog 

Source
pub struct GlyphCatalog { /* private fields */ }
Expand description

Every glyph rule in play. Answering a key is one lookup; nothing about a catalog says which set a rule came from.

Two maps, because there are two kinds of key. An arm rule is filed under four strokes, a symbol rule under a symbol and a style, and the two answer different questions about a miss: an arm cell degrades to its base stroke, while a symbol cell answers nothing. Folding them into one map over one key would make the answers collide.

Implementations§

Source§

impl GlyphCatalog

Source

pub fn from_rules(rules: impl IntoIterator<Item = (GlyphKey, Glyph)>) -> Self

Builds a catalog from an ordered group of rules. Where two rules claim the same key, the first one in rules wins.

Source

pub fn from_symbol_rules( rules: impl IntoIterator<Item = (SymbolCell, Glyph)>, ) -> Self

Builds a catalog from an ordered group of symbol rules. Where two rules claim the same pair, the first one in rules wins.

Source

pub fn union(catalogs: impl IntoIterator<Item = Self>) -> Self

Builds a catalog by merging other catalogs, in the order given. Where two claim the same key, the earlier one in catalogs wins, and each of the two maps keeps its own claims.

Source

pub fn light() -> Self

Builds a catalog from the Light table alone.

Named after what the catalog holds, not where it comes from: it stays accurate once a second built-in table exists, which is why it is not called built_in.

§Panics

Panics if a row of the Light table is not a valid glyph. That is a bug in data this library ships, never a condition a caller can trigger.

Source

pub fn solid() -> Self

Builds a catalog from the Solid style alone: one glyph per Symbol.

Named after what it holds, as light is, and it stays accurate once another style ships beside it.

§Panics

Panics if a row of the Solid table is not a valid glyph. That is a bug in data this library ships, never a condition a caller can trigger.

Source

pub fn glyph(&self, key: &GlyphKey) -> Option<&Glyph>

Returns the glyph key answers to, or None if the catalog has no rule for it.

Source

pub fn symbol(&self, key: &SymbolCell) -> Option<&Glyph>

Returns the glyph the pair key answers to, or None if the catalog has no rule for it.

A miss is final. An arm cell falls back to its base stroke; a symbol cell does not fall back to another style, because a fallback would replace the look the cell named with one it did not.

Source

pub fn symbol_styles(&self) -> Vec<&SymbolStyleName>

Every style the catalog holds a symbol rule for, each once, in name order.

Read off the rules rather than off a list, so a style added to a table is reported without a second place to change and a style with no rules is not reported at all.

Auto Trait Implementations§

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