* Reimplement all FTFont::BBox() variants using the same FTFontImpl::BBox() common method.
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
diff --git a/src/FTFont/FTFont.cpp b/src/FTFont/FTFont.cpp
index 5b278c2..cbc8373 100644
--- a/src/FTFont/FTFont.cpp
+++ b/src/FTFont/FTFont.cpp
@@ -206,7 +206,9 @@ void FTFont::BBox(const char* string, const int start, const int end,
float& llx, float& lly, float& llz,
float& urx, float& ury, float& urz)
{
- return impl->BBox(string, start, end, llx, lly, llz, urx, ury, urz);
+ FTBBox tmp = impl->BBox(string, start, end);
+ llx = tmp.Lower().X(); lly = tmp.Lower().Y(); llz = tmp.Lower().Z();
+ urx = tmp.Upper().X(); ury = tmp.Upper().Y(); urz = tmp.Upper().Z();
}
@@ -214,21 +216,27 @@ void FTFont::BBox(const wchar_t* string, const int start, const int end,
float& llx, float& lly, float& llz,
float& urx, float& ury, float& urz)
{
- return impl->BBox(string, start, end, llx, lly, llz, urx, ury, urz);
+ FTBBox tmp = impl->BBox(string, start, end);
+ llx = tmp.Lower().X(); lly = tmp.Lower().Y(); llz = tmp.Lower().Z();
+ urx = tmp.Upper().X(); ury = tmp.Upper().Y(); urz = tmp.Upper().Z();
}
void FTFont::BBox(const char* string, float& llx, float& lly, float& llz,
float& urx, float& ury, float& urz)
{
- return impl->BBox(string, 0, -1, llx, lly, llz, urx, ury, urz);
+ FTBBox tmp = impl->BBox(string, 0, -1);
+ llx = tmp.Lower().X(); lly = tmp.Lower().Y(); llz = tmp.Lower().Z();
+ urx = tmp.Upper().X(); ury = tmp.Upper().Y(); urz = tmp.Upper().Z();
}
void FTFont::BBox(const wchar_t* string, float& llx, float& lly, float& llz,
float& urx, float& ury, float& urz)
{
- return impl->BBox(string, 0, -1, llx, lly, llz, urx, ury, urz);
+ FTBBox tmp = impl->BBox(string, 0, -1);
+ llx = tmp.Lower().X(); lly = tmp.Lower().Y(); llz = tmp.Lower().Z();
+ urx = tmp.Upper().X(); ury = tmp.Upper().Y(); urz = tmp.Upper().Z();
}
@@ -449,9 +457,7 @@ float FTFontImpl::LineHeight() const
template <typename T>
-inline void FTFontImpl::BBoxI(const T* string, const int start, const int end,
- float& llx, float& lly, float& llz,
- float& urx, float& ury, float& urz)
+inline FTBBox FTFontImpl::BBoxI(const T* string, const int start, const int end)
{
FTBBox totalBBox;
@@ -481,50 +487,22 @@ inline void FTFontImpl::BBoxI(const T* string, const int start, const int end,
}
}
- // TODO: The Z values do not follow the proper ordering. I'm not sure why.
- llx = totalBBox.Lower().Xf() < totalBBox.Upper().Xf() ? totalBBox.Lower().Xf() : totalBBox.Upper().Xf();
- lly = totalBBox.Lower().Yf() < totalBBox.Upper().Yf() ? totalBBox.Lower().Yf() : totalBBox.Upper().Yf();
- llz = totalBBox.Lower().Zf() < totalBBox.Upper().Zf() ? totalBBox.Lower().Zf() : totalBBox.Upper().Zf();
- urx = totalBBox.Lower().Xf() > totalBBox.Upper().Xf() ? totalBBox.Lower().Xf() : totalBBox.Upper().Xf();
- ury = totalBBox.Lower().Yf() > totalBBox.Upper().Yf() ? totalBBox.Lower().Yf() : totalBBox.Upper().Yf();
- urz = totalBBox.Lower().Zf() > totalBBox.Upper().Zf() ? totalBBox.Lower().Zf() : totalBBox.Upper().Zf();
+ // TODO: The Z values used to not follow the proper ordering. Investigate
+ // and confirm/infirm that the bug is still there.
+ return totalBBox;
}
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)
-{
/* The chars need to be unsigned because they are cast to int later */
- return BBoxI((const unsigned char *)string, start, end,
- llx, lly, llz, urx, ury, urz);
+ return BBoxI((const unsigned char *)string, start, end);
}
-void FTFontImpl::BBox(const wchar_t* string, const int start, const int end,
- float& llx, float& lly, float& llz,
- float& urx, float& ury, float& urz)
+FTBBox FTFontImpl::BBox(const wchar_t *string, const int start, const int end)
{
- return BBoxI(string, start, end, llx, lly, llz, urx, ury, urz);
+ return BBoxI(string, start, end);
}
diff --git a/src/FTFont/FTFontImpl.h b/src/FTFont/FTFontImpl.h
index fcb5ea7..f163b7b 100644
--- a/src/FTFont/FTFontImpl.h
+++ b/src/FTFont/FTFontImpl.h
@@ -90,14 +90,6 @@ class FTFontImpl
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);
-
- void BBox(const wchar_t *string, const int start, const int end,
- float& llx, float& lly, float& llz,
- float& urx, float& ury, float& urz);
-
float Advance(const wchar_t* string);
float Advance(const char* string);
@@ -166,9 +158,7 @@ class FTFontImpl
/* Internal generic BBox() implementation */
template <typename T>
- inline void BBoxI(const T *string, const int start, const int end,
- float& llx, float& lly, float& llz,
- float& urx, float& ury, float& urz);
+ inline FTBBox BBoxI(const T *string, const int start, const int end);
/* Internal generic BBox() implementation */
template <typename T>