20 constexpr static int max() {
return 20; }
21 constexpr static int half() {
return max() / 2; }
23 constexpr font_variant(font_weight weight,
bool italic) noexcept : value(
static_cast<uint8_t
>(
static_cast<int>(weight) + (italic ? half() : 0))) {}
28 constexpr font_weight weight()
const noexcept {
29 tt_axiom(value < max());
30 return static_cast<font_weight
>(value % half());
33 [[nodiscard]]
constexpr bool italic()
const noexcept {
34 tt_axiom(value < max());
35 return value >= half();
38 constexpr font_variant &set_weight(font_weight rhs)
noexcept {
39 value =
static_cast<uint8_t
>(
static_cast<int>(rhs) + (italic() ? half() : 0));
40 tt_axiom(value < max());
45 value =
static_cast<uint8_t
>(
static_cast<int>(weight()) + (rhs ? half() : 0));
46 tt_axiom(value < max());
50 constexpr operator int ()
const noexcept {
51 tt_axiom(value < max());
59 tt_axiom(i >= 0 && i < max());
60 ttlet w = font_weight_alterative(weight(), i % half());
61 ttlet it = italic() == (i < half());
66 return std::format(
"{}", rhs.weight(), rhs.italic() ?
"/italic" :
"");
70 return lhs << to_string(rhs);