TextRenderer The font container
Construct the font by loading a True Type Font file.
Construct the font by making an altered copy of an existing TextRenderer. If you don't pass anything as the color or the italics parameter they'll be inherited from otherRenderer. Construct the font by using a Glyph Keeper font face.
The default constructor. Note that the TextRenderer will not be ready to use before you call the Load -method (IsValid() returns false). The constructors do the the same as the equivalent Load -methods. The dimensions are in pixels and the italics angle is in degrees. The alpha value of the color controls the opacity of the printed text. The higher the alpha value is, the more visible the text will be. For more information about alpha values see the definition of Bitmap. If any of these functions fail to construct the font an error log will be added to the allegro.log file. In addition the IsValid() -method will return false if the TextRenderer is not ready to use. You can also test the validity of a TextRenderer like if the TextRenderer was a boolean value. Global TextRenderers are now automated. Examples // Construct a new font by loading a true type font Arial.ttf in the fonts -folder //
// with the width of 10, the height of 15 and a black color // TextRenderer myTextRenderer( "fonts/Arial.ttf", 10, 15, Rgba::BLACK ); // Construct a same looking font but with italics angle of 12 (the common italics angle) // TextRenderer myItalicsRenderer( "fonts/Arial.ttf", 10, 15, Rgba::BLACK, 12 ); // Test if myItalicsRenderer was loaded correctly (maybe it didn't exist) // if( !myItalicsRenderer ) { allegro_message( "Couldn't load fonts/Arial.ttf" ); } // Construct a font which looks like myTextRenderer but with the opacity of only 30% // TextRenderer myTranslucentRenderer( "fonts/Arial.ttf", 10, 15, Rgba( 0.0, 0.0, 0.0, 0.30 )); // Construct a smaller copy of an existing font (sized 9x12) // // If you don't specify a color it'll be inherited // // from the passed TextRenderer // TextRenderer smallerTextRenderer( myTextRenderer, 9, 12 ); // Construct the font from a glyph keeper font face // // with a slightly yellow green color // GLYPH_FACE *glyphKeeperFace = ...; TextRenderer otherTextRenderer( glyphKeeperFace, 20, 15, Rgba( 0.3, 1.0, 0.0 )); Member functions
Questions about TextRenderer? Click here. |