00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "video_fonts.h"
00010
00011 void NGT_Font::draw(string text, SDL_Surface *surf, int draw_x, int draw_y){
00012 NGT_Surface textsurface;
00013
00014 switch (mode){
00015
00016 case TEXT_NONE:
00017 textsurface.surface = TTF_RenderText_Solid(font,text.c_str(),color);
00018 break;
00019
00020 case TEXT_BLENDED:
00021 textsurface.surface = TTF_RenderText_Blended(font,text.c_str(),color);
00022 break;
00023
00024 }
00025
00026 textsurface.x=draw_x;
00027 textsurface.y=draw_y;
00028 textsurface.draw(surf);
00029 textsurface.free();
00030
00031 }
00032
00033
00034 void NGT_Font::draw(string text, SDL_Surface *scr){
00035 NGT_Surface textsurface;
00036
00037 if (font == NULL){
00038 printf("*NGT_Font.draw: ERROR drawing. A font was not loaded previously\n");
00039 }
00040
00041 switch (mode){
00042
00043 case TEXT_NONE:
00044 textsurface.surface=TTF_RenderText_Solid(font,text.c_str(),color);
00045 break;
00046
00047 case TEXT_BLENDED:
00048 textsurface.surface=TTF_RenderText_Blended(font,text.c_str(),color);
00049 break;
00050
00051 }
00052
00053 textsurface.x=x;
00054 textsurface.y=y;
00055 textsurface.draw(scr);
00056 textsurface.free();
00057
00058 }
00059
00060 int NGT_Font::LoadTTF(){
00061 LoadTTF(filename, size);
00062
00063 return 0;
00064 }
00065
00066 int NGT_Font::LoadTTF(string filename, int size){
00067
00068 if(fopen(filename.c_str(),"r")==NULL){
00069 printf("*NGT_Font.LoadTTF: ERROR Loading the TTF file: '%s'\n",filename.c_str());
00070 return(1);
00071 }else{
00072
00073 font=TTF_OpenFont(filename.c_str(), size);
00074 printf("*NGT_Font.LoadTTF: Loaded the TTF file: '%s'\n",filename.c_str());
00075 return(0);
00076 }
00077
00078 }
00079