Commit 3823a30a149bf6127d0a8d7ec18d1d7c4d8496ff

sammy 2008-05-07T14:56:57

* Add an overload of FTFont::BBox that returns an FTBBox object. It will save us a lot of code later.

diff --git a/src/FTFont/FTFont.cpp b/src/FTFont/FTFont.cpp
index f8d1876..5b278c2 100644
--- a/src/FTFont/FTFont.cpp
+++ b/src/FTFont/FTFont.cpp
@@ -189,6 +189,19 @@ float FTFont::Advance(const char* string)
 }
 
 
+FTBBox FTFont::BBox(const char *string, const int start, const int end)
+{
+    return impl->BBox(string, start, end);
+}
+
+
+FTBBox FTFont::BBox(const wchar_t *string,
+                    const int start, const int end)
+{
+    return impl->BBox(string, start, end);
+}
+
+
 void FTFont::BBox(const char* string, const int start, const int end,
                   float& llx, float& lly, float& llz,
                   float& urx, float& ury, float& urz)
@@ -478,6 +491,25 @@ inline void FTFontImpl::BBoxI(const T* string, const int start, const int end,
 }
 
 
+FTBBox FTFontImpl::BBox(const char *string, const int start, const int end)
+{
+    float llx, lly, llz, urx, ury, urz;
+    BBoxI((const unsigned char *)string, start, end,
+          llx, lly, llz, urx, ury, urz);
+    FTBBox tmp(llx, lly, llz, urx, ury, urz);
+    return tmp;
+}
+
+
+FTBBox FTFontImpl::BBox(const wchar_t *string, const int start, const int end)
+{
+    float llx, lly, llz, urx, ury, urz;
+    BBoxI(string, start, end, llx, lly, llz, urx, ury, urz);
+    FTBBox tmp(llx, lly, llz, urx, ury, urz);
+    return tmp;
+}
+
+
 void FTFontImpl::BBox(const char* string, const int start, const int end,
                       float& llx, float& lly, float& llz,
                       float& urx, float& ury, float& urz)
diff --git a/src/FTFont/FTFontImpl.h b/src/FTFont/FTFontImpl.h
index df4a823..fcb5ea7 100644
--- a/src/FTFont/FTFontImpl.h
+++ b/src/FTFont/FTFontImpl.h
@@ -86,6 +86,10 @@ class FTFontImpl
 
         virtual void Outset(float front, float back);
 
+        FTBBox BBox(const char *s, const int start, const int end);
+
+        FTBBox BBox(const wchar_t *s, const int start, const int end);
+
         void BBox(const char *string, const int start, const int end,
                   float& llx, float& lly, float& llz,
                   float& urx, float& ury, float& urz);
diff --git a/src/FTGL/FTFont.h b/src/FTGL/FTFont.h
index 3ba7c0f..e40a9fa 100644
--- a/src/FTGL/FTFont.h
+++ b/src/FTGL/FTFont.h
@@ -210,6 +210,10 @@ class FTGL_EXPORT FTFont
          */
         float LineHeight() const;
 
+        FTBBox BBox(const char *s, const int start, const int end);
+
+        FTBBox BBox(const wchar_t *s, const int start, const int end);
+
         /**
          * Get the bounding box for a string.
          *