Changed the return type of FTFace::Glyph() from a reference to a pointer so I can return NULL on failure.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
diff --git a/include/FTFace.h b/include/FTFace.h
index c909463..1c9494b 100755
--- a/include/FTFace.h
+++ b/include/FTFace.h
@@ -52,8 +52,8 @@ class FTFace
* This doesn't guarantee that the size was set correctly. Clients
* should check errors.
*
- * @params size the face size in points (1/72 inch)
- * @params res the resolution of the target device.
+ * @param size the face size in points (1/72 inch)
+ * @param res the resolution of the target device.
* @return <code>FTSize</code> object
*/
FTSize& Size( const unsigned int size, const unsigned int res);
@@ -61,7 +61,7 @@ class FTFace
/**
* Sets the character map for the face.
*
- * @params encoding XXXXXXX
+ * @param encoding XXXXXXX
* @return <code>true</code> if charmap was valid and
* set correctly
*/
@@ -70,13 +70,14 @@ class FTFace
/**
* Get the glyph index of the input character.
*
- * @param
- * @return
+ * @param index The character code of the requested glyph in the
+ * current encoding eg apple roman.
+ * @return The glyph index for the character.
*/
unsigned int CharIndex( unsigned int index ) const;
/**
- * Gets the ferning vector between two glyphs
+ * Gets the kerning vector between two glyphs
*/
FT_Vector& KernAdvance( unsigned int index1, unsigned int index2);
@@ -84,7 +85,7 @@ class FTFace
/**
* Loads and creates a Freetype glyph.
*/
- FT_Glyph& Glyph( unsigned int index, FT_Int load_flags);
+ FT_Glyph* Glyph( unsigned int index, FT_Int load_flags);
/**
* Gets the current Freetype face.
diff --git a/src/FTFace.cpp b/src/FTFace.cpp
index 24d6dea..8be3cd0 100755
--- a/src/FTFace.cpp
+++ b/src/FTFace.cpp
@@ -122,18 +122,18 @@ FT_Vector& FTFace::KernAdvance( unsigned int index1, unsigned int index2 )
}
-FT_Glyph& FTFace::Glyph( unsigned int index, FT_Int load_flags)
+FT_Glyph* FTFace::Glyph( unsigned int index, FT_Int load_flags)
{
err = FT_Load_Glyph( *ftFace, index, load_flags);
err = FT_Get_Glyph( (*ftFace)->glyph, &ftGlyph);
if( !err)
{
- return ftGlyph;
+ return &ftGlyph;
}
else
{
- return NULL; // FIXME
+ return NULL;
}
}
diff --git a/src/FTGLBitmapFont.cpp b/src/FTGLBitmapFont.cpp
index 82116fe..53d3cca 100755
--- a/src/FTGLBitmapFont.cpp
+++ b/src/FTGLBitmapFont.cpp
@@ -20,10 +20,10 @@ bool FTGLBitmapFont::MakeGlyphList()
// if( preCache)
for( unsigned int c = 0; c < numGlyphs; ++c)
{
- FT_Glyph ftGlyph = face.Glyph( c, FT_LOAD_DEFAULT);
+ FT_Glyph* ftGlyph = face.Glyph( c, FT_LOAD_DEFAULT);
// FT_HAS_VERTICAL(face)
- tempGlyph = new FTBitmapGlyph( ftGlyph, c);
+ tempGlyph = new FTBitmapGlyph( *ftGlyph, c);
glyphList->Add( tempGlyph);
}
diff --git a/src/FTGLOutlineFont.cpp b/src/FTGLOutlineFont.cpp
index bc05bf2..8466e43 100755
--- a/src/FTGLOutlineFont.cpp
+++ b/src/FTGLOutlineFont.cpp
@@ -19,9 +19,9 @@ bool FTGLOutlineFont::MakeGlyphList()
{
for( unsigned int n = 0; n < numGlyphs; ++n)
{
- FT_Glyph ftGlyph = face.Glyph( n, FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP);
+ FT_Glyph* ftGlyph = face.Glyph( n, FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP);
- tempGlyph = new FTVectorGlyph( ftGlyph, n);
+ tempGlyph = new FTVectorGlyph( *ftGlyph, n);
glyphList->Add( tempGlyph);
}
diff --git a/src/FTGLPixmapFont.cpp b/src/FTGLPixmapFont.cpp
index 2880c0c..19aa5de 100755
--- a/src/FTGLPixmapFont.cpp
+++ b/src/FTGLPixmapFont.cpp
@@ -20,10 +20,10 @@ bool FTGLPixmapFont::MakeGlyphList()
// if( preCache)
for( unsigned int c = 0; c < numGlyphs; ++c)
{
- FT_Glyph ftGlyph = face.Glyph( c, FT_LOAD_DEFAULT);
+ FT_Glyph* ftGlyph = face.Glyph( c, FT_LOAD_DEFAULT);
// FT_HAS_VERTICAL(face)
- tempGlyph = new FTPixmapGlyph( ftGlyph, c);
+ tempGlyph = new FTPixmapGlyph( *ftGlyph, c);
glyphList->Add( tempGlyph);
}
diff --git a/src/FTGLPolygonFont.cpp b/src/FTGLPolygonFont.cpp
index de574f2..54df152 100755
--- a/src/FTGLPolygonFont.cpp
+++ b/src/FTGLPolygonFont.cpp
@@ -18,9 +18,9 @@ bool FTGLPolygonFont::MakeGlyphList()
{
for( unsigned int n = 0; n < numGlyphs; ++n)
{
- FT_Glyph ftGlyph = face.Glyph( n, FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP);
+ FT_Glyph* ftGlyph = face.Glyph( n, FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP);
- tempGlyph = new FTPolyGlyph( ftGlyph, n);
+ tempGlyph = new FTPolyGlyph( *ftGlyph, n);
glyphList->Add( tempGlyph);
}
diff --git a/src/FTGLTextureFont.cpp b/src/FTGLTextureFont.cpp
index 2ec77bf..d191db1 100755
--- a/src/FTGLTextureFont.cpp
+++ b/src/FTGLTextureFont.cpp
@@ -115,13 +115,13 @@ unsigned int FTGLTextureFont::FillGlyphs( unsigned int glyphStart, int id, int w
for( n = glyphStart; n <= numGlyphs; ++n)
{
- FT_Glyph ftGlyph = face.Glyph( n, FT_LOAD_NO_HINTING);
+ FT_Glyph* ftGlyph = face.Glyph( n, FT_LOAD_NO_HINTING);
unsigned char* data = textdata + (( currentTextY * width) + currentTextX);
currTextU = (float)currentTextX / (float)width;
- tempGlyph = new FTTextureGlyph( ftGlyph, n, id, data, width, height, currTextU, currTextV);
+ tempGlyph = new FTTextureGlyph( *ftGlyph, n, id, data, width, height, currTextU, currTextV);
glyphList->Add( tempGlyph);
currentTextX += glyphWidth;