#include "lisp/lisp.hpp"
#include "screen.hpp"
#include "font.hpp"
-//#include "renderer.hpp"
-#include <unison/video/Blittable.hpp>
+#include "renderer.hpp"
#include "drawing_context.hpp"
#include "log.hpp"
}
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 = "";
}
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
{
// no bluring as we would get with subpixel positions
pos.x = static_cast<int>(pos.x);
- draw_text(dst, temp, pos, drawing_effect, alpha);
+ draw_text(renderer, temp, pos, drawing_effect, alpha);
if (i == text.size())
break;
}
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)
// 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
}
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
{
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;
request.request_data = &surfacepartrequest;
renderer->draw_surface_part(request);
- p.x += glyphs[font_index].advance;*/
+ p.x += glyphs[font_index].advance;
}
}
}