* More cleanup following the private pointer refactoring: + Removed private type enums from the public ftgl.h header. + Protected all private implementation ctors and dtors. + Prevent accidental initialisation of the base classes by protecting their constructors. Derived classes can still be properly instantiated.
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 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986
diff --git a/include/FTFont.h b/include/FTFont.h
index f61a565..d557fc5 100644
--- a/include/FTFont.h
+++ b/include/FTFont.h
@@ -53,13 +53,13 @@ class FTGL_EXPORT FTFont
/* Allow FTLayout classes to access this->impl. */
friend class FTLayoutImpl;
- public:
+ protected:
/**
* Open and read a font file. Sets Error flag.
*
* @param fontFilePath font file path.
*/
- FTFont(FTGL::FontType type, const char* fontFilePath);
+ FTFont(const char* fontFilePath);
/**
* Open and read a font from a buffer in memory. Sets Error flag.
@@ -69,14 +69,14 @@ class FTGL_EXPORT FTFont
* @param pBufferBytes the in-memory buffer
* @param bufferSizeInBytes the length of the buffer in bytes
*/
- FTFont(FTGL::FontType type,
- const unsigned char *pBufferBytes, size_t bufferSizeInBytes);
+ FTFont(const unsigned char *pBufferBytes, size_t bufferSizeInBytes);
/**
* Destructor
*/
virtual ~FTFont();
+ public:
/**
* Attach auxilliary file to font e.g font metrics.
*
diff --git a/include/FTLayout.h b/include/FTLayout.h
index 77f1445..11242b2 100644
--- a/include/FTLayout.h
+++ b/include/FTLayout.h
@@ -45,11 +45,12 @@ class FTLayoutImpl;
*/
class FTGL_EXPORT FTLayout
{
- public:
- FTLayout(FTGL::LayoutType type);
+ protected:
+ FTLayout();
virtual ~FTLayout();
+ public:
void BBox(const char* string, float& llx, float& lly,
float& llz, float& urx, float& ury, float& urz);
diff --git a/include/ftgl.h b/include/ftgl.h
index cde4e52..b90727e 100644
--- a/include/ftgl.h
+++ b/include/ftgl.h
@@ -69,21 +69,6 @@ namespace FTGL
ALIGN_RIGHT,
ALIGN_JUSTIFY,
} TextAlignment;
-
- typedef enum
- {
- FONT_BITMAP,
- FONT_PIXMAP,
- FONT_OUTLINE,
- FONT_POLYGON,
- FONT_EXTRUDE,
- FONT_TEXTURE,
- } FontType;
-
- typedef enum
- {
- LAYOUT_SIMPLE,
- } LayoutType;
}
#else
# define FTGL_RENDER_FRONT 0x01
diff --git a/src/FTFont.cpp b/src/FTFont.cpp
index 4ecfd47..84ae767 100644
--- a/src/FTFont.cpp
+++ b/src/FTFont.cpp
@@ -47,61 +47,24 @@
//
-FTFont::FTFont(FTGL::FontType type, const char* fontFilePath)
+FTFont::FTFont(const char* fontFilePath)
{
- switch(type)
- {
- case FTGL::FONT_BITMAP:
- impl = new FTGLBitmapFontImpl(fontFilePath);
- break;
- case FTGL::FONT_EXTRUDE:
- impl = new FTGLExtrdFontImpl(fontFilePath);
- break;
- case FTGL::FONT_OUTLINE:
- impl = new FTGLOutlineFontImpl(fontFilePath);
- break;
- case FTGL::FONT_PIXMAP:
- impl = new FTGLPixmapFontImpl(fontFilePath);
- break;
- case FTGL::FONT_POLYGON:
- impl = new FTGLPolygonFontImpl(fontFilePath);
- break;
- case FTGL::FONT_TEXTURE:
- impl = new FTGLTextureFontImpl(fontFilePath);
- break;
- }
+ /* impl is set by the child class */
+ impl = NULL;
}
-FTFont::FTFont(FTGL::FontType type,
- const unsigned char *pBufferBytes, size_t bufferSizeInBytes)
+FTFont::FTFont(const unsigned char *pBufferBytes, size_t bufferSizeInBytes)
{
- switch(type)
- {
- case FTGL::FONT_BITMAP:
- impl = new FTGLBitmapFontImpl(pBufferBytes, bufferSizeInBytes);
- break;
- case FTGL::FONT_EXTRUDE:
- impl = new FTGLExtrdFontImpl(pBufferBytes, bufferSizeInBytes);
- break;
- case FTGL::FONT_OUTLINE:
- impl = new FTGLOutlineFontImpl(pBufferBytes, bufferSizeInBytes);
- break;
- case FTGL::FONT_PIXMAP:
- impl = new FTGLPixmapFontImpl(pBufferBytes, bufferSizeInBytes);
- break;
- case FTGL::FONT_POLYGON:
- impl = new FTGLPolygonFontImpl(pBufferBytes, bufferSizeInBytes);
- break;
- case FTGL::FONT_TEXTURE:
- impl = new FTGLTextureFontImpl(pBufferBytes, bufferSizeInBytes);
- break;
- }
+ /* impl is set by the child class */
+ impl = NULL;
}
FTFont::~FTFont()
{
+ /* Only the top class should be allowed to destroy impl, because
+ * we do not know how many levels of inheritance there are. */
delete impl;
}
@@ -476,20 +439,6 @@ void FTFontImpl::BBox(const wchar_t* string, const int start, const int end,
}
-void FTFontImpl::BBox(const char* string, float& llx, float& lly, float& llz,
- float& urx, float& ury, float& urz)
-{
- BBox(string, 0, -1, llx, lly, llz, urx, ury, urz);
-}
-
-
-void FTFontImpl::BBox(const wchar_t* string, float& llx, float& lly, float& llz,
- float& urx, float& ury, float& urz)
-{
- BBox(string, 0, -1, llx, lly, llz, urx, ury, urz);
-}
-
-
template <typename T>
inline float FTFontImpl::AdvanceI(const T* string)
{
diff --git a/src/FTFontGlue.cpp b/src/FTFontGlue.cpp
index 489fc7b..7a7d862 100644
--- a/src/FTFontGlue.cpp
+++ b/src/FTFontGlue.cpp
@@ -58,8 +58,7 @@ static inline FTGLfont *createFTFont(FTGL::FontType type, const char *fontname)
if(ftgl->ptr->Error())
{
- delete ftgl->ptr;
- free(ftgl);
+ ftglDestroyFont(ftgl);
return NULL;
}
diff --git a/src/FTFontImpl.h b/src/FTFontImpl.h
index a8ba3d8..7373eb1 100644
--- a/src/FTFontImpl.h
+++ b/src/FTFontImpl.h
@@ -40,13 +40,13 @@ class FTFontImpl
friend class FTLayoutImpl;
friend class FTFont;
- public:
+ protected:
FTFontImpl(char const *fontFilePath);
FTFontImpl(const unsigned char *pBufferBytes, size_t bufferSizeInBytes);
- ~FTFontImpl();
+ virtual ~FTFontImpl();
virtual void Render(const char* string);
@@ -75,17 +75,10 @@ class FTFontImpl
float& llx, float& lly, float& llz,
float& urx, float& ury, float& urz);
- void BBox(const char* string, float& llx, float& lly, float& llz,
- float& urx, float& ury, float& urz);
-
- void BBox(const wchar_t* string, float& llx, float& lly, float& llz,
- float& urx, float& ury, float& urz);
-
float Advance(const wchar_t* string);
float Advance(const char* string);
- protected:
/**
* Construct a glyph of the correct type.
*
diff --git a/src/FTGLBitmapFont.cpp b/src/FTGLBitmapFont.cpp
index 01208d4..353ee8c 100644
--- a/src/FTGLBitmapFont.cpp
+++ b/src/FTGLBitmapFont.cpp
@@ -37,18 +37,18 @@
//
-FTGLBitmapFont::FTGLBitmapFont(char const *fontFilePath) :
- FTFont(FTGL::FONT_BITMAP, fontFilePath)
+FTGLBitmapFont::FTGLBitmapFont(char const *fontFilePath)
+: FTFont(fontFilePath)
{
- ;
+ impl = new FTGLBitmapFontImpl(fontFilePath);
}
FTGLBitmapFont::FTGLBitmapFont(unsigned char const *pBufferBytes,
- size_t bufferSizeInBytes) :
- FTFont(FTGL::FONT_BITMAP, pBufferBytes, bufferSizeInBytes)
+ size_t bufferSizeInBytes)
+: FTFont(pBufferBytes, bufferSizeInBytes)
{
- ;
+ impl = new FTGLBitmapFontImpl(pBufferBytes, bufferSizeInBytes);
}
@@ -63,21 +63,6 @@ FTGLBitmapFont::~FTGLBitmapFont()
//
-FTGLBitmapFontImpl::FTGLBitmapFontImpl(char const* fontFilePath)
-: FTFontImpl(fontFilePath)
-{}
-
-
-FTGLBitmapFontImpl::FTGLBitmapFontImpl(unsigned char const *pBufferBytes,
- size_t bufferSizeInBytes)
-: FTFontImpl(pBufferBytes, bufferSizeInBytes)
-{}
-
-
-FTGLBitmapFontImpl::~FTGLBitmapFontImpl()
-{}
-
-
FTGlyph* FTGLBitmapFontImpl::MakeGlyph(unsigned int g)
{
FT_GlyphSlot ftGlyph = face.Glyph(g, FT_LOAD_DEFAULT);
diff --git a/src/FTGLBitmapFontImpl.h b/src/FTGLBitmapFontImpl.h
index bc38a69..ac50f6d 100644
--- a/src/FTGLBitmapFontImpl.h
+++ b/src/FTGLBitmapFontImpl.h
@@ -35,17 +35,17 @@ class FTGLBitmapFontImpl : public FTFontImpl
{
friend class FTGLBitmapFont;
- public:
- FTGLBitmapFontImpl(const char* fontFilePath);
+ protected:
+ FTGLBitmapFontImpl(const char* fontFilePath) :
+ FTFontImpl(fontFilePath) {};
FTGLBitmapFontImpl(const unsigned char *pBufferBytes,
- size_t bufferSizeInBytes);
+ size_t bufferSizeInBytes) :
+ FTFontImpl(pBufferBytes, bufferSizeInBytes) {};
- ~FTGLBitmapFontImpl();
+ virtual void Render(const char* string);
- void Render(const char* string);
-
- void Render(const wchar_t* string);
+ virtual void Render(const wchar_t* string);
private:
/**
diff --git a/src/FTGLExtrdFont.cpp b/src/FTGLExtrdFont.cpp
index e2fedac..46154f4 100644
--- a/src/FTGLExtrdFont.cpp
+++ b/src/FTGLExtrdFont.cpp
@@ -37,18 +37,18 @@
//
-FTGLExtrdFont::FTGLExtrdFont(char const *fontFilePath) :
- FTFont(FTGL::FONT_EXTRUDE, fontFilePath)
+FTGLExtrdFont::FTGLExtrdFont(char const *fontFilePath)
+: FTFont(fontFilePath)
{
- ;
+ impl = new FTGLExtrdFontImpl(fontFilePath);
}
FTGLExtrdFont::FTGLExtrdFont(const unsigned char *pBufferBytes,
- size_t bufferSizeInBytes) :
- FTFont(FTGL::FONT_EXTRUDE, pBufferBytes, bufferSizeInBytes)
+ size_t bufferSizeInBytes)
+: FTFont(pBufferBytes, bufferSizeInBytes)
{
- ;
+ impl = new FTGLExtrdFontImpl(pBufferBytes, bufferSizeInBytes);
}
@@ -63,31 +63,6 @@ FTGLExtrdFont::~FTGLExtrdFont()
//
-FTGLExtrdFontImpl::FTGLExtrdFontImpl(const char* fontFilePath)
-: FTFontImpl(fontFilePath),
- depth(0.0f)
-{
- ;
-}
-
-
-FTGLExtrdFontImpl::FTGLExtrdFontImpl(const unsigned char *pBufferBytes,
- size_t bufferSizeInBytes)
-: FTFontImpl(pBufferBytes, bufferSizeInBytes),
- depth(0.0f),
- front(0.0f),
- back(0.0f)
-{
- ;
-}
-
-
-FTGLExtrdFontImpl::~FTGLExtrdFontImpl()
-{
- ;
-}
-
-
FTGlyph* FTGLExtrdFontImpl::MakeGlyph(unsigned int glyphIndex)
{
FT_GlyphSlot ftGlyph = face.Glyph(glyphIndex, FT_LOAD_NO_HINTING);
diff --git a/src/FTGLExtrdFontImpl.h b/src/FTGLExtrdFontImpl.h
index 3ae9000..cbf4293 100644
--- a/src/FTGLExtrdFontImpl.h
+++ b/src/FTGLExtrdFontImpl.h
@@ -35,28 +35,29 @@ class FTGLExtrdFontImpl : public FTFontImpl
{
friend class FTGLExtrdFont;
- public:
- FTGLExtrdFontImpl(const char* fontFilePath);
+ protected:
+ FTGLExtrdFontImpl(const char* fontFilePath) :
+ FTFontImpl(fontFilePath), depth(0.0f), front(0.0f), back(0.0f) {};
FTGLExtrdFontImpl(const unsigned char *pBufferBytes,
- size_t bufferSizeInBytes);
-
- ~FTGLExtrdFontImpl();
+ size_t bufferSizeInBytes) :
+ FTFontImpl(pBufferBytes, bufferSizeInBytes),
+ depth(0.0f), front(0.0f), back(0.0f) {};
/**
* Set the extrusion distance for the font.
*
* @param d The extrusion distance.
*/
- void Depth(float d) { depth = d; }
+ virtual void Depth(float d) { depth = d; }
/**
* Set the outset distance for the font. Only implemented by
* FTGLOutlineFont, FTGLPolygonFont and FTGLExtrdFont
*
- * @param f The front outset distance.
+ * @param o The outset distance.
*/
- void Outset(float f) { front = f; }
+ virtual void Outset(float o) { front = back = o; }
/**
* Set the outset distance for the font. Only implemented by
@@ -65,7 +66,7 @@ class FTGLExtrdFontImpl : public FTFontImpl
* @param f The front outset distance.
* @param b The back outset distance.
*/
- void Outset(float f, float b) { front = f; back = b; }
+ virtual void Outset(float f, float b) { front = f; back = b; }
private:
/**
@@ -74,7 +75,7 @@ class FTGLExtrdFontImpl : public FTFontImpl
* @param glyphIndex The glyph index NOT the char code.
* @return An FTExtrdGlyph or <code>null</code> on failure.
*/
- inline virtual FTGlyph* MakeGlyph(unsigned int glyphIndex);
+ virtual FTGlyph* MakeGlyph(unsigned int glyphIndex);
/**
* The extrusion distance for the font.
diff --git a/src/FTGLOutlineFont.cpp b/src/FTGLOutlineFont.cpp
index 25b8539..65be17f 100644
--- a/src/FTGLOutlineFont.cpp
+++ b/src/FTGLOutlineFont.cpp
@@ -37,18 +37,18 @@
//
-FTGLOutlineFont::FTGLOutlineFont(char const *fontFilePath) :
- FTFont(FTGL::FONT_OUTLINE, fontFilePath)
+FTGLOutlineFont::FTGLOutlineFont(char const *fontFilePath)
+: FTFont(fontFilePath)
{
- ;
+ impl = new FTGLOutlineFontImpl(fontFilePath);
}
FTGLOutlineFont::FTGLOutlineFont(const unsigned char *pBufferBytes,
- size_t bufferSizeInBytes) :
- FTFont(FTGL::FONT_OUTLINE, pBufferBytes, bufferSizeInBytes)
+ size_t bufferSizeInBytes)
+: FTFont(pBufferBytes, bufferSizeInBytes)
{
- ;
+ impl = new FTGLOutlineFontImpl(pBufferBytes, bufferSizeInBytes);
}
@@ -63,22 +63,6 @@ FTGLOutlineFont::~FTGLOutlineFont()
//
-FTGLOutlineFontImpl::FTGLOutlineFontImpl(const char* fontFilePath)
-: FTFontImpl(fontFilePath),
- outset(0.0f)
-{}
-
-
-FTGLOutlineFontImpl::FTGLOutlineFontImpl(const unsigned char *pBufferBytes,
- size_t bufferSizeInBytes)
-: FTFontImpl(pBufferBytes, bufferSizeInBytes)
-{}
-
-
-FTGLOutlineFontImpl::~FTGLOutlineFontImpl()
-{}
-
-
FTGlyph* FTGLOutlineFontImpl::MakeGlyph(unsigned int g)
{
FT_GlyphSlot ftGlyph = face.Glyph(g, FT_LOAD_NO_HINTING);
@@ -119,8 +103,20 @@ void FTGLOutlineFontImpl::Render(const char* string)
}
+void FTGLOutlineFontImpl::Render(const char* string, int renderMode)
+{
+ RenderI(string);
+}
+
+
void FTGLOutlineFontImpl::Render(const wchar_t* string)
{
RenderI(string);
}
+
+void FTGLOutlineFontImpl::Render(const wchar_t* string, int renderMode)
+{
+ RenderI(string);
+}
+
diff --git a/src/FTGLOutlineFontImpl.h b/src/FTGLOutlineFontImpl.h
index a710a66..f8d4eda 100644
--- a/src/FTGLOutlineFontImpl.h
+++ b/src/FTGLOutlineFontImpl.h
@@ -35,13 +35,13 @@ class FTGLOutlineFontImpl : public FTFontImpl
{
friend class FTGLOutlineFont;
- public:
- FTGLOutlineFontImpl(const char* fontFilePath);
+ protected:
+ FTGLOutlineFontImpl(const char* fontFilePath) :
+ FTFontImpl(fontFilePath), outset(0.0f) {};
FTGLOutlineFontImpl(const unsigned char *pBufferBytes,
- size_t bufferSizeInBytes);
-
- ~FTGLOutlineFontImpl();
+ size_t bufferSizeInBytes) :
+ FTFontImpl(pBufferBytes, bufferSizeInBytes), outset(0.0f) {};
/**
* Set the outset distance for the font. Only implemented by
@@ -49,14 +49,14 @@ class FTGLOutlineFontImpl : public FTFontImpl
*
* @param outset The outset distance.
*/
- void Outset(float o) { outset = o; }
+ virtual void Outset(float o) { outset = o; }
/**
* Renders a string of characters
*
* @param string 'C' style string to be output.
*/
- void Render(const char* string);
+ virtual void Render(const char* string);
/**
* Render a string of characters
@@ -64,14 +64,14 @@ class FTGLOutlineFontImpl : public FTFontImpl
* @param string 'C' style string to be output.
* @param renderMode Render mode to display
*/
- void Render(const char* string, int renderMode) { Render(string); }
+ virtual void Render(const char* string, int renderMode);
/**
* Renders a string of characters
*
* @param string wchar_t string to be output.
*/
- void Render(const wchar_t* string);
+ virtual void Render(const wchar_t* string);
/**
* Render a string of characters
@@ -79,7 +79,7 @@ class FTGLOutlineFontImpl : public FTFontImpl
* @param string wchar_t string to be output.
* @param renderMode Render mode to display
*/
- void Render(const wchar_t *string, int renderMode) { Render(string); }
+ virtual void Render(const wchar_t *string, int renderMode);
private:
/**
diff --git a/src/FTGLPixmapFont.cpp b/src/FTGLPixmapFont.cpp
index d1d1eb9..569f366 100644
--- a/src/FTGLPixmapFont.cpp
+++ b/src/FTGLPixmapFont.cpp
@@ -37,18 +37,18 @@
//
-FTGLPixmapFont::FTGLPixmapFont(char const *fontFilePath) :
- FTFont(FTGL::FONT_PIXMAP, fontFilePath)
+FTGLPixmapFont::FTGLPixmapFont(char const *fontFilePath)
+: FTFont(fontFilePath)
{
- ;
+ impl = new FTGLPixmapFontImpl(fontFilePath);
}
FTGLPixmapFont::FTGLPixmapFont(const unsigned char *pBufferBytes,
- size_t bufferSizeInBytes) :
- FTFont(FTGL::FONT_PIXMAP, pBufferBytes, bufferSizeInBytes)
+ size_t bufferSizeInBytes)
+: FTFont(pBufferBytes, bufferSizeInBytes)
{
- ;
+ impl = new FTGLPixmapFontImpl(pBufferBytes, bufferSizeInBytes);
}
@@ -63,27 +63,6 @@ FTGLPixmapFont::~FTGLPixmapFont()
//
-FTGLPixmapFontImpl::FTGLPixmapFontImpl(const char* fontFilePath)
-: FTFontImpl(fontFilePath)
-{
- ;
-}
-
-
-FTGLPixmapFontImpl::FTGLPixmapFontImpl(const unsigned char *pBufferBytes,
- size_t bufferSizeInBytes)
-: FTFontImpl(pBufferBytes, bufferSizeInBytes)
-{
- ;
-}
-
-
-FTGLPixmapFontImpl::~FTGLPixmapFontImpl()
-{
- ;
-}
-
-
FTGlyph* FTGLPixmapFontImpl::MakeGlyph(unsigned int g)
{
FT_GlyphSlot ftGlyph = face.Glyph(g, FT_LOAD_NO_HINTING
@@ -132,8 +111,20 @@ void FTGLPixmapFontImpl::Render(const char* string)
}
+void FTGLPixmapFontImpl::Render(const char* string, int renderMode)
+{
+ RenderI(string);
+}
+
+
void FTGLPixmapFontImpl::Render(const wchar_t* string)
{
RenderI(string);
}
+
+void FTGLPixmapFontImpl::Render(const wchar_t* string, int renderMode)
+{
+ RenderI(string);
+}
+
diff --git a/src/FTGLPixmapFontImpl.h b/src/FTGLPixmapFontImpl.h
index ca06c66..8dcc978 100644
--- a/src/FTGLPixmapFontImpl.h
+++ b/src/FTGLPixmapFontImpl.h
@@ -35,20 +35,20 @@ class FTGLPixmapFontImpl : public FTFontImpl
{
friend class FTGLPixmapFont;
- public:
- FTGLPixmapFontImpl(const char* fontFilePath);
+ protected:
+ FTGLPixmapFontImpl(const char* fontFilePath) :
+ FTFontImpl(fontFilePath) {};
FTGLPixmapFontImpl(const unsigned char *pBufferBytes,
- size_t bufferSizeInBytes);
-
- ~FTGLPixmapFontImpl();
+ size_t bufferSizeInBytes) :
+ FTFontImpl(pBufferBytes, bufferSizeInBytes) {};
/**
* Renders a string of characters
*
* @param string 'C' style string to be output.
*/
- void Render(const char* string);
+ virtual void Render(const char* string);
/**
* Render a string of characters
@@ -56,14 +56,14 @@ class FTGLPixmapFontImpl : public FTFontImpl
* @param string 'C' style string to be output.
* @param renderMode Render mode to display
*/
- void Render(const char* string, int renderMode) { Render(string); }
+ virtual void Render(const char* string, int renderMode);
/**
* Renders a string of characters
*
* @param string wchar_t string to be output.
*/
- void Render(const wchar_t* string);
+ virtual void Render(const wchar_t* string);
/**
* Render a string of characters
@@ -71,7 +71,7 @@ class FTGLPixmapFontImpl : public FTFontImpl
* @param string wchar_t string to be output.
* @param renderMode Render mode to display
*/
- void Render(const wchar_t *string, int renderMode) { Render(string); }
+ virtual void Render(const wchar_t *string, int renderMode);
private:
/**
diff --git a/src/FTGLPolygonFont.cpp b/src/FTGLPolygonFont.cpp
index cb85688..638701e 100644
--- a/src/FTGLPolygonFont.cpp
+++ b/src/FTGLPolygonFont.cpp
@@ -37,18 +37,18 @@
//
-FTGLPolygonFont::FTGLPolygonFont(char const *fontFilePath) :
- FTFont(FTGL::FONT_POLYGON, fontFilePath)
+FTGLPolygonFont::FTGLPolygonFont(char const *fontFilePath)
+: FTFont(fontFilePath)
{
- ;
+ impl = new FTGLPolygonFontImpl(fontFilePath);
}
FTGLPolygonFont::FTGLPolygonFont(const unsigned char *pBufferBytes,
- size_t bufferSizeInBytes) :
- FTFont(FTGL::FONT_POLYGON, pBufferBytes, bufferSizeInBytes)
+ size_t bufferSizeInBytes)
+: FTFont(pBufferBytes, bufferSizeInBytes)
{
- ;
+ impl = new FTGLPolygonFontImpl(pBufferBytes, bufferSizeInBytes);
}
@@ -63,28 +63,6 @@ FTGLPolygonFont::~FTGLPolygonFont()
//
-FTGLPolygonFontImpl::FTGLPolygonFontImpl(const char* fontFilePath)
-: FTFontImpl(fontFilePath),
- outset(0.0f)
-{
- ;
-}
-
-
-FTGLPolygonFontImpl::FTGLPolygonFontImpl(const unsigned char *pBufferBytes,
- size_t bufferSizeInBytes)
-: FTFontImpl(pBufferBytes, bufferSizeInBytes)
-{
- ;
-}
-
-
-FTGLPolygonFontImpl::~FTGLPolygonFontImpl()
-{
- ;
-}
-
-
FTGlyph* FTGLPolygonFontImpl::MakeGlyph(unsigned int g)
{
FT_GlyphSlot ftGlyph = face.Glyph(g, FT_LOAD_NO_HINTING);
diff --git a/src/FTGLPolygonFontImpl.h b/src/FTGLPolygonFontImpl.h
index ffa9150..eb38ae2 100644
--- a/src/FTGLPolygonFontImpl.h
+++ b/src/FTGLPolygonFontImpl.h
@@ -35,13 +35,13 @@ class FTGLPolygonFontImpl : public FTFontImpl
{
friend class FTGLPolygonFont;
- public:
- FTGLPolygonFontImpl(const char* fontFilePath);
+ protected:
+ FTGLPolygonFontImpl(const char* fontFilePath) :
+ FTFontImpl(fontFilePath), outset(0.0f) {};
FTGLPolygonFontImpl(const unsigned char *pBufferBytes,
- size_t bufferSizeInBytes);
-
- ~FTGLPolygonFontImpl();
+ size_t bufferSizeInBytes) :
+ FTFontImpl(pBufferBytes, bufferSizeInBytes), outset(0.0f) {};
/**
* Set the outset distance for the font. Only implemented by
@@ -49,7 +49,7 @@ class FTGLPolygonFontImpl : public FTFontImpl
*
* @param depth The outset distance.
*/
- void Outset(float o) { outset = o; }
+ virtual void Outset(float o) { outset = o; }
private:
/**
@@ -58,7 +58,7 @@ class FTGLPolygonFontImpl : public FTFontImpl
* @param g The glyph index NOT the char code.
* @return An FTPolyGlyph or <code>null</code> on failure.
*/
- inline virtual FTGlyph* MakeGlyph(unsigned int g);
+ virtual FTGlyph* MakeGlyph(unsigned int g);
/**
* The outset distance (front and back) for the font.
diff --git a/src/FTGLTextureFont.cpp b/src/FTGLTextureFont.cpp
index 561bb0b..7fe49cf 100644
--- a/src/FTGLTextureFont.cpp
+++ b/src/FTGLTextureFont.cpp
@@ -40,18 +40,18 @@
//
-FTGLTextureFont::FTGLTextureFont(char const *fontFilePath) :
- FTFont(FTGL::FONT_TEXTURE, fontFilePath)
+FTGLTextureFont::FTGLTextureFont(char const *fontFilePath)
+: FTFont(fontFilePath)
{
- ;
+ impl = new FTGLTextureFontImpl(fontFilePath);
}
FTGLTextureFont::FTGLTextureFont(const unsigned char *pBufferBytes,
- size_t bufferSizeInBytes) :
- FTFont(FTGL::FONT_TEXTURE, pBufferBytes, bufferSizeInBytes)
+ size_t bufferSizeInBytes)
+: FTFont(pBufferBytes, bufferSizeInBytes)
{
- ;
+ impl = new FTGLTextureFontImpl(pBufferBytes, bufferSizeInBytes);
}
@@ -233,8 +233,20 @@ void FTGLTextureFontImpl::Render(const char* string)
}
+void FTGLTextureFontImpl::Render(const char* string, int renderMode)
+{
+ RenderI(string);
+}
+
+
void FTGLTextureFontImpl::Render(const wchar_t* string)
{
RenderI(string);
}
+
+void FTGLTextureFontImpl::Render(const wchar_t* string, int renderMode)
+{
+ RenderI(string);
+}
+
diff --git a/src/FTGLTextureFontImpl.h b/src/FTGLTextureFontImpl.h
index b6b2120..28d14cc 100644
--- a/src/FTGLTextureFontImpl.h
+++ b/src/FTGLTextureFontImpl.h
@@ -37,13 +37,13 @@ class FTGLTextureFontImpl : public FTFontImpl
{
friend class FTGLTextureFont;
- public:
+ protected:
FTGLTextureFontImpl(const char* fontFilePath);
FTGLTextureFontImpl(const unsigned char *pBufferBytes,
size_t bufferSizeInBytes);
- ~FTGLTextureFontImpl();
+ virtual ~FTGLTextureFontImpl();
/**
* Set the char size for the current face.
@@ -68,7 +68,7 @@ class FTGLTextureFontImpl : public FTFontImpl
* @param string 'C' style string to be output.
* @param renderMode Render mode to display
*/
- void Render(const char* string, int renderMode) { Render(string); }
+ virtual void Render(const char* string, int renderMode);
/**
* Renders a string of characters
@@ -83,7 +83,7 @@ class FTGLTextureFontImpl : public FTFontImpl
* @param string wchar_t string to be output.
* @param renderMode Render mode to display
*/
- void Render(const wchar_t *string, int renderMode) { Render(string); }
+ virtual void Render(const wchar_t *string, int renderMode);
private:
/**
diff --git a/src/FTInternals.h b/src/FTInternals.h
index 0b58c51..dce6887 100644
--- a/src/FTInternals.h
+++ b/src/FTInternals.h
@@ -90,12 +90,27 @@
FTGL_BEGIN_C_DECLS
+typedef enum
+{
+ FONT_BITMAP,
+ FONT_PIXMAP,
+ FONT_OUTLINE,
+ FONT_POLYGON,
+ FONT_EXTRUDE,
+ FONT_TEXTURE,
+} FontType;
+
struct _FTGLfont
{
FTFont *ptr;
FTGL::FontType type;
};
+typedef enum
+{
+ LAYOUT_SIMPLE,
+} LayoutType;
+
struct _FTGLlayout
{
FTLayout *ptr;
diff --git a/src/FTLayout.cpp b/src/FTLayout.cpp
index 0b569e9..be752b9 100644
--- a/src/FTLayout.cpp
+++ b/src/FTLayout.cpp
@@ -40,19 +40,17 @@
//
-FTLayout::FTLayout(FTGL::LayoutType type)
+FTLayout::FTLayout()
{
- switch(type)
- {
- case FTGL::LAYOUT_SIMPLE:
- impl = new FTSimpleLayoutImpl();
- break;
- }
+ /* impl is set by the child class */
+ impl = NULL;
}
FTLayout::~FTLayout()
{
+ /* Only the top class should be allowed to destroy impl, because
+ * we do not know how many levels of inheritance there are. */
delete impl;
}
diff --git a/src/FTSimpleLayout.cpp b/src/FTSimpleLayout.cpp
index 4224de4..a8af1cb 100644
--- a/src/FTSimpleLayout.cpp
+++ b/src/FTSimpleLayout.cpp
@@ -42,10 +42,9 @@
//
-FTSimpleLayout::FTSimpleLayout() :
- FTLayout(FTGL::LAYOUT_SIMPLE)
+FTSimpleLayout::FTSimpleLayout()
{
- ;
+ impl = new FTSimpleLayoutImpl();
}
diff --git a/src/FTSimpleLayoutImpl.h b/src/FTSimpleLayoutImpl.h
index ccad087..045a30a 100644
--- a/src/FTSimpleLayoutImpl.h
+++ b/src/FTSimpleLayoutImpl.h
@@ -37,10 +37,10 @@ class FTSimpleLayoutImpl : public FTLayoutImpl
{
friend class FTSimpleLayout;
- public:
+ protected:
FTSimpleLayoutImpl();
- ~FTSimpleLayoutImpl();
+ virtual ~FTSimpleLayoutImpl() {};
/**
* Get the bounding box for a string.