diff options
Diffstat (limited to 'src/ftgl/FTGL')
| -rw-r--r-- | src/ftgl/FTGL/FTBBox.h | 180 | ||||
| -rw-r--r-- | src/ftgl/FTGL/FTBitmapGlyph.h | 82 | ||||
| -rw-r--r-- | src/ftgl/FTGL/FTBuffer.h | 127 | ||||
| -rw-r--r-- | src/ftgl/FTGL/FTBufferFont.h | 99 | ||||
| -rw-r--r-- | src/ftgl/FTGL/FTBufferGlyph.h | 69 | ||||
| -rw-r--r-- | src/ftgl/FTGL/FTExtrdGlyph.h | 104 | ||||
| -rw-r--r-- | src/ftgl/FTGL/FTFont.h | 584 | ||||
| -rw-r--r-- | src/ftgl/FTGL/FTGLBitmapFont.h | 103 | ||||
| -rw-r--r-- | src/ftgl/FTGL/FTGLExtrdFont.h | 105 | ||||
| -rw-r--r-- | src/ftgl/FTGL/FTGLOutlineFont.h | 103 | ||||
| -rw-r--r-- | src/ftgl/FTGL/FTGLPixmapFont.h | 103 | ||||
| -rw-r--r-- | src/ftgl/FTGL/FTGLPolygonFont.h | 104 | ||||
| -rw-r--r-- | src/ftgl/FTGL/FTGLTextureFont.h | 103 | ||||
| -rw-r--r-- | src/ftgl/FTGL/FTGlyph.h | 201 | ||||
| -rw-r--r-- | src/ftgl/FTGL/FTLayout.h | 192 | ||||
| -rw-r--r-- | src/ftgl/FTGL/FTOutlineGlyph.h | 94 | ||||
| -rw-r--r-- | src/ftgl/FTGL/FTPixmapGlyph.h | 82 | ||||
| -rw-r--r-- | src/ftgl/FTGL/FTPoint.h | 274 | ||||
| -rw-r--r-- | src/ftgl/FTGL/FTPolyGlyph.h | 98 | ||||
| -rw-r--r-- | src/ftgl/FTGL/FTSimpleLayout.h | 191 | ||||
| -rw-r--r-- | src/ftgl/FTGL/FTTextureGlyph.h | 99 | ||||
| -rw-r--r-- | src/ftgl/FTGL/ftgl.h | 135 | 
22 files changed, 3232 insertions, 0 deletions
| diff --git a/src/ftgl/FTGL/FTBBox.h b/src/ftgl/FTGL/FTBBox.h new file mode 100644 index 0000000..858ff7a --- /dev/null +++ b/src/ftgl/FTGL/FTBBox.h @@ -0,0 +1,180 @@ +/* + * FTGL - OpenGL font library + * + * Copyright (c) 2001-2004 Henry Maddocks <ftgl@opengl.geek.nz> + * Copyright (c) 2008 Sam Hocevar <sam@zoy.org> + * 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 __FTBBox__ +#define __FTBBox__ + +#ifdef __cplusplus + + +/** + * FTBBox is a convenience class for handling bounding boxes. + */ +class FTGL_EXPORT FTBBox +{ +    public: +        /** +         * Default constructor. Bounding box is set to zero. +         */ +        FTBBox() +        :   lower(0.0f, 0.0f, 0.0f), +            upper(0.0f, 0.0f, 0.0f) +        {} + +        /** +         * Constructor. +         */ +        FTBBox(float lx, float ly, float lz, float ux, float uy, float uz) +        :   lower(lx, ly, lz), +            upper(ux, uy, uz) +        {} + +        /** +         * Constructor. +         */ +        FTBBox(FTPoint l, FTPoint u) +        :   lower(l), +            upper(u) +        {} + +        /** +         * Constructor. Extracts a bounding box from a freetype glyph. Uses +         * the control box for the glyph. <code>FT_Glyph_Get_CBox()</code> +         * +         * @param glyph A freetype glyph +         */ +        FTBBox(FT_GlyphSlot glyph) +        :   lower(0.0f, 0.0f, 0.0f), +            upper(0.0f, 0.0f, 0.0f) +        { +            FT_BBox bbox; +            FT_Outline_Get_CBox(&(glyph->outline), &bbox); + +            lower.X(static_cast<float>(bbox.xMin) / 64.0f); +            lower.Y(static_cast<float>(bbox.yMin) / 64.0f); +            lower.Z(0.0f); +            upper.X(static_cast<float>(bbox.xMax) / 64.0f); +            upper.Y(static_cast<float>(bbox.yMax) / 64.0f); +            upper.Z(0.0f); +        } + +        /** +         * Destructor +         */ +        ~FTBBox() +        {} + +        /** +         * Mark the bounds invalid by setting all lower dimensions greater +         * than the upper dimensions. +         */ +        void Invalidate() +        { +            lower = FTPoint(1.0f, 1.0f, 1.0f); +            upper = FTPoint(-1.0f, -1.0f, -1.0f); +        } + +        /** +         * Determines if this bounding box is valid. +         * +         * @return True if all lower values are <= the corresponding +         *         upper values. +         */ +        bool IsValid() +        { +            return lower.X() <= upper.X() +                && lower.Y() <= upper.Y() +                && lower.Z() <= upper.Z(); +        } + +        /** +         * Move the Bounding Box by a vector. +         * +         * @param vector  The vector to move the bbox in 3D space. +         */ +        FTBBox& operator += (const FTPoint vector) +        { +            lower += vector; +            upper += vector; + +            return *this; +        } + +        /** +         * Combine two bounding boxes. The result is the smallest bounding +         * box containing the two original boxes. +         * +         * @param bbox  The bounding box to merge with the second one. +         */ +        FTBBox& operator |= (const FTBBox& bbox) +        { +            if(bbox.lower.X() < lower.X()) lower.X(bbox.lower.X()); +            if(bbox.lower.Y() < lower.Y()) lower.Y(bbox.lower.Y()); +            if(bbox.lower.Z() < lower.Z()) lower.Z(bbox.lower.Z()); +            if(bbox.upper.X() > upper.X()) upper.X(bbox.upper.X()); +            if(bbox.upper.Y() > upper.Y()) upper.Y(bbox.upper.Y()); +            if(bbox.upper.Z() > upper.Z()) upper.Z(bbox.upper.Z()); + +            return *this; +        } + +        void SetDepth(float depth) +        { +            if(depth > 0) +                upper.Z(lower.Z() + depth); +            else +                lower.Z(upper.Z() + depth); +        } + + +        inline FTPoint const Upper() const +        { +            return upper; +        } + + +        inline FTPoint const Lower() const +        { +            return lower; +        } + +    private: +        /** +         * The bounds of the box +         */ +        FTPoint lower, upper; +}; + +#endif //__cplusplus + +#endif  //  __FTBBox__ + diff --git a/src/ftgl/FTGL/FTBitmapGlyph.h b/src/ftgl/FTGL/FTBitmapGlyph.h new file mode 100644 index 0000000..f8ef87f --- /dev/null +++ b/src/ftgl/FTGL/FTBitmapGlyph.h @@ -0,0 +1,82 @@ +/* + * FTGL - OpenGL font library + * + * Copyright (c) 2001-2004 Henry Maddocks <ftgl@opengl.geek.nz> + * Copyright (c) 2008 Sam Hocevar <sam@zoy.org> + * 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 __FTBitmapGlyph__ +#define __FTBitmapGlyph__ + +#ifdef __cplusplus + + +/** + * FTBitmapGlyph is a specialisation of FTGlyph for creating bitmaps. + */ +class FTGL_EXPORT FTBitmapGlyph : public FTGlyph +{ +    public: +        /** +         * Constructor +         * +         * @param glyph The Freetype glyph to be processed +         */ +        FTBitmapGlyph(FT_GlyphSlot glyph); + +        /** +         * Destructor +         */ +        virtual ~FTBitmapGlyph(); + +        /** +         * Render this glyph at the current pen position. +         * +         * @param pen  The current pen position. +         * @param renderMode  Render mode to display +         * @return  The advance distance for this glyph. +         */ +        virtual const FTPoint& Render(const FTPoint& pen, int renderMode); +}; + +#endif //__cplusplus + +FTGL_BEGIN_C_DECLS + +/** + * Create a specialisation of FTGLglyph for creating bitmaps. + * + * @param glyph The Freetype glyph to be processed + * @return  An FTGLglyph* object. + */ +FTGL_EXPORT FTGLglyph *ftglCreateBitmapGlyph(FT_GlyphSlot glyph); + +FTGL_END_C_DECLS + +#endif  //  __FTBitmapGlyph__ + diff --git a/src/ftgl/FTGL/FTBuffer.h b/src/ftgl/FTGL/FTBuffer.h new file mode 100644 index 0000000..11f33b5 --- /dev/null +++ b/src/ftgl/FTGL/FTBuffer.h @@ -0,0 +1,127 @@ +/* + * FTGL - OpenGL font library + * + * Copyright (c) 2008 Sam Hocevar <sam@zoy.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 Please use <FTGL/ftgl.h> instead of <FTBuffer.h>. +#   include <FTGL/ftgl.h> +#endif + +#ifndef __FTBuffer__ +#define __FTBuffer__ + +#ifdef __cplusplus + +/** + * FTBuffer is a helper class for pixel buffers. + * + * It provides the interface between FTBufferFont and FTBufferGlyph to + * optimise rendering operations. + * + * @see FTBufferGlyph + * @see FTBufferFont + */ +class FTGL_EXPORT FTBuffer +{ +    public: +        /** +         * Default constructor. +         */ +        FTBuffer(); + +        /** +         * Destructor +         */ +        ~FTBuffer(); + +        /** +         * Get the pen's position in the buffer. +         * +         * @return  The pen's position as an FTPoint object. +         */ +        inline FTPoint Pos() const +        { +            return pos; +        } + +        /** +         * Set the pen's position in the buffer. +         * +         * @param arg  An FTPoint object with the desired pen's position. +         */ +        inline void Pos(FTPoint arg) +        { +            pos = arg; +        } + +        /** +         * Set the buffer's size. +         * +         * @param w  The buffer's desired width, in pixels. +         * @param h  The buffer's desired height, in pixels. +         */ +        void Size(int w, int h); + +        /** +         * Get the buffer's width. +         * +         * @return  The buffer's width, in pixels. +         */ +        inline int Width() const { return width; } + +        /** +         * Get the buffer's height. +         * +         * @return  The buffer's height, in pixels. +         */ +        inline int Height() const { return height; } + +        /** +         * Get the buffer's direct pixel buffer. +         * +         * @return  A read-write pointer to the buffer's pixels. +         */ +        inline unsigned char *Pixels() const { return pixels; } + +    private: +        /** +         * Buffer's width and height. +         */ +        int width, height; + +        /** +         * Buffer's pixel buffer. +         */ +        unsigned char *pixels; + +        /** +         * Buffer's internal pen position. +         */ +        FTPoint pos; +}; + +#endif //__cplusplus + +#endif // __FTBuffer__ + diff --git a/src/ftgl/FTGL/FTBufferFont.h b/src/ftgl/FTGL/FTBufferFont.h new file mode 100644 index 0000000..15d358d --- /dev/null +++ b/src/ftgl/FTGL/FTBufferFont.h @@ -0,0 +1,99 @@ +/* + * FTGL - OpenGL font library + * + * Copyright (c) 2008 Sam Hocevar <sam@zoy.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 Please use <FTGL/ftgl.h> instead of <FTBufferFont.h>. +#   include <FTGL/ftgl.h> +#endif + +#ifndef __FTBufferFont__ +#define __FTBufferFont__ + +#ifdef __cplusplus + + +/** + * FTBufferFont is a specialisation of the FTFont class for handling + * memory buffer fonts. + * + * @see     FTFont + */ +class FTGL_EXPORT FTBufferFont : public FTFont +{ +    public: +        /** +         * Open and read a font file. Sets Error flag. +         * +         * @param fontFilePath  font file path. +         */ +        FTBufferFont(const char* fontFilePath); + +        /** +         * Open and read a font from a buffer in memory. Sets Error flag. +         * The buffer is owned by the client and is NOT copied by FTGL. The +         * pointer must be valid while using FTGL. +         * +         * @param pBufferBytes  the in-memory buffer +         * @param bufferSizeInBytes  the length of the buffer in bytes +         */ +        FTBufferFont(const unsigned char *pBufferBytes, +                     size_t bufferSizeInBytes); + +        /** +         * Destructor +         */ +        ~FTBufferFont(); + +    protected: +        /** +         * Construct a glyph of the correct type. +         * +         * Clients must override the function and return their specialised +         * FTGlyph. +         * +         * @param slot  A FreeType glyph slot. +         * @return  An FT****Glyph or <code>null</code> on failure. +         */ +        virtual FTGlyph* MakeGlyph(FT_GlyphSlot slot); +}; + +#endif //__cplusplus + +FTGL_BEGIN_C_DECLS + +/** + * Create a specialised FTGLfont object for handling memory buffer fonts. + * + * @param file  The font file name. + * @return  An FTGLfont* object. + * + * @see  FTGLfont + */ +FTGL_EXPORT FTGLfont *ftglCreateBufferFont(const char *file); + +FTGL_END_C_DECLS + +#endif  //  __FTBufferFont__ + diff --git a/src/ftgl/FTGL/FTBufferGlyph.h b/src/ftgl/FTGL/FTBufferGlyph.h new file mode 100644 index 0000000..cb7b3ed --- /dev/null +++ b/src/ftgl/FTGL/FTBufferGlyph.h @@ -0,0 +1,69 @@ +/* + * FTGL - OpenGL font library + * + * Copyright (c) 2008 Sam Hocevar <sam@zoy.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 Please use <FTGL/ftgl.h> instead of <FTBufferGlyph.h>. +#   include <FTGL/ftgl.h> +#endif + +#ifndef __FTBufferGlyph__ +#define __FTBufferGlyph__ + +#ifdef __cplusplus + + +/** + * FTBufferGlyph is a specialisation of FTGlyph for memory buffer rendering. + */ +class FTGL_EXPORT FTBufferGlyph : public FTGlyph +{ +    public: +        /** +         * Constructor +         * +         * @param glyph The Freetype glyph to be processed +         * @param buffer  An FTBuffer object in which to render the glyph. +         */ +        FTBufferGlyph(FT_GlyphSlot glyph, FTBuffer *buffer); + +        /** +         * Destructor +         */ +        virtual ~FTBufferGlyph(); + +        /** +         * Render this glyph at the current pen position. +         * +         * @param pen  The current pen position. +         * @param renderMode  Render mode to display +         * @return  The advance distance for this glyph. +         */ +        virtual const FTPoint& Render(const FTPoint& pen, int renderMode); +}; + +#endif //__cplusplus + +#endif  //  __FTBufferGlyph__ + diff --git a/src/ftgl/FTGL/FTExtrdGlyph.h b/src/ftgl/FTGL/FTExtrdGlyph.h new file mode 100644 index 0000000..c1eaa54 --- /dev/null +++ b/src/ftgl/FTGL/FTExtrdGlyph.h @@ -0,0 +1,104 @@ +/* + * FTGL - OpenGL font library + * + * Copyright (c) 2001-2004 Henry Maddocks <ftgl@opengl.geek.nz> + * Copyright (c) 2008 Sam Hocevar <sam@zoy.org> + * 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 __FTExtrudeGlyph__ +#define __FTExtrudeGlyph__ + +#ifdef __cplusplus + + +/** + * FTExtrudeGlyph is a specialisation of FTGlyph for creating tessellated + * extruded polygon glyphs. + */ +class FTGL_EXPORT FTExtrudeGlyph : public FTGlyph +{ +    public: +        /** +         * Constructor. Sets the Error to Invalid_Outline if the glyph isn't +         * an outline. +         * +         * @param glyph The Freetype glyph to be processed +         * @param depth The distance along the z axis to extrude the glyph +         * @param frontOutset outset contour size +         * @param backOutset outset contour size +         * @param useDisplayList Enable or disable the use of Display Lists +         *                       for this glyph +         *                       <code>true</code> turns ON display lists. +         *                       <code>false</code> turns OFF display lists. +         */ +        FTExtrudeGlyph(FT_GlyphSlot glyph, float depth, float frontOutset, +                       float backOutset, bool useDisplayList); + +        /** +         * Destructor +         */ +        virtual ~FTExtrudeGlyph(); + +        /** +         * Render this glyph at the current pen position. +         * +         * @param pen  The current pen position. +         * @param renderMode  Render mode to display +         * @return  The advance distance for this glyph. +         */ +        virtual const FTPoint& Render(const FTPoint& pen, int renderMode); +}; + +#define FTExtrdGlyph FTExtrudeGlyph + +#endif //__cplusplus + +FTGL_BEGIN_C_DECLS + +/** + * Create a specialisation of FTGLglyph for creating tessellated + * extruded polygon glyphs. + * + * @param glyph The Freetype glyph to be processed + * @param depth The distance along the z axis to extrude the glyph + * @param frontOutset outset contour size + * @param backOutset outset contour size + * @param useDisplayList Enable or disable the use of Display Lists + *                       for this glyph + *                       <code>true</code> turns ON display lists. + *                       <code>false</code> turns OFF display lists. + * @return  An FTGLglyph* object. + */ +FTGL_EXPORT FTGLglyph *ftglCreateExtrudeGlyph(FT_GlyphSlot glyph, float depth, +                                float frontOutset, float backOutset, +                                int useDisplayList); + +FTGL_END_C_DECLS + +#endif  //  __FTExtrudeGlyph__ + diff --git a/src/ftgl/FTGL/FTFont.h b/src/ftgl/FTGL/FTFont.h new file mode 100644 index 0000000..0799fff --- /dev/null +++ b/src/ftgl/FTGL/FTFont.h @@ -0,0 +1,584 @@ +/* + * FTGL - OpenGL font library + * + * Copyright (c) 2001-2004 Henry Maddocks <ftgl@opengl.geek.nz> + * Copyright (c) 2008 Sam Hocevar <sam@zoy.org> + * 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; + +/** + * FTFont is the public interface for the FTGL library. + * + * Specific font classes are derived from this class. It uses the helper + * classes FTFace and FTSize to access the Freetype library. This class + * is abstract and deriving classes must implement the protected + * <code>MakeGlyph</code> function to create glyphs of the + * appropriate type. + * + * It is good practice after using these functions to test the error + * code returned. <code>FT_Error Error()</code>. Check the freetype file + * fterrdef.h for error definitions. + * + * @see     FTFace + * @see     FTSize + */ +class FTGL_EXPORT FTFont +{ +    protected: +        /** +         * Open and read a font file. Sets Error flag. +         * +         * @param fontFilePath  font file path. +         */ +        FTFont(char const *fontFilePath); + +        /** +         * Open and read a font from a buffer in memory. Sets Error flag. +         * The buffer is owned by the client and is NOT copied by FTGL. The +         * pointer must be valid while using FTGL. +         * +         * @param pBufferBytes  the in-memory buffer +         * @param bufferSizeInBytes  the length of the buffer in bytes +         */ +        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; + +        /** +         * Internal FTGL FTFont constructor. For private use only. +         * +         * @param pImpl  Internal implementation object. Will be destroyed +         *               upon FTFont deletion. +         */ +        FTFont(FTFontImpl *pImpl); + +    public: +        virtual ~FTFont(); + +        /** +         * Attach auxilliary file to font e.g font metrics. +         * +         * Note: not all font formats implement this function. +         * +         * @param fontFilePath  auxilliary font file path. +         * @return          <code>true</code> if file has been attached +         *                  successfully. +         */ +        virtual bool Attach(const char* fontFilePath); + +        /** +         * Attach auxilliary data to font e.g font metrics, from memory. +         * +         * Note: not all font formats implement this function. +         * +         * @param pBufferBytes  the in-memory buffer. +         * @param bufferSizeInBytes  the length of the buffer in bytes. +         * @return          <code>true</code> if file has been attached +         *                  successfully. +         */ +        virtual bool Attach(const unsigned char *pBufferBytes, +                            size_t bufferSizeInBytes); + +        /** +         * Set the glyph loading flags. By default, fonts use the most +         * sensible flags when loading a font's glyph using FT_Load_Glyph(). +         * This function allows to override the default flags. +         * +         * @param flags  The glyph loading flags. +         */ +        virtual void GlyphLoadFlags(FT_Int flags); + +        /** +         * Set the character map for the face. +         * +         * @param encoding      Freetype enumerate for char map code. +         * @return              <code>true</code> if charmap was valid and +         *                      set correctly. +         */ +        virtual bool CharMap(FT_Encoding encoding); + +        /** +         * Get the number of character maps in this face. +         * +         * @return character map count. +         */ +        virtual unsigned int CharMapCount() const; + +        /** +         * Get a list of character maps in this face. +         * +         * @return pointer to the first encoding. +         */ +        virtual FT_Encoding* CharMapList(); + +        /** +         * Set the char size for the current face. +         * +         * @param size      the face size in points (1/72 inch) +         * @param res       the resolution of the target device. +         * @return          <code>true</code> if size was set correctly +         */ +        virtual bool FaceSize(const unsigned int size, +                              const unsigned int res = 72); + +        /** +         * Get the current face size in points (1/72 inch). +         * +         * @return face size +         */ +        virtual unsigned int FaceSize() const; + +        /** +         * Set the extrusion distance for the font. Only implemented by +         * FTExtrudeFont +         * +         * @param depth  The extrusion distance. +         */ +        virtual void Depth(float depth); + +        /** +         * Set the outset distance for the font. Only implemented by +         * FTOutlineFont, FTPolygonFont and FTExtrudeFont +         * +         * @param outset  The outset distance. +         */ +        virtual void Outset(float outset); + +        /** +         * Set the front and back outset distances for the font. Only +         * implemented by FTExtrudeFont +         * +         * @param front  The front outset distance. +         * @param back   The back outset distance. +         */ +        virtual void Outset(float front, float back); + +        /** +         * Enable or disable the use of Display Lists inside FTGL +         * +         * @param  useList <code>true</code> turns ON display lists. +         *                 <code>false</code> turns OFF display lists. +         */ +        virtual void UseDisplayList(bool useList); + +        /** +         * Get the global ascender height for the face. +         * +         * @return  Ascender height +         */ +        virtual float Ascender() const; + +        /** +         * Gets the global descender height for the face. +         * +         * @return  Descender height +         */ +        virtual float Descender() const; + +        /** +         * Gets the line spacing for the font. +         * +         * @return  Line height +         */ +        virtual float LineHeight() const; + +        /** +         * Get the bounding box for a string. +         * +         * @param string  A char buffer. +         * @param len  The length of the string. If < 0 then all characters +         *             will be checked until a null character is encountered +         *             (optional). +         * @param position  The pen position of the first character (optional). +         * @param spacing  A displacement vector to add after each character +         *                 has been checked (optional). +         * @return  The corresponding bounding box. +         */ +        virtual FTBBox BBox(const char *string, const int len = -1, +                            FTPoint position = FTPoint(), +                            FTPoint spacing = FTPoint()); + +        /** +         * Get the bounding box for a string (deprecated). +         * +         * @param string  A char buffer. +         * @param llx  Lower left near x coordinate. +         * @param lly  Lower left near y coordinate. +         * @param llz  Lower left near z coordinate. +         * @param urx  Upper right far x coordinate. +         * @param ury  Upper right far y coordinate. +         * @param urz  Upper right far z coordinate. +         */ +        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(); +        } + +        /** +         * Get the bounding box for a string. +         * +         * @param string  A wchar_t buffer. +         * @param len  The length of the string. If < 0 then all characters +         *             will be checked until a null character is encountered +         *             (optional). +         * @param position  The pen position of the first character (optional). +         * @param spacing  A displacement vector to add after each character +         *                 has been checked (optional). +         * @return  The corresponding bounding box. +         */ +        virtual FTBBox BBox(const wchar_t *string, const int len = -1, +                            FTPoint position = FTPoint(), +                            FTPoint spacing = FTPoint()); + +        /** +         * Get the bounding box for a string (deprecated). +         * +         * @param string  A wchar_t buffer. +         * @param llx  Lower left near x coordinate. +         * @param lly  Lower left near y coordinate. +         * @param llz  Lower left near z coordinate. +         * @param urx  Upper right far x coordinate. +         * @param ury  Upper right far y coordinate. +         * @param urz  Upper right far z coordinate. +         */ +        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(); +        } + +        /** +         * Get the advance for a string. +         * +         * @param string  'C' style string to be checked. +         * @param len  The length of the string. If < 0 then all characters +         *             will be checked until a null character is encountered +         *             (optional). +         * @param spacing  A displacement vector to add after each character +         *                 has been checked (optional). +         * @return  The string's advance width. +         */ +        virtual float Advance(const char* string, const int len = -1, +                              FTPoint spacing = FTPoint()); + +        /** +         * Get the advance for a string. +         * +         * @param string  A wchar_t string +         * @param len  The length of the string. If < 0 then all characters +         *             will be checked until a null character is encountered +         *             (optional). +         * @param spacing  A displacement vector to add after each character +         *                 has been checked (optional). +         * @return  The string's advance width. +         */ +        virtual float Advance(const wchar_t* string, const int len = -1, +                              FTPoint spacing = FTPoint()); + +        /** +         * Render a string of characters. +         * +         * @param string  'C' style string to be output. +         * @param len  The length of the string. If < 0 then all characters +         *             will be displayed until a null character is encountered +         *             (optional). +         * @param position  The pen position of the first character (optional). +         * @param spacing  A displacement vector to add after each character +         *                 has been displayed (optional). +         * @param renderMode  Render mode to use for display (optional). +         * @return  The new pen position after the last character was output. +         */ +        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 +         * +         * @param string    wchar_t string to be output. +         * @param len  The length of the string. If < 0 then all characters +         *             will be displayed until a null character is encountered +         *             (optional). +         * @param position  The pen position of the first character (optional). +         * @param spacing  A displacement vector to add after each character +         *                 has been displayed (optional). +         * @param renderMode  Render mode to use for display (optional). +         * @return  The new pen position after the last character was output. +         */ +        virtual FTPoint Render(const wchar_t *string, const int len = -1, +                               FTPoint position = FTPoint(), +                               FTPoint spacing = FTPoint(), +                               int renderMode = FTGL::RENDER_ALL); + +        /** +         * Queries the Font for errors. +         * +         * @return  The current error code. +         */ +        virtual FT_Error Error() const; + +    protected: +        /* Allow impl to access MakeGlyph */ +        friend class FTFontImpl; + +        /** +         * Construct a glyph of the correct type. +         * +         * Clients must override the function and return their specialised +         * FTGlyph. +         * +         * @param slot  A FreeType glyph slot. +         * @return  An FT****Glyph or <code>null</code> on failure. +         */ +        virtual FTGlyph* MakeGlyph(FT_GlyphSlot slot) = 0; + +    private: +        /** +         * Internal FTGL FTFont implementation object. For private use only. +         */ +        FTFontImpl *impl; +}; + +#endif //__cplusplus + +FTGL_BEGIN_C_DECLS + +/** + * FTGLfont is the public interface for the FTGL library. + * + * It is good practice after using these functions to test the error + * code returned. <code>FT_Error Error()</code>. Check the freetype file + * fterrdef.h for error definitions. + */ +struct _FTGLFont; +typedef struct _FTGLfont FTGLfont; + +/** + * Create a custom FTGL font object. + * + * @param fontFilePath  The font file name. + * @param data  A pointer to private data that will be passed to callbacks. + * @param makeglyphCallback  A glyph-making callback function. + * @return  An FTGLfont* object. + */ +FTGL_EXPORT FTGLfont *ftglCreateCustomFont(char const *fontFilePath, +                                           void *data, +                   FTGLglyph * (*makeglyphCallback) (FT_GlyphSlot, void *)); + +/** + * Destroy an FTGL font object. + * + * @param font  An FTGLfont* object. + */ +FTGL_EXPORT void ftglDestroyFont(FTGLfont* font); + +/** + * Attach auxilliary file to font e.g. font metrics. + * + * Note: not all font formats implement this function. + * + * @param font  An FTGLfont* object. + * @param path  Auxilliary font file path. + * @return  1 if file has been attached successfully. + */ +FTGL_EXPORT int ftglAttachFile(FTGLfont* font, const char* path); + +/** + * Attach auxilliary data to font, e.g. font metrics, from memory. + * + * Note: not all font formats implement this function. + * + * @param font  An FTGLfont* object. + * @param data  The in-memory buffer. + * @param size  The length of the buffer in bytes. + * @return  1 if file has been attached successfully. + */ +FTGL_EXPORT int ftglAttachData(FTGLfont* font, const unsigned char * data, +                               size_t size); + +/** + * Set the character map for the face. + * + * @param font  An FTGLfont* object. + * @param encoding  Freetype enumerate for char map code. + * @return  1 if charmap was valid and set correctly. + */ +FTGL_EXPORT int ftglSetFontCharMap(FTGLfont* font, FT_Encoding encoding); + +/** + * Get the number of character maps in this face. + * + * @param font  An FTGLfont* object. + * @return character map count. + */ +FTGL_EXPORT unsigned int ftglGetFontCharMapCount(FTGLfont* font); + +/** + * Get a list of character maps in this face. + * + * @param font  An FTGLfont* object. + * @return pointer to the first encoding. + */ +FTGL_EXPORT FT_Encoding* ftglGetFontCharMapList(FTGLfont* font); + +/** + * Set the char size for the current face. + * + * @param font  An FTGLfont* object. + * @param size  The face size in points (1/72 inch). + * @param res  The resolution of the target device, or 0 to use the default + *             value of 72. + * @return  1 if size was set correctly. + */ +FTGL_EXPORT int ftglSetFontFaceSize(FTGLfont* font, unsigned int size, +                                    unsigned int res); + +/** + * Get the current face size in points (1/72 inch). + * + * @param font  An FTGLfont* object. + * @return face size + */ +FTGL_EXPORT unsigned int ftglGetFontFaceSize(FTGLfont* font); + +/** + * Set the extrusion distance for the font. Only implemented by + * FTExtrudeFont. + * + * @param font  An FTGLfont* object. + * @param depth  The extrusion distance. + */ +FTGL_EXPORT void ftglSetFontDepth(FTGLfont* font, float depth); + +/** + * Set the outset distance for the font. Only FTOutlineFont, FTPolygonFont + * and FTExtrudeFont implement front outset. Only FTExtrudeFont implements + * back outset. + * + * @param font  An FTGLfont* object. + * @param front  The front outset distance. + * @param back  The back outset distance. + */ +FTGL_EXPORT void ftglSetFontOutset(FTGLfont* font, float front, float back); + +/** + * Enable or disable the use of Display Lists inside FTGL. + * + * @param font  An FTGLfont* object. + * @param useList  1 turns ON display lists. + *                 0 turns OFF display lists. + */ +FTGL_EXPORT void ftglSetFontDisplayList(FTGLfont* font, int useList); + +/** + * Get the global ascender height for the face. + * + * @param font  An FTGLfont* object. + * @return  Ascender height + */ +FTGL_EXPORT float ftglGetFontAscender(FTGLfont* font); + +/** + * Gets the global descender height for the face. + * + * @param font  An FTGLfont* object. + * @return  Descender height + */ +FTGL_EXPORT float ftglGetFontDescender(FTGLfont* font); + +/** + * Gets the line spacing for the font. + * + * @param font  An FTGLfont* object. + * @return  Line height + */ +FTGL_EXPORT float ftglGetFontLineHeight(FTGLfont* font); + +/** + * Get the bounding box for a string. + * + * @param font  An FTGLfont* object. + * @param string  A char buffer + * @param len  The length of the string. If < 0 then all characters will be + *             checked until a null character is encountered (optional). + * @param bounds  An array of 6 float values where the bounding box's lower + *                left near and upper right far 3D coordinates will be stored. + */ +FTGL_EXPORT void ftglGetFontBBox(FTGLfont* font, const char *string, +                                 int len, float bounds[6]); + +/** + * Get the advance width for a string. + * + * @param font  An FTGLfont* object. + * @param string  A char string. + * @return  Advance width + */ +FTGL_EXPORT float ftglGetFontAdvance(FTGLfont* font, const char *string); + +/** + * Render a string of characters. + * + * @param font  An FTGLfont* object. + * @param string  Char string to be output. + * @param mode  Render mode to display. + */ +FTGL_EXPORT void ftglRenderFont(FTGLfont* font, const char *string, int mode); + +/** + * Query a font for errors. + * + * @param font  An FTGLfont* object. + * @return  The current error code. + */ +FTGL_EXPORT FT_Error ftglGetFontError(FTGLfont* font); + +FTGL_END_C_DECLS + +#endif  //  __FTFont__ + diff --git a/src/ftgl/FTGL/FTGLBitmapFont.h b/src/ftgl/FTGL/FTGLBitmapFont.h new file mode 100644 index 0000000..d2fb1ba --- /dev/null +++ b/src/ftgl/FTGL/FTGLBitmapFont.h @@ -0,0 +1,103 @@ +/* + * FTGL - OpenGL font library + * + * Copyright (c) 2001-2004 Henry Maddocks <ftgl@opengl.geek.nz> + * Copyright (c) 2008 Sam Hocevar <sam@zoy.org> + * 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 __FTBitmapFont__ +#define __FTBitmapFont__ + +#ifdef __cplusplus + + +/** + * FTBitmapFont is a specialisation of the FTFont class for handling + * Bitmap fonts + * + * @see     FTFont + */ +class FTGL_EXPORT FTBitmapFont : public FTFont +{ +    public: +        /** +         * Open and read a font file. Sets Error flag. +         * +         * @param fontFilePath  font file path. +         */ +        FTBitmapFont(const char* fontFilePath); + +        /** +         * Open and read a font from a buffer in memory. Sets Error flag. +         * The buffer is owned by the client and is NOT copied by FTGL. The +         * pointer must be valid while using FTGL. +         * +         * @param pBufferBytes  the in-memory buffer +         * @param bufferSizeInBytes  the length of the buffer in bytes +         */ +        FTBitmapFont(const unsigned char *pBufferBytes, +                     size_t bufferSizeInBytes); + +        /** +         * Destructor +         */ +        ~FTBitmapFont(); + +    protected: +        /** +         * Construct a glyph of the correct type. +         * +         * Clients must override the function and return their specialised +         * FTGlyph. +         * +         * @param slot  A FreeType glyph slot. +         * @return  An FT****Glyph or <code>null</code> on failure. +         */ +        virtual FTGlyph* MakeGlyph(FT_GlyphSlot slot); +}; + +#define FTGLBitmapFont FTBitmapFont + +#endif //__cplusplus + +FTGL_BEGIN_C_DECLS + +/** + * Create a specialised FTGLfont object for handling bitmap fonts. + * + * @param file  The font file name. + * @return  An FTGLfont* object. + * + * @see  FTGLfont + */ +FTGL_EXPORT FTGLfont *ftglCreateBitmapFont(const char *file); + +FTGL_END_C_DECLS + +#endif  //  __FTBitmapFont__ + diff --git a/src/ftgl/FTGL/FTGLExtrdFont.h b/src/ftgl/FTGL/FTGLExtrdFont.h new file mode 100644 index 0000000..47d6714 --- /dev/null +++ b/src/ftgl/FTGL/FTGLExtrdFont.h @@ -0,0 +1,105 @@ +/* + * FTGL - OpenGL font library + * + * Copyright (c) 2001-2004 Henry Maddocks <ftgl@opengl.geek.nz> + * Copyright (c) 2008 Sam Hocevar <sam@zoy.org> + * 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 __FTExtrudeFont__ +#define __FTExtrudeFont__ + +#ifdef __cplusplus + + +/** + * FTExtrudeFont is a specialisation of the FTFont class for handling + * extruded Polygon fonts + * + * @see FTFont + * @see FTPolygonFont + */ +class FTGL_EXPORT FTExtrudeFont : public FTFont +{ +    public: +        /** +         * Open and read a font file. Sets Error flag. +         * +         * @param fontFilePath  font file path. +         */ +        FTExtrudeFont(const char* fontFilePath); + +        /** +         * Open and read a font from a buffer in memory. Sets Error flag. +         * The buffer is owned by the client and is NOT copied by FTGL. The +         * pointer must be valid while using FTGL. +         * +         * @param pBufferBytes  the in-memory buffer +         * @param bufferSizeInBytes  the length of the buffer in bytes +         */ +        FTExtrudeFont(const unsigned char *pBufferBytes, +                      size_t bufferSizeInBytes); + +        /** +         * Destructor +         */ +        ~FTExtrudeFont(); + +    protected: +        /** +         * Construct a glyph of the correct type. +         * +         * Clients must override the function and return their specialised +         * FTGlyph. +         * +         * @param slot  A FreeType glyph slot. +         * @return  An FT****Glyph or <code>null</code> on failure. +         */ +        virtual FTGlyph* MakeGlyph(FT_GlyphSlot slot); +}; + +#define FTGLExtrdFont FTExtrudeFont + +#endif //__cplusplus + +FTGL_BEGIN_C_DECLS + +/** + * Create a specialised FTGLfont object for handling extruded poygon fonts. + * + * @param file  The font file name. + * @return  An FTGLfont* object. + * + * @see  FTGLfont + * @see  ftglCreatePolygonFont + */ +FTGL_EXPORT FTGLfont *ftglCreateExtrudeFont(const char *file); + +FTGL_END_C_DECLS + +#endif // __FTExtrudeFont__ + diff --git a/src/ftgl/FTGL/FTGLOutlineFont.h b/src/ftgl/FTGL/FTGLOutlineFont.h new file mode 100644 index 0000000..bbf62da --- /dev/null +++ b/src/ftgl/FTGL/FTGLOutlineFont.h @@ -0,0 +1,103 @@ +/* + * FTGL - OpenGL font library + * + * Copyright (c) 2001-2004 Henry Maddocks <ftgl@opengl.geek.nz> + * Copyright (c) 2008 Sam Hocevar <sam@zoy.org> + * 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 __FTOutlineFont__ +#define __FTOutlineFont__ + +#ifdef __cplusplus + + +/** + * FTOutlineFont is a specialisation of the FTFont class for handling + * Vector Outline fonts + * + * @see     FTFont + */ +class FTGL_EXPORT FTOutlineFont : public FTFont +{ +    public: +        /** +         * Open and read a font file. Sets Error flag. +         * +         * @param fontFilePath  font file path. +         */ +        FTOutlineFont(const char* fontFilePath); + +        /** +         * Open and read a font from a buffer in memory. Sets Error flag. +         * The buffer is owned by the client and is NOT copied by FTGL. The +         * pointer must be valid while using FTGL. +         * +         * @param pBufferBytes  the in-memory buffer +         * @param bufferSizeInBytes  the length of the buffer in bytes +         */ +        FTOutlineFont(const unsigned char *pBufferBytes, +                      size_t bufferSizeInBytes); + +        /** +         * Destructor +         */ +        ~FTOutlineFont(); + +    protected: +        /** +         * Construct a glyph of the correct type. +         * +         * Clients must override the function and return their specialised +         * FTGlyph. +         * +         * @param slot  A FreeType glyph slot. +         * @return  An FT****Glyph or <code>null</code> on failure. +         */ +        virtual FTGlyph* MakeGlyph(FT_GlyphSlot slot); +}; + +#define FTGLOutlineFont FTOutlineFont + +#endif //__cplusplus + +FTGL_BEGIN_C_DECLS + +/** + * Create a specialised FTGLfont object for handling vector outline fonts. + * + * @param file  The font file name. + * @return  An FTGLfont* object. + * + * @see  FTGLfont + */ +FTGL_EXPORT FTGLfont *ftglCreateOutlineFont(const char *file); + +FTGL_END_C_DECLS + +#endif // __FTOutlineFont__ + diff --git a/src/ftgl/FTGL/FTGLPixmapFont.h b/src/ftgl/FTGL/FTGLPixmapFont.h new file mode 100644 index 0000000..c90b9c5 --- /dev/null +++ b/src/ftgl/FTGL/FTGLPixmapFont.h @@ -0,0 +1,103 @@ +/* + * FTGL - OpenGL font library + * + * Copyright (c) 2001-2004 Henry Maddocks <ftgl@opengl.geek.nz> + * Copyright (c) 2008 Sam Hocevar <sam@zoy.org> + * 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 __FTPixmapFont__ +#define __FTPixmapFont__ + +#ifdef __cplusplus + + +/** + * FTPixmapFont is a specialisation of the FTFont class for handling + * Pixmap (Grey Scale) fonts + * + * @see     FTFont + */ +class FTGL_EXPORT FTPixmapFont : public FTFont +{ +    public: +        /** +         * Open and read a font file. Sets Error flag. +         * +         * @param fontFilePath  font file path. +         */ +        FTPixmapFont(const char* fontFilePath); + +        /** +         * Open and read a font from a buffer in memory. Sets Error flag. +         * The buffer is owned by the client and is NOT copied by FTGL. The +         * pointer must be valid while using FTGL. +         * +         * @param pBufferBytes  the in-memory buffer +         * @param bufferSizeInBytes  the length of the buffer in bytes +         */ +        FTPixmapFont(const unsigned char *pBufferBytes, +                     size_t bufferSizeInBytes); + +        /** +         * Destructor +         */ +        ~FTPixmapFont(); + +    protected: +        /** +         * Construct a glyph of the correct type. +         * +         * Clients must override the function and return their specialised +         * FTGlyph. +         * +         * @param slot  A FreeType glyph slot. +         * @return  An FT****Glyph or <code>null</code> on failure. +         */ +        virtual FTGlyph* MakeGlyph(FT_GlyphSlot slot); +}; + +#define FTGLPixmapFont FTPixmapFont + +#endif // __cplusplus + +FTGL_BEGIN_C_DECLS + +/** + * Create a specialised FTGLfont object for handling pixmap (grey scale) fonts. + * + * @param file  The font file name. + * @return  An FTGLfont* object. + * + * @see  FTGLfont + */ +FTGL_EXPORT FTGLfont *ftglCreatePixmapFont(const char *file); + +FTGL_END_C_DECLS + +#endif  //  __FTPixmapFont__ + diff --git a/src/ftgl/FTGL/FTGLPolygonFont.h b/src/ftgl/FTGL/FTGLPolygonFont.h new file mode 100644 index 0000000..1dab097 --- /dev/null +++ b/src/ftgl/FTGL/FTGLPolygonFont.h @@ -0,0 +1,104 @@ +/* + * FTGL - OpenGL font library + * + * Copyright (c) 2001-2004 Henry Maddocks <ftgl@opengl.geek.nz> + * Copyright (c) 2008 Sam Hocevar <sam@zoy.org> + * 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 __FTPolygonFont__ +#define __FTPolygonFont__ + +#ifdef __cplusplus + + +/** + * FTPolygonFont is a specialisation of the FTFont class for handling + * tesselated Polygon Mesh fonts + * + * @see     FTFont + */ +class FTGL_EXPORT FTPolygonFont : public FTFont +{ +    public: +        /** +         * Open and read a font file. Sets Error flag. +         * +         * @param fontFilePath  font file path. +         */ +        FTPolygonFont(const char* fontFilePath); + +        /** +         * Open and read a font from a buffer in memory. Sets Error flag. +         * The buffer is owned by the client and is NOT copied by FTGL. The +         * pointer must be valid while using FTGL. +         * +         * @param pBufferBytes  the in-memory buffer +         * @param bufferSizeInBytes  the length of the buffer in bytes +         */ +        FTPolygonFont(const unsigned char *pBufferBytes, +                      size_t bufferSizeInBytes); + +        /** +         * Destructor +         */ +        ~FTPolygonFont(); + +    protected: +        /** +         * Construct a glyph of the correct type. +         * +         * Clients must override the function and return their specialised +         * FTGlyph. +         * +         * @param slot  A FreeType glyph slot. +         * @return  An FT****Glyph or <code>null</code> on failure. +         */ +        virtual FTGlyph* MakeGlyph(FT_GlyphSlot slot); +}; + +#define FTGLPolygonFont FTPolygonFont + +#endif //__cplusplus + +FTGL_BEGIN_C_DECLS + +/** + * Create a specialised FTGLfont object for handling tesselated polygon + * mesh fonts. + * + * @param file  The font file name. + * @return  An FTGLfont* object. + * + * @see  FTGLfont + */ +FTGL_EXPORT FTGLfont *ftglCreatePolygonFont(const char *file); + +FTGL_END_C_DECLS + +#endif  //  __FTPolygonFont__ + diff --git a/src/ftgl/FTGL/FTGLTextureFont.h b/src/ftgl/FTGL/FTGLTextureFont.h new file mode 100644 index 0000000..03991e9 --- /dev/null +++ b/src/ftgl/FTGL/FTGLTextureFont.h @@ -0,0 +1,103 @@ +/* + * FTGL - OpenGL font library + * + * Copyright (c) 2001-2004 Henry Maddocks <ftgl@opengl.geek.nz> + * Copyright (c) 2008 Sam Hocevar <sam@zoy.org> + * 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 __FTTextureFont__ +#define __FTTextureFont__ + +#ifdef __cplusplus + + +/** + * FTTextureFont is a specialisation of the FTFont class for handling + * Texture mapped fonts + * + * @see     FTFont + */ +class  FTGL_EXPORT FTTextureFont : public FTFont +{ +    public: +        /** +         * Open and read a font file. Sets Error flag. +         * +         * @param fontFilePath  font file path. +         */ +        FTTextureFont(const char* fontFilePath); + +        /** +         * Open and read a font from a buffer in memory. Sets Error flag. +         * The buffer is owned by the client and is NOT copied by FTGL. The +         * pointer must be valid while using FTGL. +         * +         * @param pBufferBytes  the in-memory buffer +         * @param bufferSizeInBytes  the length of the buffer in bytes +         */ +        FTTextureFont(const unsigned char *pBufferBytes, +                      size_t bufferSizeInBytes); + +        /** +         * Destructor +         */ +        virtual ~FTTextureFont(); + +    protected: +        /** +         * Construct a glyph of the correct type. +         * +         * Clients must override the function and return their specialised +         * FTGlyph. +         * +         * @param slot  A FreeType glyph slot. +         * @return  An FT****Glyph or <code>null</code> on failure. +         */ +        virtual FTGlyph* MakeGlyph(FT_GlyphSlot slot); +}; + +#define FTGLTextureFont FTTextureFont + +#endif //__cplusplus + +FTGL_BEGIN_C_DECLS + +/** + * Create a specialised FTGLfont object for handling texture-mapped fonts. + * + * @param file  The font file name. + * @return  An FTGLfont* object. + * + * @see  FTGLfont + */ +FTGL_EXPORT FTGLfont *ftglCreateTextureFont(const char *file); + +FTGL_END_C_DECLS + +#endif // __FTTextureFont__ + diff --git a/src/ftgl/FTGL/FTGlyph.h b/src/ftgl/FTGL/FTGlyph.h new file mode 100644 index 0000000..a5023b2 --- /dev/null +++ b/src/ftgl/FTGL/FTGlyph.h @@ -0,0 +1,201 @@ +/* + * FTGL - OpenGL font library + * + * Copyright (c) 2001-2004 Henry Maddocks <ftgl@opengl.geek.nz> + * Copyright (c) 2008 Sam Hocevar <sam@zoy.org> + * 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 __FTGlyph__ +#define __FTGlyph__ + +#ifdef __cplusplus + +class FTGlyphImpl; + +/** + * FTGlyph is the base class for FTGL glyphs. + * + * It provides the interface between Freetype glyphs and their openGL + * renderable counterparts. This is an abstract class and derived classes + * must implement the <code>Render</code> function. + * + * @see FTBBox + * @see FTPoint + */ +class FTGL_EXPORT FTGlyph +{ +    protected: +        /** +         * Create a glyph. +         * +         * @param glyph  The Freetype glyph to be processed +         */ +        FTGlyph(FT_GlyphSlot glyph); + +    private: +        /** +         * Internal FTGL FTGlyph constructor. For private use only. +         * +         * @param pImpl  Internal implementation object. Will be destroyed +         *               upon FTGlyph deletion. +         */ +        FTGlyph(FTGlyphImpl *pImpl); + +        /* Allow our internal subclasses to access the private constructor */ +        friend class FTBitmapGlyph; +        friend class FTBufferGlyph; +        friend class FTExtrudeGlyph; +        friend class FTOutlineGlyph; +        friend class FTPixmapGlyph; +        friend class FTPolygonGlyph; +        friend class FTTextureGlyph; + +    public: +        /** +          * Destructor +          */ +        virtual ~FTGlyph(); + +        /** +         * Renders this glyph at the current pen position. +         * +         * @param pen  The current pen position. +         * @param renderMode  Render mode to display +         * @return  The advance distance for this glyph. +         */ +        virtual const FTPoint& Render(const FTPoint& pen, int renderMode) = 0; + +        /** +         * Return the advance width for this glyph. +         * +         * @return  advance width. +         */ +        virtual float Advance() const; + +        /** +         * Return the bounding box for this glyph. +         * +         * @return  bounding box. +         */ +        virtual const FTBBox& BBox() const; + +        /** +         * Queries for errors. +         * +         * @return  The current error code. +         */ +        virtual FT_Error Error() const; + +    private: +        /** +         * Internal FTGL FTGlyph implementation object. For private use only. +         */ +        FTGlyphImpl *impl; +}; + +#endif //__cplusplus + +FTGL_BEGIN_C_DECLS + +/** + * FTGLglyph is the base class for FTGL glyphs. + * + * It provides the interface between Freetype glyphs and their openGL + * renderable counterparts. This is an abstract class and derived classes + * must implement the ftglRenderGlyph() function. + */ +struct _FTGLGlyph; +typedef struct _FTGLglyph FTGLglyph; + +/** + * Create a custom FTGL glyph object. + * FIXME: maybe get rid of "base" and have advanceCallback etc. functions + * + * @param base  The base FTGLglyph* to subclass. + * @param data  A pointer to private data that will be passed to callbacks. + * @param renderCallback  A rendering callback function. + * @param destroyCallback  A callback function to be called upon destruction. + * @return  An FTGLglyph* object. + */ +FTGL_EXPORT FTGLglyph *ftglCreateCustomGlyph(FTGLglyph *base, void *data, +    void (*renderCallback) (FTGLglyph *, void *, FTGL_DOUBLE, FTGL_DOUBLE, +                             int, FTGL_DOUBLE *, FTGL_DOUBLE *), +    void (*destroyCallback) (FTGLglyph *, void *)); + +/** + * Destroy an FTGL glyph object. + * + * @param glyph  An FTGLglyph* object. + */ +FTGL_EXPORT void ftglDestroyGlyph(FTGLglyph *glyph); + +/** + * Render a glyph at the current pen position and compute the corresponding + * advance. + * + * @param glyph  An FTGLglyph* object. + * @param penx  The current pen's X position. + * @param peny  The current pen's Y position. + * @param renderMode  Render mode to display + * @param advancex  A pointer to an FTGL_DOUBLE where to write the advance's X + *                  component. + * @param advancey  A pointer to an FTGL_DOUBLE where to write the advance's Y + *                  component. + */ +FTGL_EXPORT void ftglRenderGlyph(FTGLglyph *glyph, FTGL_DOUBLE penx, +                                 FTGL_DOUBLE peny, int renderMode, +                                 FTGL_DOUBLE *advancex, FTGL_DOUBLE *advancey); +/** + * Return the advance for a glyph. + * + * @param glyph  An FTGLglyph* object. + * @return  The advance's X component. + */ +FTGL_EXPORT float ftglGetGlyphAdvance(FTGLglyph *glyph); + +/** + * Return the bounding box for a glyph. + * + * @param glyph  An FTGLglyph* object. + * @param bounds  An array of 6 float values where the bounding box's lower + *                left near and upper right far 3D coordinates will be stored. + */ +FTGL_EXPORT void ftglGetGlyphBBox(FTGLglyph *glyph, float bounds[6]); + +/** + * Query a glyph for errors. + * + * @param glyph  An FTGLglyph* object. + * @return  The current error code. + */ +FTGL_EXPORT FT_Error ftglGetGlyphError(FTGLglyph* glyph); + +FTGL_END_C_DECLS + +#endif  //  __FTGlyph__ + diff --git a/src/ftgl/FTGL/FTLayout.h b/src/ftgl/FTGL/FTLayout.h new file mode 100644 index 0000000..329b98a --- /dev/null +++ b/src/ftgl/FTGL/FTLayout.h @@ -0,0 +1,192 @@ +/* + * FTGL - OpenGL font library + * + * Copyright (c) 2001-2004 Henry Maddocks <ftgl@opengl.geek.nz> + * Copyright (c) 2008 Sam Hocevar <sam@zoy.org> + * 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 __FTLayout__ +#define __FTLayout__ + +#ifdef __cplusplus + + +class FTLayoutImpl; + +/** + * FTLayout is the interface for layout managers that render text. + * + * Specific layout manager classes are derived from this class. This class + * is abstract and deriving classes must implement the protected + * <code>Render</code> methods to render formatted text and + * <code>BBox</code> methods to determine the bounding box of output text. + * + * @see     FTFont + * @see     FTBBox + */ +class FTGL_EXPORT FTLayout +{ +    protected: +        FTLayout(); + +    private: +        /** +         * Internal FTGL FTLayout constructor. For private use only. +         * +         * @param pImpl  Internal implementation object. Will be destroyed +         *               upon FTLayout deletion. +         */ +        FTLayout(FTLayoutImpl *pImpl); + +        /* Allow our internal subclasses to access the private constructor */ +        friend class FTSimpleLayout; + +    public: +        /** +         * Destructor +         */ +        virtual ~FTLayout(); + +        /** +         * Get the bounding box for a formatted string. +         * +         * @param string  A char string. +         * @param len  The length of the string. If < 0 then all characters +         *             will be checked until a null character is encountered +         *             (optional). +         * @param position  The pen position of the first character (optional). +         * @return  The corresponding bounding box. +         */ +        virtual FTBBox BBox(const char* string, const int len = -1, +                            FTPoint position = FTPoint()) = 0; + +        /** +         * Get the bounding box for a formatted string. +         * +         * @param string  A wchar_t string. +         * @param len  The length of the string. If < 0 then all characters +         *             will be checked until a null character is encountered +         *             (optional). +         * @param position  The pen position of the first character (optional). +         * @return  The corresponding bounding box. +         */ +        virtual FTBBox BBox(const wchar_t* string, const int len = -1, +                            FTPoint position = FTPoint()) = 0; + +        /** +         * Render a string of characters. +         * +         * @param string    'C' style string to be output. +         * @param len  The length of the string. If < 0 then all characters +         *             will be displayed until a null character is encountered +         *             (optional). +         * @param position  The pen position of the first character (optional). +         * @param renderMode  Render mode to display (optional) +         */ +        virtual void Render(const char *string, const int len = -1, +                            FTPoint position = FTPoint(), +                            int renderMode = FTGL::RENDER_ALL) = 0; + +        /** +         * Render a string of characters. +         * +         * @param string    wchar_t string to be output. +         * @param len  The length of the string. If < 0 then all characters +         *             will be displayed until a null character is encountered +         *             (optional). +         * @param position  The pen position of the first character (optional). +         * @param renderMode  Render mode to display (optional) +         */ +        virtual void Render(const wchar_t *string, const int len = -1, +                            FTPoint position = FTPoint(), +                            int renderMode = FTGL::RENDER_ALL) = 0; + +        /** +         * Queries the Layout for errors. +         * +         * @return  The current error code. +         */ +        virtual FT_Error Error() const; + +    private: +        /** +         * Internal FTGL FTLayout implementation object. For private use only. +         */ +        FTLayoutImpl *impl; +}; + +#endif //__cplusplus + +FTGL_BEGIN_C_DECLS + +/** + * FTGLlayout is the interface for layout managers that render text. + */ +struct _FTGLlayout; +typedef struct _FTGLlayout FTGLlayout; + +/** + * Destroy an FTGL layout object. + * + * @param layout  An FTGLlayout* object. + */ +FTGL_EXPORT void ftglDestroyLayout(FTGLlayout* layout); + +/** + * Get the bounding box for a string. + * + * @param layout  An FTGLlayout* object. + * @param string  A char buffer + * @param bounds  An array of 6 float values where the bounding box's lower + *                left near and upper right far 3D coordinates will be stored. + */ +FTGL_EXPORT void ftglGetLayoutBBox(FTGLlayout *layout, const char* string, +                                   float bounds[6]); + +/** + * Render a string of characters. + * + * @param layout  An FTGLlayout* object. + * @param string  Char string to be output. + * @param mode  Render mode to display. + */ +FTGL_EXPORT void ftglRenderLayout(FTGLlayout *layout, const char *string, +                                  int mode); + +/** + * Query a layout for errors. + * + * @param layout  An FTGLlayout* object. + * @return  The current error code. + */ +FTGL_EXPORT FT_Error ftglGetLayoutError(FTGLlayout* layout); + +FTGL_END_C_DECLS + +#endif  /* __FTLayout__ */ + diff --git a/src/ftgl/FTGL/FTOutlineGlyph.h b/src/ftgl/FTGL/FTOutlineGlyph.h new file mode 100644 index 0000000..2919139 --- /dev/null +++ b/src/ftgl/FTGL/FTOutlineGlyph.h @@ -0,0 +1,94 @@ +/* + * FTGL - OpenGL font library + * + * Copyright (c) 2001-2004 Henry Maddocks <ftgl@opengl.geek.nz> + * Copyright (c) 2008 Sam Hocevar <sam@zoy.org> + * 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 __FTOutlineGlyph__ +#define __FTOutlineGlyph__ + +#ifdef __cplusplus + + +/** + * FTOutlineGlyph is a specialisation of FTGlyph for creating outlines. + */ +class FTGL_EXPORT FTOutlineGlyph : public FTGlyph +{ +    public: +        /** +         * Constructor. Sets the Error to Invalid_Outline if the glyphs isn't +         * an outline. +         * +         * @param glyph The Freetype glyph to be processed +         * @param outset outset distance +         * @param useDisplayList Enable or disable the use of Display Lists +         *                       for this glyph +         *                       <code>true</code> turns ON display lists. +         *                       <code>false</code> turns OFF display lists. +         */ +        FTOutlineGlyph(FT_GlyphSlot glyph, float outset, bool useDisplayList); + +        /** +         * Destructor +         */ +        virtual ~FTOutlineGlyph(); + +        /** +         * Render this glyph at the current pen position. +         * +         * @param pen  The current pen position. +         * @param renderMode  Render mode to display +         * @return  The advance distance for this glyph. +         */ +        virtual const FTPoint& Render(const FTPoint& pen, int renderMode); +}; + +#endif //__cplusplus + +FTGL_BEGIN_C_DECLS + +/** + * Create a specialisation of FTGLglyph for creating outlines. + * + * @param glyph The Freetype glyph to be processed + * @param outset outset contour size + * @param useDisplayList Enable or disable the use of Display Lists + *                       for this glyph + *                       <code>true</code> turns ON display lists. + *                       <code>false</code> turns OFF display lists. + * @return  An FTGLglyph* object. + */ +FTGL_EXPORT FTGLglyph *ftglCreateOutlineGlyph(FT_GlyphSlot glyph, float outset, +                                  int useDisplayList); + +FTGL_END_C_DECLS + +#endif  // __FTOutlineGlyph__ + diff --git a/src/ftgl/FTGL/FTPixmapGlyph.h b/src/ftgl/FTGL/FTPixmapGlyph.h new file mode 100644 index 0000000..d9a317f --- /dev/null +++ b/src/ftgl/FTGL/FTPixmapGlyph.h @@ -0,0 +1,82 @@ +/* + * FTGL - OpenGL font library + * + * Copyright (c) 2001-2004 Henry Maddocks <ftgl@opengl.geek.nz> + * Copyright (c) 2008 Sam Hocevar <sam@zoy.org> + * 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 __FTPixmapGlyph__ +#define __FTPixmapGlyph__ + +#ifdef __cplusplus + + +/** + * FTPixmapGlyph is a specialisation of FTGlyph for creating pixmaps. + */ +class  FTGL_EXPORT FTPixmapGlyph : public FTGlyph +{ +    public: +        /** +         * Constructor +         * +         * @param glyph The Freetype glyph to be processed +         */ +        FTPixmapGlyph(FT_GlyphSlot glyph); + +        /** +         * Destructor +         */ +        virtual ~FTPixmapGlyph(); + +        /** +         * Render this glyph at the current pen position. +         * +         * @param pen  The current pen position. +         * @param renderMode  Render mode to display +         * @return  The advance distance for this glyph. +         */ +        virtual const FTPoint& Render(const FTPoint& pen, int renderMode); +}; + +#endif //__cplusplus + +FTGL_BEGIN_C_DECLS + +/** + * Create a specialisation of FTGLglyph for creating pixmaps. + * + * @param glyph The Freetype glyph to be processed + * @return  An FTGLglyph* object. + */ +FTGL_EXPORT FTGLglyph *ftglCreatePixmapGlyph(FT_GlyphSlot glyph); + +FTGL_END_C_DECLS + +#endif  //  __FTPixmapGlyph__ + diff --git a/src/ftgl/FTGL/FTPoint.h b/src/ftgl/FTGL/FTPoint.h new file mode 100644 index 0000000..fef4af6 --- /dev/null +++ b/src/ftgl/FTGL/FTPoint.h @@ -0,0 +1,274 @@ +/* + * FTGL - OpenGL font library + * + * Copyright (c) 2001-2004 Henry Maddocks <ftgl@opengl.geek.nz> + * Copyright (c) 2008 Sam Hocevar <sam@zoy.org> + * 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 __FTPoint__ +#define __FTPoint__ + +#ifdef __cplusplus + + +/** + * FTPoint class is a basic 3-dimensional point or vector. + */ +class FTGL_EXPORT FTPoint +{ +    public: +        /** +         * Default constructor. Point is set to zero. +         */ +        inline FTPoint() +        { +            values[0] = 0; +            values[1] = 0; +            values[2] = 0; +        } + +        /** +         * Constructor. Z coordinate is set to zero if unspecified. +         * +         * @param x First component +         * @param y Second component +         * @param z Third component +         */ +        inline FTPoint(const FTGL_DOUBLE x, const FTGL_DOUBLE y, +                       const FTGL_DOUBLE z = 0) +        { +            values[0] = x; +            values[1] = y; +            values[2] = z; +        } + +        /** +         * Constructor. This converts an FT_Vector to an FTPoint +         * +         * @param ft_vector A freetype vector +         */ +        inline FTPoint(const FT_Vector& ft_vector) +        { +            values[0] = ft_vector.x; +            values[1] = ft_vector.y; +            values[2] = 0; +        } + +        /** +         * Normalise a point's coordinates. If the coordinates are zero, +         * the point is left untouched. +         * +         * @return A vector of norm one. +         */ +        FTPoint Normalise(); + + +        /** +         * Operator += In Place Addition. +         * +         * @param point +         * @return this plus point. +         */ +        inline FTPoint& operator += (const FTPoint& point) +        { +            values[0] += point.values[0]; +            values[1] += point.values[1]; +            values[2] += point.values[2]; + +            return *this; +        } + +        /** +         * Operator + +         * +         * @param point +         * @return this plus point. +         */ +        inline FTPoint operator + (const FTPoint& point) const +        { +            FTPoint temp; +            temp.values[0] = values[0] + point.values[0]; +            temp.values[1] = values[1] + point.values[1]; +            temp.values[2] = values[2] + point.values[2]; + +            return temp; +        } + +         /** +         * Operator -= In Place Substraction. +         * +         * @param point +         * @return this minus point. +         */ +        inline FTPoint& operator -= (const FTPoint& point) +        { +            values[0] -= point.values[0]; +            values[1] -= point.values[1]; +            values[2] -= point.values[2]; + +            return *this; +        } + +        /** +         * Operator - +         * +         * @param point +         * @return this minus point. +         */ +        inline FTPoint operator - (const FTPoint& point) const +        { +            FTPoint temp; +            temp.values[0] = values[0] - point.values[0]; +            temp.values[1] = values[1] - point.values[1]; +            temp.values[2] = values[2] - point.values[2]; + +            return temp; +        } + +        /** +         * Operator *  Scalar multiplication +         * +         * @param multiplier +         * @return <code>this</code> multiplied by <code>multiplier</code>. +         */ +        inline FTPoint operator * (double multiplier) const +        { +            FTPoint temp; +            temp.values[0] = values[0] * multiplier; +            temp.values[1] = values[1] * multiplier; +            temp.values[2] = values[2] * multiplier; + +            return temp; +        } + + +        /** +         * Operator *  Scalar multiplication +         * +         * @param point +         * @param multiplier +         * @return <code>multiplier</code> multiplied by <code>point</code>. +         */ +        inline friend FTPoint operator * (double multiplier, FTPoint& point) +        { +            return point * multiplier; +        } + + +        /** +         * Operator *  Scalar product +         * +         * @param a  First vector. +         * @param b  Second vector. +         * @return  <code>a.b</code> scalar product. +         */ +        inline friend double operator * (FTPoint &a, FTPoint& b) +        { +            return a.values[0] * b.values[0] +                 + a.values[1] * b.values[1] +                 + a.values[2] * b.values[2]; +        } + + +        /** +         * Operator ^  Vector product +         * +         * @param point Second point +         * @return this vector point. +         */ +        inline FTPoint operator ^ (const FTPoint& point) +        { +            FTPoint temp; +            temp.values[0] = values[1] * point.values[2] +                              - values[2] * point.values[1]; +            temp.values[1] = values[2] * point.values[0] +                              - values[0] * point.values[2]; +            temp.values[2] = values[0] * point.values[1] +                              - values[1] * point.values[0]; +            return temp; +        } + + +        /** +         * Operator == Tests for equality +         * +         * @param a +         * @param b +         * @return true if a & b are equal +         */ +        friend bool operator == (const FTPoint &a, const FTPoint &b); + + +        /** +         * Operator != Tests for non equality +         * +         * @param a +         * @param b +         * @return true if a & b are not equal +         */ +        friend bool operator != (const FTPoint &a, const FTPoint &b); + + +        /** +         * Cast to FTGL_DOUBLE* +         */ +        inline operator const FTGL_DOUBLE*() const +        { +            return values; +        } + + +        /** +         * Setters +         */ +        inline void X(FTGL_DOUBLE x) { values[0] = x; }; +        inline void Y(FTGL_DOUBLE y) { values[1] = y; }; +        inline void Z(FTGL_DOUBLE z) { values[2] = z; }; + + +        /** +         * Getters +         */ +        inline FTGL_DOUBLE X() const { return values[0]; }; +        inline FTGL_DOUBLE Y() const { return values[1]; }; +        inline FTGL_DOUBLE Z() const { return values[2]; }; +        inline FTGL_FLOAT Xf() const { return static_cast<FTGL_FLOAT>(values[0]); }; +        inline FTGL_FLOAT Yf() const { return static_cast<FTGL_FLOAT>(values[1]); }; +        inline FTGL_FLOAT Zf() const { return static_cast<FTGL_FLOAT>(values[2]); }; + +    private: +        /** +         * The point data +         */ +        FTGL_DOUBLE values[3]; +}; + +#endif //__cplusplus + +#endif  //  __FTPoint__ + diff --git a/src/ftgl/FTGL/FTPolyGlyph.h b/src/ftgl/FTGL/FTPolyGlyph.h new file mode 100644 index 0000000..ce3b000 --- /dev/null +++ b/src/ftgl/FTGL/FTPolyGlyph.h @@ -0,0 +1,98 @@ +/* + * FTGL - OpenGL font library + * + * Copyright (c) 2001-2004 Henry Maddocks <ftgl@opengl.geek.nz> + * Copyright (c) 2008 Sam Hocevar <sam@zoy.org> + * 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 __FTPolygonGlyph__ +#define __FTPolygonGlyph__ + +#ifdef __cplusplus + + +/** + * FTPolygonGlyph is a specialisation of FTGlyph for creating tessellated + * polygon glyphs. + */ +class FTGL_EXPORT FTPolygonGlyph : public FTGlyph +{ +    public: +        /** +         * Constructor. Sets the Error to Invalid_Outline if the glyphs +         * isn't an outline. +         * +         * @param glyph The Freetype glyph to be processed +         * @param outset  The outset distance +         * @param useDisplayList Enable or disable the use of Display Lists +         *                       for this glyph +         *                       <code>true</code> turns ON display lists. +         *                       <code>false</code> turns OFF display lists. +         */ +        FTPolygonGlyph(FT_GlyphSlot glyph, float outset, bool useDisplayList); + +        /** +         * Destructor +         */ +        virtual ~FTPolygonGlyph(); + +        /** +         * Render this glyph at the current pen position. +         * +         * @param pen  The current pen position. +         * @param renderMode  Render mode to display +         * @return  The advance distance for this glyph. +         */ +        virtual const FTPoint& Render(const FTPoint& pen, int renderMode); +}; + +#define FTPolyGlyph FTPolygonGlyph + +#endif //__cplusplus + +FTGL_BEGIN_C_DECLS + +/** + * Create a specialisation of FTGLglyph for creating tessellated + * polygon glyphs. + * + * @param glyph The Freetype glyph to be processed + * @param outset outset contour size + * @param useDisplayList Enable or disable the use of Display Lists + *                       for this glyph + *                       <code>true</code> turns ON display lists. + *                       <code>false</code> turns OFF display lists. + * @return  An FTGLglyph* object. + */ +FTGL_EXPORT FTGLglyph *ftglCreatePolygonGlyph(FT_GlyphSlot glyph, float outset, +                                              int useDisplayList); + +FTGL_END_C_DECLS + +#endif  //  __FTPolygonGlyph__ + diff --git a/src/ftgl/FTGL/FTSimpleLayout.h b/src/ftgl/FTGL/FTSimpleLayout.h new file mode 100644 index 0000000..c778b18 --- /dev/null +++ b/src/ftgl/FTGL/FTSimpleLayout.h @@ -0,0 +1,191 @@ +/* + * FTGL - OpenGL font library + * + * Copyright (c) 2001-2004 Henry Maddocks <ftgl@opengl.geek.nz> + * Copyright (c) 2008 Sam Hocevar <sam@zoy.org> + * 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 __FTSimpleLayout__ +#define __FTSimpleLayout__ + +#ifdef __cplusplus + + +class FTFont; + +/** + * FTSimpleLayout is a specialisation of FTLayout for simple text boxes. + * + * This class has basic support for text wrapping, left, right and centered + * alignment, and text justification. + * + * @see     FTLayout + */ +class FTGL_EXPORT FTSimpleLayout : public FTLayout +{ +    public: +        /** +         * Initializes line spacing to 1.0, alignment to +         * ALIGN_LEFT and wrap to 100.0 +         */ +        FTSimpleLayout(); + +        /** +         * Destructor +         */ +        ~FTSimpleLayout(); + +        /** +         * Get the bounding box for a formatted string. +         * +         * @param string  A char string. +         * @param len  The length of the string. If < 0 then all characters +         *             will be checked until a null character is encountered +         *             (optional). +         * @param position  The pen position of the first character (optional). +         * @return  The corresponding bounding box. +         */ +        virtual FTBBox BBox(const char* string, const int len = -1, +                            FTPoint position = FTPoint()); + +        /** +         * Get the bounding box for a formatted string. +         * +         * @param string  A wchar_t string. +         * @param len  The length of the string. If < 0 then all characters +         *             will be checked until a null character is encountered +         *             (optional). +         * @param position  The pen position of the first character (optional). +         * @return  The corresponding bounding box. +         */ +        virtual FTBBox BBox(const wchar_t* string, const int len = -1, +                            FTPoint position = FTPoint()); + +        /** +         * Render a string of characters. +         * +         * @param string    'C' style string to be output. +         * @param len  The length of the string. If < 0 then all characters +         *             will be displayed until a null character is encountered +         *             (optional). +         * @param position  The pen position of the first character (optional). +         * @param renderMode  Render mode to display (optional) +         */ +        virtual void Render(const char *string, const int len = -1, +                            FTPoint position = FTPoint(), +                            int renderMode = FTGL::RENDER_ALL); + +        /** +         * Render a string of characters. +         * +         * @param string    wchar_t string to be output. +         * @param len  The length of the string. If < 0 then all characters +         *             will be displayed until a null character is encountered +         *             (optional). +         * @param position  The pen position of the first character (optional). +         * @param renderMode  Render mode to display (optional) +         */ +        virtual void Render(const wchar_t *string, const int len = -1, +                            FTPoint position = FTPoint(), +                            int renderMode = FTGL::RENDER_ALL); + +        /** +         * Set the font to use for rendering the text. +         * +         * @param fontInit A pointer to the new font.  The font is +         *                 referenced by this but will not be +         *                 disposed of when this is deleted. +         */ +        void SetFont(FTFont *fontInit); + +        /** +         * @return The current font. +         */ +        FTFont *GetFont(); + +        /** +         * The maximum line length for formatting text. +         * +         * @param LineLength The new line length. +         */ +        void SetLineLength(const float LineLength); + +        /** +         * @return The current line length. +         */ +        float GetLineLength() const; + +        /** +         * The text alignment mode used to distribute +         * space within a line or rendered text. +         * +         * @param Alignment The new alignment mode. +         */ +        void SetAlignment(const FTGL::TextAlignment Alignment); + +        /** +         * @return The text alignment mode. +         */ +        FTGL::TextAlignment GetAlignment() const; + +        /** +         * Sets the line height. +         * +         * @param LineSpacing The height of each line of text expressed as +         *                    a percentage of the current fonts line height. +         */ +        void SetLineSpacing(const float LineSpacing); + +        /** +         * @return The line spacing. +         */ +        float GetLineSpacing() const; +}; + +#endif //__cplusplus + +FTGL_BEGIN_C_DECLS + +FTGL_EXPORT FTGLlayout *ftglCreateSimpleLayout(void); + +FTGL_EXPORT void ftglSetLayoutFont(FTGLlayout *, FTGLfont*); +FTGL_EXPORT FTGLfont *ftglGetLayoutFont(FTGLlayout *); + +FTGL_EXPORT void ftglSetLayoutLineLength(FTGLlayout *, const float); +FTGL_EXPORT float ftglGetLayoutLineLength(FTGLlayout *); + +FTGL_EXPORT void ftglSetLayoutAlignment(FTGLlayout *, const int); +FTGL_EXPORT int ftglGetLayoutAlignement(FTGLlayout *); + +FTGL_EXPORT void ftglSetLayoutLineSpacing(FTGLlayout *, const float); +FTGL_EXPORT float ftglGetLayoutLineSpacing(FTGLlayout *); + +FTGL_END_C_DECLS + +#endif  /* __FTSimpleLayout__ */ + diff --git a/src/ftgl/FTGL/FTTextureGlyph.h b/src/ftgl/FTGL/FTTextureGlyph.h new file mode 100644 index 0000000..ec545f3 --- /dev/null +++ b/src/ftgl/FTGL/FTTextureGlyph.h @@ -0,0 +1,99 @@ +/* + * FTGL - OpenGL font library + * + * Copyright (c) 2001-2004 Henry Maddocks <ftgl@opengl.geek.nz> + * Copyright (c) 2008 Sam Hocevar <sam@zoy.org> + * 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 __FTTextureGlyph__ +#define __FTTextureGlyph__ + +#ifdef __cplusplus + + +/** + * FTTextureGlyph is a specialisation of FTGlyph for creating texture + * glyphs. + */ +class FTGL_EXPORT FTTextureGlyph : public FTGlyph +{ +    public: +        /** +         * Constructor +         * +         * @param glyph     The Freetype glyph to be processed +         * @param id        The id of the texture that this glyph will be +         *                  drawn in +         * @param xOffset   The x offset into the parent texture to draw +         *                  this glyph +         * @param yOffset   The y offset into the parent texture to draw +         *                  this glyph +         * @param width     The width of the parent texture +         * @param height    The height (number of rows) of the parent texture +         */ +        FTTextureGlyph(FT_GlyphSlot glyph, int id, int xOffset, int yOffset, +                       int width, int height); + +        /** +         * Destructor +         */ +        virtual ~FTTextureGlyph(); + +        /** +         * Render this glyph at the current pen position. +         * +         * @param pen  The current pen position. +         * @param renderMode  Render mode to display +         * @return  The advance distance for this glyph. +         */ +        virtual const FTPoint& Render(const FTPoint& pen, int renderMode); +}; + +#endif //__cplusplus + +FTGL_BEGIN_C_DECLS + +/** + * Create a specialisation of FTGLglyph for creating pixmaps. + * + * @param glyph The Freetype glyph to be processed. + * @param id  The id of the texture that this glyph will be drawn in. + * @param xOffset  The x offset into the parent texture to draw this glyph. + * @param yOffset  The y offset into the parent texture to draw this glyph. + * @param width  The width of the parent texture. + * @param height  The height (number of rows) of the parent texture. + * @return  An FTGLglyph* object. + */ +FTGL_EXPORT FTGLglyph *ftglCreateTextureGlyph(FT_GlyphSlot glyph, int id, +                                              int xOffset, int yOffset, +                                              int width, int height); + +FTGL_END_C_DECLS + +#endif  //  __FTTextureGlyph__ + diff --git a/src/ftgl/FTGL/ftgl.h b/src/ftgl/FTGL/ftgl.h new file mode 100644 index 0000000..f5d043c --- /dev/null +++ b/src/ftgl/FTGL/ftgl.h @@ -0,0 +1,135 @@ +/* + * FTGL - OpenGL font library + * + * Copyright (c) 2001-2004 Henry Maddocks <ftgl@opengl.geek.nz> + * Copyright (c) 2008 Sam Hocevar <sam@zoy.org> + * 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__ +#define __ftgl__ + +/* We need the Freetype headers */ +#include <ft2build.h> +#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 <FTGL/FTPoint.h> +#include <FTGL/FTBBox.h> +#include <FTGL/FTBuffer.h> + +#include <FTGL/FTGlyph.h> +#include <FTGL/FTBitmapGlyph.h> +#include <FTGL/FTBufferGlyph.h> +#include <FTGL/FTExtrdGlyph.h> +#include <FTGL/FTOutlineGlyph.h> +#include <FTGL/FTPixmapGlyph.h> +#include <FTGL/FTPolyGlyph.h> +#include <FTGL/FTTextureGlyph.h> + +#include <FTGL/FTFont.h> +#include <FTGL/FTGLBitmapFont.h> +#include <FTGL/FTBufferFont.h> +#include <FTGL/FTGLExtrdFont.h> +#include <FTGL/FTGLOutlineFont.h> +#include <FTGL/FTGLPixmapFont.h> +#include <FTGL/FTGLPolygonFont.h> +#include <FTGL/FTGLTextureFont.h> + +#include <FTGL/FTLayout.h> +#include <FTGL/FTSimpleLayout.h> + +#endif  //  __ftgl__ | 
