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
impl GlyphCatalog
Sourcepub fn from_rules(rules: impl IntoIterator<Item = (GlyphKey, Glyph)>) -> Self
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.
Sourcepub fn from_symbol_rules(
rules: impl IntoIterator<Item = (SymbolCell, Glyph)>,
) -> Self
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.
Sourcepub fn union(catalogs: impl IntoIterator<Item = Self>) -> Self
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.
Sourcepub fn light() -> Self
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.
Sourcepub fn solid() -> Self
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.
Sourcepub fn glyph(&self, key: &GlyphKey) -> Option<&Glyph>
pub fn glyph(&self, key: &GlyphKey) -> Option<&Glyph>
Returns the glyph key answers to, or None if the catalog has no rule for it.
Sourcepub fn symbol(&self, key: &SymbolCell) -> Option<&Glyph>
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.
Sourcepub fn symbol_styles(&self) -> Vec<&SymbolStyleName>
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.