|
|
@@ -15,9 +15,9 @@ namespace anki {
|
|
|
class FontCharInfo
|
|
|
{
|
|
|
public:
|
|
|
- Vec2 m_advance;
|
|
|
- Vec2 m_size;
|
|
|
- Vec2 m_offset;
|
|
|
+ Vec2 m_advance; ///< Char advance.
|
|
|
+ Vec2 m_size; ///< Bitmap size in pixels.
|
|
|
+ Vec2 m_offset; ///< Left and top bearing.
|
|
|
};
|
|
|
|
|
|
/// Font class.
|
|
|
@@ -30,14 +30,33 @@ public:
|
|
|
: m_interface(interface)
|
|
|
{}
|
|
|
|
|
|
- virtual ~Font();
|
|
|
+ ~Font();
|
|
|
|
|
|
+ /// Initialize the font.
|
|
|
ANKI_USE_RESULT Error init(const CString& filename, U32 fontHeight);
|
|
|
|
|
|
+ /// Get info for a character.
|
|
|
+ const FontCharInfo& getCharInfo(char c) const
|
|
|
+ {
|
|
|
+ ANKI_ASSERT(c >= FIRST_CHAR);
|
|
|
+ return m_chars[c - ' '];
|
|
|
+ }
|
|
|
+
|
|
|
+ /// Get font image atlas.
|
|
|
+ const UiImagePtr& getImage() const
|
|
|
+ {
|
|
|
+ return m_tex;
|
|
|
+ }
|
|
|
+
|
|
|
private:
|
|
|
+ static const char FIRST_CHAR = ' ';
|
|
|
+ static const char LAST_CHAR = 127;
|
|
|
+ static const U CHAR_COUNT = LAST_CHAR - FIRST_CHAR + 1;
|
|
|
+
|
|
|
WeakPtr<UiInterface> m_interface;
|
|
|
Atomic<I32> m_refcount = {0};
|
|
|
UiImagePtr m_tex;
|
|
|
+ Array<FontCharInfo, CHAR_COUNT> m_chars;
|
|
|
|
|
|
Atomic<I32>& getRefcount()
|
|
|
{
|