Added JavaDoc comments
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
diff --git a/include/FTFace.h b/include/FTFace.h
index 6e347a6..c909463 100755
--- a/include/FTFace.h
+++ b/include/FTFace.h
@@ -9,26 +9,95 @@
#include "FTSize.h"
-
-
+/**
+ * FTFace class provides an abstraction layer for the Freetype Face.
+ *
+ * @see "Freetype 2 Documentation - 2.0.4"
+ *
+ */
class FTFace
{
public:
// methods
+ /**
+ * Default Constructor
+ */
FTFace();
+
+ /**
+ * Destructor
+ *
+ * Disposes of the current Freetype Face.
+ */
virtual ~FTFace();
+
+ /**
+ * Opens and reads a face file.
+ *
+ * @param fontname font file name.
+ * @return <code>true</code> if file has opened
+ * successfully.
+ */
bool Open( const char* filename);
+
+ /**
+ * Disposes of the face
+ */
void Close();
+
+ /**
+ * Sets the char size for the current face.
+ *
+ * This doesn't guarantee that the size was set correctly. Clients
+ * should check errors.
+ *
+ * @params size the face size in points (1/72 inch)
+ * @params res the resolution of the target device.
+ * @return <code>FTSize</code> object
+ */
FTSize& Size( const unsigned int size, const unsigned int res);
+
+ /**
+ * Sets the character map for the face.
+ *
+ * @params encoding XXXXXXX
+ * @return <code>true</code> if charmap was valid and
+ * set correctly
+ */
bool CharMap( FT_Encoding encoding);
+
+ /**
+ * Get the glyph index of the input character.
+ *
+ * @param
+ * @return
+ */
unsigned int CharIndex( unsigned int index ) const;
+
+ /**
+ * Gets the ferning vector between two glyphs
+ */
FT_Vector& KernAdvance( unsigned int index1, unsigned int index2);
+
+ /**
+ * Loads and creates a Freetype glyph.
+ */
FT_Glyph& Glyph( unsigned int index, FT_Int load_flags);
+
+ /**
+ * Gets the current Freetype face.
+ */
FT_Face* Face() const { return ftFace;}
- FT_Error Error() const { return err;}
+
+ /**
+ * Queries for errors.
+ *
+ * @return The current error code.
+ */
+ FT_Error Error() const { return err; }
// attributes
@@ -36,16 +105,41 @@ class FTFace
// methods
// attributes
- FT_Error err;
+
+ /**
+ * The size object associated with this face
+ */
FTSize charSize;
+
+ /**
+ * The Freetype face
+ */
FT_Face* ftFace;
+
+ /**
+ * Temporary variable to hold a glyph
+ */
FT_Glyph ftGlyph;
-
+
+ /**
+ * The number of character maps in this face.
+ */
int numCharMaps;
+
+ /**
+ * The number of glyphs in this face
+ */
int numGlyphs;
-
+
+ /**
+ * Temporary variable to holding a kerning vector.
+ */
FT_Vector kernAdvance;
+ /**
+ * Current error code. Zero means no error.
+ */
+ FT_Error err;
};
diff --git a/include/FTFont.h b/include/FTFont.h
index 147f656..af55ac2 100755
--- a/include/FTFont.h
+++ b/include/FTFont.h
@@ -7,7 +7,6 @@
#include FT_FREETYPE_H
#include "FTFace.h"
-
#include "FTGL.h"
@@ -16,46 +15,158 @@ class FTGlyphContainer;
using namespace std;
+
+/**
+ * FTFont is the public interface for the FTGL library.
+ *
+ * Specific font classes are derived from this class. It uses the helper
+ * classes FTFace and FTSize to access the Freetype library. This class
+ * is abstract and deriving classes must implement the protected
+ * <code>MakeGlyphList</code> function to build a glyphList with the
+ * appropriate glyph type.
+ *
+ * @see FTFace
+ * @see FTSize
+ * @see FTGlyphContainer
+ * @see FTGlyph
+ */
class FTFont
{
public:
// methods
+
+ /**
+ * Default Constructor
+ */
FTFont();
+
+ /**
+ * Destructor
+ */
virtual ~FTFont();
+
+ /**
+ * Opens and reads a font file.
+ *
+ * @param fontname font file name.
+ * @return <code>true</code> if file has opened
+ * successfully.
+ */
virtual bool Open( const char* fontname );
+
+ /**
+ * Disposes of the font
+ */
virtual void Close();
+
+ /**
+ * Sets the char size for the current face.
+ *
+ * @params size the face size in points (1/72 inch)
+ * @params res the resolution of the target device.
+ * @return <code>true</code> if size was set correctly
+ */
virtual bool FaceSize( const unsigned int size, const unsigned int res = 72 );
+
+ /**
+ * Sets the character map for the face.
+ *
+ * @params encoding XXXXXXXXX
+ * @return <code>true</code> if charmap was valid and
+ * set correctly
+ */
virtual bool CharMap( FT_Encoding encoding );
+
+ /**
+ * Gets the global ascender height for the face in pixels.
+ *
+ * @return Ascender height
+ */
virtual int Ascender() const;
+
+ /**
+ * Gets the global descender height for the face in pixels.
+ *
+ * @return Descender height
+ */
virtual int Descender() const;
- virtual void BBox( const char* text, int& llx, int& lly, int& urx, int& ury ) const;
+
+ /**
+ * Gets the bounding box dimensions for a string.
+ *
+ * @params XXXXXXX
+ * @params XXXXXXX
+ * @params XXXXXXX
+ * @params XXXXXXX
+ * @params XXXXXXX
+ */
+ virtual void BBox( const char* string, int& llx, int& lly, int& urx, int& ury ) const;
+
+ /**
+ * Renders a string of characters
+ *
+ * @params string 'C' style string to be output.
+ */
virtual void render( const char* string );
+
+ /**
+ * Queries the Font for errors.
+ *
+ * @return The current error code.
+ */
virtual FT_Error Error() const { return err;}
// virtual const char* ErrorString();
-
// attributes
protected:
// methods
+
+ /**
+ * Constructs the internal glyph cache.
+ *
+ * This a list of glyphs processed for openGL rendering NOT
+ * freetype glyphs
+ */
virtual bool MakeGlyphList() = 0;
// attributes
- FT_Error err;
-
- // future list of faces
+
+ /**
+ * Current face object
+ */
FTFace face;
+ /**
+ * Number of faces in this font
+ */
int numFaces;
- // future list of sizes
+ /**
+ * Current size object
+ */
FTSize charSize;
- int numGlyphs;
+ /**
+ * An object that holds a list of glyphs
+ */
FTGlyphContainer* glyphList;
+ /**
+ * The number of glyphs in this font
+ */
+ int numGlyphs;
+
+ /**
+ * Current pen or sursor position;
+ */
FT_Vector pen;
+ /**
+ * Current error code. Zero means no error.
+ */
+ FT_Error err;
+
private:
// methods
diff --git a/include/FTGlyph.h b/include/FTGlyph.h
index 7bcf4d9..a60428f 100755
--- a/include/FTGlyph.h
+++ b/include/FTGlyph.h
@@ -7,30 +7,77 @@
//#include "FTGL.h"
-
+/**
+ * FTGlyph is the base clas for FTGL glyphs.
+ *
+ * It provides the interface between Freetype glyphs and their openGL
+ * renderable counterparts. This is an abstract class and derived classes
+ * must implement the <code>render</code> function.
+ *
+ * @see FTGlyphContainer
+ *
+ */
class FTGlyph
{
public:
// methods
+
+ /**
+ * Constructor
+ *
+ * @param glyphIndex The glyph index
+ */
FTGlyph( unsigned int glyphIndex);
+
+ /**
+ * Destructor
+ */
virtual ~FTGlyph();
+
+ /**
+ *
+ */
virtual float Render( const FT_Vector& v) = 0;
-
+
+ /**
+ * Queries for errors.
+ *
+ * @return The current error code.
+ */
FT_Error Error() const { return err;}
// attributes
- const unsigned int glyphIndex;
+
+ /**
+ *
+ */
+ const unsigned int glyphIndex; // FIXME make this private
protected:
// methods
// attributes
- FT_Error err;
-
+
+ /**
+ * The advance distance for this glyph
+ */
float advance;
+
+ /**
+ * Vector from the pen position to the topleft corner of the glyph
+ */
FT_Vector pos;
+
+ /**
+ * Temporary holder for the Freetype glyph
+ */
FT_Glyph ftGlyph;
+ /**
+ * Current error code. Zero means no error.
+ */
+ FT_Error err;
+
private:
// methods
diff --git a/include/FTLibrary.h b/include/FTLibrary.h
index 931adea..2c99218 100755
--- a/include/FTLibrary.h
+++ b/include/FTLibrary.h
@@ -9,30 +9,91 @@
#include "FTGL.h"
+/**
+ * FTLibrary class is the global accessor for the Freetype library.
+ *
+ * This class encapsulates the Freetype Library. This is a singleton class
+ * and ensures that only one FT_Library is in existence at any one time.
+ * All constructors are private therefore clients cannot create or
+ * instantiate this class themselves and must access it's methods via the
+ * static <code>FTLibrary::Instance()</code> function.
+ *
+ * Just because this class returns a valid <code>FTLibrary</code> object
+ * doesn't mean that the Freetype Library has been successfully initialised.
+ * Clients should check for errors. You can initialse the library AND check
+ * for errors using the following code...
+ * <code>err = FTLibrary::Instance().Error();</code>
+ *
+ * @see "Freetype 2 Documentation - 2.0.4"
+ *
+ */
class FTLibrary
{
public:
// methods
+ /**
+ * Global acces point to the single FTLibrary object.
+ *
+ * @return The global <code>FTLibrary</code> object.
+ */
static FTLibrary& Instance();
+
+ /**
+ * Gets a pointer to the native Freetype library.
+ *
+ * @return A handle to a FreeType library instance.
+ */
FT_Library* GetLibrary() const { return lib;}
+ /**
+ * Queries the library for errors.
+ *
+ * @return The current error code.
+ */
virtual FT_Error Error() const { return err;}
+ /**
+ * Destructor
+ *
+ * Disposes of the Freetype library
+ */
virtual ~FTLibrary();
// attributes
private:
// methods
+ /**
+ * Default constructors.
+ *
+ * Made private to stop clients creating there own FTLibrary
+ * objects.
+ */
FTLibrary();
FTLibrary( const FT_Library&){}
FTLibrary& operator=( const FT_Library&){}
+
+ /**
+ * Initialises the Freetype library
+ *
+ * Even though this function indicates success via the return value,
+ * clients can't see this so must check the error codes.
+ *
+ * @return <code>true</code> if the Freetype library was successfully
+ * initialised, <code>false</code> otherwise.
+ */
bool Init();
// attributes
+ /**
+ * Freetype library handle.
+ */
FT_Library* lib;
-// FTC_Manager* manager; /* the cache manager */
+// FTC_Manager* manager;
+ /**
+ * Current error code. Zero means no error.
+ */
FT_Error err;
diff --git a/include/FTSize.h b/include/FTSize.h
index 7cda0f4..2ea8b8f 100755
--- a/include/FTSize.h
+++ b/include/FTSize.h
@@ -7,19 +7,91 @@
#include "FTGL.h"
+/**
+ * FTSize class provides an abstraction layer for the Freetype Size.
+ *
+ * @see "Freetype 2 Documentation - 2.0.4"
+ *
+ */
class FTSize
{
public:
// methods
- FTSize();
+
+ /**
+ * Default Constructor
+ */
+ FTSize();
+
+ /**
+ * Destructor
+ */
virtual ~FTSize();
+
+ /**
+ * Sets the char size for the current face.
+ *
+ * This doesn't guarantee that the size was set correctly. Clients
+ * should check errors.
+ *
+ * @params point_size the face size in points (1/72 inch)
+ * @params x_resolution the horizontal resolution of the target device.
+ * @params y_resolution the vertical resolution of the target device.
+ * @return <code>true</code> if the size has been set. Clients should check Error() for more information if this function returns false()
+ */
bool CharSize( FT_Face* face, unsigned int point_size, unsigned int x_resolution, unsigned int y_resolution );
+
+ /**
+ * Gets the global ascender height for the face in pixels.
+ *
+ * @return Ascender height
+ */
int Ascender() const;
+
+ /**
+ * Gets the global descender height for the face in pixels.
+ *
+ * @return Ascender height
+ */
int Descender() const;
+
+ /**
+ * Gets the global face height for the face.
+ *
+ * If the face is scalable this returns the height of the global
+ * bounding box which ensures that any glyph will be less than or
+ * equal to this height. If the font isn't scalable there is no
+ * guarantee that glyphs will not be taller than this value.
+ *
+ * @return height in pixels.
+ */
int Height() const;
+
+ /**
+ * Gets the global face width for the face.
+ *
+ * If the face is scalable this returns the width of the global
+ * bounding box which ensures that any glyph will be less than or
+ * equal to this width. If the font isn't scalable this value is
+ * the max_advance for the face.
+ *
+ * @return width in pixels.
+ */
int Width() const;
+
+ /**
+ * Gets the underline posiotn for the face.
+ *
+ * @return underline position in pixels
+ */
int Underline() const;
+
+ /**
+ * Queries for errors.
+ *
+ * @return The current error code.
+ */
FT_Error Error() const { return err; }
// attributes
@@ -28,10 +100,25 @@ class FTSize
// methods
// attributes
+
+ /**
+ * The current Freetype face that this FTSize object relates to.
+ */
FT_Face* ftFace;
+
+ /**
+ * The Freetype size.
+ */
FT_Size ftSize;
+
+ /**
+ * The size in points.
+ */
unsigned int size;
+ /**
+ * Current error code. Zero means no error.
+ */
FT_Error err;
};