Commit 55dc91e06abc47c8da624a58db78190426358160

sammy 2008-05-11T21:43:10

* Added optional position and string length to the Layout methods.

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
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
diff --git a/demo/FTGLDemo.cpp b/demo/FTGLDemo.cpp
index d9303c7..221a545 100644
--- a/demo/FTGLDemo.cpp
+++ b/demo/FTGLDemo.cpp
@@ -406,7 +406,8 @@ void do_display (void)
         glColor3f(1.0, 1.0, 1.0);
         int renderMode = FTGL::RENDER_FRONT | FTGL::RENDER_BACK;
         if(layouts[currentLayout])
-            layouts[currentLayout]->Render(myString, renderMode);
+            layouts[currentLayout]->Render(myString, -1,
+                                           FTPoint(), renderMode);
         else
             fonts[current_font]->Render(myString, -1,
                                         FTPoint(), FTPoint(), renderMode);
@@ -416,7 +417,8 @@ void do_display (void)
             glBindTexture(GL_TEXTURE_2D, textureID[1]);
             renderMode = FTGL::RENDER_SIDE;
             if(layouts[currentLayout])
-                layouts[currentLayout]->Render(myString, renderMode);
+                layouts[currentLayout]->Render(myString, -1,
+                                               FTPoint(), renderMode);
             else
                 fonts[current_font]->Render(myString, -1,
                                             FTPoint(), FTPoint(), renderMode);
diff --git a/src/FTGL/FTFont.h b/src/FTGL/FTFont.h
index 2a5e77a..515ab82 100644
--- a/src/FTGL/FTFont.h
+++ b/src/FTGL/FTFont.h
@@ -224,8 +224,8 @@ class FTGL_EXPORT FTFont
          * @return  The corresponding bounding box.
          */
         virtual FTBBox BBox(const char *string, const int len = -1,
-                            FTPoint position = FTPoint(0, 0, 0),
-                            FTPoint spacing = FTPoint(0, 0, 0));
+                            FTPoint position = FTPoint(),
+                            FTPoint spacing = FTPoint());
 
         /**
          * Get the bounding box for a string (deprecated).
@@ -259,8 +259,8 @@ class FTGL_EXPORT FTFont
          * @return  The corresponding bounding box.
          */
         virtual FTBBox BBox(const wchar_t *string, const int len = -1,
-                            FTPoint position = FTPoint(0, 0, 0),
-                            FTPoint spacing = FTPoint(0, 0, 0));
+                            FTPoint position = FTPoint(),
+                            FTPoint spacing = FTPoint());
 
         /**
          * Get the bounding box for a string (deprecated).
@@ -294,8 +294,8 @@ class FTGL_EXPORT FTFont
          * @return  The new pen position after the last character.
          */
         virtual FTPoint Advance(const char* string, const int len = -1,
-                                FTPoint position = FTPoint(0, 0, 0),
-                                FTPoint spacing = FTPoint(0, 0, 0));
+                                FTPoint position = FTPoint(),
+                                FTPoint spacing = FTPoint());
 
         /**
          * Get the advance for a string.
@@ -310,8 +310,8 @@ class FTGL_EXPORT FTFont
          * @return  The new pen position after the last character.
          */
         virtual FTPoint Advance(const wchar_t* string, const int len = -1,
-                                FTPoint position = FTPoint(0, 0, 0),
-                                FTPoint spacing = FTPoint(0, 0, 0));
+                                FTPoint position = FTPoint(),
+                                FTPoint spacing = FTPoint());
 
         /**
          * Render a string of characters.
@@ -327,8 +327,8 @@ class FTGL_EXPORT FTFont
          * @return  The new pen position after the last character was output.
          */
         virtual FTPoint Render(const char* string, const int len = -1,
-                               FTPoint position = FTPoint(0, 0, 0),
-                               FTPoint spacing = FTPoint(0, 0, 0),
+                               FTPoint position = FTPoint(),
+                               FTPoint spacing = FTPoint(),
                                int renderMode = FTGL::RENDER_ALL);
 
         /**
@@ -345,8 +345,8 @@ class FTGL_EXPORT FTFont
          * @return  The new pen position after the last character was output.
          */
         virtual FTPoint Render(const wchar_t *string, const int len = -1,
-                               FTPoint position = FTPoint(0, 0),
-                               FTPoint spacing = FTPoint(0, 0),
+                               FTPoint position = FTPoint(),
+                               FTPoint spacing = FTPoint(),
                                int renderMode = FTGL::RENDER_ALL);
 
         /**
diff --git a/src/FTGL/FTLayout.h b/src/FTGL/FTLayout.h
index cebf2b6..329b98a 100644
--- a/src/FTGL/FTLayout.h
+++ b/src/FTGL/FTLayout.h
@@ -76,34 +76,54 @@ class FTGL_EXPORT FTLayout
          * Get the bounding box for a formatted string.
          *
          * @param string  A char string.
+         * @param len  The length of the string. If < 0 then all characters
+         *             will be checked until a null character is encountered
+         *             (optional).
+         * @param position  The pen position of the first character (optional).
          * @return  The corresponding bounding box.
          */
