1 //----------------------------------------------------------------------------
2 // Anti-Grain Geometry - Version 2.3
3 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
5 // Permission to copy, use, modify, sell and distribute this software
6 // is granted provided this copyright notice appears in all copies.
7 // This software is provided "as is" without express or implied
8 // warranty, and with no claim as to its suitability for any purpose.
10 //----------------------------------------------------------------------------
11 // Contact: mcseem@antigrain.com
12 // mcseemagg@yahoo.com
13 // http://www.antigrain.com
14 //----------------------------------------------------------------------------
16 #ifndef AGG_RENDERER_RASTER_TEXT_INCLUDED
17 #define AGG_RENDERER_RASTER_TEXT_INCLUDED
19 #include "agg_basics.h"
24 //==============================================renderer_raster_htext_solid
25 template<class BaseRenderer
, class GlyphGenerator
>
26 class renderer_raster_htext_solid
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
;
34 renderer_raster_htext_solid(ren_type
& ren
, glyph_gen_type
& glyph
) :
40 //--------------------------------------------------------------------
41 void color(const color_type
& c
) { m_color
= c
; }
42 const color_type
& color() const { return m_color
; }
44 //--------------------------------------------------------------------
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
;
88 //=============================================renderer_raster_vtext_solid
89 template<class BaseRenderer
, class GlyphGenerator
>
90 class renderer_raster_vtext_solid
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
;
98 renderer_raster_vtext_solid(ren_type
& ren
, glyph_gen_type
& glyph
) :
104 //--------------------------------------------------------------------
105 void color(const color_type
& c
) { m_color
= c
; }
106 const color_type
& color() const { return m_color
; }
108 //--------------------------------------------------------------------
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
;
155 //===================================================renderer_raster_htext
156 template<class ScanlineRenderer
, class GlyphGenerator
>
157 class renderer_raster_htext
160 typedef ScanlineRenderer ren_type
;
161 typedef GlyphGenerator glyph_gen_type
;
162 typedef typename
glyph_gen_type::glyph_rect glyph_rect
;
164 class scanline_single_span
167 typedef agg::cover_type cover_type
;
169 //----------------------------------------------------------------
174 const cover_type
* covers
;
177 const_span(int x_
, unsigned len_
, const cover_type
* covers_
) :
178 x(x_
), len(len_
), covers(covers_
)
182 typedef const const_span
* const_iterator
;
184 //----------------------------------------------------------------
185 scanline_single_span(int x
, int y
, unsigned len
,
186 const cover_type
* covers
) :
188 m_span(x
, len
, covers
)
191 //----------------------------------------------------------------
192 int y() const { return m_y
; }
193 unsigned num_spans() const { return 1; }
194 const_iterator
begin() const { return &m_span
; }
197 //----------------------------------------------------------------
204 //--------------------------------------------------------------------
205 renderer_raster_htext(ren_type
& ren
, glyph_gen_type
& glyph
) :
212 //--------------------------------------------------------------------
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
);
222 m_ren
->prepare(r
.x2
- r
.x1
+ 1);
226 for(i
= r
.y1
; i
<= r
.y2
; i
++)
229 scanline_single_span(r
.x1
,
232 m_glyph
->span(r
.y2
- i
)));
237 for(i
= r
.y1
; i
<= r
.y2
; i
++)
240 scanline_single_span(r
.x1
,
243 m_glyph
->span(i
- r
.y1
)));
255 glyph_gen_type
* m_glyph
;