X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fvideo%2Ffont.cpp;h=7628f673e0f6ab1e84f7063ce6afca06981f5eac;hb=472d0ad804844d28811c86f03da74b6d6be53f1b;hp=cc23a733fc48eee743402feff7951f688b7d3c21;hpb=99cf62c2d44b4555e9761f1c8f1b10cf880c33fb;p=supertux.git diff --git a/src/video/font.cpp b/src/video/font.cpp index cc23a733f..7628f673e 100644 --- a/src/video/font.cpp +++ b/src/video/font.cpp @@ -31,8 +31,7 @@ #include "lisp/lisp.hpp" #include "screen.hpp" #include "font.hpp" -//#include "renderer.hpp" -#include +#include "renderer.hpp" #include "drawing_context.hpp" #include "log.hpp" @@ -244,8 +243,10 @@ Font::wrap_to_chars(const std::string& s, int line_length, std::string* overflow } std::string -Font::wrap_to_width(const std::string& s, float width, std::string* overflow) +Font::wrap_to_width(const std::string& s_, float width, std::string* overflow) { + std::string s = s_; + // if text is already smaller, return full text if (get_text_width(s) <= width) { if (overflow) *overflow = ""; @@ -268,7 +269,7 @@ Font::wrap_to_width(const std::string& s, float width, std::string* overflow) } void -Font::draw(Unison::Video::Blittable &dst, const std::string& text, const Vector& pos_, +Font::draw(Renderer *renderer, const std::string& text, const Vector& pos_, FontAlignment alignment, DrawingEffect drawing_effect, float alpha) const { @@ -294,7 +295,7 @@ Font::draw(Unison::Video::Blittable &dst, const std::string& text, const Vector& // no bluring as we would get with subpixel positions pos.x = static_cast(pos.x); - draw_text(dst, temp, pos, drawing_effect, alpha); + draw_text(renderer, temp, pos, drawing_effect, alpha); if (i == text.size()) break; @@ -306,7 +307,7 @@ Font::draw(Unison::Video::Blittable &dst, const std::string& text, const Vector& } void -Font::draw_text(Unison::Video::Blittable &dst, const std::string& text, const Vector& pos, +Font::draw_text(Renderer *renderer, const std::string& text, const Vector& pos, DrawingEffect drawing_effect, float alpha) const { if(shadowsize > 0) @@ -314,11 +315,11 @@ Font::draw_text(Unison::Video::Blittable &dst, const std::string& text, const Ve // FIXME: shadow_glyph_surface and glyph_surface do currently // share the same glyph array, this is incorrect and should be // fixed, it is however hardly noticable - draw_chars(dst, shadow_glyph_surface, text, + draw_chars(renderer, shadow_glyph_surface, text, pos + Vector(shadowsize, shadowsize), drawing_effect, alpha); } - draw_chars(dst, glyph_surface, text, pos, drawing_effect, alpha); + draw_chars(renderer, glyph_surface, text, pos, drawing_effect, alpha); } int @@ -344,7 +345,7 @@ Font::chr2glyph(uint32_t chr) const } void -Font::draw_chars(Unison::Video::Blittable &dst, Surface* pchars, const std::string& text, +Font::draw_chars(Renderer *renderer, Surface* pchars, const std::string& text, const Vector& pos, DrawingEffect drawing_effect, float alpha) const { @@ -366,26 +367,7 @@ Font::draw_chars(Unison::Video::Blittable &dst, Surface* pchars, const std::stri else { const Glyph& glyph = glyphs[font_index]; - - assert(pchars != 0); - - Unison::Video::TextureSection texture = pchars->get_texture(); - texture.clip_rect.pos.x += (int) glyph.rect.p1.x; - texture.clip_rect.pos.y += (int) glyph.rect.p1.y; - texture.clip_rect.size.x += (unsigned int) glyph.rect.get_width(); - texture.clip_rect.size.y += (unsigned int) glyph.rect.get_height(); - - Unison::Video::RenderOptions options; - options.alpha = (unsigned char) alpha * 0xff; - options.h_flip = (drawing_effect == HORIZONTAL_FLIP); - options.v_flip = (drawing_effect == VERTICAL_FLIP); - - Vector transformed = p + glyph.offset; - Unison::Video::Point dst_pos((int) transformed.x, (int) transformed.y); - - dst.blit_section(texture, dst_pos, options); - - /*DrawingRequest request; + DrawingRequest request; request.pos = p + glyph.offset; request.drawing_effect = drawing_effect; @@ -399,7 +381,7 @@ Font::draw_chars(Unison::Video::Blittable &dst, Surface* pchars, const std::stri request.request_data = &surfacepartrequest; renderer->draw_surface_part(request); - p.x += glyphs[font_index].advance;*/ + p.x += glyphs[font_index].advance; } } }