diff options
author | chai <chaifix@163.com> | 2018-07-27 00:01:34 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-07-27 00:01:34 +0800 |
commit | b855ebb91ad8d97617ec1aa418b4add84670a07d (patch) | |
tree | b11847a1879a2582c9cfd380074ad4c70f17a1a8 /src/libjin/Render/Font.h | |
parent | 1a882936e91826e4d69584745e16a79650272015 (diff) |
*change name
Diffstat (limited to 'src/libjin/Render/Font.h')
-rw-r--r-- | src/libjin/Render/Font.h | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/libjin/Render/Font.h b/src/libjin/Render/Font.h new file mode 100644 index 0000000..f2a57ed --- /dev/null +++ b/src/libjin/Render/Font.h @@ -0,0 +1,61 @@ +#ifndef __JIN_FONT_H +#define __JIN_FONT_H +#include "../modules.h" +#if JIN_MODULES_RENDER + +#include "drawable.h" +#include "3rdparty/stb/stb_truetype.h" +#include "../math/quad.h" + +namespace jin +{ +namespace render +{ + /** + * Usage of stb_truetype.h here might be a little + * bit dummy. Implementation of Font is referring + * to stb_truetype.h L243~284. I basicly copy it:) + */ + class Font: public Drawable + { + public: + + Font(); + + /** + * load ttf font data from .ttf + */ + void loadf(const char* file); + + /** + * load ttf font data from memory + */ + void loadb(const unsigned char* data); + + /** + * render text to screen + */ + void render( + const char* str, // rendered text + float x, float y, // render position + int fheight, // font size + int spacing, // font spacing + int lheight // line height + ); + + void box(const char* str, int fheight, int spacing, int lheight, int* w, int * h); + + private: + + /** + * ASCII 32(space)..126(~) is 95 glyphs + */ + stbtt_bakedchar cdata[96]; + + }; + +} +} + +#endif // JIN_MODULES_RENDER +#endif
\ No newline at end of file |