1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
use std::fmt;
use crate::checked_value::impl_checked_value;
use crate::serialization::CssWriteTo;
/// CSS font-weight values.
///
/// Represents the `font-weight` CSS property as a typed enum rather than a raw string.
/// Numeric weights range from 100 (thinnest) to 900 (boldest), with keyword aliases
/// for common values.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum FontWeight {
/// Weight 100 — Thin / Hairline.
W100,
/// Weight 200 — Extra Light / Ultra Light.
W200,
/// Weight 300 — Light.
W300,
/// Weight 400 — Normal / Regular (same as `WNormal`).
W400,
/// Weight 500 — Medium.
W500,
/// Weight 600 — Semi Bold / Demi Bold.
W600,
/// Weight 700 — Bold (same as `WBold`).
W700,
/// Weight 800 — Extra Bold / Ultra Bold.
W800,
/// Weight 900 — Black / Heavy.
W900,
/// Keyword `lighter` — one relative step lighter than the inherited weight.
WLighter,
/// Keyword `normal` — equivalent to weight 400.
WNormal,
/// Keyword `bold` — equivalent to weight 700.
WBold,
/// Keyword `bolder` — one relative step bolder than the inherited weight.
WBolder,
}
impl CssWriteTo for FontWeight {
fn css_fmt<W: fmt::Write>(&self, w: &mut W) -> fmt::Result {
match self {
Self::W100 => w.write_str("100"),
Self::W200 => w.write_str("200"),
Self::W300 => w.write_str("300"),
Self::W400 => w.write_str("400"),
Self::W500 => w.write_str("500"),
Self::W600 => w.write_str("600"),
Self::W700 => w.write_str("700"),
Self::W800 => w.write_str("800"),
Self::W900 => w.write_str("900"),
Self::WLighter => w.write_str("lighter"),
Self::WNormal => w.write_str("normal"),
Self::WBold => w.write_str("bold"),
Self::WBolder => w.write_str("bolder"),
}
}
}
impl_checked_value!(FontWeight);