00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef KEROSIN_FONT_H
00023 #define KEROSIN_FONT_H
00024
00025 #include <string>
00026 #include <salt/vector.h>
00027 #include "glyph.h"
00028
00029 namespace kerosin
00030 {
00031
00032 class FontServer;
00033
00063 class Font
00064 {
00065 private:
00066 struct GlyphMetric
00067 {
00068 unsigned int mByteWidth;
00069 unsigned int mByteHeight;
00070 unsigned int mXOffset;
00071 unsigned int mYOffset;
00072 unsigned int mAdvance;
00073 salt::Vector2f mTC1;
00074 salt::Vector2f mTC2;
00075 };
00076 public:
00077 Font(FontServer &fontServer);
00078 ~Font();
00079
00080 bool Init(const std::string &name, unsigned int size, FT_Face face);
00081 bool Bind(int vRows = -1);
00082 void Dump();
00083 void DrawString(float x, float y, const char *string);
00084 void Printf(float x, float y, const char *format, ...);
00085 void RowPrintf(float x, float row, const char *format, ...);
00086
00093 float GetStringWidth(const char* string, int numChar = -1);
00094
00096 float GetRowHeight();
00097
00099 const std::string& GetName() const;
00100
00102 unsigned int GetSize() const;
00103
00104 private:
00106 GlyphMetric mMetrics[96];
00107
00109 unsigned int mTexID;
00110
00112 unsigned int mRowHeight;
00113
00115 std::string mName;
00116
00118 unsigned int mSize;
00119
00121 FontServer& mFontServer;
00122 };
00123
00124 }
00125
00126 #endif //KEROSIN_FONT_H