diff options
Diffstat (limited to 'include/minikin/FontStyle.h')
-rw-r--r-- | include/minikin/FontStyle.h | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/include/minikin/FontStyle.h b/include/minikin/FontStyle.h index 51e4ad8..7a9e597 100644 --- a/include/minikin/FontStyle.h +++ b/include/minikin/FontStyle.h @@ -19,6 +19,8 @@ #include <minikin/Buffer.h> +#include <ostream> + namespace minikin { // FontStyle represents style information. @@ -61,10 +63,6 @@ public: constexpr uint16_t weight() const { return mWeight; } constexpr Slant slant() const { return mSlant; } - constexpr bool operator==(const FontStyle& other) const { - return weight() == other.weight() && slant() == other.slant(); - } - constexpr uint32_t identifier() const { return (static_cast<uint32_t>(weight()) << 16) | static_cast<uint32_t>(slant()); } @@ -74,6 +72,29 @@ private: Slant mSlant; }; +inline std::ostream& operator<<(std::ostream& os, const FontStyle::Slant& slant) { + switch (slant) { + case FontStyle::Slant::ITALIC: + return os << "italic"; + case FontStyle::Slant::UPRIGHT: + return os << "upright"; + default: + return os << "[UNKNOWN]"; + } +} + +inline std::ostream& operator<<(std::ostream& os, const FontStyle& style) { + return os << "{weight=" << style.weight() << ", slant=" << style.slant() << "}"; +} + +constexpr bool operator==(const FontStyle& l, const FontStyle& r) { + return l.weight() == r.weight() && l.slant() == r.slant(); +} + +constexpr bool operator!=(const FontStyle& l, const FontStyle& r) { + return !(l == r); +} + } // namespace minikin #endif // MINIKIN_FONT_STYLE_H |