aboutsummaryrefslogtreecommitdiff
path: root/include/smttfont.hpp
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2018-02-03 00:55:26 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2018-02-03 00:55:26 +0800
commit1eb88d4f5d5cb05d62be1d4a0c88c7399f7c0de0 (patch)
tree4daf8fa3f4e8fff38a61b8e2da752df8b519f232 /include/smttfont.hpp
parent6f955e10a71e364f527ea654156ea83785e9ada8 (diff)
downloadSMELT-1eb88d4f5d5cb05d62be1d4a0c88c7399f7c0de0.tar.xz
Added the GL 3.2+ port.
Fixed poor performance of the truetype renderer. (Partially) Fixed texture locking. Minor addition and fixes to the math library.
Diffstat (limited to 'include/smttfont.hpp')
-rw-r--r--include/smttfont.hpp33
1 files changed, 15 insertions, 18 deletions
diff --git a/include/smttfont.hpp b/include/smttfont.hpp
index 08860ce..c0865f2 100644
--- a/include/smttfont.hpp
+++ b/include/smttfont.hpp
@@ -13,6 +13,8 @@
#include "smelt.hpp"
#include <cwchar>
#include <map>
+#include <utility>
+#include <vector>
#include <ft2build.h>
#include FT_FREETYPE_H
@@ -22,32 +24,26 @@
#define ALIGN_CENTER 2
#endif
-class smTTChar
-{
-private:
- smQuad quad;
- int rw,rh,_w,_h,xofs,yofs;
- static SMELT *sm;
-public:
- float w(){return (float)_w;}
- float h(){return (float)_h;}
- void free();
- bool setChar(wchar_t c,FT_Face ttface);
- void render(float x,float y,float z,DWORD col,float scalex,float scaley,bool rtl);
-};
+struct _smTexState;
+class _smTTChar;
class smTTFont
{
-protected:
+private:
FT_Library ftlib;
FT_Face ttface;
-private:
wchar_t buf[1025];
- std::map<wchar_t,smTTChar> chars;
+ std::map<wchar_t,_smTTChar*> chars;
+ std::vector<_smTexState*> textures;
float w,h;
+ int mx,my,texw,texh;
+ unsigned _npot(unsigned x);
+ std::pair<SMTEX,std::pair<int,int>> _allocate_char(int rw,int rh);
+ static SMELT* sm;
public:
- bool loadTTF(const char* path,int pt);
- bool loadTTFFromMemory(char* ptr,DWORD size,int pt);
+ ~smTTFont();
+ bool loadTTF(const char* path,int pt,int cachesize_x=16,int cachesize_y=16);
+ bool loadTTFFromMemory(char* ptr,DWORD size,int pt,int cachesize_x=16,int cachesize_y=16);
void releaseTTF();
float getWidth(){return w;}
float getHeight(){return h;}
@@ -55,5 +51,6 @@ public:
void render(float x,float y,float z,DWORD col,int align,float scalex=1,float scaley=1);
DWORD getCacheSize();
void clearCache();
+ friend class _smTTChar;
};
#endif