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

font.cpp

Go to the documentation of this file.
00001 /*
00002         $Id: font.cpp,v 1.1 2001/03/06 15:09:20 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 class.
00016 
00017 */
00018 
00019 #include "Core/precomp.h"
00020 
00021 #include <API/Display/Font/font.h>
00022 #include <API/Core/Resources/resource_manager.h>
00023 #include <API/Core/Resources/resource.h>
00024 #include <API/Core/System/cl_assert.h>
00025 #include <API/Core/System/error.h>
00026 
00027 #include "font_bitmap.h"
00028 #include "resourcetype_font.h"
00029 
00030 CL_Font *CL_Font::create(CL_Font_Description *font_desc)
00031 {
00032         return new CL_Font(font_desc);
00033 }       
00034 
00035 CL_Font *CL_Font::load(
00036         const char *resource_id,
00037         CL_ResourceManager *manager)
00038 {
00039         return new CL_Font(resource_id, manager);
00040 }
00041 
00042 CL_Font::CL_Font(CL_Font_Description *provider)
00043 {
00044         impl = new CL_Font_Bitmap(provider);
00045         impl->add_reference();
00046 }
00047 
00048 CL_Font::CL_Font(
00049         const char *resource_id,
00050         CL_ResourceManager *manager)
00051 {
00052         CL_Font_Resource_Generic *resource = 
00053                 (CL_Font_Resource_Generic *) manager->get_resource(resource_id);
00054         cl_assert(resource != NULL);
00055 
00056         if (resource->get_type() != "font" && resource->get_type() != "TTF")
00057                 throw CL_Error("Resource is not a valid font !");
00058 
00059         impl = resource->get_font()->impl;
00060         impl->add_reference();
00061 }
00062 
00063 CL_Font::CL_Font(class CL_Font_Generic *_impl) : impl(_impl)
00064 {
00065         impl->add_reference();
00066 }
00067 
00068 CL_Font::CL_Font(const CL_Font &font)
00069 {
00070         impl->add_reference();
00071 }
00072 
00073 CL_Font::~CL_Font()
00074 {
00075         if (impl->release_reference() == 0) delete impl;
00076 }
00077 
00078 int CL_Font::get_height()
00079 {
00080         return impl->get_height();
00081 }
00082 
00083 int CL_Font::get_text_width(const char *text)
00084 {
00085         return impl->get_text_width(text);
00086 }
00087 
00088 int CL_Font::get_char_width(const char character)
00089 {
00090         return impl->get_char_width(character);
00091 }
00092         
00093 void CL_Font::print_left(int x, int y, const char *text, int n_height)
00094 {
00095         impl->print_left(x, y, text, n_height);
00096 }
00097 
00098 void CL_Font::print_left(int x, int y, float scale_x, float scale_y, const char *text)
00099 {
00100         impl->print_left(x, y, scale_x, scale_y, text);
00101 }
00102         
00103 void CL_Font::print_center(int x, int y, const char *text)
00104 {
00105         impl->print_center(x, y, text);
00106 }
00107 
00108 void CL_Font::print_right(int x, int y, const char *text)
00109 {
00110         impl->print_right(x, y, text);
00111 }
00112         
00113 void CL_Font::put_target(int x, int y, const char *text, CL_Target *target, int alignment)
00114 {
00115         impl->put_target(x, y, text, target, alignment);
00116 }
00117 
00118 int CL_Font::change_size(int size)
00119 {
00120         return impl->change_size(size);
00121 }
00122 
00123 unsigned int CL_Font::change_colour(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
00124 {
00125         return impl->change_colour(r, g, b, a);
00126 }
00127 

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