* Refactor the documentation to have a cleaner frontpage: put the tutorial and the FAQ in two separate pages, add links to the most important C and C++ documentation, and add projects_using_ftgl.txt to the doxygen project.
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
diff --git a/docs/Makefile.am b/docs/Makefile.am
index fb5358e..d999833 100644
--- a/docs/Makefile.am
+++ b/docs/Makefile.am
@@ -59,6 +59,9 @@ EXTRA_DIST = \
FTGL_1_3.gif \
doxygen.cfg.in \
ftgl.dox \
+ tutorial.dox \
+ projects_using_ftgl.txt \
+ faq.dox \
images/metrics.svg \
$(NULL)
diff --git a/docs/doxygen.cfg.in b/docs/doxygen.cfg.in
index 65c3fdd..4346eed 100644
--- a/docs/doxygen.cfg.in
+++ b/docs/doxygen.cfg.in
@@ -533,7 +533,8 @@ INPUT_ENCODING = UTF-8
FILE_PATTERNS = *.cpp \
*.h \
- *.dox
+ *.dox \
+ *.txt
# The RECURSIVE tag can be used to turn specify whether or not subdirectories
# should be searched for input files as well. Possible values are YES and NO.
diff --git a/docs/faq.dox b/docs/faq.dox
new file mode 100644
index 0000000..f61975f
--- /dev/null
+++ b/docs/faq.dox
@@ -0,0 +1,55 @@
+/** \page ftgl-faq Frequently Asked Questions
+
+ \section faq FAQ
+
+ \subsection faq1 When I try to compile FTGL it complains about a missing file from the include: #include <ft2build.h>
+
+ %FTGL relies on FreeType 2 for opening and decoding font files. This include
+ is the main include for FreeType. You will need to download Freetype 2 and
+ install it. Then make sure that the %FTGL project that you are using points to
+ your FreeType installation.
+
+ \subsection faq2 Is it possible to map a font to a "unit" size? My application relies on the fonts being a certain "physical" height (in OpenGL coordinate space) rather than a point size in display space. Any thoughts/suggestions?
+
+ We can do anything:) It would be easy to allow you to set the size in pixels,
+ though I'm not sure this is what you want. Setting the size to 'OpenGL units'
+ may be a bit harder. What does 1.0 in opengl space mean and how does that
+ relate to point size? For one person it might mean scaling the font up, for
+ someone else it may mean scaling down. Plus bitmaps and pixmaps have a pixel
+ to pixel relationship that you can't change.
+
+ Here's some guidelines for vector and texture fonts. Take note that I say
+ 'should' a lot :)
+
+ - One point in pixel space maps to 1 unit in OpenGL space, so a glyph that is
+ 18 points high should be 18.0 units high.
+
+ - If you set an ortho projection to the window size and draw a glyph it's
+ screen size should be the correct physical size ie a 72 point glyph on a 72dpi
+ screen will be 1 inch high. Also if you set a perspective projection that maps
+ 0.0 in the z axis to screen size you will get the same eg.
+ \code
+gluPerspective(90, window_height / 2 , small_number, large_number);
+ \endcode
+ So basically it all depends on your projection matrix. Obviously you can use
+ glScale but I understand if you don't want to.
+
+ Couple of extra things to note:
+
+ - The quality of vector glyphs will not change when you change the size, ie.
+ a really small polygon glyph up close will look exactly the same as a big one
+ from far away. They both contain the same amount of data. This doesn't apply
+ to texture fonts.
+
+ - Secondly, there is a bug in the advance/kerning code that will cause
+ ugliness at really small point sizes. This is because the advance and kerning
+ use ints so an advance of 0.4 will become zero. If this is going to be a
+ probelm, I can fix this.
+
+ Early on I did a lot of head scratching over the OpenGL unit to font size
+ thing because when I was first integrating %FTGL into my engine the fonts
+ weren't the size I was expecting. I was tempted to build in some scaling but I
+ decided doing nothing was the best approach because you can't please everyone.
+ Plus it's 'correct' as it is.
+
+*/
diff --git a/docs/ftgl.dox b/docs/ftgl.dox
index fe57107..29810a2 100644
--- a/docs/ftgl.dox
+++ b/docs/ftgl.dox
@@ -15,323 +15,31 @@
- http://www.opengl.org/resources/features/fontsurvey/
Most of these systems require a pre-processing stage to take the native fonts
- and convert them into a proprietry format.
+ and convert them into a proprietary format.
%FTGL was born out of the need to treat fonts in OpenGL applications just like
any other application. For example when using Adobe Photoshop or Microsoft
Word you don't need an intermediate pre-processing step to use high quality
scalable fonts.
- \section starting Starting to use FTGL
+ \section documentation Documentation
- Only one header is required to use %FTGL:
+ - \subpage ftgl-tutorial
-\code
-#include <FTGL/ftgl.h>
-\endcode
+ - C API reference:
+ - FTGlyph.h
+ - FTFont.h
+ - FTLayout.h
- \section type Choosing a font type
+ - C++ API reference:
+ - class FTGlyph
+ - class FTFont
+ - class FTLayout
- %FTGL supports 6 font output types among 3 groups: raster fonts, vector
- fonts, and texture fonts which are a mixture of both. Each font type has its
- advantages and disadvantages.
+ \section information Additional information
- \subsection raster Raster fonts
+ - \subpage ftgl-faq
- Raster fonts are made of pixels painted directly on the viewport's
- framebuffer. They cannot be directly rotated or scaled.
-
- - Bitmap fonts use 1-bit (2-colour) rasterised glyphs.
- - Pixmap fonts use 8-bit (256 levels) rasterised glyphs.
-
- \image html rasterfont.png
- \image latex rasterfont.eps "" width=0.7\textwidth
-
- \subsection vector Vector fonts
-
- Vector fonts are 3D objects that are rendered at the current matrix location.
- All position, scale, texture and material effects apply to vector fonts.
-
- - Polygon fonts use planar triangle meshes and can be texture-mapped.
- - Outline fonts use OpenGL lines.
- - Extruded fonts are extruded polygon fonts, with the front, back and side
- meshes renderable separately to apply different effects and materials.
-
- \image html vectorfont.png
- \image latex vectorfont.eps "" width=0.7\textwidth
-
- \subsection texture Texture fonts
-
- Texture fonts are probably the most versatile type. They are fast,
- antialiased, and can be transformed just like any OpenGL primitive.
-
- \image html texturefont.png
- \image latex texturefont.eps "" width=0.7\textwidth
-
- \section creating Create font objects
-
- Creating a font and displaying some text is really straightforward, be it
- in C or in C++.
-
- \subsection c in C
-
- \code
-/* Create a pixmap font from a TrueType file. */
-FTGLfont *font = ftglCreatePixmapFont("/home/user/Arial.ttf");
-
-/* If something went wrong, bail out. */
-if(!font)
- return -1;
-
-/* Set the font size and render a small text. */
-ftglSetFontFaceSize(font, 72, 72);
-ftglRenderFont(font, "Hello World!", FTGL_RENDER_ALL);
-
-/* Destroy the font object. */
-ftglDestroyFont(font);
- \endcode
-
- \subsection cxx in C++
-
- \code
-// Create a pixmap font from a TrueType file.
-FTGLPixmapFont font("/home/user/Arial.ttf");
-
-// If something went wrong, bail out.
-if(font.Error())
- return -1;
-
-// Set the font size and render a small text.
-font.FaceSize(72);
-font.Render("Hello World!");
- \endcode
-
- The first 128 glyphs of the font (generally corresponding to the ASCII set)
- are preloaded. This means that usual text is rendered fast enough, but no
- memory is wasted loading glyphs that will not be used.
-
- \section commands More font commands
-
- \subsection metrics Font metrics
-
- \image html metrics.png
- \image latex metrics.eps "" width=0.5\textwidth
-
- If you ask a font to render at 0.0, 0.0 the bottom left most pixel or polygon
- may not be aligned to 0.0, 0.0. With FTFont::Ascender(), FTFont::Descender()
- and FTFont::Advance() an approximate bounding box can be calculated.
-
- For an exact bounding box, use the FTFont::BBox() function. This function
- returns the extent of the volume containing 'string'. 0.0 on the y axis will
- be aligned with the font baseline.
-
- \subsection charmap Specifying a character map encoding
-
- From the FreeType documentation:
-
- "By default, when a new face object is created, (FreeType) lists all the
- charmaps contained in the font face and selects the one that supports Unicode
- character codes if it finds one. Otherwise, it tries to find support for
- Latin-1, then ASCII."
-
- It then gives up. In this case %FTGL will set the charmap to the first it
- finds in the fonts charmap list. You can expilcitly set the char encoding with
- FTFont::CharMap().
-
- Valid encodings as of FreeType 2.0.4 are:
-
- - ft_encoding_none
- - ft_encoding_unicode
- - ft_encoding_symbol
- - ft_encoding_latin_1
- - ft_encoding_latin_2
- - ft_encoding_sjis
- - ft_encoding_gb2312
- - ft_encoding_big5
- - ft_encoding_wansung
- - ft_encoding_johab
- - ft_encoding_adobe_standard
- - ft_encoding_adobe_expert
- - ft_encoding_adobe_custom
- - ft_encoding_apple_roman
-
- For instance:
-
- \code
-font.CharMap(ft_encoding_apple_roman);
- \endcode
-
- This will return an error if the requested encoding can't be found in the
- font.
-
- If your application uses Latin-1 characters, you can preload this character
- set using the following code:
-
- \code
-// Create a pixmap font from a TrueType file.
-FTGLPixmapFont font("/home/user/Arial.ttf");
-
-// If something went wrong, bail out.
-if(font.Error())
- return -1;
-
-// Set the face size and the character map. If something went wrong, bail out.
-font.FaceSize(72);
-if(!font.CharMap(ft_encoding_latin_1))
- return -1;
-
-// Create a string containing all characters between 128 and 255
-// and preload the Latin-1 chars without rendering them.
-char buf[129];
-for(int i = 128; i < 256; i++)
-{
- buf[i] = (char)(unsigned char)i;
-}
-buf[128] = '\0';
-
-font.Advance(buf);
-}
- \endcode
-
-
- \section faq FAQ
-
- \subsection faq1 When I try to compile FTGL it complains about a missing file from the include: #include <ft2build.h>
-
- %FTGL relies on FreeType 2 for opening and decoding font files. This include
- is the main include for FreeType. You will need to download Freetype 2 and
- install it. Then make sure that the %FTGL project that you are using points to
- your FreeType installation.
-
- \subsection faq2 Is it possible to map a font to a "unit" size? My application relies on the fonts being a certain "physical" height (in OpenGL coordinate space) rather than a point size in display space. Any thoughts/suggestions?
-
- We can do anything:) It would be easy to allow you to set the size in pixels,
- though I'm not sure this is what you want. Setting the size to 'OpenGL units'
- may be a bit harder. What does 1.0 in opengl space mean and how does that
- relate to point size? For one person it might mean scaling the font up, for
- someone else it may mean scaling down. Plus bitmaps and pixmaps have a pixel
- to pixel relationship that you can't change.
-
- Here's some guidelines for vector and texture fonts. Take note that I say
- 'should' a lot :)
-
- - One point in pixel space maps to 1 unit in OpenGL space, so a glyph that is
- 18 points high should be 18.0 units high.
-
- - If you set an ortho projection to the window size and draw a glyph it's
- screen size should be the correct physical size ie a 72 point glyph on a 72dpi
- screen will be 1 inch high. Also if you set a perspective projection that maps
- 0.0 in the z axis to screen size you will get the same eg.
- \code
-gluPerspective(90, window_height / 2 , small_number, large_number);
- \endcode
- So basically it all depends on your projection matrix. Obviously you can use
- glScale but I understand if you don't want to.
-
- Couple of extra things to note:
-
- - The quality of vector glyphs will not change when you change the size, ie.
- a really small polygon glyph up close will look exactly the same as a big one
- from far away. They both contain the same amount of data. This doesn't apply
- to texture fonts.
-
- - Secondly, there is a bug in the advance/kerning code that will cause
- ugliness at really small point sizes. This is because the advance and kerning
- use ints so an advance of 0.4 will become zero. If this is going to be a
- probelm, I can fix this.
-
- Early on I did a lot of head scratching over the OpenGL unit to font size
- thing because when I was first integrating %FTGL into my engine the fonts
- weren't the size I was expecting. I was tempted to build in some scaling but I
- decided doing nothing was the best approach because you can't please everyone.
- Plus it's 'correct' as it is.
-
-
- \section sample Sample font manager class
-
-\code
-FTTextureFont* myFont = FTGLFontManager::Instance().GetFont("arial.ttf", 72);
-
-#include <map>
-#include <string>
-#include <FTGL/ftgl.h>
-
-using namespace std;
-
-typedef map<string, FTFont*> FontList;
-typedef FontList::const_iterator FontIter;
-
-class FTGLFontManager
-{
- public:
- // NOTE
- // This is shown here for brevity. The implementation should be in the source
- // file otherwise your compiler may inline the function resulting in
- // multiple instances of FTGLFontManager
- static FTGLFontManager& Instance()
- {
- static FTGLFontManager tm;
- return tm;
- }
-
- ~FTGLFontManager()
- {
- FontIter font;
- for(font = fonts.begin(); font != fonts.end(); font++)
- {
- delete (*font).second;
- }
-
- fonts.clear();
- }
-
-
- FTFont* GetFont(const char *filename, int size)
- {
- char buf[256];
- sprintf(buf, "%s%i", filename, size);
- string fontKey = string(buf);
-
- FontIter result = fonts.find(fontKey);
- if(result != fonts.end())
- {
- LOGMSG("Found font %s in list", filename);
- return result->second;
- }
-
- FTFont* font = new FTTextureFont;
-
- string fullname = path + string(filename);
-
- if(!font->Open(fullname.c_str()))
- {
- LOGERROR("Font %s failed to open", fullname.c_str());
- delete font;
- return NULL;
- }
-
- if(!font->FaceSize(size))
- {
- LOGERROR("Font %s failed to set size %i", filename, size);
- delete font;
- return NULL;
- }
-
- fonts[fontKey] = font;
-
- return font;
- }
-
-
- private:
- // Hide these 'cause this is a singleton.
- FTGLFontManager(){}
- FTGLFontManager(const FTGLFontManager&){};
- FTGLFontManager& operator = (const FTGLFontManager&){ return *this; };
-
- // container for fonts
- FontList fonts;
-};
-\endcode
+ - \subpage ftgl-projects
*/
diff --git a/docs/projects_using_ftgl.txt b/docs/projects_using_ftgl.txt
index c12d992..8b16558 100644
--- a/docs/projects_using_ftgl.txt
+++ b/docs/projects_using_ftgl.txt
@@ -1,35 +1,27 @@
+/** \page ftgl-projects Projects using FTGL
-To add your name to this list, please contact one of the FTGL
+To add your project to this list, please contact one of the %FTGL
developers at http://sf.net/projects/ftgl
Projects are listed in alphabetical order.
-Projects currently using FTGL
------------------------------
+\section current Projects currently using FTGL
-Blender
-http://blender.org/
+ - Blender (http://blender.org/)
-BZFlag
-http://BZFlag.org/
-as of version 2.99
+ - BZFlag (http://BZFlag.org/), as of version 2.99
-Duel
-http://www.personal.rdg.ac.uk/~sir03me/play/code.html
+ - Duel (http://www.personal.rdg.ac.uk/~sir03me/play/code.html)
-FTGL#
-http://www.paskaluk.com/projects.php
+ - %FTGL# (http://www.paskaluk.com/projects.php)
-Ruby FTGL
-http://rubyforge.org/projects/ruby-ftgl/
+ - Ruby %FTGL (http://rubyforge.org/projects/ruby-ftgl/)
-VTK
-http://www.vtk.org/
+ - VTK (http://www.vtk.org/)
-Projects that used to use FTGL
-------------------------------
+\section old Projects that used to use FTGL
-GNU Backgammon
-http://www.gnubg.org/
-until version 0.14.3+20060520-1
+ - GNU Backgammon (http://www.gnubg.org/), until version 0.14.3+20060520-1
+
+*/
diff --git a/docs/tutorial.dox b/docs/tutorial.dox
new file mode 100644
index 0000000..dae3062
--- /dev/null
+++ b/docs/tutorial.dox
@@ -0,0 +1,262 @@
+/** \page ftgl-tutorial FTGL tutorial
+
+ \section starting Starting to use FTGL
+
+ Only one header is required to use %FTGL:
+
+\code
+#include <FTGL/ftgl.h>
+\endcode
+
+ \section type Choosing a font type
+
+ %FTGL supports 6 font output types among 3 groups: raster fonts, vector
+ fonts, and texture fonts which are a mixture of both. Each font type has its
+ advantages and disadvantages.
+
+ \subsection raster Raster fonts
+
+ Raster fonts are made of pixels painted directly on the viewport's
+ framebuffer. They cannot be directly rotated or scaled.
+
+ - Bitmap fonts use 1-bit (2-colour) rasterised glyphs.
+ - Pixmap fonts use 8-bit (256 levels) rasterised glyphs.
+
+ \image html rasterfont.png
+ \image latex rasterfont.eps "" width=0.7\textwidth
+
+ \subsection vector Vector fonts
+
+ Vector fonts are 3D objects that are rendered at the current matrix location.
+ All position, scale, texture and material effects apply to vector fonts.
+
+ - Polygon fonts use planar triangle meshes and can be texture-mapped.
+ - Outline fonts use OpenGL lines.
+ - Extruded fonts are extruded polygon fonts, with the front, back and side
+ meshes renderable separately to apply different effects and materials.
+
+ \image html vectorfont.png
+ \image latex vectorfont.eps "" width=0.7\textwidth
+
+ \subsection texture Texture fonts
+
+ Texture fonts are probably the most versatile type. They are fast,
+ antialiased, and can be transformed just like any OpenGL primitive.
+
+ \image html texturefont.png
+ \image latex texturefont.eps "" width=0.7\textwidth
+
+ \section creating Create font objects
+
+ Creating a font and displaying some text is really straightforward, be it
+ in C or in C++.
+
+ \subsection c in C
+
+ \code
+/* Create a pixmap font from a TrueType file. */
+FTGLfont *font = ftglCreatePixmapFont("/home/user/Arial.ttf");
+
+/* If something went wrong, bail out. */
+if(!font)
+ return -1;
+
+/* Set the font size and render a small text. */
+ftglSetFontFaceSize(font, 72, 72);
+ftglRenderFont(font, "Hello World!", FTGL_RENDER_ALL);
+
+/* Destroy the font object. */
+ftglDestroyFont(font);
+ \endcode
+
+ \subsection cxx in C++
+
+ \code
+// Create a pixmap font from a TrueType file.
+FTGLPixmapFont font("/home/user/Arial.ttf");
+
+// If something went wrong, bail out.
+if(font.Error())
+ return -1;
+
+// Set the font size and render a small text.
+font.FaceSize(72);
+font.Render("Hello World!");
+ \endcode
+
+ The first 128 glyphs of the font (generally corresponding to the ASCII set)
+ are preloaded. This means that usual text is rendered fast enough, but no
+ memory is wasted loading glyphs that will not be used.
+
+ \section commands More font commands
+
+ \subsection metrics Font metrics
+
+ \image html metrics.png
+ \image latex metrics.eps "" width=0.5\textwidth
+
+ If you ask a font to render at 0.0, 0.0 the bottom left most pixel or polygon
+ may not be aligned to 0.0, 0.0. With FTFont::Ascender(), FTFont::Descender()
+ and FTFont::Advance() an approximate bounding box can be calculated.
+
+ For an exact bounding box, use the FTFont::BBox() function. This function
+ returns the extent of the volume containing 'string'. 0.0 on the y axis will
+ be aligned with the font baseline.
+
+ \subsection charmap Specifying a character map encoding
+
+ From the FreeType documentation:
+
+ "By default, when a new face object is created, (FreeType) lists all the
+ charmaps contained in the font face and selects the one that supports Unicode
+ character codes if it finds one. Otherwise, it tries to find support for
+ Latin-1, then ASCII."
+
+ It then gives up. In this case %FTGL will set the charmap to the first it
+ finds in the fonts charmap list. You can expilcitly set the char encoding with
+ FTFont::CharMap().
+
+ Valid encodings as of FreeType 2.0.4 are:
+
+ - ft_encoding_none
+ - ft_encoding_unicode
+ - ft_encoding_symbol
+ - ft_encoding_latin_1
+ - ft_encoding_latin_2
+ - ft_encoding_sjis
+ - ft_encoding_gb2312
+ - ft_encoding_big5
+ - ft_encoding_wansung
+ - ft_encoding_johab
+ - ft_encoding_adobe_standard
+ - ft_encoding_adobe_expert
+ - ft_encoding_adobe_custom
+ - ft_encoding_apple_roman
+
+ For instance:
+
+ \code
+font.CharMap(ft_encoding_apple_roman);
+ \endcode
+
+ This will return an error if the requested encoding can't be found in the
+ font.
+
+ If your application uses Latin-1 characters, you can preload this character
+ set using the following code:
+
+ \code
+// Create a pixmap font from a TrueType file.
+FTGLPixmapFont font("/home/user/Arial.ttf");
+
+// If something went wrong, bail out.
+if(font.Error())
+ return -1;
+
+// Set the face size and the character map. If something went wrong, bail out.
+font.FaceSize(72);
+if(!font.CharMap(ft_encoding_latin_1))
+ return -1;
+
+// Create a string containing all characters between 128 and 255
+// and preload the Latin-1 chars without rendering them.
+char buf[129];
+for(int i = 128; i < 256; i++)
+{
+ buf[i] = (char)(unsigned char)i;
+}
+buf[128] = '\0';
+
+font.Advance(buf);
+}
+ \endcode
+
+
+ \section sample Sample font manager class
+
+\code
+FTTextureFont* myFont = FTGLFontManager::Instance().GetFont("arial.ttf", 72);
+
+#include <map>
+#include <string>
+#include <FTGL/ftgl.h>
+
+using namespace std;
+
+typedef map<string, FTFont*> FontList;
+typedef FontList::const_iterator FontIter;
+
+class FTGLFontManager
+{
+ public:
+ // NOTE
+ // This is shown here for brevity. The implementation should be in the source
+ // file otherwise your compiler may inline the function resulting in
+ // multiple instances of FTGLFontManager
+ static FTGLFontManager& Instance()
+ {
+ static FTGLFontManager tm;
+ return tm;
+ }
+
+ ~FTGLFontManager()
+ {
+ FontIter font;
+ for(font = fonts.begin(); font != fonts.end(); font++)
+ {
+ delete (*font).second;
+ }
+
+ fonts.clear();
+ }
+
+
+ FTFont* GetFont(const char *filename, int size)
+ {
+ char buf[256];
+ sprintf(buf, "%s%i", filename, size);
+ string fontKey = string(buf);
+
+ FontIter result = fonts.find(fontKey);
+ if(result != fonts.end())
+ {
+ LOGMSG("Found font %s in list", filename);
+ return result->second;
+ }
+
+ FTFont* font = new FTTextureFont;
+
+ string fullname = path + string(filename);
+
+ if(!font->Open(fullname.c_str()))
+ {
+ LOGERROR("Font %s failed to open", fullname.c_str());
+ delete font;
+ return NULL;
+ }
+
+ if(!font->FaceSize(size))
+ {
+ LOGERROR("Font %s failed to set size %i", filename, size);
+ delete font;
+ return NULL;
+ }
+
+ fonts[fontKey] = font;
+
+ return font;
+ }
+
+
+ private:
+ // Hide these 'cause this is a singleton.
+ FTGLFontManager(){}
+ FTGLFontManager(const FTGLFontManager&){};
+ FTGLFontManager& operator = (const FTGLFontManager&){ return *this; };
+
+ // container for fonts
+ FontList fonts;
+};
+\endcode
+
+*/