diff options
author | chai <chaifix@163.com> | 2019-01-12 21:48:33 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-01-12 21:48:33 +0800 |
commit | 8b00d67febf133e89f6a0bfabc41feed555dc4a9 (patch) | |
tree | fe48ef17c250afa40c2588300fcdb5920dba6951 /src/libjin/graphics/fonts/texture_font.h | |
parent | a907c39756ef6b368d06643afa491c49a9044a8e (diff) |
*去掉文件前缀je_
Diffstat (limited to 'src/libjin/graphics/fonts/texture_font.h')
-rw-r--r-- | src/libjin/graphics/fonts/texture_font.h | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/src/libjin/graphics/fonts/texture_font.h b/src/libjin/graphics/fonts/texture_font.h new file mode 100644 index 0000000..1d7f0d2 --- /dev/null +++ b/src/libjin/graphics/fonts/texture_font.h @@ -0,0 +1,131 @@ +#ifndef __JE_TEXTURE_FONT_H__ +#define __JE_TEXTURE_FONT_H__ + +#include <map> +#include <vector> + +#include "../../math/vector4.hpp" + +#include "../graphic.h" +#include "../bitmap.h" + +#include "page.h" +#include "font.h" +#include "text.h" + +namespace JinEngine +{ + namespace Graphics + { + namespace Fonts + { + + /// + /// + /// + class TextureFont : public Font, public Graphic, public Object + { + public: + /// + /// + /// + TextureFont(const Bitmap* bitmap, const Content& codepoints, int cellw, int cellh); + + /// + /// + /// + TextureFont(const Bitmap* bitmap, const Content& codepoints, Color mask, int cellh); + + /// + /// + /// + TextureFont(const Bitmap* bitmap, const Text& text, Color mask, int cellh); + + /// + /// + /// + TextureFont(const Bitmap* bitmap, const Text& text, int cellw, int cellh); + + /// + /// + /// + ~TextureFont(); + + /// + /// + /// + Page* typeset(const Text& text, int lineheight, int spacing = 0) override; + + /// + /// + /// + Page* typeset(const Content& text, int lineheight, int spacing = 0) override; + + /// + /// + /// + void render(const Page* page, int x, int y) override; + + /// + /// + /// + void render(const Content& text, int x, int y, int linehgiht, int spacing = 0) override; + + /// + /// + /// + void render(const Text& text, int x, int y, int lineheight, int spacing = 0)override; + + private: + + /// + /// + /// + struct TextureGlyph + { + float x, y, w, h; + }; + + /// + /// + /// + int getCharWidth(int c); + + /// + /// + /// + int getCharHeight(int c); + + /// + /// + /// + int getTextWidth(const Content& text, int spacing = 0); + + /// + /// + /// + int getTextHeight(const Content& text, int lineheight); + + /// + /// + /// + void getTextBox(const Content& text, int* w, int* h, int lineheight, int spacing = 0); + + /// + /// + /// + const TextureGlyph* findGlyph(Codepoint codepoint) const; + + + /// + /// + /// + std::map<Codepoint, TextureGlyph> glyphs; + + }; + + } // namespace Fonts + } // namespace Graphics +} // namespace JinEngine + +#endif
\ No newline at end of file |