-        virtual FTBBox BBox(const char* string) = 0;
+        virtual FTBBox BBox(const char* string, const int len = -1,
+                            FTPoint position = FTPoint()) = 0;
 
         /**
          * Get the bounding box for a formatted string.
          *
          * @param string  A wchar_t string.
+         * @param len  The length of the string. If < 0 then all characters
+         *             will be checked until a null character is encountered
+         *             (optional).
+         * @param position  The pen position of the first character (optional).
          * @return  The corresponding bounding box.
          */
-        virtual FTBBox BBox(const wchar_t* string) = 0;
+        virtual FTBBox BBox(const wchar_t* string, const int len = -1,
+                            FTPoint position = FTPoint()) = 0;
 
         /**
-         * Render a string of characters
+         * Render a string of characters.
          *
          * @param string    'C' style string to be output.
+         * @param len  The length of the string. If < 0 then all characters
+         *             will be displayed until a null character is encountered
+         *             (optional).
+         * @param position  The pen position of the first character (optional).
          * @param renderMode  Render mode to display (optional)
          */
-        virtual void Render(const char *string,
+        virtual void Render(const char *string, const int len = -1,
+                            FTPoint position = FTPoint(),
                             int renderMode = FTGL::RENDER_ALL) = 0;
 
         /**
-         * Render a string of characters
+         * Render a string of characters.
          *
          * @param string    wchar_t string to be output.
+         * @param len  The length of the string. If < 0 then all characters
+         *             will be displayed until a null character is encountered
+         *             (optional).
+         * @param position  The pen position of the first character (optional).
          * @param renderMode  Render mode to display (optional)
          */
-        virtual void Render(const wchar_t *string,
+        virtual void Render(const wchar_t *string, const int len = -1,
+                            FTPoint position = FTPoint(),
                             int renderMode = FTGL::RENDER_ALL) = 0;
 
         /**
diff --git a/src/FTGL/FTSimpleLayout.h b/src/FTGL/FTSimpleLayout.h
index 69d63a2..c504ad3 100644
--- a/src/FTGL/FTSimpleLayout.h
+++ b/src/FTGL/FTSimpleLayout.h
@@ -63,35 +63,55 @@ class FTGL_EXPORT FTSimpleLayout : public FTLayout
         /**
          * Get the bounding box for a formatted string.
          *
-         * @param string  A char string
+         * @param string  A char string.
+         * @param len  The length of the string. If < 0 then all characters
+         *             will be checked until a null character is encountered
+         *             (optional).
+         * @param position  The pen position of the first character (optional).
          * @return  The corresponding bounding box.
          */
-        virtual FTBBox BBox(const char* string);
+        virtual FTBBox BBox(const char* string, const int len = -1,
+                            FTPoint position = FTPoint());
 
         /**
          * Get the bounding box for a formatted string.
          *
-         * @param string  A wchar_t string
+         * @param string  A wchar_t string.
+         * @param len  The length of the string. If < 0 then all characters
+         *             will be checked until a null character is encountered
+         *             (optional).
+         * @param position  The pen position of the first character (optional).
          * @return  The corresponding bounding box.
          */
-        virtual FTBBox BBox(const wchar_t* string);
+        virtual FTBBox BBox(const wchar_t* string, const int len = -1,
+                            FTPoint position = FTPoint());
 
         /**
-         * Render a string of characters
+         * Render a string of characters.
          *
          * @param string    'C' style string to be output.
+         * @param len  The length of the string. If < 0 then all characters
+         *             will be displayed until a null character is encountered
+         *             (optional).
+         * @param position  The pen position of the first character (optional).
          * @param renderMode  Render mode to display (optional)
          */
-        virtual void Render(const char *string,
+        virtual void Render(const char *string, const int len = -1,
+                            FTPoint position = FTPoint(),
                             int renderMode = FTGL::RENDER_ALL);
 
         /**
-         * Render a string of characters
+         * Render a string of characters.
          *
          * @param string    wchar_t string to be output.
+         * @param len  The length of the string. If < 0 then all characters
+         *             will be displayed until a null character is encountered
+         *             (optional).
+         * @param position  The pen position of the first character (optional).
          * @param renderMode  Render mode to display (optional)
          */
-        virtual void Render(const wchar_t *string,
+        virtual void Render(const wchar_t *string, const int len = -1,
+                            FTPoint position = FTPoint(),
                             int renderMode = FTGL::RENDER_ALL);
 
         /**
@@ -154,7 +174,10 @@ class FTGL_EXPORT FTSimpleLayout : public FTLayout
          * @param ExtraSpace  The amount of extra space to add to each run of
          *                    whitespace.
          */
-        void RenderSpace(const char *string, const float ExtraSpace = 0.0);
+        void RenderSpace(const char *string, const int len = -1,
+                         FTPoint position = FTPoint(),
+                         int renderMode = FTGL::RENDER_ALL,
+                         const float ExtraSpace = 0.0);
 
         /**
          * Render a string of characters and distribute extra space amongst
@@ -164,7 +187,10 @@ class FTGL_EXPORT FTSimpleLayout : public FTLayout
          * @param ExtraSpace  The amount of extra space to add to each run of
          *                    whitespace.
          */
-        void RenderSpace(const wchar_t *string, const float ExtraSpace = 0.0);
+        void RenderSpace(const wchar_t *string, const int len = -1,
+                         FTPoint position = FTPoint(),
+                         int renderMode = FTGL::RENDER_ALL,
+                         const float ExtraSpace = 0.0);
 };
 
 #endif //__cplusplus
diff --git a/src/FTLayout/FTSimpleLayout.cpp b/src/FTLayout/FTSimpleLayout.cpp
index ce8ce8d..0aac2f8 100644
--- a/src/FTLayout/FTSimpleLayout.cpp
+++ b/src/FTLayout/FTSimpleLayout.cpp
@@ -47,27 +47,31 @@ FTSimpleLayout::~FTSimpleLayout()
 {}
 
 
-FTBBox FTSimpleLayout::BBox(const char *string)
+FTBBox FTSimpleLayout::BBox(const char *string, const int len, FTPoint pos)
 {
-    return dynamic_cast<FTSimpleLayoutImpl*>(impl)->BBox(string);
+    return dynamic_cast<FTSimpleLayoutImpl*>(impl)->BBox(string, len, pos);
 }
 
 
-FTBBox FTSimpleLayout::BBox(const wchar_t *string)
+FTBBox FTSimpleLayout::BBox(const wchar_t *string, const int len, FTPoint pos)
 {
-    return dynamic_cast<FTSimpleLayoutImpl*>(impl)->BBox(string);
+    return dynamic_cast<FTSimpleLayoutImpl*>(impl)->BBox(string, len, pos);
 }
 
 
-void FTSimpleLayout::Render(const char *string, int renderMode)
+void FTSimpleLayout::Render(const char *string, const int len, FTPoint pos,
+                            int renderMode)
 {
-    return dynamic_cast<FTSimpleLayoutImpl*>(impl)->Render(string, renderMode);
+    return dynamic_cast<FTSimpleLayoutImpl*>(impl)->Render(string, len, pos,
+                                                           renderMode);
 }
 
 
-void FTSimpleLayout::Render(const wchar_t* string, int renderMode)
+void FTSimpleLayout::Render(const wchar_t* string, const int len, FTPoint pos,
+                            int renderMode)
 {
-    return dynamic_cast<FTSimpleLayoutImpl*>(impl)->Render(string, renderMode);
+    return dynamic_cast<FTSimpleLayoutImpl*>(impl)->Render(string, len, pos,
+                                                           renderMode);
 }
 
 
@@ -119,17 +123,21 @@ float FTSimpleLayout::GetLineSpacing() const
 }
 
 
-void FTSimpleLayout::RenderSpace(const char *string, const float ExtraSpace)
+void FTSimpleLayout::RenderSpace(const char *string, const int len,
+                                 FTPoint position, int renderMode,
+                                 const float extraSpace)
 {
-    return dynamic_cast<FTSimpleLayoutImpl*>(impl)->RenderSpace(string,
-                                                                ExtraSpace);
+    FTSimpleLayoutImpl *pImpl = dynamic_cast<FTSimpleLayoutImpl*>(impl);
+    return pImpl->RenderSpace(string, len, position, renderMode, extraSpace);
 }
 
 
-void FTSimpleLayout::RenderSpace(const wchar_t *string, const float ExtraSpace)
+void FTSimpleLayout::RenderSpace(const wchar_t *string, const int len,
+                                 FTPoint position, int renderMode,
+                                 const float extraSpace)
 {
-    return dynamic_cast<FTSimpleLayoutImpl*>(impl)->RenderSpace(string,
-                                                                ExtraSpace);
+    FTSimpleLayoutImpl *pImpl = dynamic_cast<FTSimpleLayoutImpl*>(impl);
+    return pImpl->RenderSpace(string, len, position, renderMode, extraSpace);
 }
 
 
@@ -148,68 +156,57 @@ FTSimpleLayoutImpl::FTSimpleLayoutImpl()
 
 
 template <typename T>
-inline FTBBox FTSimpleLayoutImpl::BBoxI(const T* string)
+inline FTBBox FTSimpleLayoutImpl::BBoxI(const T* string, const int len,
+                                        FTPoint position)
 {
     FTBBox tmp;
 
-    WrapText(string, 0, &tmp);
+    WrapText(string, len, position, 0, &tmp);
 
     return tmp;
 }
 
 
-FTBBox FTSimpleLayoutImpl::BBox(const char *string)
+FTBBox FTSimpleLayoutImpl::BBox(const char *string, const int len,
+                                FTPoint position)
 {
-    return BBoxI(string);
+    return BBoxI(string, len, position);
 }
 
 
-FTBBox FTSimpleLayoutImpl::BBox(const wchar_t *string)
+FTBBox FTSimpleLayoutImpl::BBox(const wchar_t *string, const int len,
+                                FTPoint position)
 {
-    return BBoxI(string);
+    return BBoxI(string, len, position);
 }
 
 
 template <typename T>
-inline void FTSimpleLayoutImpl::RenderI(const T *string, int renderMode)
+inline void FTSimpleLayoutImpl::RenderI(const T *string, const int len,
+                                        FTPoint position, int renderMode)
 {
     pen = FTPoint(0.0f, 0.0f);
-    WrapText(string, renderMode, NULL);
+    WrapText(string, len, position, renderMode, NULL);
 }
 
 
-void FTSimpleLayoutImpl::Render(const char *string, int renderMode)
+void FTSimpleLayoutImpl::Render(const char *string, const int len,
+                                FTPoint position, int renderMode)
 {
-    RenderI(string, renderMode);
+    RenderI(string, len, position, renderMode);
 }
 
 
-void FTSimpleLayoutImpl::Render(const wchar_t* string, int renderMode)
+void FTSimpleLayoutImpl::Render(const wchar_t* string, const int len,
+                                FTPoint position, int renderMode)
 {
-    RenderI(string, renderMode);
-}
-
-
-void FTSimpleLayoutImpl::RenderSpace(const char *string,
-                                     const float ExtraSpace)
-{
-    pen.X(0);
-    pen.Y(0);
-    RenderSpace(string, 0, -1, 0, ExtraSpace);
-}
-
-
-void FTSimpleLayoutImpl::RenderSpace(const wchar_t *string,
-                                     const float ExtraSpace)
-{
-    pen.X(0);
-    pen.Y(0);
-    RenderSpace(string, 0, -1, 0, ExtraSpace);
+    RenderI(string, len, position, renderMode);
 }
 
 
 template <typename T>
-inline void FTSimpleLayoutImpl::WrapTextI(const T *buf, int renderMode,
+inline void FTSimpleLayoutImpl::WrapTextI(const T *buf, const int len,
+                                          FTPoint position, int renderMode,
                                           FTBBox *bounds)
 {
     int breakIdx = 0;          // index of the last break character
@@ -270,12 +267,13 @@ inline void FTSimpleLayoutImpl::WrapTextI(const T *buf, int renderMode,
             if(buf[breakIdx + 1] == '\n')
             {
                 breakIdx++;
-                OutputWrapped(buf, lineStart, breakIdx - 1,
-                              remainingWidth, bounds, renderMode);
+                OutputWrapped(buf + lineStart, breakIdx - lineStart - 1,
+                              position, renderMode, remainingWidth, bounds);
             }
             else
             {
-                OutputWrapped(buf, lineStart, breakIdx, remainingWidth, bounds, renderMode);
+                OutputWrapped(buf + lineStart, breakIdx - lineStart,
+                              position, renderMode, remainingWidth, bounds);
             }
 
             // Store the start of the next line
@@ -314,35 +312,39 @@ inline void FTSimpleLayoutImpl::WrapTextI(const T *buf, int renderMode,
     if(alignment == FTGL::ALIGN_JUSTIFY)
     {
         alignment = FTGL::ALIGN_LEFT;
-        OutputWrapped(buf, lineStart, -1, remainingWidth, bounds, renderMode);
+        OutputWrapped(buf + lineStart, -1, position, renderMode,
+                      remainingWidth, bounds);
         alignment = FTGL::ALIGN_JUSTIFY;
     }
     else
     {
-        OutputWrapped(buf, lineStart, -1, remainingWidth, bounds, renderMode);
+        OutputWrapped(buf + lineStart, -1, position, renderMode,
+                      remainingWidth, bounds);
     }
 }
 
 
-void FTSimpleLayoutImpl::WrapText(const char *buf, int renderMode,
+void FTSimpleLayoutImpl::WrapText(const char *buf, const int len,
+                                  FTPoint position, int renderMode,
                                   FTBBox *bounds)
 {
-    WrapTextI(buf, renderMode, bounds);
+    WrapTextI(buf, len, position, renderMode, bounds);
 }
 
 
-void FTSimpleLayoutImpl::WrapText(const wchar_t* buf, int renderMode,
+void FTSimpleLayoutImpl::WrapText(const wchar_t* buf, const int len,
+                                  FTPoint position, int renderMode,
                                   FTBBox *bounds)
 {
-    WrapTextI(buf, renderMode, bounds);
+    WrapTextI(buf, len, position, renderMode, bounds);
 }
 
 
 template <typename T>
-inline void FTSimpleLayoutImpl::OutputWrappedI(const T *buf, const int start,
-                                               const int end,
+inline void FTSimpleLayoutImpl::OutputWrappedI(const T *buf, const int len,
+                                               FTPoint position, int renderMode,
                                                const float remaining,
-                                               FTBBox *bounds, int renderMode)
+                                               FTBBox *bounds)
 {
     float distributeWidth = 0.0;
     // Align the text according as specified by Alignment
@@ -367,7 +369,7 @@ inline void FTSimpleLayoutImpl::OutputWrappedI(const T *buf, const int start,
     // the line.
     if(bounds)
     {
-        FTBBox temp = currentFont->BBox(buf + start, end - start);
+        FTBBox temp = currentFont->BBox(buf, len);
 
         // Add the extra space to the upper x dimension
         temp = FTBBox(temp.Lower() + pen,
@@ -385,60 +387,60 @@ inline void FTSimpleLayoutImpl::OutputWrappedI(const T *buf, const int start,
     }
     else
     {
-        RenderSpace(buf, start, end, renderMode, distributeWidth);
+        RenderSpace(buf, len, position, renderMode, distributeWidth);
     }
 }
 
 
-void FTSimpleLayoutImpl::OutputWrapped(const char *buf, const int start,
-                                       const int end, const float remaining,
-                                       FTBBox *bounds, int renderMode)
+void FTSimpleLayoutImpl::OutputWrapped(const char *buf, const int len,
+                                       FTPoint position, int renderMode,
+                                       const float remaining, FTBBox *bounds)
 {
-    OutputWrappedI(buf, start, end, remaining, bounds, renderMode);
+    OutputWrappedI(buf, len, position, renderMode, remaining, bounds);
 }
 
 
-void FTSimpleLayoutImpl::OutputWrapped(const wchar_t *buf, const int start,
-                                       const int end, const float remaining,
-                                       FTBBox *bounds, int renderMode)
+void FTSimpleLayoutImpl::OutputWrapped(const wchar_t *buf, const int len,
+                                       FTPoint position, int renderMode,
+                                       const float remaining, FTBBox *bounds)
 {
-    OutputWrappedI(buf, start, end, remaining, bounds, renderMode);
+    OutputWrappedI(buf, len, position, renderMode, remaining, bounds);
 }
 
 
 template <typename T>
-inline void FTSimpleLayoutImpl::RenderSpaceI(const T *string, const int start,
-                                             const int end, int renderMode,
-                                             const float ExtraSpace)
+inline void FTSimpleLayoutImpl::RenderSpaceI(const T *string, const int len,
+                                             FTPoint position, int renderMode,
+                                             const float extraSpace)
 {
     float space = 0.0;
 
     // If there is space to distribute, count the number of spaces
-    if(ExtraSpace > 0.0)
+    if(extraSpace > 0.0)
     {
         int numSpaces = 0;
 
         // Count the number of space blocks in the input
-        for(int i = start; ((end < 0) && string[i])
-                              || ((end >= 0) && (i <= end)); i++)
+        for(int i = 0; ((len < 0) && string[i])
+                              || ((len >= 0) && (i <= len)); i++)
         {
             // If this is the end of a space block, increment the counter
-            if((i > start) && !isspace(string[i]) && isspace(string[i - 1]))
+            if((i > 0) && !isspace(string[i]) && isspace(string[i - 1]))
             {
                 numSpaces++;
             }
         }
 
-        space = ExtraSpace/numSpaces;
+        space = extraSpace/numSpaces;
     }
 
     // Output all characters of the string
-    for(int i = start; ((end < 0) && string[i])
-                          || ((end >= 0) && (i <= end)); i++)
+    for(int i = 0; ((len < 0) && string[i])
+                          || ((len >= 0) && (i <= len)); i++)
     {
         // If this is the end of a space block, distribute the extra space
         // inside it
-        if((i > start) && !isspace(string[i]) && isspace(string[i - 1]))
+        if((i > 0) && !isspace(string[i]) && isspace(string[i - 1]))
         {
             pen += FTPoint(space, 0);
         }
@@ -448,18 +450,18 @@ inline void FTSimpleLayoutImpl::RenderSpaceI(const T *string, const int start,
 }
 
 
-void FTSimpleLayoutImpl::RenderSpace(const char *string, const int start,
-                                     const int end, int renderMode,
-                                     const float ExtraSpace)
+void FTSimpleLayoutImpl::RenderSpace(const char *string, const int len,
+                                     FTPoint position, int renderMode,
+                                     const float extraSpace)
 {
-    RenderSpaceI(string, start, end, renderMode, ExtraSpace);
+    RenderSpaceI(string, len, position, renderMode, extraSpace);
 }
 
 
-void FTSimpleLayoutImpl::RenderSpace(const wchar_t *string, const int start,
-                                     const int end, int renderMode,
-                                     const float ExtraSpace)
+void FTSimpleLayoutImpl::RenderSpace(const wchar_t *string, const int len,
+                                     FTPoint position, int renderMode,
+                                     const float extraSpace)
 {
-    RenderSpaceI(string, start, end, renderMode, ExtraSpace);
+    RenderSpaceI(string, len, position, renderMode, extraSpace);
 }
 
diff --git a/src/FTLayout/FTSimpleLayoutImpl.h b/src/FTLayout/FTSimpleLayoutImpl.h
index 79c805d..83754c2 100644
--- a/src/FTLayout/FTSimpleLayoutImpl.h
+++ b/src/FTLayout/FTSimpleLayoutImpl.h
@@ -40,94 +40,49 @@ class FTSimpleLayoutImpl : public FTLayoutImpl
 
         virtual ~FTSimpleLayoutImpl() {};
 
-        /**
-         * Get the bounding box for a string.
-         *
-         * @param string  A char string.
-         * @return  The corresponding bounding box.
-         */
-        virtual FTBBox BBox(const char* string);
-
-        /**
-         * Get the bounding box for a string.
-         *
-         * @param string  A wchar_t string.
-         * @return  The corresponding bounding box.
-         */
-        virtual FTBBox BBox(const wchar_t* string);
+        virtual FTBBox BBox(const char* string, const int len,
+                            FTPoint position);
 
-        /**
-         * Render a string of characters
-         *
-         * @param string    'C' style string to be output.
-         * @param renderMode    Render mode to display
-         */
-        virtual void Render(const char* string, int renderMode);
+        virtual FTBBox BBox(const wchar_t* string, const int len,
+                            FTPoint position);
 
-        /**
-         * Render a string of characters
-         *
-         * @param string    wchar_t string to be output.
-         * @param renderMode    Render mode to display
-         */
-        virtual void Render(const wchar_t* string, int renderMode);
+        virtual void Render(const char *string, const int len,
+                            FTPoint position, int renderMode);
 
-        /**
-         * Render a string of characters and distribute extra space amongst
-         * the whitespace regions of the string.
-         *
-         * @param string      'C' style string to output.
-         * @param ExtraSpace  The amount of extra space to add to each run of
-         *                    whitespace.
-         */
-        void RenderSpace(const char *string, const float ExtraSpace = 0.0);
+        virtual void Render(const wchar_t *string, const int len,
+                            FTPoint position, int renderMode);
 
         /**
          * Render a string of characters and distribute extra space amongst
          * the whitespace regions of the string.
          *
-         * @param string      wchar_t string to output.
-         * @param ExtraSpace  The amount of extra space to add to each run of
-         *                    whitespace.
-         */
-        void RenderSpace(const wchar_t *string, const float ExtraSpace = 0.0);
-
-   protected:
-        /**
-         * Render a string of characters and distribute extra space amongst
-         * the whitespace regions of the string.  Note that this method
-         * does not reset the pen position before rendering.  This method
-         * provides the implementation for other RenderSpace methods and
-         * thus should be overloaded when attempting to overload any
-         * RenderSpace methods.
-         *
          * @param string   A buffer of wchar_t characters to output.
-         * @param start    The index of the first character in string to output.
-         * @param end      The index of the last character in string to output.
+         * @param len  The length of the string. If < 0 then all characters
+         *             will be displayed until a null character is encountered.
+         * @param position TODO
          * @param renderMode Render mode to display
-         * @param ExtraSpace The amount of extra space to distribute amongst
+         * @param extraSpace The amount of extra space to distribute amongst
          *                   the characters.
          */
-        virtual void RenderSpace(const char *string, const int start,
-                                 const int end, int renderMode, const float ExtraSpace = 0.0);
+        virtual void RenderSpace(const char *string, const int len,
+                                 FTPoint position, int renderMode,
+                                 const float extraSpace);
 
         /**
          * Render a string of characters and distribute extra space amongst
-         * the whitespace regions of the string.  Note that this method
-         * does not reset the pen position before rendering.  This method
-         * provides the implementation for other RenderSpace methods and
-         * thus should be overloaded when attempting to overload any
-         * RenderSpace methods.
+         * the whitespace regions of the string.
          *
          * @param string   A buffer of wchar_t characters to output.
-         * @param start    The index of the first character in string to output.
-         * @param end      The index of the last character in string to output.
+         * @param len  The length of the string. If < 0 then all characters
+         *             will be displayed until a null character is encountered.
+         * @param position TODO
          * @param renderMode Render mode to display
-         * @param ExtraSpace The amount of extra space to distribute amongst
+         * @param extraSpace The amount of extra space to distribute amongst
          *                   the characters.
          */
-        virtual void RenderSpace(const wchar_t *string, const int start,
-                                 const int end, int renderMode, const float ExtraSpace = 0.0);
+        virtual void RenderSpace(const wchar_t *string, const int len,
+                                 FTPoint position, int renderMode,
+                                 const float extraSpace);
 
     private:
         /**
@@ -137,14 +92,19 @@ class FTSimpleLayoutImpl : public FTLayoutImpl
          * of this method is exposed by the BBoxWrapped and
          * RenderWrapped methods.
          *
-         * @param buf         wchar_t style string to output.
+         * @param buf  A char string to output.
+         * @param len  The length of the string. If < 0 then all characters
+         *             will be displayed until a null character is encountered.
+         * @param position TODO
          * @param renderMode  Render mode to display
          * @param bounds      A pointer to a bounds object.  If non null
          *                    the bounds of the text when laid out
          *                    will be stored in bounds.  If null the
          *                    text will be rendered.
          */
-        virtual void WrapText(const char *buf, int renderMode, FTBBox *bounds = NULL);
+        virtual void WrapText(const char *buf, const int len,
+                              FTPoint position, int renderMode,
+                              FTBBox *bounds);
 
         /**
          * Either render a string of characters and wrap lines
@@ -153,24 +113,29 @@ class FTSimpleLayoutImpl : public FTLayoutImpl
          * of this method is exposed by the BBoxWrapped and
          * RenderWrapped methods.
          *
-         * @param buf         wchar_t style string to output.
+         * @param buf  A wchar_t style string to output.
+         * @param len  The length of the string. If < 0 then all characters
+         *             will be displayed until a null character is encountered.
+         * @param position TODO
          * @param renderMode  Render mode to display
          * @param bounds      A pointer to a bounds object.  If non null
          *                    the bounds of the text when laid out
          *                    will be stored in bounds.  If null the
          *                    text will be rendered.
          */
-        virtual void WrapText(const wchar_t *buf, int renderMode, FTBBox *bounds = NULL);
+        virtual void WrapText(const wchar_t *buf, const int len,
+                              FTPoint position, int renderMode,
+                              FTBBox *bounds);
 
         /**
          * A helper method used by WrapText to either output the text or
          * compute it's bounds.
          *
          * @param buf      A pointer to an array of character data.
-         * @param start    The index of the first character to process.
-         * @param end      The index of the last character to process.  If
-         *                 < 0 then characters will be parsed until a '\0'
-         *                 is encountered.
+         * @param len  The length of the string. If < 0 then all characters
+         *             will be displayed until a null character is encountered.
+         * @param position TODO
+         * @param renderMode  Render mode to display
          * @param RemainingWidth The amount of extra space left on the line.
          * @param bounds     A pointer to a bounds object.  If non null the
          *                   bounds will be initialized or expanded by the
@@ -178,20 +143,20 @@ class FTSimpleLayoutImpl : public FTLayoutImpl
          *                   rendered.  If the bounds are invalid (lower > upper)
          *                   they will be initialized.  Otherwise they
          *                   will be expanded.
-         * @param renderMode  Render mode to display
          */
-        void OutputWrapped(const char *buf, const int start, const int end,
-                           const float RemainingWidth, FTBBox *bounds, int renderMode);
+        void OutputWrapped(const char *buf, const int len,
+                           FTPoint position, int renderMode,
+                           const float RemainingWidth, FTBBox *bounds);
 
         /**
          * A helper method used by WrapText to either output the text or
          * compute it's bounds.
          *
          * @param buf      A pointer to an array of character data.
-         * @param start    The index of the first character to process.
-         * @param end      The index of the last character to process.  If
-         *                 < 0 then characters will be parsed until a '\0'
-         *                 is encountered.
+         * @param len  The length of the string. If < 0 then all characters
+         *             will be displayed until a null character is encountered.
+         * @param position TODO
+         * @param renderMode  Render mode to display
          * @param RemainingWidth The amount of extra space left on the line.
          * @param bounds     A pointer to a bounds object.  If non null the
          *                   bounds will be initialized or expanded by the
@@ -199,10 +164,10 @@ class FTSimpleLayoutImpl : public FTLayoutImpl
          *                   rendered.  If the bounds are invalid (lower > upper)
          *                   they will be initialized.  Otherwise they
          *                   will be expanded.
-         * @param renderMode  Render mode to display
          */
-        void OutputWrapped(const wchar_t *buf, const int start, const int end,
-                           const float RemainingWidth, FTBBox *bounds, int renderMode);
+        void OutputWrapped(const wchar_t *buf, const int len,
+                           FTPoint position, int renderMode,
+                           const float RemainingWidth, FTBBox *bounds);
 
         /**
          * The font to use for rendering the text.  The font is
@@ -230,25 +195,29 @@ class FTSimpleLayoutImpl : public FTLayoutImpl
 
         /* Internal generic BBox() implementation */
         template <typename T>
-        inline FTBBox BBoxI(const T* string);
+        inline FTBBox BBoxI(const T* string, const int len, FTPoint position);
 
         /* Internal generic Render() implementation */
         template <typename T>
-        inline void RenderI(const T* string, int renderMode);
+        inline void RenderI(const T* string, const int len,
+                            FTPoint position, int renderMode);
 
         /* Internal generic RenderSpace() implementation */
         template <typename T>
-        inline void RenderSpaceI(const T* string, const int start,
-                                 const int end, int renderMode, const float ExtraSpace = 0.0);
+        inline void RenderSpaceI(const T* string, const int len,
+                                 FTPoint position, int renderMode,
+                                 const float extraSpace);
 
         /* Internal generic WrapText() implementation */
         template <typename T>
-        void WrapTextI(const T* buf, int renderMode, FTBBox *bounds = NULL);
+        void WrapTextI(const T* buf, const int len, FTPoint position,
+                       int renderMode, FTBBox *bounds);
 
         /* Internal generic OutputWrapped() implementation */
         template <typename T>
-        void OutputWrappedI(const T* buf, const int start, const int end,
-                            const float RemainingWidth, FTBBox *bounds, int renderMode);
+        void OutputWrappedI(const T* buf, const int len, FTPoint position,
+                            int renderMode, const float RemainingWidth,
+                            FTBBox *bounds);
 };
 
 #endif  //  __FTSimpleLayoutImpl__