X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fvideo%2Ffont.cpp;h=90b32afbf33da80bcffda85a0e248de4797389e0;hb=101b0a78b682a8b6b87407edc625adaf7c51da40;hp=ed431e2d06616a1f0b9ecfc2071f82543baac7d2;hpb=bd47623805cd3eb2bcb5953946282a7a92453eb9;p=supertux.git diff --git a/src/video/font.cpp b/src/video/font.cpp index ed431e2d0..90b32afbf 100644 --- a/src/video/font.cpp +++ b/src/video/font.cpp @@ -64,6 +64,7 @@ Font::Font(GlyphWidth glyph_width_, char_height(), shadowsize(shadowsize_), border(0), + rtl(false), glyphs(65536) { for(unsigned int i=0; i<65536;i++) glyphs[i].surface_idx = -1; @@ -74,9 +75,9 @@ Font::Font(GlyphWidth glyph_width_, // scan for prefix-filename in addons search path char **rc = PHYSFS_enumerateFiles(fontdir.c_str()); for (char **i = rc; *i != NULL; i++) { - std::string filename(*i); - if( filename.rfind(fontname) != std::string::npos ) { - loadFontFile(fontdir + filename); + std::string filename_(*i); + if( filename_.rfind(fontname) != std::string::npos ) { + loadFontFile(fontdir + filename_); } } PHYSFS_freeList(rc); @@ -109,6 +110,7 @@ Font::loadFontFile(const std::string &filename) } config_l->get("glyph-border", border); + config_l->get("rtl", rtl); lisp::ListIterator iter(config_l); while(iter.next()) { @@ -164,7 +166,7 @@ Font::loadFontSurface( const std::string &glyphimage, const std::string &shadowimage, const std::vector &chars, - GlyphWidth glyph_width, + GlyphWidth glyph_width_, int char_width ) { @@ -180,7 +182,7 @@ Font::loadFontSurface( SDL_Surface *surface = NULL; - if( glyph_width == VARIABLE ) { + if( glyph_width_ == VARIABLE ) { //this does not work: // surface = ((SDL::Texture *)glyph_surface.get_texture())->get_texture(); surface = IMG_Load_RW(get_physfs_SDLRWops("images/engine/fonts/"+glyphimage), 1); @@ -202,7 +204,7 @@ Font::loadFontSurface( Glyph glyph; glyph.surface_idx = surface_idx; - if( glyph_width == FIXED ) + if( glyph_width_ == FIXED || isdigit(*chr) ) { glyph.rect = Rectf(x, y, x + char_width, y + char_height); glyph.offset = Vector(0, 0); @@ -394,10 +396,10 @@ Font::draw_text(Renderer *renderer, const std::string& text, const Vector& pos, DrawingEffect drawing_effect, Color color, float alpha) const { if(shadowsize > 0) - draw_chars(renderer, false, text, + draw_chars(renderer, false, rtl ? std::string(text.rbegin(), text.rend()) : text, pos + Vector(shadowsize, shadowsize), drawing_effect, Color(1,1,1), alpha); - draw_chars(renderer, true, text, pos, drawing_effect, color, alpha); + draw_chars(renderer, true, rtl ? std::string(text.rbegin(), text.rend()) : text, pos, drawing_effect, color, alpha); } void @@ -434,8 +436,8 @@ Font::draw_chars(Renderer *renderer, bool notshadow, const std::string& text, request.alpha = alpha; SurfacePartRequest surfacepartrequest; - surfacepartrequest.size = glyph.rect.p2 - glyph.rect.p1; - surfacepartrequest.source = glyph.rect.p1; + surfacepartrequest.srcrect = glyph.rect; + surfacepartrequest.dstsize = glyph.rect.get_size(); surfacepartrequest.surface = notshadow ? glyph_surfaces[glyph.surface_idx].get() : shadow_surfaces[glyph.surface_idx].get(); request.request_data = &surfacepartrequest;