Commit 57ca18fb34a00349db71901c6ff5ff753de888b8

henry 2002-12-01T07:52:12

Better error handling

diff --git a/src/FTFace.cpp b/src/FTFace.cpp
index b6ae66b..18162fb 100755
--- a/src/FTFace.cpp
+++ b/src/FTFace.cpp
@@ -83,11 +83,9 @@ void FTFace::Close()
 
 FTSize& FTFace::Size( const unsigned int size, const unsigned int res)
 {
-    if( !charSize.CharSize( ftFace, size, res, res))
-    {
-        err = charSize.Error();
-    }
-    
+    charSize.CharSize( ftFace, size, res, res);
+    err = charSize.Error();
+
     return charSize;
 }
 
diff --git a/src/FTSize.cpp b/src/FTSize.cpp
index a9ad747..15f7d0b 100755
--- a/src/FTSize.cpp
+++ b/src/FTSize.cpp
@@ -3,6 +3,7 @@
 
 FTSize::FTSize()
 :   ftFace(0),
+    ftSize(0),
     size(0),
     err(0)
 {}
@@ -14,11 +15,20 @@ FTSize::~FTSize()
 
 bool FTSize::CharSize( FT_Face* face, unsigned int point_size, unsigned int x_resolution, unsigned int y_resolution )
 {
-    ftFace = face;
-    size = point_size;
     err = FT_Set_Char_Size( *ftFace, 0L, point_size * 64, x_resolution, y_resolution);
-    
-    ftSize = (*ftFace)->size;
+
+    if( !err)
+    {
+        ftFace = face;
+        size = point_size;
+        ftSize = (*ftFace)->size;
+    }
+    else
+    {
+        ftFace = 0;
+        size = 0;
+        ftSize = 0;
+    }
     
     return !err;
 }
@@ -32,18 +42,23 @@ unsigned int FTSize::CharSize() const
 
 int FTSize::Ascender() const
 {
-    return ftSize->metrics.ascender >> 6;
+    return ftSize == 0 ? 0 : ftSize->metrics.ascender >> 6;
 }
 
 
 int FTSize::Descender() const
 {
-    return ftSize->metrics.descender >> 6;
+    return ftSize == 0 ? 0 : ftSize->metrics.descender >> 6;
 }
 
 
 int FTSize::Height() const
 {
+    if( ftSize == 0)
+    {
+        return 0;
+    }
+    
     if( FT_IS_SCALABLE((*ftFace)))
     {
         float height = ( (*ftFace)->bbox.yMax - (*ftFace)->bbox.yMin)
@@ -60,6 +75,11 @@ int FTSize::Height() const
 
 int FTSize::Width() const
 {
+    if( ftSize == 0)
+    {
+        return 0;
+    }
+    
     if( FT_IS_SCALABLE((*ftFace)))
     {
         float width = ( (*ftFace)->bbox.xMax - (*ftFace)->bbox.xMin)