2
* FTGL - OpenGL font library
4
* Copyright (c) 2001-2004 Henry Maddocks <ftgl@opengl.geek.nz>
5
* Copyright (c) 2008 Sam Hocevar <sam@zoy.org>
6
* Copyright (c) 2008 Sean Morrison <learner@brlcad.org>
8
* Permission is hereby granted, free of charge, to any person obtaining
9
* a copy of this software and associated documentation files (the
10
* "Software"), to deal in the Software without restriction, including
11
* without limitation the rights to use, copy, modify, merge, publish,
12
* distribute, sublicense, and/or sell copies of the Software, and to
13
* permit persons to whom the Software is furnished to do so, subject to
14
* the following conditions:
16
* The above copyright notice and this permission notice shall be
17
* included in all copies or substantial portions of the Software.
19
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
23
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
# include <FTGL/ftgles.h>
40
* FTGlyph is the base class for FTGL glyphs.
42
* It provides the interface between Freetype glyphs and their openGL
43
* renderable counterparts. This is an abstract class and derived classes
44
* must implement the <code>Render</code> function.
49
class FTGL_EXPORT FTGlyph
55
* @param glyph The Freetype glyph to be processed
57
FTGlyph(FT_GlyphSlot glyph);
61
* Internal FTGL FTGlyph constructor. For private use only.
63
* @param pImpl Internal implementation object. Will be destroyed
64
* upon FTGlyph deletion.
66
FTGlyph(FTGlyphImpl *pImpl);
68
/* Allow our internal subclasses to access the private constructor */
69
friend class FTBitmapGlyph;
70
friend class FTBufferGlyph;
71
//friend class FTExtrudeGlyph;
72
friend class FTOutlineGlyph;
73
friend class FTPixmapGlyph;
74
friend class FTPolygonGlyph;
75
friend class FTTextureGlyph;
84
* Renders this glyph at the current pen position.
86
* @param pen The current pen position.
87
* @param renderMode Render mode to display
88
* @return The advance distance for this glyph.
90
virtual const FTPoint& Render(const FTPoint& pen, int renderMode) = 0;
93
* Return the advance width for this glyph.
95
* @return advance width.
97
virtual float Advance() const;
100
* Return the bounding box for this glyph.
102
* @return bounding box.
104
virtual const FTBBox& BBox() const;
107
* Queries for errors.
109
* @return The current error code.
111
virtual FT_Error Error() const;
115
* Internal FTGL FTGlyph implementation object. For private use only.
125
* FTGLglyph is the base class for FTGL glyphs.
127
* It provides the interface between Freetype glyphs and their openGL
128
* renderable counterparts. This is an abstract class and derived classes
129
* must implement the ftglRenderGlyph() function.
132
typedef struct _FTGLglyph FTGLglyph;
135
* Create a custom FTGL glyph object.
136
* FIXME: maybe get rid of "base" and have advanceCallback etc. functions
138
* @param base The base FTGLglyph* to subclass.
139
* @param data A pointer to private data that will be passed to callbacks.
140
* @param renderCallback A rendering callback function.
141
* @param destroyCallback A callback function to be called upon destruction.
142
* @return An FTGLglyph* object.
144
FTGL_EXPORT FTGLglyph *ftglCreateCustomGlyph(FTGLglyph *base, void *data,
145
void (*renderCallback) (FTGLglyph *, void *, FTGL_DOUBLE, FTGL_DOUBLE,
146
int, FTGL_DOUBLE *, FTGL_DOUBLE *),
147
void (*destroyCallback) (FTGLglyph *, void *));
150
* Destroy an FTGL glyph object.
152
* @param glyph An FTGLglyph* object.
154
FTGL_EXPORT void ftglDestroyGlyph(FTGLglyph *glyph);
157
* Render a glyph at the current pen position and compute the corresponding
160
* @param glyph An FTGLglyph* object.
161
* @param penx The current pen's X position.
162
* @param peny The current pen's Y position.
163
* @param renderMode Render mode to display
164
* @param advancex A pointer to an FTGL_DOUBLE where to write the advance's X
166
* @param advancey A pointer to an FTGL_DOUBLE where to write the advance's Y
169
FTGL_EXPORT void ftglRenderGlyph(FTGLglyph *glyph, FTGL_DOUBLE penx,
170
FTGL_DOUBLE peny, int renderMode,
171
FTGL_DOUBLE *advancex, FTGL_DOUBLE *advancey);
173
* Return the advance for a glyph.
175
* @param glyph An FTGLglyph* object.
176
* @return The advance's X component.
178
FTGL_EXPORT float ftglGetGlyphAdvance(FTGLglyph *glyph);
181
* Return the bounding box for a glyph.
183
* @param glyph An FTGLglyph* object.
184
* @param bounds An array of 6 float values where the bounding box's lower
185
* left near and upper right far 3D coordinates will be stored.
187
FTGL_EXPORT void ftglGetGlyphBBox(FTGLglyph *glyph, float bounds[6]);
190
* Query a glyph for errors.
192
* @param glyph An FTGLglyph* object.
193
* @return The current error code.
195
FTGL_EXPORT FT_Error ftglGetGlyphError(FTGLglyph* glyph);
199
#endif // __FTGlyph__