pub enum SizeStep {
XxSmall,
XSmall,
Small,
Large,
XLarge,
XxLarge,
XxxLarge,
}Expand description
How large a run is set relative to the text around it — CSS’s
<absolute-size> keyword set with medium removed, because medium is
absence.
A step, never a measurement, for the reason MarkColor is a name and
not a hex triple: a run set to 14pt in a theme whose body is 12pt is a
step up, and the same run under a 16pt theme is a step down — the author’s
intent inverted by a change they never made. A run set to Large is a step
up under every theme.
A heading keeps its own ramp: a data-size on a heading scales the
heading’s size, not the body’s.
Variants§
Implementations§
Source§impl SizeStep
impl SizeStep
Sourcepub const ALL: [Self; 7]
pub const ALL: [Self; 7]
Every step, smallest first. medium is absent because medium is
absence — a menu draws it as the entry that calls
crate::Doc::set_font_size with None.
Sourcepub fn from_attrs(attrs: &[(String, Option<String>)]) -> Option<Self>
pub fn from_attrs(attrs: &[(String, Option<String>)]) -> Option<Self>
The size a run’s or block’s attributes name, if any — twig records it
under data-size.
Sourcepub fn from_attr(value: &str) -> Option<Self>
pub fn from_attr(value: &str) -> Option<Self>
Read a data-size value. None for a name outside the vocabulary — a
data-size="14pt" from elsewhere is carried and drawn at the theme’s
own size, which is the same answer the stylesheet gives it.
Sourcepub const fn name(self) -> &'static str
pub const fn name(self) -> &'static str
The token twig spells it with, and what from_attr
reads back — CSS’s own keyword, so a stylesheet rule is
[data-size="large"] { font-size: large } and nothing is learned twice.
Sourcepub const fn scale(self) -> f32
pub const fn scale(self) -> f32
The multiple of the theme’s body size this step sets — the ratios CSS’s
own user-agent stylesheet uses for the same seven words, so a browser
given only leaf’s stylesheet and a native renderer given the theme agree
about how big large is.
A default: a theme is free to scale its own ramp, the way a frontend
is free to pick its own red for MarkColor::Red. What the document
carries is the name.