mirror of
https://github.com/edubart/otclient.git
synced 2025-12-27 02:07:10 +01:00
basic font redering
This commit is contained in:
@@ -26,20 +26,56 @@
|
||||
#define FONT_H
|
||||
|
||||
#include "prerequisites.h"
|
||||
#include "color.h"
|
||||
#include "texture.h"
|
||||
|
||||
class Font
|
||||
{
|
||||
public:
|
||||
Font() { }
|
||||
Font();
|
||||
virtual ~Font() { }
|
||||
|
||||
/// Load font from file
|
||||
bool load(const std::string &file);
|
||||
|
||||
/// Simple text render
|
||||
void renderText(const Point& pos, const std::string& text);
|
||||
|
||||
/*
|
||||
enum EAlign {
|
||||
ALIGN_TOP = 1 << 0,
|
||||
ALIGN_BOTTOM = 1 << 1,
|
||||
ALIGN_LEFT = 1 << 2,
|
||||
ALIGN_RIGHT = 1 << 3,
|
||||
ALIGN_HORIZONTAL_CENTER = 1 << 4,
|
||||
ALIGN_VERTICAL_CENTER = 1 << 5,
|
||||
ALIGN_CENTER = ALIGN_HORIZONTAL_CENTER | ALIGN_VERTICAL_CENTER,
|
||||
ALIGN_TOP_RIGHT = ALIGN_TOP | ALIGN_RIGHT,
|
||||
ALIGN_TOP_LEFT = ALIGN_TOP | ALIGN_LEFT,
|
||||
ALIGN_BOTTOM_RIGHT = ALIGN_BOTTOM | ALIGN_RIGHT,
|
||||
ALIGN_BOTTOM_LEFT = ALIGN_BOTTOM | ALIGN_LEFT
|
||||
};
|
||||
/// Render a text inside a rect
|
||||
void renderText(const Rect& screenCoords, EAlign align, const std::string& text);
|
||||
*/
|
||||
|
||||
/// Render a text
|
||||
const std::string& getName() const { return m_name; }
|
||||
int renderGlyph(const Point& pos, int glyph);
|
||||
|
||||
private:
|
||||
|
||||
std::string m_name;
|
||||
int m_lineHeight;
|
||||
int m_cursorSize;
|
||||
Color m_color;
|
||||
TexturePtr m_texture;
|
||||
Size m_textureSize;
|
||||
Size m_glyphSize;
|
||||
int m_firstGlyph;
|
||||
int m_glyphWidths[256];
|
||||
int m_numHorizontalGlyphs;
|
||||
int m_numVerticalGlyphs;
|
||||
};
|
||||
|
||||
#endif // FONT_H
|
||||
|
||||
Reference in New Issue
Block a user