Commit 4f44ec81563923e5d4d593bff3105f5a8a1e5b5b

sammy 2008-05-07T15:01:47

* Make all BBox functions return an FTBBox object instead of doing countless conversions to floats or arrays of floats.

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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
diff --git a/demo/FTGLDemo.cpp b/demo/FTGLDemo.cpp
index 9679c75..ac4061a 100644
--- a/demo/FTGLDemo.cpp
+++ b/demo/FTGLDemo.cpp
@@ -190,14 +190,18 @@ void setUpFonts(const char* file)
 
 void renderFontmetrics()
 {
+    FTBBox bbox;
     float x1, y1, z1, x2, y2, z2;
 
     // If there is a layout, use it to compute the bbox, otherwise query as
     // a string.
     if(layouts[currentLayout])
-        layouts[currentLayout]->BBox(myString, x1, y1, z1, x2, y2, z2);
+        bbox = layouts[currentLayout]->BBox(myString);
     else
-        fonts[current_font]->BBox(myString, x1, y1, z1, x2, y2, z2);
+        bbox = fonts[current_font]->BBox(myString);
+
+    x1 = bbox.Lower().Xf(); y1 = bbox.Lower().Yf(); z1 = bbox.Lower().Zf();
+    x2 = bbox.Upper().Xf(); y2 = bbox.Upper().Yf(); z2 = bbox.Upper().Zf();
 
     // Draw the bounding box
     glDisable(GL_LIGHTING);
diff --git a/demo/FTGLMFontDemo.cpp b/demo/FTGLMFontDemo.cpp
index cbce443..f8ceb1e 100644
--- a/demo/FTGLMFontDemo.cpp
+++ b/demo/FTGLMFontDemo.cpp
@@ -214,13 +214,18 @@ void setUpFonts(int numFontFiles)
 
 void renderFontmetrics()
 {
+    FTBBox bbox;
     float x1, y1, z1, x2, y2, z2;
+
     // If there is a layout, use it to compute the bbox, otherwise query as
     // a string.
     if(layouts[currentLayout])
-        layouts[currentLayout]->BBox(myString, x1, y1, z1, x2, y2, z2);
+        bbox = layouts[currentLayout]->BBox(myString);
     else
-        fonts[current_font]->BBox(myString, x1, y1, z1, x2, y2, z2);
+        bbox = fonts[current_font]->BBox(myString);
+
+    x1 = bbox.Lower().Xf(); y1 = bbox.Lower().Yf(); z1 = bbox.Lower().Zf();
+    x2 = bbox.Upper().Xf(); y2 = bbox.Upper().Yf(); z2 = bbox.Upper().Zf();
 
     // Draw the bounding box
     glDisable(GL_LIGHTING);
diff --git a/src/FTFont/FTFont.cpp b/src/FTFont/FTFont.cpp
index cbc8373..2c9b070 100644
--- a/src/FTFont/FTFont.cpp
+++ b/src/FTFont/FTFont.cpp
@@ -189,54 +189,27 @@ 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)
+FTBBox FTFont::BBox(const char *string)
 {
-    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();
+    return impl->BBox(string, 0, -1);
 }
 
 
-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)
+FTBBox FTFont::BBox(const wchar_t *string)
 {
-    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();
+    return impl->BBox(string, 0, -1);
 }
 
 
-void FTFont::BBox(const char* string, float& llx, float& lly, float& llz,
-                  float& urx, float& ury, float& urz)
+FTBBox FTFont::BBox(const char *string, const int start, const int end)
 {
-    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();
+    return impl->BBox(string, start, end);
 }
 
 
-void FTFont::BBox(const wchar_t* string, float& llx, float& lly, float& llz,
-                  float& urx, float& ury, float& urz)
+FTBBox FTFont::BBox(const wchar_t *string, const int start, const int end)
 {
-    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();
+    return impl->BBox(string, start, end);
 }
 
 
@@ -487,8 +460,6 @@ inline FTBBox FTFontImpl::BBoxI(const T* string, const int start, const int end)
         }
     }
 
