diff options
Diffstat (limited to 'src/libjin/Graphics/Font')
-rw-r--r-- | src/libjin/Graphics/Font/Decoder.h | 44 | ||||
-rw-r--r-- | src/libjin/Graphics/Font/Page.h | 38 | ||||
-rw-r--r-- | src/libjin/Graphics/Font/je_decoder.cpp (renamed from src/libjin/Graphics/Font/Decoder.cpp) | 2 | ||||
-rw-r--r-- | src/libjin/Graphics/Font/je_decoder.h | 88 | ||||
-rw-r--r-- | src/libjin/Graphics/Font/je_font.h (renamed from src/libjin/Graphics/Font/Font.h) | 6 | ||||
-rw-r--r-- | src/libjin/Graphics/Font/je_page.h | 51 | ||||
-rw-r--r-- | src/libjin/Graphics/Font/je_text.cpp (renamed from src/libjin/Graphics/Font/Text.cpp) | 4 | ||||
-rw-r--r-- | src/libjin/Graphics/Font/je_text.h (renamed from src/libjin/Graphics/Font/Text.h) | 15 | ||||
-rw-r--r-- | src/libjin/Graphics/Font/je_texture_font.cpp (renamed from src/libjin/Graphics/Font/TextureFont.cpp) | 8 | ||||
-rw-r--r-- | src/libjin/Graphics/Font/je_texture_font.h (renamed from src/libjin/Graphics/Font/TextureFont.h) | 23 | ||||
-rw-r--r-- | src/libjin/Graphics/Font/je_ttf.cpp (renamed from src/libjin/Graphics/Font/TTF.cpp) | 18 | ||||
-rw-r--r-- | src/libjin/Graphics/Font/je_ttf.h (renamed from src/libjin/Graphics/Font/TTF.h) | 16 |
12 files changed, 194 insertions, 119 deletions
diff --git a/src/libjin/Graphics/Font/Decoder.h b/src/libjin/Graphics/Font/Decoder.h deleted file mode 100644 index 533f60b..0000000 --- a/src/libjin/Graphics/Font/Decoder.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef __LIBJIN_UTF8_H -#define __LIBJIN_UTF8_H - -#include <vector> - -#include "Text.h" - -namespace jin -{ - namespace graphics - { - - class Decoder - { - public: - virtual const void* decode(const void* data, Codepoint* c) const = 0 ; - virtual const void* next(const void* data) const = 0; - }; - - class Utf8 : public Decoder - { - public: - const void* decode(const void* data, Codepoint* c) const override; - const void* next(const void* data) const override; - }; - /* - class Utf16 : public Decoder - { - public: - const void* decode(const void* data, Codepoint* c) const override; - const void* next(const void* data) const override; - }; - */ - class Ascii : public Decoder - { - public: - const void* decode(const void* data, Codepoint* c) const override; - const void* next(const void* data) const override; - }; - - } // namespace graphics -} // namespace jin - -#endif
\ No newline at end of file diff --git a/src/libjin/Graphics/Font/Page.h b/src/libjin/Graphics/Font/Page.h deleted file mode 100644 index e1430e1..0000000 --- a/src/libjin/Graphics/Font/Page.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef __LIBJIN_PAGE_H -#define __LIBJIN_PAGE_H -#include "../../math/Vector2.hpp" -#include "Font.h" - -namespace jin -{ - namespace graphics - { - - class Font; - - struct GlyphVertex - { - int x, y; // screen coordinates - float u, v; // texture uv - }; - - struct GlyphArrayDrawInfo - { - GLuint texture; // atlas - unsigned int start; // glyph vertex indecies - unsigned int count; // glyph vertex count - }; - - /* for reduce draw call */ - struct Page - { - Font* font; - std::vector<GlyphArrayDrawInfo> glyphinfolist; - std::vector<GlyphVertex> glyphvertices; - math::Vector2<int> size; - }; - - } -} - -#endif
\ No newline at end of file diff --git a/src/libjin/Graphics/Font/Decoder.cpp b/src/libjin/Graphics/Font/je_decoder.cpp index 362fd2a..20695e7 100644 --- a/src/libjin/Graphics/Font/Decoder.cpp +++ b/src/libjin/Graphics/Font/je_decoder.cpp @@ -1,6 +1,6 @@ #include <stdlib.h> #include <string.h> -#include "Decoder.h" +#include "je_decoder.h" namespace jin { diff --git a/src/libjin/Graphics/Font/je_decoder.h b/src/libjin/Graphics/Font/je_decoder.h new file mode 100644 index 0000000..e95f7c3 --- /dev/null +++ b/src/libjin/Graphics/Font/je_decoder.h @@ -0,0 +1,88 @@ +#ifndef __LIBJIN_UTF8_H +#define __LIBJIN_UTF8_H + +#include <vector> + +#include "je_text.h" + +namespace jin +{ + namespace graphics + { + + /// + /// Text decoder. + /// + class Decoder + { + public: + /// + /// Decode a code unit. + /// + /// @param data Code units. + /// @param codepoint Value of code point. + /// @return Next code unit location. + /// + virtual const void* decode(const void* data, Codepoint* codepoint) const = 0 ; + + /// + /// Get next code unit location. + /// + /// @param data Code units. + /// @return Next code unit location. + /// + virtual const void* next(const void* data) const = 0; + }; + + /// + /// Utf-8 decoder. + /// + class Utf8 : public Decoder + { + public: + /// + /// Decode a code unit. + /// + /// @param data Code units. + /// @param codepoint Value of code point. + /// @return Next code unit location. + /// + const void* decode(const void* data, Codepoint* codepoint) const override; + + /// + /// Get next code unit location. + /// + /// @param data Code units. + /// @return Next code unit location. + /// + const void* next(const void* data) const override; + }; + + /// + /// Ascii decoder. + /// + class Ascii : public Decoder + { + public: + /// + /// Decode a code unit. + /// + /// @param data Code units. + /// @param codepoint Value of code point. + /// @return Next code unit location. + /// + const void* decode(const void* data, Codepoint* codepoint) const override; + + /// + /// Get next code unit location. + /// + /// @param data Code units. + /// @return Next code unit location. + /// + const void* next(const void* data) const override; + }; + + } // namespace graphics +} // namespace jin + +#endif
\ No newline at end of file diff --git a/src/libjin/Graphics/Font/Font.h b/src/libjin/Graphics/Font/je_font.h index 1d09cfc..9fde723 100644 --- a/src/libjin/Graphics/Font/Font.h +++ b/src/libjin/Graphics/Font/je_font.h @@ -1,7 +1,8 @@ #ifndef __LIBJIN_FONT_H #define __LIBJIN_FONT_H + #include <vector> -#include "Text.h" +#include "je_text.h" namespace jin { @@ -10,6 +11,9 @@ namespace jin struct Page; + /// + /// Base Font class. + /// class Font { public: diff --git a/src/libjin/Graphics/Font/je_page.h b/src/libjin/Graphics/Font/je_page.h new file mode 100644 index 0000000..d887c9b --- /dev/null +++ b/src/libjin/Graphics/Font/je_page.h @@ -0,0 +1,51 @@ +#ifndef __LIBJIN_PAGE_H +#define __LIBJIN_PAGE_H + +#include "../../math/je_vector2.hpp" + +#include "je_font.h" + +namespace jin +{ + namespace graphics + { + + class Font; + + /// + /// Glyphs data to be rendered. + /// + struct GlyphVertex + { + int x, y; ///< screen coordinates + float u, v; ///< normalized texture uv + }; + + /// + /// Glyphs info for reducing draw call. + /// + struct GlyphArrayDrawInfo + { + GLuint texture; ///< atlas + unsigned int start; ///< glyph vertex indecies + unsigned int count; ///< glyph vertex count + }; + + /// + /// Page to be rendered. + /// + /// A page is a pre-rendered text struct for reducing draw call. Each page + /// keeps a font pointer which should not be changed. + /// + struct Page + { + Font* font; + std::vector<GlyphArrayDrawInfo> glyphinfolist; + std::vector<GlyphVertex> glyphvertices; + math::Vector2<int> size; + }; + + } // namespace graphics +} // namespace jin + +#endif
\ No newline at end of file diff --git a/src/libjin/Graphics/Font/Text.cpp b/src/libjin/Graphics/Font/je_text.cpp index f2231f8..aa5cbda 100644 --- a/src/libjin/Graphics/Font/Text.cpp +++ b/src/libjin/Graphics/Font/je_text.cpp @@ -1,7 +1,7 @@ #include <cstring> -#include "Text.h" -#include "Decoder.h" +#include "je_text.h" +#include "je_decoder.h" namespace jin { diff --git a/src/libjin/Graphics/Font/Text.h b/src/libjin/Graphics/Font/je_text.h index 7256a52..38e60ca 100644 --- a/src/libjin/Graphics/Font/Text.h +++ b/src/libjin/Graphics/Font/je_text.h @@ -13,17 +13,22 @@ namespace jin typedef std::vector<Codepoint> Content; class Text; + class Decoder; + /// + /// Supported text encoding. + /// enum Encode { - UTF8, // utf-8 - //UTF16, // utf-16 - ASCII, // ASCII + UTF8, ///< utf-8 + ASCII, ///< ASCII }; - /* raw encoded text */ - class Text + /// + /// Decoded text. Saved as unicode codepoints. + /// + class Text { public: Text(Encode encode, const void* data); diff --git a/src/libjin/Graphics/Font/TextureFont.cpp b/src/libjin/Graphics/Font/je_texture_font.cpp index 4f6f5d6..3df77e5 100644 --- a/src/libjin/Graphics/Font/TextureFont.cpp +++ b/src/libjin/Graphics/Font/je_texture_font.cpp @@ -1,8 +1,10 @@ #include <vector> -#include "../../Math/Vector2.hpp" -#include "../Shader/Shader.h" -#include "TextureFont.h" +#include "../../math/je_vector2.hpp" + +#include "../shader/je_shader.h" + +#include "je_texture_font.h" namespace jin { diff --git a/src/libjin/Graphics/Font/TextureFont.h b/src/libjin/Graphics/Font/je_texture_font.h index a1d1a37..fa3f72e 100644 --- a/src/libjin/Graphics/Font/TextureFont.h +++ b/src/libjin/Graphics/Font/je_texture_font.h @@ -4,20 +4,23 @@ #include <map> #include <vector> -#include "../../Math/Vector4.hpp" -#include "../Drawable.h" -#include "../Bitmap.h" +#include "../../math/je_vector4.hpp" -#include "Page.h" -#include "Font.h" -#include "Text.h" +#include "../je_drawable.h" +#include "../je_bitmap.h" + +#include "je_page.h" +#include "je_font.h" +#include "je_text.h" namespace jin { namespace graphics { - - /* Texture font */ + + /// + /// + /// class TextureFont : public Font , public Drawable { @@ -56,7 +59,7 @@ namespace jin }; - } -} + } // namespace graphics +} // namespace jin #endif
\ No newline at end of file diff --git a/src/libjin/Graphics/Font/TTF.cpp b/src/libjin/Graphics/Font/je_ttf.cpp index fe47630..d44b2c7 100644 --- a/src/libjin/Graphics/Font/TTF.cpp +++ b/src/libjin/Graphics/Font/je_ttf.cpp @@ -1,14 +1,16 @@ -#include "../../configuration.h" +#include "../../core/je_configuration.h" #if LIBJIN_MODULES_RENDER #include <stdio.h> -#include "../../Common/Array.hpp" -#include "../OpenGL.h" -#include "../Color.h" -#include "../Shader/Shader.h" -#include "TTF.h" -#include "Page.h" +#include "../../common/je_array.hpp" + +#include "../je_gl.h" +#include "../je_color.h" +#include "../shader/je_shader.h" + +#include "je_ttf.h" +#include "je_page.h" #define STB_TRUETYPE_IMPLEMENTATION #include "../../3rdparty/stb/stb_truetype.h" @@ -142,7 +144,7 @@ namespace jin // TTF ///////////////////////////////////////////////////////////////////////////// - #include "../Shader/font.shader.h" + #include "../shader/je_font.shader.h" using namespace std; using namespace jin::math; diff --git a/src/libjin/Graphics/Font/TTF.h b/src/libjin/Graphics/Font/je_ttf.h index 88ddfd6..f3761ac 100644 --- a/src/libjin/Graphics/Font/TTF.h +++ b/src/libjin/Graphics/Font/je_ttf.h @@ -1,19 +1,20 @@ #ifndef __LIBJINTTF_H #define __LIBJIN_TTF_H -#include "../../configuration.h" +#include "../../core/je_configuration.h" #if LIBJIN_MODULES_RENDER #include <vector> #include <map> #include "../../3rdparty/stb/stb_truetype.h" -#include "../../math/quad.h" -#include "../Color.h" -#include "../drawable.h" +#include "../../math/je_quad.h" -#include "Page.h" -#include "Font.h" -#include "Text.h" +#include "../je_color.h" +#include "../je_drawable.h" + +#include "je_page.h" +#include "je_font.h" +#include "je_text.h" namespace jin { @@ -129,4 +130,5 @@ namespace jin } // namespace jin #endif // LIBJIN_MODULES_RENDER + #endif // __LIBJIN_FONT_H
\ No newline at end of file |