Panagiotis Christopoulos Charitos 10 tahun lalu
induk
melakukan
0f6d659b6d
2 mengubah file dengan 24 tambahan dan 5 penghapusan
  1. 23 4
      include/anki/ui/Font.h
  2. 1 1
      include/anki/ui/UiInterface.h

+ 23 - 4
include/anki/ui/Font.h

@@ -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()
 	{

+ 1 - 1
include/anki/ui/UiInterface.h

@@ -48,7 +48,7 @@ public:
 	/// @name Painting related methods.
 	/// @{
 #if 0
-	virtual void drawImage(ImagePtr image, const Rect& subImageRect,
+	virtual void drawImage(ImagePtr image, const Rect& uvs,
 		const Rect& drawingRect) = 0;
 #endif