* Add an overload of FTFont::BBox that returns an FTBBox object. It will save us a lot of code later.
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
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.
*