FTFont.h
Go to the documentation of this file.
/*
* FTGL - OpenGL font library
*
* Copyright (c) 2001-2004 Henry Maddocks <ftgl@opengl.geek.nz>
* Copyright (c) 2008 Sam Hocevar <sam@hocevar.net>
* Copyright (c) 2008 Sean Morrison <learner@brlcad.org>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __ftgl__
# warning This header is deprecated. Please use <FTGL/ftgl.h> from now.
# include <FTGL/ftgl.h>
#endif
#ifndef __FTFont__
#define __FTFont__
#ifdef __cplusplus
class FTFontImpl;
class FTGL_EXPORT FTFont
{
protected:
FTFont(char const *fontFilePath);
FTFont(const unsigned char *pBufferBytes, size_t bufferSizeInBytes);
private:
/* Allow our internal subclasses to access the private constructor */
friend class FTBitmapFont;
friend class FTBufferFont;
friend class FTExtrudeFont;
friend class FTOutlineFont;
friend class FTPixmapFont;
friend class FTPolygonFont;
friend class FTTextureFont;
friend class FTTriangleExtractorFont;
FTFont(FTFontImpl *pImpl);
public:
virtual ~FTFont();
virtual bool Attach(const char* fontFilePath);
virtual bool Attach(const unsigned char *pBufferBytes,
size_t bufferSizeInBytes);
virtual void GlyphLoadFlags(FT_Int flags);
virtual bool CharMap(FT_Encoding encoding);
virtual unsigned int CharMapCount() const;
virtual FT_Encoding* CharMapList();
virtual bool FaceSize(const unsigned int size,
const unsigned int res = 72);
virtual unsigned int FaceSize() const;
virtual void Depth(float depth);
virtual void Outset(float outset);
virtual void Outset(float front, float back);
virtual void UseDisplayList(bool useList);
virtual float Ascender() const;
virtual float Descender() const;
virtual float LineHeight() const;
virtual FTBBox BBox(const char *string, const int len = -1,
FTPoint position = FTPoint(),
FTPoint spacing = FTPoint());
void BBox(const char* string, float& llx, float& lly, float& llz,
float& urx, float& ury, float& urz)
{
FTBBox b = BBox(string);
llx = b.Lower().Xf(); lly = b.Lower().Yf(); llz = b.Lower().Zf();
urx = b.Upper().Xf(); ury = b.Upper().Yf(); urz = b.Upper().Zf();
}
virtual FTBBox BBox(const wchar_t *string, const int len = -1,
FTPoint position = FTPoint(),
FTPoint spacing = FTPoint());
void BBox(const wchar_t* string, float& llx, float& lly, float& llz,
float& urx, float& ury, float& urz)
{
FTBBox b = BBox(string);
llx = b.Lower().Xf(); lly = b.Lower().Yf(); llz = b.Lower().Zf();
urx = b.Upper().Xf(); ury = b.Upper().Yf(); urz = b.Upper().Zf();
}
virtual float Advance(const char* string, const int len = -1,
FTPoint spacing = FTPoint());
virtual float Advance(const wchar_t* string, const int len = -1,
FTPoint spacing = FTPoint());
virtual FTPoint Render(const char* string, const int len = -1,
FTPoint position = FTPoint(),
FTPoint spacing = FTPoint(),
int renderMode = FTGL::RENDER_ALL);
virtual FTPoint Render(const wchar_t *string, const int len = -1,
FTPoint position = FTPoint(),
FTPoint spacing = FTPoint(),
int renderMode = FTGL::RENDER_ALL);
virtual FT_Error Error() const;
protected:
/* Allow impl to access MakeGlyph */
friend class FTFontImpl;
virtual FTGlyph* MakeGlyph(FT_GlyphSlot slot) = 0;
private:
FTFontImpl *impl;
};
#endif //__cplusplus
FTGL_BEGIN_C_DECLS
struct _FTGLFont;
typedef struct _FTGLfont FTGLfont;
FTGL_EXPORT FTGLfont *ftglCreateCustomFont(char const *fontFilePath,
void *data,
FTGLglyph * (*makeglyphCallback) (FT_GlyphSlot, void *));
FTGL_EXPORT FTGLfont *ftglCreateCustomFontFromMem(const unsigned char *bytes,
size_t len, void *data,
FTGLglyph * (*makeglyphCallback) (FT_GlyphSlot, void *));
FTGL_EXPORT void ftglDestroyFont(FTGLfont* font);
FTGL_EXPORT int ftglAttachFile(FTGLfont* font, const char* path);
FTGL_EXPORT int ftglAttachData(FTGLfont* font, const unsigned char * data,
size_t size);
FTGL_EXPORT void ftglSetFontGlyphLoadFlags(FTGLfont* font, FT_Int flags);
FTGL_EXPORT int ftglSetFontCharMap(FTGLfont* font, FT_Encoding encoding);
FTGL_EXPORT unsigned int ftglGetFontCharMapCount(FTGLfont* font);
FTGL_EXPORT FT_Encoding* ftglGetFontCharMapList(FTGLfont* font);
FTGL_EXPORT int ftglSetFontFaceSize(FTGLfont* font, unsigned int size,
unsigned int res);
FTGL_EXPORT unsigned int ftglGetFontFaceSize(FTGLfont* font);
FTGL_EXPORT void ftglSetFontDepth(FTGLfont* font, float depth);
FTGL_EXPORT void ftglSetFontOutset(FTGLfont* font, float front, float back);
FTGL_EXPORT void ftglSetFontDisplayList(FTGLfont* font, int useList);
FTGL_EXPORT float ftglGetFontAscender(FTGLfont* font);
FTGL_EXPORT float ftglGetFontDescender(FTGLfont* font);
FTGL_EXPORT float ftglGetFontLineHeight(FTGLfont* font);
FTGL_EXPORT void ftglGetFontBBox(FTGLfont* font, const char *string,
int len, float bounds[6]);
FTGL_EXPORT float ftglGetFontAdvance(FTGLfont* font, const char *string);
FTGL_EXPORT void ftglRenderFont(FTGLfont* font, const char *string, int mode);
FTGL_EXPORT FT_Error ftglGetFontError(FTGLfont* font);
FTGL_END_C_DECLS
#endif // __FTFont__
ftglSetFontFaceSize
int ftglSetFontFaceSize(FTGLfont *font, unsigned int size, unsigned int res)
Set the char size for the current face.
ftglRenderFont
void ftglRenderFont(FTGLfont *font, const char *string, int mode)
Render a string of characters.
ftglGetFontAdvance
float ftglGetFontAdvance(FTGLfont *font, const char *string)
Get the advance width for a string.
ftglSetFontDisplayList
void ftglSetFontDisplayList(FTGLfont *font, int useList)
Enable or disable the use of Display Lists inside FTGL.
ftglGetFontCharMapCount
unsigned int ftglGetFontCharMapCount(FTGLfont *font)
Get the number of character maps in this face.
ftglGetFontDescender
float ftglGetFontDescender(FTGLfont *font)
Gets the global descender height for the face.
ftglCreateCustomFontFromMem
FTGLfont * ftglCreateCustomFontFromMem(const unsigned char *bytes, size_t len, void *data, FTGLglyph *(*makeglyphCallback)(FT_GlyphSlot, void *))
Create a custom FTGL font object from a buffer in memory.
ftglAttachFile
int ftglAttachFile(FTGLfont *font, const char *path)
Attach auxilliary file to font e.g.
ftglSetFontGlyphLoadFlags
void ftglSetFontGlyphLoadFlags(FTGLfont *font, FT_Int flags)
Set the glyph loading flags.
ftglGetFontAscender
float ftglGetFontAscender(FTGLfont *font)
Get the global ascender height for the face.
ftglGetFontError
FT_Error ftglGetFontError(FTGLfont *font)
Query a font for errors.
ftglGetFontFaceSize
unsigned int ftglGetFontFaceSize(FTGLfont *font)
Get the current face size in points (1/72 inch).
ftglSetFontCharMap
int ftglSetFontCharMap(FTGLfont *font, FT_Encoding encoding)
Set the character map for the face.
ftglSetFontDepth
void ftglSetFontDepth(FTGLfont *font, float depth)
Set the extrusion distance for the font.
ftglSetFontOutset
void ftglSetFontOutset(FTGLfont *font, float front, float back)
Set the outset distance for the font.
ftglGetFontCharMapList
FT_Encoding * ftglGetFontCharMapList(FTGLfont *font)
Get a list of character maps in this face.
ftglGetFontLineHeight
float ftglGetFontLineHeight(FTGLfont *font)
Gets the line spacing for the font.
ftglAttachData
int ftglAttachData(FTGLfont *font, const unsigned char *data, size_t size)
Attach auxilliary data to font, e.g.
ftglGetFontBBox
void ftglGetFontBBox(FTGLfont *font, const char *string, int len, float bounds[6])
Get the bounding box for a string.
ftglDestroyFont
void ftglDestroyFont(FTGLfont *font)
Destroy an FTGL font object.
FTGLfont
struct _FTGLfont FTGLfont
Definition FTFont.h:414
ftglCreateCustomFont
FTGLfont * ftglCreateCustomFont(char const *fontFilePath, void *data, FTGLglyph *(*makeglyphCallback)(FT_GlyphSlot, void *))
Create a custom FTGL font object.
FTGLglyph
struct _FTGLglyph FTGLglyph
Definition FTGlyph.h:134
FTBBox
FTBBox is a convenience class for handling bounding boxes.
Definition FTBBox.h:43
FTBBox::Lower
FTPoint const Lower() const
Definition FTBBox.h:165
FTBBox::Upper
FTPoint const Upper() const
Definition FTBBox.h:159
FTBitmapFont
FTBitmapFont is a specialisation of the FTFont class for handling Bitmap fonts.
Definition FTGLBitmapFont.h:46
FTBufferFont
FTBufferFont is a specialisation of the FTFont class for handling memory buffer fonts.
Definition FTBufferFont.h:44
FTExtrudeFont
FTExtrudeFont is a specialisation of the FTFont class for handling extruded Polygon fonts.
Definition FTGLExtrdFont.h:47
FTFont
FTFont is the public interface for the FTGL library.
Definition FTFont.h:57
FTFont::Advance
virtual float Advance(const wchar_t *string, const int len=-1, FTPoint spacing=FTPoint())
Get the advance for a string.
FTFont::BBox
virtual FTBBox BBox(const char *string, const int len=-1, FTPoint position=FTPoint(), FTPoint spacing=FTPoint())
Get the bounding box for a string.
FTFont::Render
virtual FTPoint Render(const wchar_t *string, const int len=-1, FTPoint position=FTPoint(), FTPoint spacing=FTPoint(), int renderMode=FTGL::RENDER_ALL)
Render a string of characters.
FTFont::Descender
virtual float Descender() const
Gets the global descender height for the face.
FTFont::BBox
void BBox(const char *string, float &llx, float &lly, float &llz, float &urx, float &ury, float &urz)
Get the bounding box for a string (deprecated).
Definition FTFont.h:252
FTFont::Outset
virtual void Outset(float front, float back)
Set the front and back outset distances for the font.
FTFont::BBox
virtual FTBBox BBox(const wchar_t *string, const int len=-1, FTPoint position=FTPoint(), FTPoint spacing=FTPoint())
Get the bounding box for a string.
FTFont::UseDisplayList
virtual void UseDisplayList(bool useList)
Enable or disable the use of Display Lists inside FTGL.
FTFont::CharMap
virtual bool CharMap(FT_Encoding encoding)
Set the character map for the face.
FTFont::Error
virtual FT_Error Error() const
Queries the Font for errors.
FTFont::CharMapCount
virtual unsigned int CharMapCount() const
Get the number of character maps in this face.
FTFont::Attach
virtual bool Attach(const char *fontFilePath)
Attach auxilliary file to font e.g font metrics.
FTFont::Depth
virtual void Depth(float depth)
Set the extrusion distance for the font.
FTFont::Ascender
virtual float Ascender() const
Get the global ascender height for the face.
FTFont::FaceSize
virtual unsigned int FaceSize() const
Get the current face size in points (1/72 inch).
FTFont::FTFont
FTFont(const unsigned char *pBufferBytes, size_t bufferSizeInBytes)
Open and read a font from a buffer in memory.
FTFont::Attach
virtual bool Attach(const unsigned char *pBufferBytes, size_t bufferSizeInBytes)
Attach auxilliary data to font e.g font metrics, from memory.
FTFont::~FTFont
virtual ~FTFont()
FTFont::FaceSize
virtual bool FaceSize(const unsigned int size, const unsigned int res=72)
Set the char size for the current face.
FTFont::LineHeight
virtual float LineHeight() const
Gets the line spacing for the font.
FTFont::Render
virtual FTPoint Render(const char *string, const int len=-1, FTPoint position=FTPoint(), FTPoint spacing=FTPoint(), int renderMode=FTGL::RENDER_ALL)
Render a string of characters.
FTFont::MakeGlyph
virtual FTGlyph * MakeGlyph(FT_GlyphSlot slot)=0
Construct a glyph of the correct type.
FTFont::CharMapList
virtual FT_Encoding * CharMapList()
Get a list of character maps in this face.
FTFont::Advance
virtual float Advance(const char *string, const int len=-1, FTPoint spacing=FTPoint())
Get the advance for a string.
FTFont::GlyphLoadFlags
virtual void GlyphLoadFlags(FT_Int flags)
Set the glyph loading flags.
FTFont::BBox
void BBox(const wchar_t *string, float &llx, float &lly, float &llz, float &urx, float &ury, float &urz)
Get the bounding box for a string (deprecated).
Definition FTFont.h:287
FTFont::FTFont
FTFont(char const *fontFilePath)
Open and read a font file.
FTFont::Outset
virtual void Outset(float outset)
Set the outset distance for the font.
FTGlyph
FTGlyph is the base class for FTGL glyphs.
Definition FTGlyph.h:51
FTOutlineFont
FTOutlineFont is a specialisation of the FTFont class for handling Vector Outline fonts.
Definition FTGLOutlineFont.h:46
FTPixmapFont
FTPixmapFont is a specialisation of the FTFont class for handling Pixmap (Grey Scale) fonts.
Definition FTGLPixmapFont.h:46
FTPoint
FTPoint class is a basic 3-dimensional point or vector.
Definition FTPoint.h:43
FTPoint::Yf
FTGL_FLOAT Yf() const
Definition FTPoint.h:261
FTPoint::Xf
FTGL_FLOAT Xf() const
Definition FTPoint.h:260
FTPoint::Zf
FTGL_FLOAT Zf() const
Definition FTPoint.h:262
FTPolygonFont
FTPolygonFont is a specialisation of the FTFont class for handling tesselated Polygon Mesh fonts.
Definition FTGLPolygonFont.h:47
FTTextureFont
FTTextureFont is a specialisation of the FTFont class for handling Texture mapped fonts.
Definition FTGLTextureFont.h:46
FTTriangleExtractorFont
FTPolygonFont is a specialisation of the FTFont class for handling tesselated Polygon Mesh fonts.
Definition FTGLTriangleExtractorFont.h:45
ftgl.h
FTGL_BEGIN_C_DECLS
#define FTGL_BEGIN_C_DECLS
Definition ftgl.h:43
FTGL_END_C_DECLS
#define FTGL_END_C_DECLS
Definition ftgl.h:44
FTGL_EXPORT
#define FTGL_EXPORT
Definition ftgl.h:134
FTGL::RENDER_ALL
@ RENDER_ALL
Definition ftgl.h:58