19hi_export
class font_variant {
21 [[nodiscard]]
constexpr static size_t size()
noexcept
23 return font_weight_metadata.size() * font_style_metadata.size();
26 constexpr font_variant(
font_weight weight, font_style style) noexcept :
27 _value(narrow_cast<uint8_t>((std::to_underlying(weight) << 1) | std::to_underlying(style)))
32 constexpr font_variant(
font_weight weight) noexcept : font_variant(weight, font_style::normal) {}
35 [[nodiscard]]
constexpr operator size_t()
const noexcept
37 return std::to_underlying(style()) + std::to_underlying(weight()) * font_style_metadata.size();
40 [[nodiscard]]
size_t hash()
const noexcept
50 [[nodiscard]]
constexpr font_style style()
const noexcept
52 return static_cast<font_style
>(_value & 1);
55 constexpr font_variant& set_weight(
font_weight rhs)
noexcept
58 _value |= std::to_underlying(rhs) << 1;
62 constexpr font_variant& set_style(font_style rhs)
noexcept
65 _value |= std::to_underlying(rhs);
79 co_yield font_variant{w, s};
86 return std::format(
"{}", rhs.weight(), rhs.style() == font_style::italic ?
"/italic" :
"");
91 return lhs << to_string(rhs);
friend generator< font_variant > alternatives(font_variant const &start) noexcept
Get an alternative font variant.
Definition font_variant.hpp:75