00001
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef emftgl_h__
00036 #define emftgl_h__
00037
00038 #include <string>
00039 using std::string;
00040
00041 #include <vector>
00042 using std::vector;
00043
00044 #include <map>
00045 using std::map;
00046
00047 #ifdef OLD_FTGL
00048 #include <FTGL/FTGL.h>
00049 #else
00050 #include <FTGL/ftgl.h>
00051 #endif
00052
00053
00054 #include <FTGL/FTFont.h>
00055 namespace EMAN {
00056
00057
00081 class EMFTGL
00082 {
00083 public:
00087 #ifdef __APPLE__
00088 EMFTGL() : font_file_name("/Library/Fonts/Arial.ttf" ), face_size(32), depth(32), use_display_lists(true), mode(TEXTURE) {};
00089 #else
00090 #ifdef WIN32
00091 EMFTGL() : font_file_name("" ), face_size(32), depth(32), use_display_lists(true), mode(TEXTURE) {};
00092 #else
00093 EMFTGL() : font_file_name("/usr/share/fonts/dejavu/DejaVuSerif.ttf"), face_size(32), depth(32), use_display_lists(true), mode(TEXTURE) {};
00094 #endif
00095
00096
00097 #endif
00098
00100 ~EMFTGL() {};
00101
00102
00108 enum FontMode {
00109 EXTRUDE,
00110 PIXMAP,
00111 TEXTURE,
00112 BITMAP,
00113 OUTLINE,
00114 POLYGON
00115 };
00116
00121 void render_string(const string& message);
00122
00128 vector<float> bounding_box(const string& message);
00129
00133 void set_font_file_name(const string& file_name) { font_file_name = file_name; }
00134
00138 void set_face_size(const unsigned int size) { face_size = size; }
00139
00142 void set_depth(const unsigned int d ) { depth = d; }
00143
00146 void set_using_display_lists(const bool b) { use_display_lists = b; }
00147
00150 void set_font_mode(const FontMode m ) { mode = m; }
00153 string get_font_file_name() { return font_file_name; }
00156 unsigned int get_face_size() {return face_size; }
00159 unsigned int get_depth() { return depth; }
00162 bool get_using_display_lists() { return use_display_lists; }
00165 FontMode get_font_mode() { return mode; }
00166
00167
00168
00169 private:
00171
00173
00174
00175 string font_file_name;
00176 unsigned int face_size;
00177 unsigned int depth;
00178 bool use_display_lists;
00179
00180 FontMode mode;
00181
00189 class EMFTGLFontInstance
00190 {
00191 public:
00194 EMFTGLFontInstance(EMFTGL::FontMode mode, const string& file_name, const unsigned int face_size, const unsigned int d, const bool use_dl);
00195 ~EMFTGLFontInstance();
00196
00199 bool params_match(EMFTGL::FontMode mode, const string& file_name, const unsigned int face_size, const unsigned int depth, const bool use_dl);
00200
00203 FTFont* get_font() { return font; }
00204 private:
00206
00208
00209
00210 EMFTGL::FontMode font_mode;
00211 string font_file_name;
00212 unsigned int face_size;
00213 unsigned int depth;
00214 bool use_display_lists;
00215 FTFont* font;
00216 };
00217
00224 class EMFTGLManager
00225 {
00226 public:
00227 EMFTGLManager();
00228
00229
00230 ~EMFTGLManager();
00231
00234 FTFont* get_font(EMFTGL::FontMode mode, const string& file_name, const unsigned int face_size, const unsigned int d, const bool use_dl);
00235 private:
00237
00239
00240
00241 vector<EMFTGLFontInstance*> font_instances;
00242 };
00243
00244 EMFTGLManager fm;
00245 };
00246
00247
00248
00249
00250 }
00251
00252 #endif //emftgl_h__