Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

font.h

Go to the documentation of this file.
00001 /*
00002         $Id: font.h,v 1.1 2001/03/06 15:09:10 mbn Exp $
00003 
00004         ------------------------------------------------------------------------
00005         ClanLib, the platform independent game SDK.
00006 
00007         This library is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE
00008         version 2. See COPYING for details.
00009 
00010         For a total list of contributers see CREDITS.
00011 
00012         ------------------------------------------------------------------------
00013 
00014         File purpose:
00015                 Simple font support.
00016 */
00017 
00019 
00020 #ifndef header_font
00021 #define header_font
00022 
00023 class CL_Target;
00024 class CL_ResourceManager;
00025 class CL_Font_Description;
00026 class CL_Font_Generic;
00027 
00028 class CL_Font
00029 //: ClanLib's font class.
00030 // <p>This class allows you to easilly draw text onto the backbuffer or to a
00031 // renderer target.</p>
00032 //
00033 // <p>The font can be created in two ways. Either it is loaded from a
00034 // resource, or it is created using the font description interface. The font
00035 // and its description have the same relationship/functionality as the <a
00036 // class="CL_Surface">surface</a> and its <a
00037 // class="CL_SurfaceProvider">provider</a>.</p>
00038 //
00039 // <p>Please read the CL_Font_Description page if you want an description on
00040 // how to create your own font.</p>
00041 {
00042 public:
00043         enum alignments
00044         {
00045                 ALIGN_LEFT,
00046                 ALIGN_CENTER,
00047                 ALIGN_RIGHT
00048         };
00049         // Contains the alignment of the text.
00050         // Doesn't need to be set and is used to hold and set the current alignment
00051         // You can safely ignore this
00055 
00056 public:
00058         static CL_Font *create(CL_Font_Description *font_desc);
00059         // Creates the font from a font description.
00061         
00062         static CL_Font *load(
00063                 const char *resource_id,
00064                 CL_ResourceManager *resource_manager);
00065         // Loads the font from resources.
00069 
00071         CL_Font(CL_Font_Description *provider);
00072         //: Creates a font from a font provider/description
00073 
00074         CL_Font(const char *resource_id, CL_ResourceManager *manager);
00075         //: Loads a font from a resource file.
00076 
00077         CL_Font(const CL_Font &font);
00078         //: Make a copy of an other font, but share the image data.
00079 
00080         virtual ~CL_Font();
00081 
00083         int get_height();
00084         //: Returns the height of the font.
00086 
00087         int get_text_width(const char *text);
00088         //: Return the width of 'text' if drawn with this font.
00091 
00092         int get_char_width(const char character);
00093         //: Return the width of character if drawn with this font.
00096         
00097         void print_left(int x, int y, const char *text, int n_height=1);
00098         //: Prints 'text' left aligned at coordinates ('x','y').
00103 
00104         void print_left(int x, int y, float scale_x, float scale_y, const char *text);
00105         //: Prints 'text' left aligned at coordinates ('x','y').
00111         
00112         void print_center(int x, int y, const char *text);
00113         //: Prints 'text' center aligned at coordinates ('x','y').
00117 
00118         void print_right(int x, int y, const char *text);
00119         //: Prints 'text' right aligned at coordinates ('x','y').
00123         
00124         void put_target(int x, int y, const char *text, CL_Target *target, int alignment = ALIGN_LEFT);
00125         //: Prints 'text' aligned with alignment at coordinates ('x','y') to the target surface.
00126         //: If CL_Font::ALIGN_LEFT is specified the text is draw starting from x, y.
00127         //: If CL_Font::ALIGN_CENTER is specified the text is centered at x, y.
00128         //: If CL_Font::ALIGN_RIGHT is specified the text ends at x, y;
00134 
00135   int change_size(int size);
00136   //: Changes the size of the font used.
00137   //: This function only does something meaninful if you use TrueType fonts
00140 
00141   unsigned int change_colour(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
00142   //: Changes the colour of the font used.
00148 
00149 
00151         CL_Font(class CL_Font_Generic *impl);
00152         class CL_Font_Generic *impl;
00153 };
00154 
00155 #endif

Generated at Wed Apr 4 19:54:00 2001 for ClanLib by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001