pub enum FontSize {
Step(SizeStep),
Points(Hundredths),
}Expand description
How large a run is set: a SizeStep relative to the text around it, or
the point size the author asked for.
The step is what a menu offers first, and is what a document should say where a name will do — it reads as a step up under every theme. The point size is what the author typed and is all it is: 14 points of the sheet on the paginated view, and 14 points before the zoom on screen, which is how every other point size on a page behaves. A heading set to an exact size is that size and not its ramp scaled — the name scales the ramp, the value replaces it.
Only pt is a unit. px is a screen’s unit and a document is not a screen;
em, rem and % are relative, which is what the steps already are.
Variants§
Step(SizeStep)
Points(Hundredths)
Implementations§
Source§impl FontSize
impl FontSize
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: one of CSS’s seven keywords, or a <number>pt.
The unit is matched without regard to case, because a hand-written
document says 14PT as readily as 14pt and CSS reads both.
Sourcepub fn points(points: f32) -> Option<Self>
pub fn points(points: f32) -> Option<Self>
A size in points, or None for a number this vocabulary cannot carry —
the constructor an Other… field calls with what the author typed.
Sourcepub fn name(self) -> Cow<'static, str>
pub fn name(self) -> Cow<'static, str>
The token twig spells it with, and what from_attr
reads back: the step’s CSS keyword, or the shortest decimal with pt
after it.
Sourcepub const fn step(self) -> Option<SizeStep>
pub const fn step(self) -> Option<SizeStep>
The step, for a menu asking which of its seven rows to tick — None
when the size is an exact one, which the menu shows as its own row.
Sourcepub fn points_value(self) -> Option<f32>
pub fn points_value(self) -> Option<f32>
The point size, or None when the size is a step — whose size in points
is the theme’s business and not this type’s.