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

resourcetype_ttf.cpp

Go to the documentation of this file.
00001 #include "Core/precomp.h"
00002 #include "../Display/Font/resourcetype_ttf.h"
00003 #include <API/Core/IOData/inputsource.h>
00004 #include <API/Display/Font/font.h>
00005 #include <API/Core/System/cl_assert.h>
00006 #include "TTF/font_ttf.h"
00007 
00008 CL_Res_Font_TTF::CL_Res_Font_TTF() : CL_Res_Font_Generic("TTF")
00009 {
00010 
00011 }
00012 
00013 
00014 CL_Resource *CL_Res_Font_TTF::create_from_location(
00015                 std::string name,
00016                 std::string location,
00017                 CL_ResourceOptions *options,
00018                 CL_ResourceManager *parent)
00019 {
00020 
00021         CL_String ext = CL_String(location).right(4);
00022         ext.to_lower();
00023 
00024         bool is_font_type = false;
00025         if (options->exists("type")) 
00026         {
00027                 if (options->get_value("type") != "TTF") return NULL;
00028                 is_font_type = true;
00029         }
00030 
00031         if (is_font_type || options->exists("TTF"))
00032         {
00033                 return new CL_Font_Resource_TTF(
00034                         name,
00035                         location,
00036                         options,
00037                         parent);
00038         }
00039 
00040         return NULL;
00041 
00042 }
00043 
00044 CL_Resource *CL_Res_Font_TTF::create_from_serialization(
00045                 std::string name,
00046                 CL_ResourceManager *parent)
00047 {
00048 
00049         return new CL_Font_Resource_TTF(
00050                 name,
00051                 parent);
00052 
00053 }
00054 
00055 
00056 CL_Font_Resource_TTF::CL_Font_Resource_TTF(
00057                 std::string name,
00058                 std::string location,
00059                 CL_ResourceOptions *options,
00060                 CL_ResourceManager *parent)
00061      : CL_Font_Resource_Generic("TTF", name)
00062 {
00063 
00064         this->location = location;
00065         this->options = options;
00066         this->parent = parent;
00067         from_datafile = false;
00068         load_count = 0;
00069 
00070         font = NULL;
00071         font_desc = NULL;
00072 
00073 }
00074 
00075 CL_Font_Resource_TTF::CL_Font_Resource_TTF(
00076         std::string name,
00077         CL_ResourceManager *parent)
00078 : CL_Font_Resource_Generic("TTF", name)
00079 {
00080         location = "";
00081         options = NULL;
00082         this->parent = parent;
00083         from_datafile = true;
00084         load_count = 0;
00085 
00086         font = NULL;
00087         font_desc = NULL;
00088 }
00089 
00090 
00091 
00092 
00093 void CL_Font_Resource_TTF::serialize_save(CL_OutputSource *output)
00094 {
00095 
00096 
00097 }
00098 
00099 void CL_Font_Resource_TTF::load()
00100 {
00101   load_count++;
00102   if(load_count>1) return; //We're good to go
00103 
00104   if(from_datafile) load_from_datafile();
00105   else load_from_file();
00106 
00107 }
00108 
00109 void CL_Font_Resource_TTF::unload()
00110 {
00111 
00112 
00113 
00114 }
00115 
00116 
00117 void CL_Font_Resource_TTF::load_from_datafile()
00118 {
00119   CL_InputSourceProvider *provider = parent->get_resource_provider();
00120   ttf = new CL_Font_TTF(get_name().c_str(),provider);
00121   font = new CL_Font(ttf);
00122 }
00123 
00124 void CL_Font_Resource_TTF::load_from_file()
00125 {
00126 
00127   ttf = new CL_Font_TTF(location,NULL);
00128   font = new CL_Font(ttf);  
00129 
00130 }
00131 
00132 
00133 

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