pub enum LineHeight {
Step(LineSpacing),
Ratio(Hundredths),
}Expand description
How far apart a block’s lines are set: a LineSpacing from the menu’s
three, or the ratio the author asked for. FontSize’s peer, one property
along, and with no unit at all — a line height is a multiple.
A ratio that spells one of the three names is that name:
from_attr answers Step(OneHalf) for 1.50 as well as
for 1.5, so that two spellings of one spacing are one value and the
document is rewritten with the name a menu can tick.
And a ratio of 1 is absence, exactly as it is for LineSpacing, whose
three names begin above it: single spacing is what a block with no
data-line-height is set at, and a document should not carry a key that
says nothing. from_attr("1") and ratio(1.0) both answer None, so a
gesture given one clears the key and the query then ticks Single.
Variants§
Step(LineSpacing)
Ratio(Hundredths)
Implementations§
Source§impl LineHeight
impl LineHeight
Sourcepub fn from_attrs(attrs: &[(String, Option<String>)]) -> Option<Self>
pub fn from_attrs(attrs: &[(String, Option<String>)]) -> Option<Self>
The spacing a block’s attributes name, if any — twig records it under
data-line-height.
Sourcepub fn from_attr(value: &str) -> Option<Self>
pub fn from_attr(value: &str) -> Option<Self>
Read a data-line-height value: one of the three names, or any positive
decimal other than 1, which is absence.
Sourcepub fn ratio(ratio: f32) -> Option<Self>
pub fn ratio(ratio: f32) -> Option<Self>
A ratio, or None for a number this vocabulary cannot carry — the
constructor an Other… field calls with what the author typed. 1 is one
of those numbers: see the type’s note.
Sourcepub fn is_absence(value: &str) -> bool
pub fn is_absence(value: &str) -> bool
Whether value spells the one ratio that is absence — 1, in any
of its spellings (1, 1.0, 1.00), which is single spacing and is
the theme’s own.
from_attr answers None for it exactly as it does
for a token outside the grammar, and the two mean opposite things: 1
is an author asking for the theme’s spacing, and huge is a typo. A
binding that turns the first into a cleared key and the second into a
refusal asks this to tell them apart — leaf-wasm’s setLineSpacing
does.
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.
Sourcepub const fn step(self) -> Option<LineSpacing>
pub const fn step(self) -> Option<LineSpacing>
The step, for a menu asking which of its three rows to tick — None for
an exact ratio, which the menu shows as its own row.
Sourcepub fn as_f32(self) -> f32
pub fn as_f32(self) -> f32
The ratio itself — what a frontend multiplies the theme’s line height
by. Unlike FontSize’s points this always answers, because a step’s
ratio is the name read as arithmetic (LineSpacing::ratio) and not a
theme’s choice.