Load
Load 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. 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 load 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. A word of caution: You can't load any TextRenderers before Setup::SetupProgram and Setup::SetupScreen are called! Examples // The usage of the Load -method is generally the same as with the constructors //
// 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; if( myTextRenderer.Load( "fonts/Arial.ttf", 10, 15, Rgba::BLACK ) == false ) { allegro_message( "Couldn't load the font Arial.ttf!" ); exit( -1 ); } // Construct a same looking font but with italics angle of 12 (the common italics angle) // TextRenderer myItalicsRenderer; if( myItalicsRenderer.Load( "fonts/Arial.ttf", 10, 15, Rgba::BLACK, 12 ) == false ) { allegro_message( "Couldn't load the font Arial.ttf!" ); exit( -1 ); } // Construct a font which looks like myTextRenderer but with the opacity of only 30% // TextRenderer myTranslucentRenderer; if( myTranslucentRenderer.Load( "fonts/Arial.ttf", 10, 15, Rgba( 0.0, 0.0, 0.0, 0.30 )) == false ) { allegro_message( "Couldn't load the font Arial.ttf!" ); exit( -1 ); } // 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; smallerTextRenderer.Load( myTextRenderer, 9, 12 ); // Construct the font from a glyph keeper font face // // with a slightly yellow green color // GLYPH_FACE *glyphKeeperFace = ...; TextRenderer otherTextRenderer; if( otherTextRenderer.Load( glyphKeeperFace, 20, 15, Rgba( 0.3, 1.0, 0.0 )) == false ) { allegro_message( "Couldn't load the font from a Glyph Keeper face!" ); exit( -1 ); } Other functions of the class TextRenderer
Questions about Load? Click here. |