From 068d1812399e60da4f5268b2fdbf1ce72b7f22f3 Mon Sep 17 00:00:00 2001 From: micio Date: Sat, 17 Sep 2011 21:25:44 +0000 Subject: [PATCH] Bazaar/FTGL : fixed compilation on windows git-svn-id: svn://ultimatepp.org/upp/trunk@3878 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- bazaar/FTGL/FTGL.upp | 1 + bazaar/FTGL/ftgl.h | 272 +++++++++++----------- bazaar/FTGL/src/FTCharmap.h | 330 +++++++++++++------------- bazaar/FTGL/src/FTFace.h | 362 ++++++++++++++--------------- bazaar/FTGL/src/FTGlyphContainer.h | 310 ++++++++++++------------ bazaar/FTGL/src/FTLibrary.h | 244 +++++++++---------- bazaar/FTGL/src/FTSize.h | 328 +++++++++++++------------- bazaar/FTGL/src/config.h | 15 +- 8 files changed, 935 insertions(+), 927 deletions(-) diff --git a/bazaar/FTGL/FTGL.upp b/bazaar/FTGL/FTGL.upp index 83de0b4f6..bbd08ce4d 100644 --- a/bazaar/FTGL/FTGL.upp +++ b/bazaar/FTGL/FTGL.upp @@ -10,6 +10,7 @@ library(FREEBSD) "GL GLU"; library(WIN32 GCC) "glaux glu32 opengl32"; file + ftgl.h, src/config.h, src/FTBuffer.cpp, src/FTCharmap.cpp, diff --git a/bazaar/FTGL/ftgl.h b/bazaar/FTGL/ftgl.h index f5d043cda..248e080e9 100644 --- a/bazaar/FTGL/ftgl.h +++ b/bazaar/FTGL/ftgl.h @@ -1,135 +1,137 @@ -/* - * FTGL - OpenGL font library - * - * Copyright (c) 2001-2004 Henry Maddocks - * Copyright (c) 2008 Sam Hocevar - * Copyright (c) 2008 Sean Morrison - * - * 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__ -#define __ftgl__ - -/* We need the Freetype headers */ -#include -#include FT_FREETYPE_H -#include FT_GLYPH_H -#include FT_OUTLINE_H - -/* Floating point types used by the library */ -typedef double FTGL_DOUBLE; -typedef float FTGL_FLOAT; - -/* Macros used to declare C-linkage types and symbols */ -#ifdef __cplusplus -# define FTGL_BEGIN_C_DECLS extern "C" { namespace FTGL { -# define FTGL_END_C_DECLS } } -#else -# define FTGL_BEGIN_C_DECLS -# define FTGL_END_C_DECLS -#endif - -#ifdef __cplusplus -namespace FTGL -{ - typedef enum - { - RENDER_FRONT = 0x0001, - RENDER_BACK = 0x0002, - RENDER_SIDE = 0x0004, - RENDER_ALL = 0xffff - } RenderMode; - - typedef enum - { - ALIGN_LEFT = 0, - ALIGN_CENTER = 1, - ALIGN_RIGHT = 2, - ALIGN_JUSTIFY = 3 - } TextAlignment; -} -#else -# define FTGL_RENDER_FRONT 0x0001 -# define FTGL_RENDER_BACK 0x0002 -# define FTGL_RENDER_SIDE 0x0004 -# define FTGL_RENDER_ALL 0xffff - -# define FTGL_ALIGN_LEFT 0 -# define FTGL_ALIGN_CENTER 1 -# define FTGL_ALIGN_RIGHT 2 -# define FTGL_ALIGN_JUSTIFY 3 -#endif - -// Compiler-specific conditional compilation -#ifdef _MSC_VER // MS Visual C++ - - // Disable various warning. - // 4786: template name too long - #pragma warning(disable : 4251) - #pragma warning(disable : 4275) - #pragma warning(disable : 4786) - - // The following definitions control how symbols are exported. - // If the target is a static library ensure that FTGL_LIBRARY_STATIC - // is defined. If building a dynamic library (ie DLL) ensure the - // FTGL_LIBRARY macro is defined, as it will mark symbols for - // export. If compiling a project to _use_ the _dynamic_ library - // version of the library, no definition is required. - #ifdef FTGL_LIBRARY_STATIC // static lib - no special export required - # define FTGL_EXPORT - #elif FTGL_LIBRARY // dynamic lib - must export/import symbols appropriately. - # define FTGL_EXPORT __declspec(dllexport) - #else - # define FTGL_EXPORT __declspec(dllimport) - #endif - -#else - // Compiler that is not MS Visual C++. - // Ensure that the export symbol is defined (and blank) - #define FTGL_EXPORT -#endif - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#endif // __ftgl__ +/* + * FTGL - OpenGL font library + * + * Copyright (c) 2001-2004 Henry Maddocks + * Copyright (c) 2008 Sam Hocevar + * Copyright (c) 2008 Sean Morrison + * + * 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__ +#define __ftgl__ + +/* We need the Freetype headers */ +#include +#include FT_FREETYPE_H +#include FT_GLYPH_H +#include FT_OUTLINE_H + +/* Floating point types used by the library */ +typedef double FTGL_DOUBLE; +typedef float FTGL_FLOAT; + +/* Macros used to declare C-linkage types and symbols */ +#ifdef __cplusplus +# define FTGL_BEGIN_C_DECLS extern "C" { namespace FTGL { +# define FTGL_END_C_DECLS } } +#else +# define FTGL_BEGIN_C_DECLS +# define FTGL_END_C_DECLS +#endif + +#ifdef __cplusplus +namespace FTGL +{ + typedef enum + { + RENDER_FRONT = 0x0001, + RENDER_BACK = 0x0002, + RENDER_SIDE = 0x0004, + RENDER_ALL = 0xffff + } RenderMode; + + typedef enum + { + ALIGN_LEFT = 0, + ALIGN_CENTER = 1, + ALIGN_RIGHT = 2, + ALIGN_JUSTIFY = 3 + } TextAlignment; +} +#else +# define FTGL_RENDER_FRONT 0x0001 +# define FTGL_RENDER_BACK 0x0002 +# define FTGL_RENDER_SIDE 0x0004 +# define FTGL_RENDER_ALL 0xffff + +# define FTGL_ALIGN_LEFT 0 +# define FTGL_ALIGN_CENTER 1 +# define FTGL_ALIGN_RIGHT 2 +# define FTGL_ALIGN_JUSTIFY 3 +#endif + +// Compiler-specific conditional compilation +#ifdef _MSC_VER // MS Visual C++ + + // Disable various warning. + // 4786: template name too long + #pragma warning(disable : 4251) + #pragma warning(disable : 4275) + #pragma warning(disable : 4786) + + // The following definitions control how symbols are exported. + // If the target is a static library ensure that FTGL_LIBRARY_STATIC + // is defined. If building a dynamic library (ie DLL) ensure the + // FTGL_LIBRARY macro is defined, as it will mark symbols for + // export. If compiling a project to _use_ the _dynamic_ library + // version of the library, no definition is required. + #ifdef FTGL_LIBRARY_STATIC // static lib - no special export required + # define FTGL_EXPORT + #elif FTGL_LIBRARY // dynamic lib - must export/import symbols appropriately. + # define FTGL_EXPORT __declspec(dllexport) + #else + # define FTGL_EXPORT __declspec(dllimport) + #endif +#else + // Compiler that is not MS Visual C++. + // Ensure that the export symbol is defined (and blank) + #define FTGL_EXPORT +#endif + +#undef FTGL_EXPORT +#define FTGL_EXPORT + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#endif // __ftgl__ diff --git a/bazaar/FTGL/src/FTCharmap.h b/bazaar/FTGL/src/FTCharmap.h index f4ce867d2..9e6fdc8d3 100644 --- a/bazaar/FTGL/src/FTCharmap.h +++ b/bazaar/FTGL/src/FTCharmap.h @@ -1,165 +1,165 @@ -/* - * FTGL - OpenGL font library - * - * Copyright (c) 2001-2004 Henry Maddocks - * - * 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 __FTCharmap__ -#define __FTCharmap__ - - -#include -#include FT_FREETYPE_H -#include FT_GLYPH_H - -#include "FTGL/ftgl.h" -#include "FTCharToGlyphIndexMap.h" - - -/** - * FTCharmap takes care of specifying the encoding for a font and mapping - * character codes to glyph indices. - * - * It doesn't preprocess all indices, only on an as needed basis. This may - * seem like a performance penalty but it is quicker than using the 'raw' - * freetype calls and will save significant amounts of memory when dealing - * with unicode encoding - * - * @see "Freetype 2 Documentation" - * - */ - -class FTFace; - -class FTCharmap -{ - public: - /** - * Constructor - */ - FTCharmap(FTFace* face); - - /** - * Destructor - */ - virtual ~FTCharmap(); - - /** - * Queries for the current character map code. - * - * @return The current character map code. - */ - FT_Encoding Encoding() const { return ftEncoding; } - - /** - * Sets the character map for the face. If an error occurs the object is not modified. - * Valid encodings as at Freetype 2.0.4 - * ft_encoding_none - * ft_encoding_symbol - * ft_encoding_unicode - * ft_encoding_latin_2 - * ft_encoding_sjis - * ft_encoding_gb2312 - * ft_encoding_big5 - * ft_encoding_wansung - * ft_encoding_johab - * ft_encoding_adobe_standard - * ft_encoding_adobe_expert - * ft_encoding_adobe_custom - * ft_encoding_apple_roman - * - * @param encoding the Freetype encoding symbol. See above. - * @return true if charmap was valid and set - * correctly. - */ - bool CharMap(FT_Encoding encoding); - - /** - * Get the FTGlyphContainer index of the input character. - * - * @param characterCode The character code of the requested glyph in - * the current encoding eg apple roman. - * @return The FTGlyphContainer index for the character or zero - * if it wasn't found - */ - unsigned int GlyphListIndex(const unsigned int characterCode); - - /** - * Get the font glyph index of the input character. - * - * @param characterCode The character code of the requested glyph in - * the current encoding eg apple roman. - * @return The glyph index for the character. - */ - unsigned int FontIndex(const unsigned int characterCode); - - /** - * Set the FTGlyphContainer index of the character code. - * - * @param characterCode The character code of the requested glyph in - * the current encoding eg apple roman. - * @param containerIndex The index into the FTGlyphContainer of the - * character code. - */ - void InsertIndex(const unsigned int characterCode, - const size_t containerIndex); - - /** - * Queries for errors. - * - * @return The current error code. Zero means no error. - */ - FT_Error Error() const { return err; } - - private: - /** - * Current character map code. - */ - FT_Encoding ftEncoding; - - /** - * The current Freetype face. - */ - const FT_Face ftFace; - - /** - * A structure that maps glyph indices to character codes - * - * < character code, face glyph index> - */ - typedef FTCharToGlyphIndexMap CharacterMap; - CharacterMap charMap; - - /** - * Precomputed font indices. - */ - static const unsigned int MAX_PRECOMPUTED = 128; - unsigned int charIndexCache[MAX_PRECOMPUTED]; - - /** - * Current error code. - */ - FT_Error err; -}; - - -#endif // __FTCharmap__ +/* + * FTGL - OpenGL font library + * + * Copyright (c) 2001-2004 Henry Maddocks + * + * 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 __FTCharmap__ +#define __FTCharmap__ + + +#include +#include FT_FREETYPE_H +#include FT_GLYPH_H + +#include "FTGL/ftgl.h" +#include "FTCharToGlyphIndexMap.h" + + +/** + * FTCharmap takes care of specifying the encoding for a font and mapping + * character codes to glyph indices. + * + * It doesn't preprocess all indices, only on an as needed basis. This may + * seem like a performance penalty but it is quicker than using the 'raw' + * freetype calls and will save significant amounts of memory when dealing + * with unicode encoding + * + * @see "Freetype 2 Documentation" + * + */ + +class FTFace; + +class FTCharmap +{ + public: + /** + * Constructor + */ + FTCharmap(FTFace* face); + + /** + * Destructor + */ + virtual ~FTCharmap(); + + /** + * Queries for the current character map code. + * + * @return The current character map code. + */ + FT_Encoding Encoding() const { return ftEncoding; } + + /** + * Sets the character map for the face. If an error occurs the object is not modified. + * Valid encodings as at Freetype 2.0.4 + * ft_encoding_none + * ft_encoding_symbol + * ft_encoding_unicode + * ft_encoding_latin_2 + * ft_encoding_sjis + * ft_encoding_gb2312 + * ft_encoding_big5 + * ft_encoding_wansung + * ft_encoding_johab + * ft_encoding_adobe_standard + * ft_encoding_adobe_expert + * ft_encoding_adobe_custom + * ft_encoding_apple_roman + * + * @param encoding the Freetype encoding symbol. See above. + * @return true if charmap was valid and set + * correctly. + */ + bool CharMap(FT_Encoding encoding); + + /** + * Get the FTGlyphContainer index of the input character. + * + * @param characterCode The character code of the requested glyph in + * the current encoding eg apple roman. + * @return The FTGlyphContainer index for the character or zero + * if it wasn't found + */ + unsigned int GlyphListIndex(const unsigned int characterCode); + + /** + * Get the font glyph index of the input character. + * + * @param characterCode The character code of the requested glyph in + * the current encoding eg apple roman. + * @return The glyph index for the character. + */ + unsigned int FontIndex(const unsigned int characterCode); + + /** + * Set the FTGlyphContainer index of the character code. + * + * @param characterCode The character code of the requested glyph in + * the current encoding eg apple roman. + * @param containerIndex The index into the FTGlyphContainer of the + * character code. + */ + void InsertIndex(const unsigned int characterCode, + const size_t containerIndex); + + /** + * Queries for errors. + * + * @return The current error code. Zero means no error. + */ + FT_Error Error() const { return err; } + + private: + /** + * Current character map code. + */ + FT_Encoding ftEncoding; + + /** + * The current Freetype face. + */ + const FT_Face ftFace; + + /** + * A structure that maps glyph indices to character codes + * + * < character code, face glyph index> + */ + typedef FTCharToGlyphIndexMap CharacterMap; + CharacterMap charMap; + + /** + * Precomputed font indices. + */ + static const unsigned int MAX_PRECOMPUTED = 128; + unsigned int charIndexCache[MAX_PRECOMPUTED]; + + /** + * Current error code. + */ + FT_Error err; +}; + + +#endif // __FTCharmap__ diff --git a/bazaar/FTGL/src/FTFace.h b/bazaar/FTGL/src/FTFace.h index 0e903b572..966b39b4e 100644 --- a/bazaar/FTGL/src/FTFace.h +++ b/bazaar/FTGL/src/FTFace.h @@ -1,181 +1,181 @@ -/* - * FTGL - OpenGL font library - * - * Copyright (c) 2001-2004 Henry Maddocks - * - * 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 __FTFace__ -#define __FTFace__ - -#include -#include FT_FREETYPE_H -#include FT_GLYPH_H - -#include "FTGL/ftgl.h" - -#include "FTSize.h" - -/** - * FTFace class provides an abstraction layer for the Freetype Face. - * - * @see "Freetype 2 Documentation" - * - */ -class FTFace -{ - public: - /** - * Opens and reads a face file. Error is set. - * - * @param fontFilePath font file path. - */ - FTFace(const char* fontFilePath, bool precomputeKerning = true); - - /** - * Read face data from an in-memory buffer. Error is set. - * - * @param pBufferBytes the in-memory buffer - * @param bufferSizeInBytes the length of the buffer in bytes - */ - FTFace(const unsigned char *pBufferBytes, size_t bufferSizeInBytes, - bool precomputeKerning = true); - - /** - * Destructor - * - * Disposes of the current Freetype Face. - */ - virtual ~FTFace(); - - /** - * Attach auxilliary file to font (e.g., font metrics). - * - * @param fontFilePath auxilliary font file path. - * @return true if file has opened - * successfully. - */ - bool Attach(const char* fontFilePath); - - /** - * Attach auxilliary data to font (e.g., font metrics) from memory - * - * @param pBufferBytes the in-memory buffer - * @param bufferSizeInBytes the length of the buffer in bytes - * @return true if file has opened - * successfully. - */ - bool Attach(const unsigned char *pBufferBytes, - size_t bufferSizeInBytes); - - /** - * Get the freetype face object.. - * - * @return pointer to an FT_Face. - */ - FT_Face* Face() const { return ftFace; } - - /** - * Sets the char size for the current face. - * - * This doesn't guarantee that the size was set correctly. Clients - * should check errors. - * - * @param size the face size in points (1/72 inch) - * @param res the resolution of the target device. - * @return FTSize object - */ - const FTSize& Size(const unsigned int size, const unsigned int res); - - /** - * Get the number of character maps in this face. - * - * @return character map count. - */ - unsigned int CharMapCount() const; - - /** - * Get a list of character maps in this face. - * - * @return pointer to the first encoding. - */ - FT_Encoding* CharMapList(); - - /** - * Gets the kerning vector between two glyphs - */ - FTPoint KernAdvance(unsigned int index1, unsigned int index2); - - /** - * Loads and creates a Freetype glyph. - */ - FT_GlyphSlot Glyph(unsigned int index, FT_Int load_flags); - - /** - * Gets the number of glyphs in the current face. - */ - unsigned int GlyphCount() const { return numGlyphs; } - - /** - * Queries for errors. - * - * @return The current error code. - */ - FT_Error Error() const { return err; } - - private: - /** - * The Freetype face - */ - FT_Face* ftFace; - - /** - * The size object associated with this face - */ - FTSize charSize; - - /** - * The number of glyphs in this face - */ - int numGlyphs; - - FT_Encoding* fontEncodingList; - - /** - * This face has kerning tables - */ - bool hasKerningTable; - - /** - * If this face has kerning tables, we can cache them. - */ - void BuildKerningCache(); - static const unsigned int MAX_PRECOMPUTED = 128; - float *kerningCache; - - /** - * Current error code. Zero means no error. - */ - FT_Error err; -}; - - -#endif // __FTFace__ +/* + * FTGL - OpenGL font library + * + * Copyright (c) 2001-2004 Henry Maddocks + * + * 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 __FTFace__ +#define __FTFace__ + +#include +#include FT_FREETYPE_H +#include FT_GLYPH_H + +#include "FTGL/ftgl.h" + +#include "FTSize.h" + +/** + * FTFace class provides an abstraction layer for the Freetype Face. + * + * @see "Freetype 2 Documentation" + * + */ +class FTFace +{ + public: + /** + * Opens and reads a face file. Error is set. + * + * @param fontFilePath font file path. + */ + FTFace(const char* fontFilePath, bool precomputeKerning = true); + + /** + * Read face data from an in-memory buffer. Error is set. + * + * @param pBufferBytes the in-memory buffer + * @param bufferSizeInBytes the length of the buffer in bytes + */ + FTFace(const unsigned char *pBufferBytes, size_t bufferSizeInBytes, + bool precomputeKerning = true); + + /** + * Destructor + * + * Disposes of the current Freetype Face. + */ + virtual ~FTFace(); + + /** + * Attach auxilliary file to font (e.g., font metrics). + * + * @param fontFilePath auxilliary font file path. + * @return true if file has opened + * successfully. + */ + bool Attach(const char* fontFilePath); + + /** + * Attach auxilliary data to font (e.g., font metrics) from memory + * + * @param pBufferBytes the in-memory buffer + * @param bufferSizeInBytes the length of the buffer in bytes + * @return true if file has opened + * successfully. + */ + bool Attach(const unsigned char *pBufferBytes, + size_t bufferSizeInBytes); + + /** + * Get the freetype face object.. + * + * @return pointer to an FT_Face. + */ + FT_Face* Face() const { return ftFace; } + + /** + * Sets the char size for the current face. + * + * This doesn't guarantee that the size was set correctly. Clients + * should check errors. + * + * @param size the face size in points (1/72 inch) + * @param res the resolution of the target device. + * @return FTSize object + */ + const FTSize& Size(const unsigned int size, const unsigned int res); + + /** + * Get the number of character maps in this face. + * + * @return character map count. + */ + unsigned int CharMapCount() const; + + /** + * Get a list of character maps in this face. + * + * @return pointer to the first encoding. + */ + FT_Encoding* CharMapList(); + + /** + * Gets the kerning vector between two glyphs + */ + FTPoint KernAdvance(unsigned int index1, unsigned int index2); + + /** + * Loads and creates a Freetype glyph. + */ + FT_GlyphSlot Glyph(unsigned int index, FT_Int load_flags); + + /** + * Gets the number of glyphs in the current face. + */ + unsigned int GlyphCount() const { return numGlyphs; } + + /** + * Queries for errors. + * + * @return The current error code. + */ + FT_Error Error() const { return err; } + + private: + /** + * The Freetype face + */ + FT_Face* ftFace; + + /** + * The size object associated with this face + */ + FTSize charSize; + + /** + * The number of glyphs in this face + */ + int numGlyphs; + + FT_Encoding* fontEncodingList; + + /** + * This face has kerning tables + */ + bool hasKerningTable; + + /** + * If this face has kerning tables, we can cache them. + */ + void BuildKerningCache(); + static const unsigned int MAX_PRECOMPUTED = 128; + float *kerningCache; + + /** + * Current error code. Zero means no error. + */ + FT_Error err; +}; + + +#endif // __FTFace__ diff --git a/bazaar/FTGL/src/FTGlyphContainer.h b/bazaar/FTGL/src/FTGlyphContainer.h index d4bbb7473..2f9bd4272 100644 --- a/bazaar/FTGL/src/FTGlyphContainer.h +++ b/bazaar/FTGL/src/FTGlyphContainer.h @@ -1,155 +1,155 @@ -/* - * FTGL - OpenGL font library - * - * Copyright (c) 2001-2004 Henry Maddocks - * - * 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 __FTGlyphContainer__ -#define __FTGlyphContainer__ - -#include -#include FT_FREETYPE_H -#include FT_GLYPH_H - -#include "FTGL/ftgl.h" - -#include "FTVector.h" - -class FTFace; -class FTGlyph; -class FTCharmap; - -/** - * FTGlyphContainer holds the post processed FTGlyph objects. - * - * @see FTGlyph - */ -class FTGlyphContainer -{ - typedef FTVector GlyphVector; - public: - /** - * Constructor - * - * @param face The Freetype face - */ - FTGlyphContainer(FTFace* face); - - /** - * Destructor - */ - ~FTGlyphContainer(); - - /** - * Sets the character map for the face. - * - * @param encoding the Freetype encoding symbol. See above. - * @return true if charmap was valid - * and set correctly - */ - bool CharMap(FT_Encoding encoding); - - /** - * Get the font index of the input character. - * - * @param characterCode The character code of the requested glyph in the - * current encoding eg apple roman. - * @return The font index for the character. - */ - unsigned int FontIndex(const unsigned int characterCode) const; - - /** - * Adds a glyph to this glyph list. - * - * @param glyph The FTGlyph to be inserted into the container - * @param characterCode The char code of the glyph NOT the glyph index. - */ - void Add(FTGlyph* glyph, const unsigned int characterCode); - - /** - * Get a glyph from the glyph list - * - * @param characterCode The char code of the glyph NOT the glyph index - * @return An FTGlyph or null is it hasn't been - * loaded. - */ - const FTGlyph* const Glyph(const unsigned int characterCode) const; - - /** - * Get the bounding box for a character. - * @param characterCode The char code of the glyph NOT the glyph index - */ - FTBBox BBox(const unsigned int characterCode) const; - - /** - * Returns the kerned advance width for a glyph. - * - * @param characterCode glyph index of the character - * @param nextCharacterCode the next glyph in a string - * @return advance width - */ - float Advance(const unsigned int characterCode, - const unsigned int nextCharacterCode); - - /** - * Renders a character - * @param characterCode the glyph to be Rendered - * @param nextCharacterCode the next glyph in the string. Used for kerning. - * @param penPosition the position to Render the glyph - * @param renderMode Render mode to display - * @return The distance to advance the pen position after Rendering - */ - FTPoint Render(const unsigned int characterCode, - const unsigned int nextCharacterCode, - FTPoint penPosition, int renderMode); - - /** - * Queries the Font for errors. - * - * @return The current error code. - */ - FT_Error Error() const { return err; } - - private: - /** - * The FTGL face - */ - FTFace* face; - - /** - * The Character Map object associated with the current face - */ - FTCharmap* charMap; - - /** - * A structure to hold the glyphs - */ - GlyphVector glyphs; - - /** - * Current error code. Zero means no error. - */ - FT_Error err; -}; - - -#endif // __FTGlyphContainer__ +/* + * FTGL - OpenGL font library + * + * Copyright (c) 2001-2004 Henry Maddocks + * + * 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 __FTGlyphContainer__ +#define __FTGlyphContainer__ + +#include +#include FT_FREETYPE_H +#include FT_GLYPH_H + +#include "FTGL/ftgl.h" + +#include "FTVector.h" + +class FTFace; +class FTGlyph; +class FTCharmap; + +/** + * FTGlyphContainer holds the post processed FTGlyph objects. + * + * @see FTGlyph + */ +class FTGlyphContainer +{ + typedef FTVector GlyphVector; + public: + /** + * Constructor + * + * @param face The Freetype face + */ + FTGlyphContainer(FTFace* face); + + /** + * Destructor + */ + ~FTGlyphContainer(); + + /** + * Sets the character map for the face. + * + * @param encoding the Freetype encoding symbol. See above. + * @return true if charmap was valid + * and set correctly + */ + bool CharMap(FT_Encoding encoding); + + /** + * Get the font index of the input character. + * + * @param characterCode The character code of the requested glyph in the + * current encoding eg apple roman. + * @return The font index for the character. + */ + unsigned int FontIndex(const unsigned int characterCode) const; + + /** + * Adds a glyph to this glyph list. + * + * @param glyph The FTGlyph to be inserted into the container + * @param characterCode The char code of the glyph NOT the glyph index. + */ + void Add(FTGlyph* glyph, const unsigned int characterCode); + + /** + * Get a glyph from the glyph list + * + * @param characterCode The char code of the glyph NOT the glyph index + * @return An FTGlyph or null is it hasn't been + * loaded. + */ + const FTGlyph* const Glyph(const unsigned int characterCode) const; + + /** + * Get the bounding box for a character. + * @param characterCode The char code of the glyph NOT the glyph index + */ + FTBBox BBox(const unsigned int characterCode) const; + + /** + * Returns the kerned advance width for a glyph. + * + * @param characterCode glyph index of the character + * @param nextCharacterCode the next glyph in a string + * @return advance width + */ + float Advance(const unsigned int characterCode, + const unsigned int nextCharacterCode); + + /** + * Renders a character + * @param characterCode the glyph to be Rendered + * @param nextCharacterCode the next glyph in the string. Used for kerning. + * @param penPosition the position to Render the glyph + * @param renderMode Render mode to display + * @return The distance to advance the pen position after Rendering + */ + FTPoint Render(const unsigned int characterCode, + const unsigned int nextCharacterCode, + FTPoint penPosition, int renderMode); + + /** + * Queries the Font for errors. + * + * @return The current error code. + */ + FT_Error Error() const { return err; } + + private: + /** + * The FTGL face + */ + FTFace* face; + + /** + * The Character Map object associated with the current face + */ + FTCharmap* charMap; + + /** + * A structure to hold the glyphs + */ + GlyphVector glyphs; + + /** + * Current error code. Zero means no error. + */ + FT_Error err; +}; + + +#endif // __FTGlyphContainer__ diff --git a/bazaar/FTGL/src/FTLibrary.h b/bazaar/FTGL/src/FTLibrary.h index 951fecc78..a0119a39a 100644 --- a/bazaar/FTGL/src/FTLibrary.h +++ b/bazaar/FTGL/src/FTLibrary.h @@ -1,122 +1,122 @@ -/* - * FTGL - OpenGL font library - * - * Copyright (c) 2001-2004 Henry Maddocks - * - * 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 __FTLibrary__ -#define __FTLibrary__ - -#include -#include FT_FREETYPE_H -//#include FT_CACHE_H - -#include "FTGL/ftgl.h" - - -/** - * FTLibrary class is the global accessor for the Freetype library. - * - * This class encapsulates the Freetype Library. This is a singleton class - * and ensures that only one FT_Library is in existence at any one time. - * All constructors are private therefore clients cannot create or - * instantiate this class themselves and must access it's methods via the - * static FTLibrary::Instance() function. - * - * Just because this class returns a valid FTLibrary object - * doesn't mean that the Freetype Library has been successfully initialised. - * Clients should check for errors. You can initialse the library AND check - * for errors using the following code... - * err = FTLibrary::Instance().Error(); - * - * @see "Freetype 2 Documentation" - * - */ -class FTLibrary -{ - public: - /** - * Global acces point to the single FTLibrary object. - * - * @return The global FTLibrary object. - */ - static const FTLibrary& Instance(); - - /** - * Gets a pointer to the native Freetype library. - * - * @return A handle to a FreeType library instance. - */ - const FT_Library* const GetLibrary() const { return library; } - - /** - * Queries the library for errors. - * - * @return The current error code. - */ - FT_Error Error() const { return err; } - - /** - * Destructor - * - * Disposes of the Freetype library - */ - ~FTLibrary(); - - private: - /** - * Default constructors. - * - * Made private to stop clients creating there own FTLibrary - * objects. - */ - FTLibrary(); - FTLibrary(const FT_Library&){} - FTLibrary& operator=(const FT_Library&) { return *this; } - - /** - * Initialises the Freetype library - * - * Even though this function indicates success via the return value, - * clients can't see this so must check the error codes. This function - * is only ever called by the default c_stor - * - * @return true if the Freetype library was - * successfully initialised, false - * otherwise. - */ - bool Initialise(); - - /** - * Freetype library handle. - */ - FT_Library* library; -// FTC_Manager* manager; - - /** - * Current error code. Zero means no error. - */ - FT_Error err; - -}; - -#endif // __FTLibrary__ +/* + * FTGL - OpenGL font library + * + * Copyright (c) 2001-2004 Henry Maddocks + * + * 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 __FTLibrary__ +#define __FTLibrary__ + +#include +#include FT_FREETYPE_H +//#include FT_CACHE_H + +#include "FTGL/ftgl.h" + + +/** + * FTLibrary class is the global accessor for the Freetype library. + * + * This class encapsulates the Freetype Library. This is a singleton class + * and ensures that only one FT_Library is in existence at any one time. + * All constructors are private therefore clients cannot create or + * instantiate this class themselves and must access it's methods via the + * static FTLibrary::Instance() function. + * + * Just because this class returns a valid FTLibrary object + * doesn't mean that the Freetype Library has been successfully initialised. + * Clients should check for errors. You can initialse the library AND check + * for errors using the following code... + * err = FTLibrary::Instance().Error(); + * + * @see "Freetype 2 Documentation" + * + */ +class FTLibrary +{ + public: + /** + * Global acces point to the single FTLibrary object. + * + * @return The global FTLibrary object. + */ + static const FTLibrary& Instance(); + + /** + * Gets a pointer to the native Freetype library. + * + * @return A handle to a FreeType library instance. + */ + const FT_Library* const GetLibrary() const { return library; } + + /** + * Queries the library for errors. + * + * @return The current error code. + */ + FT_Error Error() const { return err; } + + /** + * Destructor + * + * Disposes of the Freetype library + */ + ~FTLibrary(); + + private: + /** + * Default constructors. + * + * Made private to stop clients creating there own FTLibrary + * objects. + */ + FTLibrary(); + FTLibrary(const FT_Library&){} + FTLibrary& operator=(const FT_Library&) { return *this; } + + /** + * Initialises the Freetype library + * + * Even though this function indicates success via the return value, + * clients can't see this so must check the error codes. This function + * is only ever called by the default c_stor + * + * @return true if the Freetype library was + * successfully initialised, false + * otherwise. + */ + bool Initialise(); + + /** + * Freetype library handle. + */ + FT_Library* library; +// FTC_Manager* manager; + + /** + * Current error code. Zero means no error. + */ + FT_Error err; + +}; + +#endif // __FTLibrary__ diff --git a/bazaar/FTGL/src/FTSize.h b/bazaar/FTGL/src/FTSize.h index 4ba2666cd..c3125d663 100644 --- a/bazaar/FTGL/src/FTSize.h +++ b/bazaar/FTGL/src/FTSize.h @@ -1,164 +1,164 @@ -/* - * FTGL - OpenGL font library - * - * Copyright (c) 2001-2004 Henry Maddocks - * - * 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 __FTSize__ -#define __FTSize__ - - -#include -#include FT_FREETYPE_H - -#include "FTGL/ftgl.h" - - - -/** - * FTSize class provides an abstraction layer for the Freetype Size. - * - * @see "Freetype 2 Documentation" - * - */ -class FTSize -{ - public: - /** - * Default Constructor - */ - FTSize(); - - /** - * Destructor - */ - virtual ~FTSize(); - - /** - * Sets the char size for the current face. - * - * This doesn't guarantee that the size was set correctly. Clients - * should check errors. If an error does occur the size object isn't modified. - * - * @param face Parent face for this size object - * @param point_size the face size in points (1/72 inch) - * @param x_resolution the horizontal resolution of the target device. - * @param y_resolution the vertical resolution of the target device. - * @return true if the size has been set. Clients should check Error() for more information if this function returns false() - */ - bool CharSize(FT_Face* face, unsigned int point_size, - unsigned int x_resolution, unsigned int y_resolution); - - /** - * get the char size for the current face. - * - * @return The char size in points - */ - unsigned int CharSize() const; - - /** - * Gets the global ascender height for the face in pixels. - * - * @return Ascender height - */ - float Ascender() const; - - /** - * Gets the global descender height for the face in pixels. - * - * @return Ascender height - */ - float Descender() const; - - /** - * Gets the global face height for the face. - * - * If the face is scalable this returns the height of the global - * bounding box which ensures that any glyph will be less than or - * equal to this height. If the font isn't scalable there is no - * guarantee that glyphs will not be taller than this value. - * - * @return height in pixels. - */ - float Height() const; - - /** - * Gets the global face width for the face. - * - * If the face is scalable this returns the width of the global - * bounding box which ensures that any glyph will be less than or - * equal to this width. If the font isn't scalable this value is - * the max_advance for the face. - * - * @return width in pixels. - */ - float Width() const; - - /** - * Gets the underline position for the face. - * - * @return underline position in pixels - */ - float Underline() const; - - /** - * Queries for errors. - * - * @return The current error code. - */ - FT_Error Error() const { return err; } - - private: - /** - * The current Freetype face that this FTSize object relates to. - */ - FT_Face* ftFace; - - /** - * The Freetype size. - */ - FT_Size ftSize; - - /** - * The size in points. - */ - unsigned int size; - - /** - * The horizontal resolution. - */ - unsigned int xResolution; - - /** - * The vertical resolution. - */ - unsigned int yResolution; - - /** - * Current error code. Zero means no error. - */ - FT_Error err; - -}; - -#endif // __FTSize__ - +/* + * FTGL - OpenGL font library + * + * Copyright (c) 2001-2004 Henry Maddocks + * + * 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 __FTSize__ +#define __FTSize__ + + +#include +#include FT_FREETYPE_H + +#include "FTGL/ftgl.h" + + + +/** + * FTSize class provides an abstraction layer for the Freetype Size. + * + * @see "Freetype 2 Documentation" + * + */ +class FTSize +{ + public: + /** + * Default Constructor + */ + FTSize(); + + /** + * Destructor + */ + virtual ~FTSize(); + + /** + * Sets the char size for the current face. + * + * This doesn't guarantee that the size was set correctly. Clients + * should check errors. If an error does occur the size object isn't modified. + * + * @param face Parent face for this size object + * @param point_size the face size in points (1/72 inch) + * @param x_resolution the horizontal resolution of the target device. + * @param y_resolution the vertical resolution of the target device. + * @return true if the size has been set. Clients should check Error() for more information if this function returns false() + */ + bool CharSize(FT_Face* face, unsigned int point_size, + unsigned int x_resolution, unsigned int y_resolution); + + /** + * get the char size for the current face. + * + * @return The char size in points + */ + unsigned int CharSize() const; + + /** + * Gets the global ascender height for the face in pixels. + * + * @return Ascender height + */ + float Ascender() const; + + /** + * Gets the global descender height for the face in pixels. + * + * @return Ascender height + */ + float Descender() const; + + /** + * Gets the global face height for the face. + * + * If the face is scalable this returns the height of the global + * bounding box which ensures that any glyph will be less than or + * equal to this height. If the font isn't scalable there is no + * guarantee that glyphs will not be taller than this value. + * + * @return height in pixels. + */ + float Height() const; + + /** + * Gets the global face width for the face. + * + * If the face is scalable this returns the width of the global + * bounding box which ensures that any glyph will be less than or + * equal to this width. If the font isn't scalable this value is + * the max_advance for the face. + * + * @return width in pixels. + */ + float Width() const; + + /** + * Gets the underline position for the face. + * + * @return underline position in pixels + */ + float Underline() const; + + /** + * Queries for errors. + * + * @return The current error code. + */ + FT_Error Error() const { return err; } + + private: + /** + * The current Freetype face that this FTSize object relates to. + */ + FT_Face* ftFace; + + /** + * The Freetype size. + */ + FT_Size ftSize; + + /** + * The size in points. + */ + unsigned int size; + + /** + * The horizontal resolution. + */ + unsigned int xResolution; + + /** + * The vertical resolution. + */ + unsigned int yResolution; + + /** + * Current error code. Zero means no error. + */ + FT_Error err; + +}; + +#endif // __FTSize__ + diff --git a/bazaar/FTGL/src/config.h b/bazaar/FTGL/src/config.h index 77c6d629c..fdc19c1c4 100644 --- a/bazaar/FTGL/src/config.h +++ b/bazaar/FTGL/src/config.h @@ -1,5 +1,10 @@ -#ifndef _FTGL_config_h_ -#define _FTGL_config_h_ - - -#endif +#ifndef _FTGL_config_h_ +#define _FTGL_config_h_ + +#include + +#ifdef WIN32 +#define FTGL_LIBRARY_STATIC +#endif + +#endif