00001 #ifdef HAVE_CONFIG_H
00002 #include<config.h>
00003 #endif
00004
00005 #if (MX_TTF == 1)
00006 #include"mxttf.h"
00007 #include"mx_exception.h"
00008
00009
00010 namespace mx
00011 {
00012
00013 mxTTF_Font::mxTTF_Font(std::string name, int size) {
00014 font = TTF_OpenFont(name.c_str(), size);
00015 if(!font) font = 0;
00016
00017 }
00018
00019 mxTTF_Font::~mxTTF_Font() {
00020 if(font)
00021 TTF_CloseFont(font);
00022 }
00023
00024 SDL_Surface *mxTTF_Font::renderText(std::string text, SDL_Color col) {
00025
00026 if(!font)
00027 throw mx::mxException<std::string>("Error font not loaded: \n");
00028
00029 SDL_Surface *surf = TTF_RenderText_Solid(font, text.c_str(), col);
00030 return surf;
00031 }
00032
00033 void mxTTF_Font::renderText(mxSurface &surface, std::string text, SDL_Color col) {
00034
00035 if(!font)
00036 throw mx::mxException<std::string>("Error font not loaded mxTTF_Font::renderText(string, SDL_Color)\n");
00037
00038 surface = TTF_RenderText_Solid(font, text.c_str(), col);
00039 }
00040 }
00041
00042
00043
00044
00045
00046 #endif
00047