diff --git a/LibFont/Font.cpp b/LibFont/Font.cpp index 6a3a742b..00456fa3 100644 --- a/LibFont/Font.cpp +++ b/LibFont/Font.cpp @@ -274,14 +274,4 @@ namespace LibFont return result; } - bool Font::has_glyph(uint32_t codepoint) const - { - return m_glyph_offsets.contains(codepoint); - } - - const uint8_t* Font::glyph(uint32_t codepoint) const - { - return m_glyph_data.data() + m_glyph_offsets[codepoint]; - } - } diff --git a/LibFont/include/LibFont/Font.h b/LibFont/include/LibFont/Font.h index 87d6ad8a..0e7c9260 100644 --- a/LibFont/include/LibFont/Font.h +++ b/LibFont/include/LibFont/Font.h @@ -19,8 +19,14 @@ namespace LibFont uint32_t height() const { return m_height; } uint32_t pitch() const { return m_pitch; } - bool has_glyph(uint32_t) const; - const uint8_t* glyph(uint32_t) const; + bool has_glyph(uint32_t codepoint) const { return glyph(codepoint) != nullptr; } + const uint8_t* glyph(uint32_t codepoint) const + { + auto it = m_glyph_offsets.find(codepoint); + if (it == m_glyph_offsets.end()) + return nullptr; + return m_glyph_data.data() + it->value; + } private: static BAN::ErrorOr parse_psf1(BAN::ConstByteSpan);