16 #ifndef AGG_RENDERER_RASTER_TEXT_INCLUDED 17 #define AGG_RENDERER_RASTER_TEXT_INCLUDED 19 #include "agg_basics.h" 25 template<
class BaseRenderer,
class GlyphGenerator>
29 typedef BaseRenderer ren_type;
30 typedef GlyphGenerator glyph_gen_type;
31 typedef typename glyph_gen_type::glyph_rect glyph_rect;
32 typedef typename ren_type::color_type color_type;
38 void attach(ren_type& ren) { m_ren = &ren; }
41 void color(
const color_type& c) { m_color = c; }
42 const color_type& color()
const {
return m_color; }
46 void render_text(
double x,
double y,
const CharT* str,
bool flip=
false)
51 m_glyph->prepare(&r, x, y, *str, flip);
57 for(i = r.y1; i <= r.y2; i++)
59 m_ren->blend_solid_hspan(r.x1, i, (r.x2 - r.x1 + 1),
61 m_glyph->span(r.y2 - i));
66 for(i = r.y1; i <= r.y2; i++)
68 m_ren->blend_solid_hspan(r.x1, i, (r.x2 - r.x1 + 1),
70 m_glyph->span(i - r.y1));
82 glyph_gen_type* m_glyph;
89 template<
class BaseRenderer,
class GlyphGenerator>
93 typedef BaseRenderer ren_type;
94 typedef GlyphGenerator glyph_gen_type;
95 typedef typename glyph_gen_type::glyph_rect glyph_rect;
96 typedef typename ren_type::color_type color_type;
105 void color(
const color_type& c) { m_color = c; }
106 const color_type& color()
const {
return m_color; }
109 template<
class CharT>
110 void render_text(
double x,
double y,
const CharT* str,
bool flip=
false)
115 m_glyph->prepare(&r, x, y, *str, !flip);
121 for(i = r.y1; i <= r.y2; i++)
123 m_ren->blend_solid_vspan(i, r.x1, (r.x2 - r.x1 + 1),
125 m_glyph->span(i - r.y1));
130 for(i = r.y1; i <= r.y2; i++)
132 m_ren->blend_solid_vspan(i, r.x1, (r.x2 - r.x1 + 1),
134 m_glyph->span(r.y2 - i));
146 glyph_gen_type* m_glyph;
156 template<
class ScanlineRenderer,
class GlyphGenerator>
160 typedef ScanlineRenderer ren_type;
161 typedef GlyphGenerator glyph_gen_type;
162 typedef typename glyph_gen_type::glyph_rect glyph_rect;
167 typedef agg::cover_type cover_type;
174 const cover_type* covers;
177 const_span(
int x_,
unsigned len_,
const cover_type* covers_) :
178 x(x_), len(len_), covers(covers_)
186 const cover_type* covers) :
188 m_span(x, len, covers)
192 int y()
const {
return m_y; }
193 unsigned num_spans()
const {
return 1; }
194 const_iterator begin()
const {
return &m_span; }
213 template<
class CharT>
214 void render_text(
double x,
double y,
const CharT* str,
bool flip=
false)
219 m_glyph->prepare(&r, x, y, *str, flip);
226 for(i = r.y1; i <= r.y2; i++)
232 m_glyph->span(r.y2 - i)));
237 for(i = r.y1; i <= r.y2; i++)
243 m_glyph->span(i - r.y1)));
255 glyph_gen_type* m_glyph;