26 #include <boost/filesystem/convenience.hpp>
27 #include <boost/scoped_array.hpp>
29 #include <SDL_image.h>
35 #include "util/base/exception.h"
36 #include "util/structures/rect.h"
37 #include "util/utf8/utf8.h"
38 #include "video/image.h"
39 #include "video/renderbackend.h"
41 #include "imagefontbase.h"
49 type_glyphs::iterator i = m_glyphs.begin();
50 for(; i != m_glyphs.end(); ++i) {
51 SDL_FreeSurface(i->second.surface);
58 std::string::const_iterator text_it = text.begin();
59 while(text_it != text.end()) {
60 uint32_t codepoint = utf8::next(text_it,text.end());
61 type_glyphs::const_iterator it = m_glyphs.find( codepoint );
63 if( it != m_glyphs.end() ) {
68 if( m_placeholder.surface ) {
79 SDL_Surface *ImageFontBase::renderString(
const std::string& text) {
80 SDL_Surface *surface = SDL_CreateRGBSurface(SDL_SWSURFACE,
82 RMASK, GMASK, BMASK ,AMASK);
84 SDL_FillRect(surface,0,0x00000000);
90 std::string::const_iterator text_it = text.begin();
91 while(text_it != text.end()) {
92 uint32_t codepoint = utf8::next(text_it,text.end());
93 type_glyphs::iterator it = m_glyphs.find( codepoint );
95 if( it == m_glyphs.end() ) {
96 if( !m_placeholder.surface ) {
99 glyph = &m_placeholder;
101 glyph = &(it->second);
103 dst.y = glyph->offset.y;
104 dst.x += glyph->offset.x;
106 SDL_BlitSurface(glyph->surface,0,surface,&dst);
113 void ImageFontBase::setColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a) {