aboutsummaryrefslogtreecommitdiff
path: root/include/smttfont.hpp
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2015-10-06 21:28:40 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2015-10-06 21:28:40 +0800
commit038b31f0158a0018dbf2eceb71026cc4e665faa9 (patch)
treea373ddab7bc162e477e28a780b0d729660ff8634 /include/smttfont.hpp
parenta8077292d5d9118866f7358c11a90c855e1b1b02 (diff)
downloadSMELT-038b31f0158a0018dbf2eceb71026cc4e665faa9.tar.xz
Add the SMELT files...
Please, do not laugh too loudly.
Diffstat (limited to 'include/smttfont.hpp')
-rw-r--r--include/smttfont.hpp59
1 files changed, 59 insertions, 0 deletions
diff --git a/include/smttfont.hpp b/include/smttfont.hpp
new file mode 100644
index 0000000..777d8ed
--- /dev/null
+++ b/include/smttfont.hpp
@@ -0,0 +1,59 @@
+// -*- C++ -*-
+/*
+ * Simple MultimEdia LiTerator(SMELT)
+ * by Chris Xiong 2015
+ * Truetype font support header
+ *
+ * WARNING: This library is in development and interfaces would be very
+ * unstable.
+ * This library is developed for the BLR series games.
+ */
+#ifndef SMTTFONT_H
+#define SMTTFONT_H
+#include "smelt.hpp"
+#include <cwchar>
+#include <map>
+#include <ft2build.h>
+#include FT_FREETYPE_H
+
+#ifndef ALIGN_LEFT
+#define ALIGN_LEFT 0
+#define ALIGN_RIGHT 1
+#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,DWORD col);
+};
+
+class smTTFont
+{
+protected:
+ FT_Library ftlib;
+ FT_Face ttface;
+private:
+ wchar_t buf[1024];
+ std::map<wchar_t,smTTChar> chars;
+ float w,h;
+public:
+ bool loadTTF(const char* path,int pt);
+ bool loadTTFFromMemory(char* ptr,DWORD size,int pt);
+ void releaseTTF();
+ float getWidth(){return w;}
+ float getHeight(){return h;}
+ void updateString(const wchar_t *format,...);
+ void render(float x,float y,DWORD col,int align);
+ DWORD getCacheSize();
+ void clearCache();
+};
+#endif