-    // TODO: The Z values used to not follow the proper ordering.  Investigate
-    // and confirm/infirm that the bug is still there.
     return totalBBox;
 }
 
diff --git a/src/FTFont/FTFontGlue.cpp b/src/FTFont/FTFontGlue.cpp
index f1a1e6b..2ebdb4b 100644
--- a/src/FTFont/FTFontGlue.cpp
+++ b/src/FTFont/FTFontGlue.cpp
@@ -28,6 +28,8 @@
 
 #include "FTInternals.h"
 
+static const FTBBox static_ftbbox;
+
 FTGL_BEGIN_C_DECLS
 
 #define C_TOR(cname, cargs, cxxname, cxxarg, cxxtype) \
@@ -181,9 +183,18 @@ C_FUN(float, ftglGetFontLineHeight, (FTGLfont *f), return 0.f, LineHeight, ());
 
 // void FTFont::BBox(const char* string, float& llx, float& lly, float& llz,
 //                   float& urx, float& ury, float& urz);
-C_FUN(void, ftglGetFontBBox, (FTGLfont *f, const char* s, int start, int end,
-                              float c[6]),
-      return, BBox, (s, start, end, c[0], c[1], c[2], c[3], c[4], c[5]));
+C_FUN(static FTBBox, _ftglGetFontBBox, (FTGLfont *f, char const *s,
+                                        int start, int end),
+      return static_ftbbox, BBox, (s, start, end));
+
+void ftglGetFontBBox(FTGLfont *f, const char* s, int start, int end,
+                     float c[6])
+{
+    FTBBox ret = _ftglGetFontBBox(f, s, start, end);
+    FTPoint lower = ret.Lower(), upper = ret.Upper();
+    c[0] = lower.Xf(); c[1] = lower.Yf(); c[2] = lower.Zf();
+    c[3] = upper.Xf(); c[4] = upper.Yf(); c[5] = upper.Zf();
+}
 
 // float FTFont::Advance(const char* string);
 C_FUN(float, ftglGetFontAdvance, (FTGLfont *f, const char* s),
diff --git a/src/FTGL/FTFont.h b/src/FTGL/FTFont.h
index e40a9fa..338da10 100644
--- a/src/FTGL/FTFont.h
+++ b/src/FTGL/FTFont.h
@@ -210,77 +210,47 @@ 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.
          *
-         * @param string    a char buffer
-         * @param start     The index of the first character of string
-         *                  to check.
-         * @param end       The index of the last character of string to
-         *                  check.  If < 0 then characters will be parsed
-         *                  until a '@\0' is encountered.
-         * @param llx       lower left near x coord
-         * @param lly       lower left near y coord
-         * @param llz       lower left near z coord
-         * @param urx       upper right far x coord
-         * @param ury       upper right far y coord
-         * @param urz       upper right far z coord
+         * @param string  A char buffer.
+         * @return  The corresponding bounding box.
          */
-        void BBox(const char *string, const int start, const int end,
-                  float& llx, float& lly, float& llz,
-                  float& urx, float& ury, float& urz);
+        FTBBox BBox(const char *s);
 
         /**
          * Get the bounding box for a string.
          *
-         * @param string    a wchar_t buffer
-         * @param start     The index of the first character of string
-         *                  to check.
-         * @param end       The index of the last character of string
-         *                  to check.    If < 0 then characters will
-         *                  be parsed until a '@\0' is encountered.
-         * @param llx       lower left near x coord
-         * @param lly       lower left near y coord
-         * @param llz       lower left near z coord
-         * @param urx       upper right far x coord
-         * @param ury       upper right far y coord
-         * @param urz       upper right far z coord
+         * @param string  A wchar_t buffer.
+         * @return  The corresponding bounding box.
          */
-        void BBox(const wchar_t *string, const int start, const int end,
-                  float& llx, float& lly, float& llz,
-                  float& urx, float& ury, float& urz);
+        FTBBox BBox(const wchar_t *s);
 
         /**
          * Get the bounding box for a string.
          *
-         * @param string    a char string
-         * @param llx       lower left near x coord
-         * @param lly       lower left near y coord
-         * @param llz       lower left near z coord
-         * @param urx       upper right far x coord
-         * @param ury       upper right far y coord
-         * @param urz       upper right far z coord
+         * @param string  A char buffer.
+         * @param start  The index of the first character of string
+         *               to check.
+         * @param end  The index of the last character of string to
+         *             check.  If < 0 then characters will be parsed
+         *             until a '@\0' is encountered.
+         * @return  The corresponding bounding box.
          */
-        void BBox(const char* string, float& llx, float& lly, float& llz,
-                  float& urx, float& ury, float& urz);
+        FTBBox BBox(const char *s, const int start, const int end);
 
         /**
          * Get the bounding box for a string.
          *
-         * @param string    a wchar_t string
-         * @param llx       lower left near x coord
-         * @param lly       lower left near y coord
-         * @param llz       lower left near z coord
-         * @param urx       upper right far x coord
-         * @param ury       upper right far y coord
-         * @param urz       upper right far z coord
+         * @param string  A wchar_t buffer.
+         * @param start  The index of the first character of string
+         *               to check.
+         * @param end  The index of the last character of string to
+         *             check.  If < 0 then characters will be parsed
+         *             until a '@\0' is encountered.
+         * @return  The corresponding bounding box.
          */
-        void BBox(const wchar_t* string, float& llx, float& lly, float& llz,
-                  float& urx, float& ury, float& urz);
+        FTBBox BBox(const wchar_t *s, const int start, const int end);
 
         /**
          * Get the advance width for a string.
diff --git a/src/FTGL/FTLayout.h b/src/FTGL/FTLayout.h
index a207b0e..12e3407 100644
--- a/src/FTGL/FTLayout.h
+++ b/src/FTGL/FTLayout.h
@@ -47,6 +47,7 @@ class FTLayoutImpl;
  * <code>BBox</code> methods to determine the bounding box of output text.
  *
  * @see     FTFont
+ * @see     FTBBox
  */
 class FTGL_EXPORT FTLayout
 {
@@ -74,30 +75,18 @@ class FTGL_EXPORT FTLayout
         /**
          * Get the bounding box for a formatted string.
          *
-         * @param string    a char string
-         * @param llx       lower left near x coord
-         * @param lly       lower left near y coord
-         * @param llz       lower left near z coord
-         * @param urx       upper right far x coord
-         * @param ury       upper right far y coord
-         * @param urz       upper right far z coord
+         * @param string  A char string.
+         * @return  The corresponding bounding box.
          */
-        virtual void BBox(const char* string, float& llx, float& lly,
-                          float& llz, float& urx, float& ury, float& urz) = 0;
+        virtual FTBBox BBox(const char* string) = 0;
 
         /**
          * Get the bounding box for a formatted string.
          *
-         * @param string    a wchar_t string
-         * @param llx       lower left near x coord
-         * @param lly       lower left near y coord
-         * @param llz       lower left near z coord
-         * @param urx       upper right far x coord
-         * @param ury       upper right far y coord
-         * @param urz       upper right far z coord
+         * @param string  A wchar_t string.
+         * @return  The corresponding bounding box.
          */
-        virtual void BBox(const wchar_t* string, float& llx, float& lly,
-                          float& llz, float& urx, float& ury, float& urz) = 0;
+        virtual FTBBox BBox(const wchar_t* string) = 0;
 
         /**
          * Render a string of characters
diff --git a/src/FTGL/FTSimpleLayout.h b/src/FTGL/FTSimpleLayout.h
index 7396190..a04ffa6 100644
--- a/src/FTGL/FTSimpleLayout.h
+++ b/src/FTGL/FTSimpleLayout.h
@@ -63,30 +63,18 @@ class FTGL_EXPORT FTSimpleLayout : public FTLayout
         /**
          * Get the bounding box for a formatted string.
          *
-         * @param string    a char string
-         * @param llx       lower left near x coord
-         * @param lly       lower left near y coord
-         * @param llz       lower left near z coord
-         * @param urx       upper right far x coord
-         * @param ury       upper right far y coord
-         * @param urz       upper right far z coord
+         * @param string  A char string
+         * @return  The corresponding bounding box.
          */
-        virtual void BBox(const char* string, float& llx, float& lly,
-                          float& llz, float& urx, float& ury, float& urz);
+        virtual FTBBox BBox(const char* string);
 
         /**
          * Get the bounding box for a formatted string.
          *
-         * @param string    a wchar_t string
-         * @param llx       lower left near x coord
-         * @param lly       lower left near y coord
-         * @param llz       lower left near z coord
-         * @param urx       upper right far x coord
-         * @param ury       upper right far y coord
-         * @param urz       upper right far z coord
-         */
-        virtual void BBox(const wchar_t* string, float& llx, float& lly,
-                          float& llz, float& urx, float& ury, float& urz);
+         * @param string  A wchar_t string
+         * @return  The corresponding bounding box.
+         */
+        virtual FTBBox BBox(const wchar_t* string);
 
         /**
          * Render a string of characters
diff --git a/src/FTGlyph/FTGlyphGlue.cpp b/src/FTGlyph/FTGlyphGlue.cpp
index bf892c2..874e7b2 100644
--- a/src/FTGlyph/FTGlyphGlue.cpp
+++ b/src/FTGlyph/FTGlyphGlue.cpp
@@ -30,8 +30,8 @@
 
 #include "FTInternals.h"
 
-static FTPoint static_ftpoint;
-static FTBBox static_ftbbox;
+static const FTPoint static_ftpoint;
+static const FTBBox static_ftbbox;
 
 FTGL_BEGIN_C_DECLS
 
diff --git a/src/FTLayout/FTLayoutGlue.cpp b/src/FTLayout/FTLayoutGlue.cpp
index c8b3704..87439f8 100644
--- a/src/FTLayout/FTLayoutGlue.cpp
+++ b/src/FTLayout/FTLayoutGlue.cpp
@@ -28,6 +28,8 @@
 
 #include "FTInternals.h"
 
+static const FTBBox static_ftbbox;
+
 FTGL_BEGIN_C_DECLS
 
 #define C_TOR(cname, cargs, cxxname, cxxarg, cxxtype) \
@@ -87,8 +89,16 @@ void ftglDestroyLayout(FTGLlayout *l)
 }
 
 // virtual void BBox(const char* string, float& llx, float& lly, float& llz, float& urx, float& ury, float& urz)
-C_FUN(void, ftgGetlLayoutBBox, (FTGLlayout *f, const char * s, float c[6]),
-      return, BBox, (s, c[0], c[1], c[2], c[3], c[4], c[5]));
+C_FUN(static FTBBox, _ftgGetlLayoutBBox, (FTGLlayout *f, const char *s),
+      return static_ftbbox, BBox, (s));
+
+void ftgGetlLayoutBBox(FTGLlayout *f, const char * s, float c[6])
+{
+    FTBBox ret = _ftgGetlLayoutBBox(f, s);
+    FTPoint lower = ret.Lower(), upper = ret.Upper();
+    c[0] = lower.Xf(); c[1] = lower.Yf(); c[2] = lower.Zf();
+    c[3] = upper.Xf(); c[4] = upper.Yf(); c[5] = upper.Zf();
+}
 
 // virtual void Render(const char* string, int renderMode);
 C_FUN(void, ftglRenderLayout, (FTGLlayout *f, const char *s, int r),
diff --git a/src/FTLayout/FTSimpleLayout.cpp b/src/FTLayout/FTSimpleLayout.cpp
index 444a198..e57c214 100644
--- a/src/FTLayout/FTSimpleLayout.cpp
+++ b/src/FTLayout/FTSimpleLayout.cpp
@@ -47,43 +47,39 @@ FTSimpleLayout::~FTSimpleLayout()
 {}
 
 
-void FTSimpleLayout::BBox(const char *string, float& llx, float& lly,
-                              float& llz, float& urx, float& ury, float& urz)
+FTBBox FTSimpleLayout::BBox(const char *string)
 {
-    dynamic_cast<FTSimpleLayoutImpl*>(impl)->BBox(string, llx, lly, llz,
-                                                  urx, ury, urz);
+    return dynamic_cast<FTSimpleLayoutImpl*>(impl)->BBox(string);
 }
 
 
-void FTSimpleLayout::BBox(const wchar_t *string, float& llx, float& lly,
-                              float& llz, float& urx, float& ury, float& urz)
+FTBBox FTSimpleLayout::BBox(const wchar_t *string)
 {
-    dynamic_cast<FTSimpleLayoutImpl*>(impl)->BBox(string, llx, lly, llz,
-                                                  urx, ury, urz);
+    return dynamic_cast<FTSimpleLayoutImpl*>(impl)->BBox(string);
 }
 
 
 void FTSimpleLayout::Render(const char *string)
 {
-    dynamic_cast<FTSimpleLayoutImpl*>(impl)->Render(string);
+    return dynamic_cast<FTSimpleLayoutImpl*>(impl)->Render(string);
 }
 
 
 void FTSimpleLayout::Render(const wchar_t* string)
 {
-    dynamic_cast<FTSimpleLayoutImpl*>(impl)->Render(string);
+    return dynamic_cast<FTSimpleLayoutImpl*>(impl)->Render(string);
 }
 
 
 void FTSimpleLayout::Render(const char *string, int renderMode)
 {
-    dynamic_cast<FTSimpleLayoutImpl*>(impl)->Render(string, renderMode);
+    return dynamic_cast<FTSimpleLayoutImpl*>(impl)->Render(string, renderMode);
 }
 
 
 void FTSimpleLayout::Render(const wchar_t* string, int renderMode)
 {
-    dynamic_cast<FTSimpleLayoutImpl*>(impl)->Render(string, renderMode);
+    return dynamic_cast<FTSimpleLayoutImpl*>(impl)->Render(string, renderMode);
 }
 
 
@@ -137,13 +133,15 @@ float FTSimpleLayout::GetLineSpacing() const
 
 void FTSimpleLayout::RenderSpace(const char *string, const float ExtraSpace)
 {
-    dynamic_cast<FTSimpleLayoutImpl*>(impl)->RenderSpace(string, ExtraSpace);
+    return dynamic_cast<FTSimpleLayoutImpl*>(impl)->RenderSpace(string,
+                                                                ExtraSpace);
 }
 
 
 void FTSimpleLayout::RenderSpace(const wchar_t *string, const float ExtraSpace)
 {
-    dynamic_cast<FTSimpleLayoutImpl*>(impl)->RenderSpace(string, ExtraSpace);
+    return dynamic_cast<FTSimpleLayoutImpl*>(impl)->RenderSpace(string,
+                                                                ExtraSpace);
 }
 
 
@@ -162,29 +160,25 @@ FTSimpleLayoutImpl::FTSimpleLayoutImpl()
 
 
 template <typename T>
-inline void FTSimpleLayoutImpl::BBoxI(const T* string,
-                                      float& llx, float& lly, float& llz,
-                                      float& urx, float& ury, float& urz)
+inline FTBBox FTSimpleLayoutImpl::BBoxI(const T* string)
 {
-    FTBBox bounds;
+    FTBBox tmp;
 
-    WrapText(string, 0, &bounds);
-    llx = bounds.Lower().Xf(); lly = bounds.Lower().Yf(); llz = bounds.Lower().Zf();
-    urx = bounds.Upper().Xf(); ury = bounds.Upper().Yf(); urz = bounds.Upper().Zf();
+    WrapText(string, 0, &tmp);
+
+    return tmp;
 }
 
 
-void FTSimpleLayoutImpl::BBox(const char *string, float& llx, float& lly,
-                              float& llz, float& urx, float& ury, float& urz)
+FTBBox FTSimpleLayoutImpl::BBox(const char *string)
 {
-    BBoxI(string, llx, lly, llz, urx, ury, urz);
+    return BBoxI(string);
 }
 
 
-void FTSimpleLayoutImpl::BBox(const wchar_t *string, float& llx, float& lly,
-                              float& llz, float& urx, float& ury, float& urz)
+FTBBox FTSimpleLayoutImpl::BBox(const wchar_t *string)
 {
-    BBoxI(string, llx, lly, llz, urx, ury, urz);
+    return BBoxI(string);
 }
 
 
@@ -398,25 +392,20 @@ inline void FTSimpleLayoutImpl::OutputWrappedI(const T *buf, const int start,
     // the line.
     if(bounds)
     {
-        float llx, lly, llz, urx, ury, urz;
-        currentFont->BBox(buf, start, end, llx, lly, llz, urx, ury, urz);
+        FTBBox temp = currentFont->BBox(buf, start, end);
 
         // Add the extra space to the upper x dimension
-        urx += distributeWidth;
-        // TODO: It's a little silly to convert from a FTBBox to floats and
-        // back again, but I don't want to implement yet another method for
-        // finding the bounding box as a BBox.
-        FTBBox temp(llx, lly, llz, urx, ury, urz);
-        temp.Move(FTPoint(pen.X(), pen.Y(), 0.0f));
+        temp = FTBBox(temp.Lower() + pen,
+                      temp.Upper() + pen + FTPoint(distributeWidth, 0));
 
         // See if this is the first area to be added to the bounds
-        if(!bounds->IsValid())
+        if(bounds->IsValid())
         {
-            *bounds = temp;
+            *bounds += temp;
         }
         else
         {
-            *bounds += temp;
+            *bounds = temp;
         }
     }
     else
diff --git a/src/FTLayout/FTSimpleLayoutImpl.h b/src/FTLayout/FTSimpleLayoutImpl.h
index c0afb63..f7add36 100644
--- a/src/FTLayout/FTSimpleLayoutImpl.h
+++ b/src/FTLayout/FTSimpleLayoutImpl.h
@@ -43,30 +43,18 @@ class FTSimpleLayoutImpl : public FTLayoutImpl
         /**
          * Get the bounding box for a string.
          *
-         * @param string    a char string
-         * @param llx       lower left near x coord
-         * @param lly       lower left near y coord
-         * @param llz       lower left near z coord
-         * @param urx       upper right far x coord
-         * @param ury       upper right far y coord
-         * @param urz       upper right far z coord
+         * @param string  A char string.
+         * @return  The corresponding bounding box.
          */
-        virtual void BBox(const char* string, float& llx, float& lly,
-                          float& llz, float& urx, float& ury, float& urz);
+        virtual FTBBox BBox(const char* string);
 
         /**
          * Get the bounding box for a string.
          *
-         * @param string    a wchar_t string
-         * @param llx       lower left near x coord
-         * @param lly       lower left near y coord
-         * @param llz       lower left near z coord
-         * @param urx       upper right far x coord
-         * @param ury       upper right far y coord
-         * @param urz       upper right far z coord
+         * @param string  A wchar_t string.
+         * @return  The corresponding bounding box.
          */
-        virtual void BBox(const wchar_t* string, float& llx, float& lly,
-                          float& llz, float& urx, float& ury, float& urz);
+        virtual FTBBox BBox(const wchar_t* string);
 
         /**
          * Render a string of characters
@@ -256,8 +244,7 @@ class FTSimpleLayoutImpl : public FTLayoutImpl
 
         /* Internal generic BBox() implementation */
         template <typename T>
-        inline void BBoxI(const T* string, float& llx, float& lly, float& llz,
-                          float& urx, float& ury, float& urz);
+        inline FTBBox BBoxI(const T* string);
 
         /* Internal generic Render() implementation */
         template <typename T>