1/* Pango
2 * pango-renderer.h: Base class for rendering
3 *
4 * Copyright (C) 2004, Red Hat, Inc.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21#ifndef __PANGO_RENDERER_H_
22#define __PANGO_RENDERER_H_
23
24#include <pango/pango-layout.h>
25
26G_BEGIN_DECLS
27
28#define PANGO_TYPE_RENDERER (pango_renderer_get_type())
29#define PANGO_RENDERER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_RENDERER, PangoRenderer))
30#define PANGO_IS_RENDERER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_RENDERER))
31#define PANGO_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_RENDERER, PangoRendererClass))
32#define PANGO_IS_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_RENDERER))
33#define PANGO_RENDERER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_RENDERER, PangoRendererClass))
34
35typedef struct _PangoRenderer PangoRenderer;
36typedef struct _PangoRendererClass PangoRendererClass;
37typedef struct _PangoRendererPrivate PangoRendererPrivate;
38
39/**
40 * PangoRenderPart:
41 * @PANGO_RENDER_PART_FOREGROUND: the text itself
42 * @PANGO_RENDER_PART_BACKGROUND: the area behind the text
43 * @PANGO_RENDER_PART_UNDERLINE: underlines
44 * @PANGO_RENDER_PART_STRIKETHROUGH: strikethrough lines
45 * @PANGO_RENDER_PART_OVERLINE: overlines
46 *
47 * `PangoRenderPart` defines different items to render for such
48 * purposes as setting colors.
49 *
50 * Since: 1.8
51 **/
52/* When extending, note N_RENDER_PARTS #define in pango-renderer.c */
53typedef enum
54{
55 PANGO_RENDER_PART_FOREGROUND,
56 PANGO_RENDER_PART_BACKGROUND,
57 PANGO_RENDER_PART_UNDERLINE,
58 PANGO_RENDER_PART_STRIKETHROUGH,
59 PANGO_RENDER_PART_OVERLINE
60} PangoRenderPart;
61
62/**
63 * PangoRenderer:
64 * @matrix: (nullable): the current transformation matrix for
65 * the Renderer; may be %NULL, which should be treated the
66 * same as the identity matrix.
67 *
68 * `PangoRenderer` is a base class for objects that can render text
69 * provided as `PangoGlyphString` or `PangoLayout`.
70 *
71 * By subclassing `PangoRenderer` and overriding operations such as
72 * @draw_glyphs and @draw_rectangle, renderers for particular font
73 * backends and destinations can be created.
74 *
75 * Since: 1.8
76 */
77struct _PangoRenderer
78{
79 /*< private >*/
80 GObject parent_instance;
81
82 PangoUnderline underline;
83 gboolean strikethrough;
84 int active_count;
85
86 /*< public >*/
87 PangoMatrix *matrix; /* May be NULL */
88
89 /*< private >*/
90 PangoRendererPrivate *priv;
91};
92
93/**
94 * PangoRendererClass:
95 * @draw_glyphs: draws a `PangoGlyphString`
96 * @draw_rectangle: draws a rectangle
97 * @draw_error_underline: draws a squiggly line that approximately
98 * covers the given rectangle in the style of an underline used to
99 * indicate a spelling error.
100 * @draw_shape: draw content for a glyph shaped with `PangoAttrShape`
101 * @x, @y are the coordinates of the left edge of the baseline,
102 * in user coordinates.
103 * @draw_trapezoid: draws a trapezoidal filled area
104 * @draw_glyph: draws a single glyph
105 * @part_changed: do renderer specific processing when rendering
106 * attributes change
107 * @begin: Do renderer-specific initialization before drawing
108 * @end: Do renderer-specific cleanup after drawing
109 * @prepare_run: updates the renderer for a new run
110 * @draw_glyph_item: draws a `PangoGlyphItem`
111 *
112 * Class structure for `PangoRenderer`.
113 *
114 * The following vfuncs take user space coordinates in Pango units
115 * and have default implementations:
116 * - draw_glyphs
117 * - draw_rectangle
118 * - draw_error_underline
119 * - draw_shape
120 * - draw_glyph_item
121 *
122 * The default draw_shape implementation draws nothing.
123 *
124 * The following vfuncs take device space coordinates as doubles
125 * and must be implemented:
126 * - draw_trapezoid
127 * - draw_glyph
128 *
129 * Since: 1.8
130 */
131struct _PangoRendererClass
132{
133 /*< private >*/
134 GObjectClass parent_class;
135
136 /* vtable - not signals */
137 /*< public >*/
138
139 void (*draw_glyphs) (PangoRenderer *renderer,
140 PangoFont *font,
141 PangoGlyphString *glyphs,
142 int x,
143 int y);
144 void (*draw_rectangle) (PangoRenderer *renderer,
145 PangoRenderPart part,
146 int x,
147 int y,
148 int width,
149 int height);
150 void (*draw_error_underline) (PangoRenderer *renderer,
151 int x,
152 int y,
153 int width,
154 int height);
155 void (*draw_shape) (PangoRenderer *renderer,
156 PangoAttrShape *attr,
157 int x,
158 int y);
159
160 void (*draw_trapezoid) (PangoRenderer *renderer,
161 PangoRenderPart part,
162 double y1_,
163 double x11,
164 double x21,
165 double y2,
166 double x12,
167 double x22);
168 void (*draw_glyph) (PangoRenderer *renderer,
169 PangoFont *font,
170 PangoGlyph glyph,
171 double x,
172 double y);
173
174 void (*part_changed) (PangoRenderer *renderer,
175 PangoRenderPart part);
176
177 void (*begin) (PangoRenderer *renderer);
178 void (*end) (PangoRenderer *renderer);
179
180 void (*prepare_run) (PangoRenderer *renderer,
181 PangoLayoutRun *run);
182
183 void (*draw_glyph_item) (PangoRenderer *renderer,
184 const char *text,
185 PangoGlyphItem *glyph_item,
186 int x,
187 int y);
188
189 /*< private >*/
190
191 /* Padding for future expansion */
192 void (*_pango_reserved2) (void);
193 void (*_pango_reserved3) (void);
194 void (*_pango_reserved4) (void);
195};
196
197PANGO_AVAILABLE_IN_1_8
198GType pango_renderer_get_type (void) G_GNUC_CONST;
199
200PANGO_AVAILABLE_IN_1_8
201void pango_renderer_draw_layout (PangoRenderer *renderer,
202 PangoLayout *layout,
203 int x,
204 int y);
205PANGO_AVAILABLE_IN_1_8
206void pango_renderer_draw_layout_line (PangoRenderer *renderer,
207 PangoLayoutLine *line,
208 int x,
209 int y);
210PANGO_AVAILABLE_IN_1_8
211void pango_renderer_draw_glyphs (PangoRenderer *renderer,
212 PangoFont *font,
213 PangoGlyphString *glyphs,
214 int x,
215 int y);
216PANGO_AVAILABLE_IN_1_22
217void pango_renderer_draw_glyph_item (PangoRenderer *renderer,
218 const char *text,
219 PangoGlyphItem *glyph_item,
220 int x,
221 int y);
222PANGO_AVAILABLE_IN_1_8
223void pango_renderer_draw_rectangle (PangoRenderer *renderer,
224 PangoRenderPart part,
225 int x,
226 int y,
227 int width,
228 int height);
229PANGO_AVAILABLE_IN_1_8
230void pango_renderer_draw_error_underline (PangoRenderer *renderer,
231 int x,
232 int y,
233 int width,
234 int height);
235PANGO_AVAILABLE_IN_1_8
236void pango_renderer_draw_trapezoid (PangoRenderer *renderer,
237 PangoRenderPart part,
238 double y1_,
239 double x11,
240 double x21,
241 double y2,
242 double x12,
243 double x22);
244PANGO_AVAILABLE_IN_1_8
245void pango_renderer_draw_glyph (PangoRenderer *renderer,
246 PangoFont *font,
247 PangoGlyph glyph,
248 double x,
249 double y);
250
251PANGO_AVAILABLE_IN_1_8
252void pango_renderer_activate (PangoRenderer *renderer);
253PANGO_AVAILABLE_IN_1_8
254void pango_renderer_deactivate (PangoRenderer *renderer);
255
256PANGO_AVAILABLE_IN_1_8
257void pango_renderer_part_changed (PangoRenderer *renderer,
258 PangoRenderPart part);
259
260PANGO_AVAILABLE_IN_1_8
261void pango_renderer_set_color (PangoRenderer *renderer,
262 PangoRenderPart part,
263 const PangoColor *color);
264PANGO_AVAILABLE_IN_1_8
265PangoColor *pango_renderer_get_color (PangoRenderer *renderer,
266 PangoRenderPart part);
267
268PANGO_AVAILABLE_IN_1_38
269void pango_renderer_set_alpha (PangoRenderer *renderer,
270 PangoRenderPart part,
271 guint16 alpha);
272PANGO_AVAILABLE_IN_1_38
273guint16 pango_renderer_get_alpha (PangoRenderer *renderer,
274 PangoRenderPart part);
275
276PANGO_AVAILABLE_IN_1_8
277void pango_renderer_set_matrix (PangoRenderer *renderer,
278 const PangoMatrix *matrix);
279PANGO_AVAILABLE_IN_1_8
280const PangoMatrix *pango_renderer_get_matrix (PangoRenderer *renderer);
281
282PANGO_AVAILABLE_IN_1_20
283PangoLayout *pango_renderer_get_layout (PangoRenderer *renderer);
284PANGO_AVAILABLE_IN_1_20
285PangoLayoutLine *pango_renderer_get_layout_line (PangoRenderer *renderer);
286
287G_END_DECLS
288
289#endif /* __PANGO_RENDERER_H_ */
290
291

source code of include/pango-1.0/pango/pango-renderer.h