diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/libjin/Graphics/Font/TTF.cpp | 15 | ||||
-rw-r--r-- | src/libjin/Graphics/Font/TTF.h | 14 | ||||
-rw-r--r-- | src/libjin/Graphics/Font/Text.cpp | 19 | ||||
-rw-r--r-- | src/libjin/Graphics/Font/Text.h | 4 | ||||
-rw-r--r-- | src/libjin/Graphics/Image.h | 1 | ||||
-rw-r--r-- | src/lua/modules/types.h | 16 |
6 files changed, 48 insertions, 21 deletions
diff --git a/src/libjin/Graphics/Font/TTF.cpp b/src/libjin/Graphics/Font/TTF.cpp index 98e57dd..5c77e7f 100644 --- a/src/libjin/Graphics/Font/TTF.cpp +++ b/src/libjin/Graphics/Font/TTF.cpp @@ -55,6 +55,20 @@ namespace graphics free(raw.data); } + TTF* TTFData::createTTF(unsigned ttfsize) + { + TTF* ttf; + try + { + ttf = new TTF(this, ttfsize); + } + catch (...) + { + return nullptr; + } + return ttf; + } + /* * (0, 0) * +--------------+ ascent @@ -417,6 +431,7 @@ namespace graphics const Color* bitmap = ttf->getCodepointBitmap(character, &w, &h, &xoff, &yoff); int adw, lsb; { + /* bake glyph */ ttf->getHMetrics(character, &adw, &lsb); ttf->popTTFsize(); if (cursor.x + adw > textureWidth ) diff --git a/src/libjin/Graphics/Font/TTF.h b/src/libjin/Graphics/Font/TTF.h index 4f51138..7f4f873 100644 --- a/src/libjin/Graphics/Font/TTF.h +++ b/src/libjin/Graphics/Font/TTF.h @@ -19,11 +19,13 @@ namespace jin { namespace graphics { + + class TTF; /** * TTFData - * |- TTF - * |- TTF + * |- TTF(14px) + * |- TTF(15px) * . * . * . @@ -35,7 +37,9 @@ namespace graphics ~TTFData(); - void pushTTFsize(unsigned int ttfsize); + TTF* createTTF(unsigned ttfsize); + + void pushTTFsize(unsigned ttfsize); void popTTFsize(); Channel* getCodepointBitmapAlpha(unsigned int codepoint, int* width, int* height, int* xoff, int* yoff) const; @@ -62,7 +66,7 @@ namespace graphics class TTF : public Font { public: - static TTF* createTTF(TTFData* ttfData, unsigned int ttfSzie); + static TTF* createTTF(TTFData* ttfData, unsigned ttfSzie); Page* typeset(const Text& text, int lineheight, int spacing = 0) override; Page* typeset(const Content& text, int lineheight, int spacing = 0) override; @@ -74,6 +78,8 @@ namespace graphics ~TTF(); private: + friend class TTFData; + struct TTFGlyph { GLuint atlas; diff --git a/src/libjin/Graphics/Font/Text.cpp b/src/libjin/Graphics/Font/Text.cpp index 68601de..f202267 100644 --- a/src/libjin/Graphics/Font/Text.cpp +++ b/src/libjin/Graphics/Font/Text.cpp @@ -56,7 +56,7 @@ namespace graphics { return get(); } - +/* Text::Iterator Text::Iterator::begin() { Iterator itor(encode, data, length); @@ -70,7 +70,7 @@ namespace graphics itor.toEnd(); return itor; } - +*/ void Text::Iterator::toBegin() { p = (const unsigned char*)data; @@ -117,17 +117,22 @@ namespace graphics Text::Text(Encode encode, const void* data) { - Iterator it = Iterator(encode, data, strlen((const char*)data)); - for (; it != it.end(); ++it) + unsigned length = strlen((const char*)data); + Iterator end = Iterator(encode, data, length); + end.toEnd(); + Iterator it = Iterator(encode, data, length); + for (; it != end; ++it) { content.push_back(*it); } } - Text::Text(Encode _encode, const void* _data, unsigned int _length) + Text::Text(Encode encode, const void* data, unsigned length) { - Iterator it = Iterator(_encode, _data, _length); - for (; it != it.end(); ++it) + Iterator end = Iterator(encode, data, length); + end.toEnd(); + Iterator it = Iterator(encode, data, length); + for (; it != end; ++it) { content.push_back(*it); } diff --git a/src/libjin/Graphics/Font/Text.h b/src/libjin/Graphics/Font/Text.h index 3faabc0..9fe152d 100644 --- a/src/libjin/Graphics/Font/Text.h +++ b/src/libjin/Graphics/Font/Text.h @@ -42,8 +42,8 @@ namespace graphics ~Iterator(); Codepoint get(); - Iterator begin(); - Iterator end(); + //Iterator begin(); + //Iterator end(); void toBegin(); void toEnd(); Codepoint operator *(); diff --git a/src/libjin/Graphics/Image.h b/src/libjin/Graphics/Image.h index 5c426dc..29546cc 100644 --- a/src/libjin/Graphics/Image.h +++ b/src/libjin/Graphics/Image.h @@ -9,6 +9,7 @@ namespace graphics { /* just like bitmap but only from image file*/ + /* readonly bitmap */ class Image : public Bitmap { public: diff --git a/src/lua/modules/types.h b/src/lua/modules/types.h index dcf3631..123604e 100644 --- a/src/lua/modules/types.h +++ b/src/lua/modules/types.h @@ -13,13 +13,13 @@ #define JIN_GRAPHICS_BITMAP "Bitmap" // audio module -#define JIN_AUDIO_SOURCE "Source" - -// thread module -#define JIN_THREAD_THREAD "Thread" - -// network module -#define JIN_NETWORK_SOCKET "Socket" -#define JIN_NETWORK_BUFFER "Buffer" +#define JIN_AUDIO_SOURCE "Source" + +// thread module +#define JIN_THREAD_THREAD "Thread" + +// network module +#define JIN_NETWORK_SOCKET "Socket" +#define JIN_NETWORK_BUFFER "Buffer" #endif
\ No newline at end of file |