pub enum FontFamily {
Serif,
SansSerif,
Monospace,
Cursive,
}Expand description
The face a run is set in — CSS’s generic families, less fantasy and
system-ui, neither of which an author asks for.
A generic, never a font name, for SizeStep’s reason: a document that
names Georgia renders in the fallback everywhere Georgia is not installed,
which is every Linux terminal and most of the web. The theme names the
concrete face for each — Serif is Georgia on a Mac and Noto Serif on a
Linux box, and Monospace is the theme’s mono face, which inline code
already uses.
A named family is not in this vocabulary: from_attr
answers None for it, and it is FontFace::Named’s to read — the open
type beside this one, which the toolbar offers under the four generics.
Variants§
Implementations§
Source§impl FontFamily
impl FontFamily
Sourcepub const ALL: [Self; 4]
pub const ALL: [Self; 4]
Every face, in the order a menu offers them. The theme’s own body face
is absent because it is absence — the menu entry for it calls
crate::Doc::set_font_family with None.
Sourcepub fn from_attrs(attrs: &[(String, Option<String>)]) -> Option<Self>
pub fn from_attrs(attrs: &[(String, Option<String>)]) -> Option<Self>
The face a run’s or block’s attributes name, if any — twig records it
under data-font.
Sourcepub fn from_attr(value: &str) -> Option<Self>
pub fn from_attr(value: &str) -> Option<Self>
Read a data-font value. None for a concrete family name, which is
FontFace::Named’s to read; FontFace::from_attr is the door that
reads both.
The four generics are matched without regard to case, because they are
CSS keywords and CSS reads a keyword either way — a hand-written
document says Serif as readily as serif, and a family actually
named “Serif” is not a thing anyone has installed. The canonical
spelling name writes back is the lowercase one.