FTGL 2.1.3~rc5
|
00001 /* 00002 * FTGL - OpenGL font library 00003 * 00004 * Copyright (c) 2001-2004 Henry Maddocks <ftgl@opengl.geek.nz> 00005 * Copyright (c) 2008 Sam Hocevar <sam@zoy.org> 00006 * Copyright (c) 2008 Sean Morrison <learner@brlcad.org> 00007 * 00008 * Permission is hereby granted, free of charge, to any person obtaining 00009 * a copy of this software and associated documentation files (the 00010 * "Software"), to deal in the Software without restriction, including 00011 * without limitation the rights to use, copy, modify, merge, publish, 00012 * distribute, sublicense, and/or sell copies of the Software, and to 00013 * permit persons to whom the Software is furnished to do so, subject to 00014 * the following conditions: 00015 * 00016 * The above copyright notice and this permission notice shall be 00017 * included in all copies or substantial portions of the Software. 00018 * 00019 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00020 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00021 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00022 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 00023 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 00024 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 00025 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00026 */ 00027 00028 #ifndef __ftgl__ 00029 # warning This header is deprecated. Please use <FTGL/ftgl.h> from now. 00030 # include <FTGL/ftgl.h> 00031 #endif 00032 00033 #ifndef __FTFont__ 00034 #define __FTFont__ 00035 00036 #ifdef __cplusplus 00037 00038 class FTFontImpl; 00039 00056 class FTGL_EXPORT FTFont 00057 { 00058 protected: 00064 FTFont(char const *fontFilePath); 00065 00074 FTFont(const unsigned char *pBufferBytes, size_t bufferSizeInBytes); 00075 00076 private: 00077 /* Allow our internal subclasses to access the private constructor */ 00078 friend class FTBitmapFont; 00079 friend class FTBufferFont; 00080 friend class FTExtrudeFont; 00081 friend class FTOutlineFont; 00082 friend class FTPixmapFont; 00083 friend class FTPolygonFont; 00084 friend class FTTextureFont; 00085 00092 FTFont(FTFontImpl *pImpl); 00093 00094 public: 00095 virtual ~FTFont(); 00096 00106 virtual bool Attach(const char* fontFilePath); 00107 00118 virtual bool Attach(const unsigned char *pBufferBytes, 00119 size_t bufferSizeInBytes); 00120 00128 virtual void GlyphLoadFlags(FT_Int flags); 00129 00137 virtual bool CharMap(FT_Encoding encoding); 00138 00144 virtual unsigned int CharMapCount() const; 00145 00151 virtual FT_Encoding* CharMapList(); 00152 00160 virtual bool FaceSize(const unsigned int size, 00161 const unsigned int res = 72); 00162 00168 virtual unsigned int FaceSize() const; 00169 00176 virtual void Depth(float depth); 00177 00184 virtual void Outset(float outset); 00185 00193 virtual void Outset(float front, float back); 00194 00201 virtual void UseDisplayList(bool useList); 00202 00208 virtual float Ascender() const; 00209 00215 virtual float Descender() const; 00216 00222 virtual float LineHeight() const; 00223 00236 virtual FTBBox BBox(const char *string, const int len = -1, 00237 FTPoint position = FTPoint(), 00238 FTPoint spacing = FTPoint()); 00239 00251 void BBox(const char* string, float& llx, float& lly, float& llz, 00252 float& urx, float& ury, float& urz) 00253 { 00254 FTBBox b = BBox(string); 00255 llx = b.Lower().Xf(); lly = b.Lower().Yf(); llz = b.Lower().Zf(); 00256 urx = b.Upper().Xf(); ury = b.Upper().Yf(); urz = b.Upper().Zf(); 00257 } 00258 00271 virtual FTBBox BBox(const wchar_t *string, const int len = -1, 00272 FTPoint position = FTPoint(), 00273 FTPoint spacing = FTPoint()); 00274 00286 void BBox(const wchar_t* string, float& llx, float& lly, float& llz, 00287 float& urx, float& ury, float& urz) 00288 { 00289 FTBBox b = BBox(string); 00290 llx = b.Lower().Xf(); lly = b.Lower().Yf(); llz = b.Lower().Zf(); 00291 urx = b.Upper().Xf(); ury = b.Upper().Yf(); urz = b.Upper().Zf(); 00292 } 00293 00305 virtual float Advance(const char* string, const int len = -1, 00306 FTPoint spacing = FTPoint()); 00307 00319 virtual float Advance(const wchar_t* string, const int len = -1, 00320 FTPoint spacing = FTPoint()); 00321 00335 virtual FTPoint Render(const char* string, const int len = -1, 00336 FTPoint position = FTPoint(), 00337 FTPoint spacing = FTPoint(), 00338 int renderMode = FTGL::RENDER_ALL); 00339 00353 virtual FTPoint Render(const wchar_t *string, const int len = -1, 00354 FTPoint position = FTPoint(), 00355 FTPoint spacing = FTPoint(), 00356 int renderMode = FTGL::RENDER_ALL); 00357 00363 virtual FT_Error Error() const; 00364 00365 protected: 00366 /* Allow impl to access MakeGlyph */ 00367 friend class FTFontImpl; 00368 00378 virtual FTGlyph* MakeGlyph(FT_GlyphSlot slot) = 0; 00379 00380 private: 00384 FTFontImpl *impl; 00385 }; 00386 00387 #endif //__cplusplus 00388 00389 FTGL_BEGIN_C_DECLS 00390 00398 struct _FTGLFont; 00399 typedef struct _FTGLfont FTGLfont; 00400 00409 FTGL_EXPORT FTGLfont *ftglCreateCustomFont(char const *fontFilePath, 00410 void *data, 00411 FTGLglyph * (*makeglyphCallback) (FT_GlyphSlot, void *)); 00412 00418 FTGL_EXPORT void ftglDestroyFont(FTGLfont* font); 00419 00429 FTGL_EXPORT int ftglAttachFile(FTGLfont* font, const char* path); 00430 00441 FTGL_EXPORT int ftglAttachData(FTGLfont* font, const unsigned char * data, 00442 size_t size); 00443 00451 FTGL_EXPORT int ftglSetFontCharMap(FTGLfont* font, FT_Encoding encoding); 00452 00459 FTGL_EXPORT unsigned int ftglGetFontCharMapCount(FTGLfont* font); 00460 00467 FTGL_EXPORT FT_Encoding* ftglGetFontCharMapList(FTGLfont* font); 00468 00478 FTGL_EXPORT int ftglSetFontFaceSize(FTGLfont* font, unsigned int size, 00479 unsigned int res); 00480 00487 FTGL_EXPORT unsigned int ftglGetFontFaceSize(FTGLfont* font); 00488 00496 FTGL_EXPORT void ftglSetFontDepth(FTGLfont* font, float depth); 00497 00507 FTGL_EXPORT void ftglSetFontOutset(FTGLfont* font, float front, float back); 00508 00516 FTGL_EXPORT void ftglSetFontDisplayList(FTGLfont* font, int useList); 00517 00524 FTGL_EXPORT float ftglGetFontAscender(FTGLfont* font); 00525 00532 FTGL_EXPORT float ftglGetFontDescender(FTGLfont* font); 00533 00540 FTGL_EXPORT float ftglGetFontLineHeight(FTGLfont* font); 00541 00552 FTGL_EXPORT void ftglGetFontBBox(FTGLfont* font, const char *string, 00553 int len, float bounds[6]); 00554 00562 FTGL_EXPORT float ftglGetFontAdvance(FTGLfont* font, const char *string); 00563 00571 FTGL_EXPORT void ftglRenderFont(FTGLfont* font, const char *string, int mode); 00572 00579 FTGL_EXPORT FT_Error ftglGetFontError(FTGLfont* font); 00580 00581 FTGL_END_C_DECLS 00582 00583 #endif // __FTFont__ 00584