1 /* cairo - a vector graphics library with display and print output
3 * Copyright © 2002 University of Southern California
4 * Copyright © 2005 Red Hat, Inc.
6 * This library is free software; you can redistribute it and/or
7 * modify it either under the terms of the GNU Lesser General Public
8 * License version 2.1 as published by the Free Software Foundation
9 * (the "LGPL") or, at your option, under the terms of the Mozilla
10 * Public License Version 1.1 (the "MPL"). If you do not alter this
11 * notice, a recipient may use your version of this file under either
12 * the MPL or the LGPL.
14 * You should have received a copy of the LGPL along with this library
15 * in the file COPYING-LGPL-2.1; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 * You should have received a copy of the MPL along with this library
18 * in the file COPYING-MPL-1.1
20 * The contents of this file are subject to the Mozilla Public License
21 * Version 1.1 (the "License"); you may not use this file except in
22 * compliance with the License. You may obtain a copy of the License at
23 * http://www.mozilla.org/MPL/
25 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
26 * OF ANY KIND, either express or implied. See the LGPL or the MPL for
27 * the specific language governing rights and limitations.
29 * The Original Code is the cairo graphics library.
31 * The Initial Developer of the Original Code is University of Southern
35 * Carl D. Worth <cworth@cworth.org>
41 #include "cairo-version.h"
42 #include "cairo-features.h"
43 #include "cairo-deprecated.h"
46 # define CAIRO_BEGIN_DECLS extern "C" {
47 # define CAIRO_END_DECLS }
49 # define CAIRO_BEGIN_DECLS
50 # define CAIRO_END_DECLS
54 # if defined (_MSC_VER) && ! defined (CAIRO_WIN32_STATIC_BUILD)
55 # define cairo_public __declspec(dllimport)
63 #define CAIRO_VERSION_ENCODE(major, minor, micro) ( \
68 #define CAIRO_VERSION CAIRO_VERSION_ENCODE( \
69 CAIRO_VERSION_MAJOR, \
70 CAIRO_VERSION_MINOR, \
74 #define CAIRO_VERSION_STRINGIZE_(major, minor, micro) \
75 #major"."#minor"."#micro
76 #define CAIRO_VERSION_STRINGIZE(major, minor, micro) \
77 CAIRO_VERSION_STRINGIZE_(major, minor, micro)
79 #define CAIRO_VERSION_STRING CAIRO_VERSION_STRINGIZE( \
80 CAIRO_VERSION_MAJOR, \
81 CAIRO_VERSION_MINOR, \
88 cairo_public
const char*
89 cairo_version_string (void);
94 * #cairo_bool_t is used for boolean values. Returns of type
95 * #cairo_bool_t will always be either 0 or 1, but testing against
96 * these values explicitly is not encouraged; just use the
97 * value as a boolean condition.
99 * <informalexample><programlisting>
100 * if (cairo_in_stroke (cr, x, y)) {
101 * /<!-- -->* do something *<!-- -->/
103 * </programlisting></informalexample>
105 typedef int cairo_bool_t
;
110 * A #cairo_t contains the current state of the rendering device,
111 * including coordinates of yet to be drawn shapes.
113 * Cairo contexts, as #cairo_t objects are named, are central to
114 * cairo and all drawing with cairo is always done to a #cairo_t
117 * Memory management of #cairo_t is done with
118 * cairo_reference() and cairo_destroy().
120 typedef struct _cairo cairo_t
;
125 * A #cairo_surface_t represents an image, either as the destination
126 * of a drawing operation or as source when drawing onto another
127 * surface. To draw to a #cairo_surface_t, create a cairo context
128 * with the surface as the target, using cairo_create().
130 * There are different subtypes of #cairo_surface_t for
131 * different drawing backends; for example, cairo_image_surface_create()
132 * creates a bitmap image in memory.
133 * The type of a surface can be queried with cairo_surface_get_type().
135 * Memory management of #cairo_surface_t is done with
136 * cairo_surface_reference() and cairo_surface_destroy().
138 typedef struct _cairo_surface cairo_surface_t
;
142 * @xx: xx component of the affine transformation
143 * @yx: yx component of the affine transformation
144 * @xy: xy component of the affine transformation
145 * @yy: yy component of the affine transformation
146 * @x0: X translation component of the affine transformation
147 * @y0: Y translation component of the affine transformation
149 * A #cairo_matrix_t holds an affine transformation, such as a scale,
150 * rotation, shear, or a combination of those. The transformation of
151 * a point (x, y) is given by:
153 * x_new = xx * x + xy * y + x0;
154 * y_new = yx * x + yy * y + y0;
157 typedef struct _cairo_matrix
{
158 double xx
; double yx
;
159 double xy
; double yy
;
160 double x0
; double y0
;
166 * A #cairo_pattern_t represents a source when drawing onto a
167 * surface. There are different subtypes of #cairo_pattern_t,
168 * for different types of sources; for example,
169 * cairo_pattern_create_rgb() creates a pattern for a solid
172 * Other than various cairo_pattern_create_<emphasis>type</emphasis>()
173 * functions, some of the pattern types can be implicitly created
174 * using various cairo_set_source_<emphasis>type</emphasis>() functions;
175 * for example cairo_set_source_rgb().
177 * The type of a pattern can be queried with cairo_pattern_get_type().
179 * Memory management of #cairo_pattern_t is done with
180 * cairo_pattern_reference() and cairo_pattern_destroy().
182 typedef struct _cairo_pattern cairo_pattern_t
;
185 * cairo_destroy_func_t:
186 * @data: The data element being destroyed.
188 * #cairo_destroy_func_t the type of function which is called when a
189 * data element is destroyed. It is passed the pointer to the data
190 * element and should free any memory and resources allocated for it.
192 typedef void (*cairo_destroy_func_t
) (void *data
);
195 * cairo_user_data_key_t:
196 * @unused: not used; ignore.
198 * #cairo_user_data_key_t is used for attaching user data to cairo
199 * data structures. The actual contents of the struct is never used,
200 * and there is no need to initialize the object; only the unique
201 * address of a #cairo_data_key_t object is used. Typically, you
202 * would just use the address of a static #cairo_data_key_t object.
204 typedef struct _cairo_user_data_key
{
206 } cairo_user_data_key_t
;
210 * @CAIRO_STATUS_SUCCESS: no error has occurred
211 * @CAIRO_STATUS_NO_MEMORY: out of memory
212 * @CAIRO_STATUS_INVALID_RESTORE: cairo_restore() called without matching cairo_save()
213 * @CAIRO_STATUS_INVALID_POP_GROUP: no saved group to pop, i.e. cairo_pop_group() without matching cairo_push_group()
214 * @CAIRO_STATUS_NO_CURRENT_POINT: no current point defined
215 * @CAIRO_STATUS_INVALID_MATRIX: invalid matrix (not invertible)
216 * @CAIRO_STATUS_INVALID_STATUS: invalid value for an input #cairo_status_t
217 * @CAIRO_STATUS_NULL_POINTER: %NULL pointer
218 * @CAIRO_STATUS_INVALID_STRING: input string not valid UTF-8
219 * @CAIRO_STATUS_INVALID_PATH_DATA: input path data not valid
220 * @CAIRO_STATUS_READ_ERROR: error while reading from input stream
221 * @CAIRO_STATUS_WRITE_ERROR: error while writing to output stream
222 * @CAIRO_STATUS_SURFACE_FINISHED: target surface has been finished
223 * @CAIRO_STATUS_SURFACE_TYPE_MISMATCH: the surface type is not appropriate for the operation
224 * @CAIRO_STATUS_PATTERN_TYPE_MISMATCH: the pattern type is not appropriate for the operation
225 * @CAIRO_STATUS_INVALID_CONTENT: invalid value for an input #cairo_content_t
226 * @CAIRO_STATUS_INVALID_FORMAT: invalid value for an input #cairo_format_t
227 * @CAIRO_STATUS_INVALID_VISUAL: invalid value for an input Visual*
228 * @CAIRO_STATUS_FILE_NOT_FOUND: file not found
229 * @CAIRO_STATUS_INVALID_DASH: invalid value for a dash setting
230 * @CAIRO_STATUS_INVALID_DSC_COMMENT: invalid value for a DSC comment (Since 1.2)
231 * @CAIRO_STATUS_INVALID_INDEX: invalid index passed to getter (Since 1.4)
232 * @CAIRO_STATUS_CLIP_NOT_REPRESENTABLE: clip region not representable in desired format (Since 1.4)
233 * @CAIRO_STATUS_TEMP_FILE_ERROR: error creating or writing to a temporary file (Since 1.6)
234 * @CAIRO_STATUS_INVALID_STRIDE: invalid value for stride (Since 1.6)
235 * @CAIRO_STATUS_FONT_TYPE_MISMATCH: the font type is not appropriate for the operation (Since 1.8)
236 * @CAIRO_STATUS_USER_FONT_IMMUTABLE: the user-font is immutable (Since 1.8)
237 * @CAIRO_STATUS_USER_FONT_ERROR: error occurred in a user-font callback function (Since 1.8)
238 * @CAIRO_STATUS_NEGATIVE_COUNT: negative number used where it is not allowed (Since 1.8)
239 * @CAIRO_STATUS_INVALID_CLUSTERS: input clusters do not represent the accompanying text and glyph array (Since 1.8)
240 * @CAIRO_STATUS_INVALID_SLANT: invalid value for an input #cairo_font_slant_t (Since 1.8)
241 * @CAIRO_STATUS_INVALID_WEIGHT: invalid value for an input #cairo_font_weight_t (Since 1.8)
242 * @CAIRO_STATUS_INVALID_SIZE: invalid value (typically too big) for the size of the input (surface, pattern, etc.) (Since 1.10)
243 * @CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED: user-font method not implemented (Since 1.10)
244 * @CAIRO_STATUS_LAST_STATUS: this is a special value indicating the number of
245 * status values defined in this enumeration. When using this value, note
246 * that the version of cairo at run-time may have additional status values
247 * defined than the value of this symbol at compile-time. (Since 1.10)
249 * #cairo_status_t is used to indicate errors that can occur when
250 * using Cairo. In some cases it is returned directly by functions.
251 * but when using #cairo_t, the last error, if any, is stored in
252 * the context and can be retrieved with cairo_status().
254 * New entries may be added in future versions. Use cairo_status_to_string()
255 * to get a human-readable representation of an error message.
257 typedef enum _cairo_status
{
258 CAIRO_STATUS_SUCCESS
= 0,
260 CAIRO_STATUS_NO_MEMORY
,
261 CAIRO_STATUS_INVALID_RESTORE
,
262 CAIRO_STATUS_INVALID_POP_GROUP
,
263 CAIRO_STATUS_NO_CURRENT_POINT
,
264 CAIRO_STATUS_INVALID_MATRIX
,
265 CAIRO_STATUS_INVALID_STATUS
,
266 CAIRO_STATUS_NULL_POINTER
,
267 CAIRO_STATUS_INVALID_STRING
,
268 CAIRO_STATUS_INVALID_PATH_DATA
,
269 CAIRO_STATUS_READ_ERROR
,
270 CAIRO_STATUS_WRITE_ERROR
,
271 CAIRO_STATUS_SURFACE_FINISHED
,
272 CAIRO_STATUS_SURFACE_TYPE_MISMATCH
,
273 CAIRO_STATUS_PATTERN_TYPE_MISMATCH
,
274 CAIRO_STATUS_INVALID_CONTENT
,
275 CAIRO_STATUS_INVALID_FORMAT
,
276 CAIRO_STATUS_INVALID_VISUAL
,
277 CAIRO_STATUS_FILE_NOT_FOUND
,
278 CAIRO_STATUS_INVALID_DASH
,
279 CAIRO_STATUS_INVALID_DSC_COMMENT
,
280 CAIRO_STATUS_INVALID_INDEX
,
281 CAIRO_STATUS_CLIP_NOT_REPRESENTABLE
,
282 CAIRO_STATUS_TEMP_FILE_ERROR
,
283 CAIRO_STATUS_INVALID_STRIDE
,
284 CAIRO_STATUS_FONT_TYPE_MISMATCH
,
285 CAIRO_STATUS_USER_FONT_IMMUTABLE
,
286 CAIRO_STATUS_USER_FONT_ERROR
,
287 CAIRO_STATUS_NEGATIVE_COUNT
,
288 CAIRO_STATUS_INVALID_CLUSTERS
,
289 CAIRO_STATUS_INVALID_SLANT
,
290 CAIRO_STATUS_INVALID_WEIGHT
,
291 CAIRO_STATUS_INVALID_SIZE
,
292 CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED
,
294 CAIRO_STATUS_LAST_STATUS
299 * @CAIRO_CONTENT_COLOR: The surface will hold color content only.
300 * @CAIRO_CONTENT_ALPHA: The surface will hold alpha content only.
301 * @CAIRO_CONTENT_COLOR_ALPHA: The surface will hold color and alpha content.
303 * #cairo_content_t is used to describe the content that a surface will
304 * contain, whether color information, alpha information (translucence
305 * vs. opacity), or both.
307 * Note: The large values here are designed to keep #cairo_content_t
308 * values distinct from #cairo_format_t values so that the
309 * implementation can detect the error if users confuse the two types.
311 typedef enum _cairo_content
{
312 CAIRO_CONTENT_COLOR
= 0x1000,
313 CAIRO_CONTENT_ALPHA
= 0x2000,
314 CAIRO_CONTENT_COLOR_ALPHA
= 0x3000
318 * cairo_write_func_t:
319 * @closure: the output closure
320 * @data: the buffer containing the data to write
321 * @length: the amount of data to write
323 * #cairo_write_func_t is the type of function which is called when a
324 * backend needs to write data to an output stream. It is passed the
325 * closure which was specified by the user at the time the write
326 * function was registered, the data to write and the length of the
327 * data in bytes. The write function should return
328 * %CAIRO_STATUS_SUCCESS if all the data was successfully written,
329 * %CAIRO_STATUS_WRITE_ERROR otherwise.
331 * Returns: the status code of the write operation
333 typedef cairo_status_t (*cairo_write_func_t
) (void *closure
,
334 const unsigned char *data
,
335 unsigned int length
);
339 * @closure: the input closure
340 * @data: the buffer into which to read the data
341 * @length: the amount of data to read
343 * #cairo_read_func_t is the type of function which is called when a
344 * backend needs to read data from an input stream. It is passed the
345 * closure which was specified by the user at the time the read
346 * function was registered, the buffer to read the data into and the
347 * length of the data in bytes. The read function should return
348 * %CAIRO_STATUS_SUCCESS if all the data was successfully read,
349 * %CAIRO_STATUS_READ_ERROR otherwise.
351 * Returns: the status code of the read operation
353 typedef cairo_status_t (*cairo_read_func_t
) (void *closure
,
355 unsigned int length
);
357 /* Functions for manipulating state objects */
358 cairo_public cairo_t
*
359 cairo_create (cairo_surface_t
*target
);
361 cairo_public cairo_t
*
362 cairo_reference (cairo_t
*cr
);
365 cairo_destroy (cairo_t
*cr
);
367 cairo_public
unsigned int
368 cairo_get_reference_count (cairo_t
*cr
);
371 cairo_get_user_data (cairo_t
*cr
,
372 const cairo_user_data_key_t
*key
);
374 cairo_public cairo_status_t
375 cairo_set_user_data (cairo_t
*cr
,
376 const cairo_user_data_key_t
*key
,
378 cairo_destroy_func_t destroy
);
381 cairo_save (cairo_t
*cr
);
384 cairo_restore (cairo_t
*cr
);
387 cairo_push_group (cairo_t
*cr
);
390 cairo_push_group_with_content (cairo_t
*cr
, cairo_content_t content
);
392 cairo_public cairo_pattern_t
*
393 cairo_pop_group (cairo_t
*cr
);
396 cairo_pop_group_to_source (cairo_t
*cr
);
402 * @CAIRO_OPERATOR_CLEAR: clear destination layer (bounded)
403 * @CAIRO_OPERATOR_SOURCE: replace destination layer (bounded)
404 * @CAIRO_OPERATOR_OVER: draw source layer on top of destination layer
406 * @CAIRO_OPERATOR_IN: draw source where there was destination content
408 * @CAIRO_OPERATOR_OUT: draw source where there was no destination
409 * content (unbounded)
410 * @CAIRO_OPERATOR_ATOP: draw source on top of destination content and
412 * @CAIRO_OPERATOR_DEST: ignore the source
413 * @CAIRO_OPERATOR_DEST_OVER: draw destination on top of source
414 * @CAIRO_OPERATOR_DEST_IN: leave destination only where there was
415 * source content (unbounded)
416 * @CAIRO_OPERATOR_DEST_OUT: leave destination only where there was no
418 * @CAIRO_OPERATOR_DEST_ATOP: leave destination on top of source content
419 * and only there (unbounded)
420 * @CAIRO_OPERATOR_XOR: source and destination are shown where there is only
422 * @CAIRO_OPERATOR_ADD: source and destination layers are accumulated
423 * @CAIRO_OPERATOR_SATURATE: like over, but assuming source and dest are
424 * disjoint geometries
426 * #cairo_operator_t is used to set the compositing operator for all cairo
427 * drawing operations.
429 * The default operator is %CAIRO_OPERATOR_OVER.
431 * The operators marked as <firstterm>unbounded</firstterm> modify their
432 * destination even outside of the mask layer (that is, their effect is not
433 * bound by the mask layer). However, their effect can still be limited by
436 * To keep things simple, the operator descriptions here
437 * document the behavior for when both source and destination are either fully
438 * transparent or fully opaque. The actual implementation works for
439 * translucent layers too.
440 * For a more detailed explanation of the effects of each operator, including
441 * the mathematical definitions, see
442 * <ulink url="http://cairographics.org/operators/">http://cairographics.org/operators/</ulink>.
444 typedef enum _cairo_operator
{
445 CAIRO_OPERATOR_CLEAR
,
447 CAIRO_OPERATOR_SOURCE
,
454 CAIRO_OPERATOR_DEST_OVER
,
455 CAIRO_OPERATOR_DEST_IN
,
456 CAIRO_OPERATOR_DEST_OUT
,
457 CAIRO_OPERATOR_DEST_ATOP
,
461 CAIRO_OPERATOR_SATURATE
465 cairo_set_operator (cairo_t
*cr
, cairo_operator_t op
);
468 cairo_set_source (cairo_t
*cr
, cairo_pattern_t
*source
);
471 cairo_set_source_rgb (cairo_t
*cr
, double red
, double green
, double blue
);
474 cairo_set_source_rgba (cairo_t
*cr
,
475 double red
, double green
, double blue
,
479 cairo_set_source_surface (cairo_t
*cr
,
480 cairo_surface_t
*surface
,
485 cairo_set_tolerance (cairo_t
*cr
, double tolerance
);
489 * @CAIRO_ANTIALIAS_DEFAULT: Use the default antialiasing for
490 * the subsystem and target device
491 * @CAIRO_ANTIALIAS_NONE: Use a bilevel alpha mask
492 * @CAIRO_ANTIALIAS_GRAY: Perform single-color antialiasing (using
493 * shades of gray for black text on a white background, for example).
494 * @CAIRO_ANTIALIAS_SUBPIXEL: Perform antialiasing by taking
495 * advantage of the order of subpixel elements on devices
498 * Specifies the type of antialiasing to do when rendering text or shapes.
500 typedef enum _cairo_antialias
{
501 CAIRO_ANTIALIAS_DEFAULT
,
502 CAIRO_ANTIALIAS_NONE
,
503 CAIRO_ANTIALIAS_GRAY
,
504 CAIRO_ANTIALIAS_SUBPIXEL
507 #define CAIRO_ANTIALIAS_TYPE_MASK 3
508 #define CAIRO_ANTIALIAS_SAMPLES_SHIFT 12
509 #define CAIRO_ANTIALIAS_SAMPLES_MASK 0xfffff000
510 #define CAIRO_ANTIALIAS_SAMPLES_GREAT ((255 * 255) << CAIRO_ANTIALIAS_SAMPLES_SHIFT)
511 #define CAIRO_ANTIALIAS_SAMPLES_PERFECT CAIRO_ANTIALIAS_SAMPLES_MASK
513 /* for running the testsuite */
514 #define CAIRO_ANTIALIAS_SAMPLES_DEFAULT CAIRO_ANTIALIAS_SAMPLES_GREAT
516 /* for performance */
517 /* #define CAIRO_ANTIALIAS_SAMPLES_DEFAULT (4 << CAIRO_ANTIALIAS_SAMPLES_SHIFT) */
520 cairo_set_antialias (cairo_t
*cr
, cairo_antialias_t antialias
);
524 * @CAIRO_FILL_RULE_WINDING: If the path crosses the ray from
525 * left-to-right, counts +1. If the path crosses the ray
526 * from right to left, counts -1. (Left and right are determined
527 * from the perspective of looking along the ray from the starting
528 * point.) If the total count is non-zero, the point will be filled.
529 * @CAIRO_FILL_RULE_EVEN_ODD: Counts the total number of
530 * intersections, without regard to the orientation of the contour. If
531 * the total number of intersections is odd, the point will be
534 * #cairo_fill_rule_t is used to select how paths are filled. For both
535 * fill rules, whether or not a point is included in the fill is
536 * determined by taking a ray from that point to infinity and looking
537 * at intersections with the path. The ray can be in any direction,
538 * as long as it doesn't pass through the end point of a segment
539 * or have a tricky intersection such as intersecting tangent to the path.
540 * (Note that filling is not actually implemented in this way. This
541 * is just a description of the rule that is applied.)
543 * The default fill rule is %CAIRO_FILL_RULE_WINDING.
545 * New entries may be added in future versions.
547 typedef enum _cairo_fill_rule
{
548 CAIRO_FILL_RULE_WINDING
,
549 CAIRO_FILL_RULE_EVEN_ODD
553 cairo_set_fill_rule (cairo_t
*cr
, cairo_fill_rule_t fill_rule
);
556 cairo_set_line_width (cairo_t
*cr
, double width
);
560 * @CAIRO_LINE_CAP_BUTT: start(stop) the line exactly at the start(end) point
561 * @CAIRO_LINE_CAP_ROUND: use a round ending, the center of the circle is the end point
562 * @CAIRO_LINE_CAP_SQUARE: use squared ending, the center of the square is the end point
564 * Specifies how to render the endpoints of the path when stroking.
566 * The default line cap style is %CAIRO_LINE_CAP_BUTT.
568 typedef enum _cairo_line_cap
{
570 CAIRO_LINE_CAP_ROUND
,
571 CAIRO_LINE_CAP_SQUARE
575 cairo_set_line_cap (cairo_t
*cr
, cairo_line_cap_t line_cap
);
579 * @CAIRO_LINE_JOIN_MITER: use a sharp (angled) corner, see
580 * cairo_set_miter_limit()
581 * @CAIRO_LINE_JOIN_ROUND: use a rounded join, the center of the circle is the
583 * @CAIRO_LINE_JOIN_BEVEL: use a cut-off join, the join is cut off at half
584 * the line width from the joint point
586 * Specifies how to render the junction of two lines when stroking.
588 * The default line join style is %CAIRO_LINE_JOIN_MITER.
590 typedef enum _cairo_line_join
{
591 CAIRO_LINE_JOIN_MITER
,
592 CAIRO_LINE_JOIN_ROUND
,
593 CAIRO_LINE_JOIN_BEVEL
597 cairo_set_line_join (cairo_t
*cr
, cairo_line_join_t line_join
);
600 cairo_set_dash (cairo_t
*cr
,
601 const double *dashes
,
606 cairo_set_miter_limit (cairo_t
*cr
, double limit
);
609 cairo_translate (cairo_t
*cr
, double tx
, double ty
);
612 cairo_scale (cairo_t
*cr
, double sx
, double sy
);
615 cairo_rotate (cairo_t
*cr
, double angle
);
618 cairo_transform (cairo_t
*cr
,
619 const cairo_matrix_t
*matrix
);
622 cairo_set_matrix (cairo_t
*cr
,
623 const cairo_matrix_t
*matrix
);
626 cairo_identity_matrix (cairo_t
*cr
);
629 cairo_user_to_device (cairo_t
*cr
, double *x
, double *y
);
632 cairo_user_to_device_distance (cairo_t
*cr
, double *dx
, double *dy
);
635 cairo_device_to_user (cairo_t
*cr
, double *x
, double *y
);
638 cairo_device_to_user_distance (cairo_t
*cr
, double *dx
, double *dy
);
640 /* Path creation functions */
642 cairo_new_path (cairo_t
*cr
);
645 cairo_move_to (cairo_t
*cr
, double x
, double y
);
648 cairo_new_sub_path (cairo_t
*cr
);
651 cairo_line_to (cairo_t
*cr
, double x
, double y
);
654 cairo_curve_to (cairo_t
*cr
,
655 double x1
, double y1
,
656 double x2
, double y2
,
657 double x3
, double y3
);
660 cairo_arc (cairo_t
*cr
,
661 double xc
, double yc
,
663 double angle1
, double angle2
);
666 cairo_arc_negative (cairo_t
*cr
,
667 double xc
, double yc
,
669 double angle1
, double angle2
);
673 cairo_arc_to (cairo_t *cr,
674 double x1, double y1,
675 double x2, double y2,
680 cairo_rel_move_to (cairo_t
*cr
, double dx
, double dy
);
683 cairo_rel_line_to (cairo_t
*cr
, double dx
, double dy
);
686 cairo_rel_curve_to (cairo_t
*cr
,
687 double dx1
, double dy1
,
688 double dx2
, double dy2
,
689 double dx3
, double dy3
);
692 cairo_rectangle (cairo_t
*cr
,
694 double width
, double height
);
698 cairo_stroke_to_path (cairo_t *cr);
702 cairo_close_path (cairo_t
*cr
);
705 cairo_path_extents (cairo_t
*cr
,
706 double *x1
, double *y1
,
707 double *x2
, double *y2
);
709 /* Painting functions */
711 cairo_paint (cairo_t
*cr
);
714 cairo_paint_with_alpha (cairo_t
*cr
,
718 cairo_mask (cairo_t
*cr
,
719 cairo_pattern_t
*pattern
);
722 cairo_mask_surface (cairo_t
*cr
,
723 cairo_surface_t
*surface
,
728 cairo_stroke (cairo_t
*cr
);
731 cairo_stroke_preserve (cairo_t
*cr
);
734 cairo_fill (cairo_t
*cr
);
737 cairo_fill_preserve (cairo_t
*cr
);
740 cairo_copy_page (cairo_t
*cr
);
743 cairo_show_page (cairo_t
*cr
);
746 cairo_swap_page (cairo_t
*cr
);
748 /* Insideness testing */
749 cairo_public cairo_bool_t
750 cairo_in_stroke (cairo_t
*cr
, double x
, double y
);
752 cairo_public cairo_bool_t
753 cairo_in_fill (cairo_t
*cr
, double x
, double y
);
755 /* Rectangular extents */
757 cairo_stroke_extents (cairo_t
*cr
,
758 double *x1
, double *y1
,
759 double *x2
, double *y2
);
762 cairo_fill_extents (cairo_t
*cr
,
763 double *x1
, double *y1
,
764 double *x2
, double *y2
);
768 cairo_reset_clip (cairo_t
*cr
);
771 cairo_clip (cairo_t
*cr
);
774 cairo_clip_preserve (cairo_t
*cr
);
777 cairo_clip_extents (cairo_t
*cr
,
778 double *x1
, double *y1
,
779 double *x2
, double *y2
);
783 * @x: X coordinate of the left side of the rectangle
784 * @y: Y coordinate of the the top side of the rectangle
785 * @width: width of the rectangle
786 * @height: height of the rectangle
788 * A data structure for holding a rectangle.
792 typedef struct _cairo_rectangle
{
793 double x
, y
, width
, height
;
797 * cairo_rectangle_list_t:
798 * @status: Error status of the rectangle list
799 * @rectangles: Array containing the rectangles
800 * @num_rectangles: Number of rectangles in this list
802 * A data structure for holding a dynamically allocated
803 * array of rectangles.
807 typedef struct _cairo_rectangle_list
{
808 cairo_status_t status
;
809 cairo_rectangle_t
*rectangles
;
811 } cairo_rectangle_list_t
;
813 cairo_public cairo_rectangle_list_t
*
814 cairo_copy_clip_rectangle_list (cairo_t
*cr
);
817 cairo_rectangle_list_destroy (cairo_rectangle_list_t
*rectangle_list
);
819 /* Font/Text functions */
822 * cairo_scaled_font_t:
824 * A #cairo_scaled_font_t is a font scaled to a particular size and device
825 * resolution. A #cairo_scaled_font_t is most useful for low-level font
826 * usage where a library or application wants to cache a reference
827 * to a scaled font to speed up the computation of metrics.
829 * There are various types of scaled fonts, depending on the
830 * <firstterm>font backend</firstterm> they use. The type of a
831 * scaled font can be queried using cairo_scaled_font_get_type().
833 * Memory management of #cairo_scaled_font_t is done with
834 * cairo_scaled_font_reference() and cairo_scaled_font_destroy().
836 typedef struct _cairo_scaled_font cairo_scaled_font_t
;
841 * A #cairo_font_face_t specifies all aspects of a font other
842 * than the size or font matrix (a font matrix is used to distort
843 * a font by sheering it or scaling it unequally in the two
844 * directions) . A font face can be set on a #cairo_t by using
845 * cairo_set_font_face(); the size and font matrix are set with
846 * cairo_set_font_size() and cairo_set_font_matrix().
848 * There are various types of font faces, depending on the
849 * <firstterm>font backend</firstterm> they use. The type of a
850 * font face can be queried using cairo_font_face_get_type().
852 * Memory management of #cairo_font_face_t is done with
853 * cairo_font_face_reference() and cairo_font_face_destroy().
855 typedef struct _cairo_font_face cairo_font_face_t
;
859 * @index: glyph index in the font. The exact interpretation of the
860 * glyph index depends on the font technology being used.
861 * @x: the offset in the X direction between the origin used for
862 * drawing or measuring the string and the origin of this glyph.
863 * @y: the offset in the Y direction between the origin used for
864 * drawing or measuring the string and the origin of this glyph.
866 * The #cairo_glyph_t structure holds information about a single glyph
867 * when drawing or measuring text. A font is (in simple terms) a
868 * collection of shapes used to draw text. A glyph is one of these
869 * shapes. There can be multiple glyphs for a single character
870 * (alternates to be used in different contexts, for example), or a
871 * glyph can be a <firstterm>ligature</firstterm> of multiple
872 * characters. Cairo doesn't expose any way of converting input text
873 * into glyphs, so in order to use the Cairo interfaces that take
874 * arrays of glyphs, you must directly access the appropriate
875 * underlying font system.
877 * Note that the offsets given by @x and @y are not cumulative. When
878 * drawing or measuring text, each glyph is individually positioned
879 * with respect to the overall origin
887 cairo_public cairo_glyph_t
*
888 cairo_glyph_allocate (int num_glyphs
);
891 cairo_glyph_free (cairo_glyph_t
*glyphs
);
894 * cairo_text_cluster_t:
895 * @num_bytes: the number of bytes of UTF-8 text covered by cluster
896 * @num_glyphs: the number of glyphs covered by cluster
898 * The #cairo_text_cluster_t structure holds information about a single
899 * <firstterm>text cluster</firstterm>. A text cluster is a minimal
900 * mapping of some glyphs corresponding to some UTF-8 text.
902 * For a cluster to be valid, both @num_bytes and @num_glyphs should
903 * be non-negative, and at least one should be non-zero.
904 * Note that clusters with zero glyphs are not as well supported as
905 * normal clusters. For example, PDF rendering applications typically
906 * ignore those clusters when PDF text is being selected.
908 * See cairo_show_text_glyphs() for how clusters are used in advanced
916 } cairo_text_cluster_t
;
918 cairo_public cairo_text_cluster_t
*
919 cairo_text_cluster_allocate (int num_clusters
);
922 cairo_text_cluster_free (cairo_text_cluster_t
*clusters
);
925 * cairo_text_cluster_flags_t:
926 * @CAIRO_TEXT_CLUSTER_FLAG_BACKWARD: The clusters in the cluster array
927 * map to glyphs in the glyph array from end to start.
929 * Specifies properties of a text cluster mapping.
933 typedef enum _cairo_text_cluster_flags
{
934 CAIRO_TEXT_CLUSTER_FLAG_BACKWARD
= 0x00000001
935 } cairo_text_cluster_flags_t
;
938 * cairo_text_extents_t:
939 * @x_bearing: the horizontal distance from the origin to the
940 * leftmost part of the glyphs as drawn. Positive if the
941 * glyphs lie entirely to the right of the origin.
942 * @y_bearing: the vertical distance from the origin to the
943 * topmost part of the glyphs as drawn. Positive only if the
944 * glyphs lie completely below the origin; will usually be
946 * @width: width of the glyphs as drawn
947 * @height: height of the glyphs as drawn
948 * @x_advance:distance to advance in the X direction
949 * after drawing these glyphs
950 * @y_advance: distance to advance in the Y direction
951 * after drawing these glyphs. Will typically be zero except
952 * for vertical text layout as found in East-Asian languages.
954 * The #cairo_text_extents_t structure stores the extents of a single
955 * glyph or a string of glyphs in user-space coordinates. Because text
956 * extents are in user-space coordinates, they are mostly, but not
957 * entirely, independent of the current transformation matrix. If you call
958 * <literal>cairo_scale(cr, 2.0, 2.0)</literal>, text will
959 * be drawn twice as big, but the reported text extents will not be
960 * doubled. They will change slightly due to hinting (so you can't
961 * assume that metrics are independent of the transformation matrix),
962 * but otherwise will remain unchanged.
971 } cairo_text_extents_t
;
974 * cairo_font_extents_t:
975 * @ascent: the distance that the font extends above the baseline.
976 * Note that this is not always exactly equal to the maximum
977 * of the extents of all the glyphs in the font, but rather
978 * is picked to express the font designer's intent as to
979 * how the font should align with elements above it.
980 * @descent: the distance that the font extends below the baseline.
981 * This value is positive for typical fonts that include
982 * portions below the baseline. Note that this is not always
983 * exactly equal to the maximum of the extents of all the
984 * glyphs in the font, but rather is picked to express the
985 * font designer's intent as to how the the font should
986 * align with elements below it.
987 * @height: the recommended vertical distance between baselines when
988 * setting consecutive lines of text with the font. This
989 * is greater than @ascent+@descent by a
990 * quantity known as the <firstterm>line spacing</firstterm>
991 * or <firstterm>external leading</firstterm>. When space
992 * is at a premium, most fonts can be set with only
993 * a distance of @ascent+@descent between lines.
994 * @max_x_advance: the maximum distance in the X direction that
995 * the the origin is advanced for any glyph in the font.
996 * @max_y_advance: the maximum distance in the Y direction that
997 * the the origin is advanced for any glyph in the font.
998 * this will be zero for normal fonts used for horizontal
999 * writing. (The scripts of East Asia are sometimes written
1002 * The #cairo_font_extents_t structure stores metric information for
1003 * a font. Values are given in the current user-space coordinate
1006 * Because font metrics are in user-space coordinates, they are
1007 * mostly, but not entirely, independent of the current transformation
1008 * matrix. If you call <literal>cairo_scale(cr, 2.0, 2.0)</literal>,
1009 * text will be drawn twice as big, but the reported text extents will
1010 * not be doubled. They will change slightly due to hinting (so you
1011 * can't assume that metrics are independent of the transformation
1012 * matrix), but otherwise will remain unchanged.
1018 double max_x_advance
;
1019 double max_y_advance
;
1020 } cairo_font_extents_t
;
1023 * cairo_font_slant_t:
1024 * @CAIRO_FONT_SLANT_NORMAL: Upright font style
1025 * @CAIRO_FONT_SLANT_ITALIC: Italic font style
1026 * @CAIRO_FONT_SLANT_OBLIQUE: Oblique font style
1028 * Specifies variants of a font face based on their slant.
1030 typedef enum _cairo_font_slant
{
1031 CAIRO_FONT_SLANT_NORMAL
,
1032 CAIRO_FONT_SLANT_ITALIC
,
1033 CAIRO_FONT_SLANT_OBLIQUE
1034 } cairo_font_slant_t
;
1037 * cairo_font_weight_t:
1038 * @CAIRO_FONT_WEIGHT_NORMAL: Normal font weight
1039 * @CAIRO_FONT_WEIGHT_BOLD: Bold font weight
1041 * Specifies variants of a font face based on their weight.
1043 typedef enum _cairo_font_weight
{
1044 CAIRO_FONT_WEIGHT_NORMAL
,
1045 CAIRO_FONT_WEIGHT_BOLD
1046 } cairo_font_weight_t
;
1049 * cairo_subpixel_order_t:
1050 * @CAIRO_SUBPIXEL_ORDER_DEFAULT: Use the default subpixel order for
1051 * for the target device
1052 * @CAIRO_SUBPIXEL_ORDER_RGB: Subpixel elements are arranged horizontally
1053 * with red at the left
1054 * @CAIRO_SUBPIXEL_ORDER_BGR: Subpixel elements are arranged horizontally
1055 * with blue at the left
1056 * @CAIRO_SUBPIXEL_ORDER_VRGB: Subpixel elements are arranged vertically
1057 * with red at the top
1058 * @CAIRO_SUBPIXEL_ORDER_VBGR: Subpixel elements are arranged vertically
1059 * with blue at the top
1061 * The subpixel order specifies the order of color elements within
1062 * each pixel on the display device when rendering with an
1063 * antialiasing mode of %CAIRO_ANTIALIAS_SUBPIXEL.
1065 typedef enum _cairo_subpixel_order
{
1066 CAIRO_SUBPIXEL_ORDER_DEFAULT
,
1067 CAIRO_SUBPIXEL_ORDER_RGB
,
1068 CAIRO_SUBPIXEL_ORDER_BGR
,
1069 CAIRO_SUBPIXEL_ORDER_VRGB
,
1070 CAIRO_SUBPIXEL_ORDER_VBGR
1071 } cairo_subpixel_order_t
;
1074 * cairo_hint_style_t:
1075 * @CAIRO_HINT_STYLE_DEFAULT: Use the default hint style for
1076 * font backend and target device
1077 * @CAIRO_HINT_STYLE_NONE: Do not hint outlines
1078 * @CAIRO_HINT_STYLE_SLIGHT: Hint outlines slightly to improve
1079 * contrast while retaining good fidelity to the original
1081 * @CAIRO_HINT_STYLE_MEDIUM: Hint outlines with medium strength
1082 * giving a compromise between fidelity to the original shapes
1084 * @CAIRO_HINT_STYLE_FULL: Hint outlines to maximize contrast
1086 * Specifies the type of hinting to do on font outlines. Hinting
1087 * is the process of fitting outlines to the pixel grid in order
1088 * to improve the appearance of the result. Since hinting outlines
1089 * involves distorting them, it also reduces the faithfulness
1090 * to the original outline shapes. Not all of the outline hinting
1091 * styles are supported by all font backends.
1093 * New entries may be added in future versions.
1095 typedef enum _cairo_hint_style
{
1096 CAIRO_HINT_STYLE_DEFAULT
,
1097 CAIRO_HINT_STYLE_NONE
,
1098 CAIRO_HINT_STYLE_SLIGHT
,
1099 CAIRO_HINT_STYLE_MEDIUM
,
1100 CAIRO_HINT_STYLE_FULL
1101 } cairo_hint_style_t
;
1104 * cairo_hint_metrics_t:
1105 * @CAIRO_HINT_METRICS_DEFAULT: Hint metrics in the default
1106 * manner for the font backend and target device
1107 * @CAIRO_HINT_METRICS_OFF: Do not hint font metrics
1108 * @CAIRO_HINT_METRICS_ON: Hint font metrics
1110 * Specifies whether to hint font metrics; hinting font metrics
1111 * means quantizing them so that they are integer values in
1112 * device space. Doing this improves the consistency of
1113 * letter and line spacing, however it also means that text
1114 * will be laid out differently at different zoom factors.
1116 typedef enum _cairo_hint_metrics
{
1117 CAIRO_HINT_METRICS_DEFAULT
,
1118 CAIRO_HINT_METRICS_OFF
,
1119 CAIRO_HINT_METRICS_ON
1120 } cairo_hint_metrics_t
;
1123 * cairo_font_options_t:
1125 * An opaque structure holding all options that are used when
1128 * Individual features of a #cairo_font_options_t can be set or
1129 * accessed using functions named
1130 * cairo_font_options_set_<emphasis>feature_name</emphasis> and
1131 * cairo_font_options_get_<emphasis>feature_name</emphasis>, like
1132 * cairo_font_options_set_antialias() and
1133 * cairo_font_options_get_antialias().
1135 * New features may be added to a #cairo_font_options_t in the
1136 * future. For this reason, cairo_font_options_copy(),
1137 * cairo_font_options_equal(), cairo_font_options_merge(), and
1138 * cairo_font_options_hash() should be used to copy, check
1139 * for equality, merge, or compute a hash value of
1140 * #cairo_font_options_t objects.
1142 typedef struct _cairo_font_options cairo_font_options_t
;
1144 cairo_public cairo_font_options_t
*
1145 cairo_font_options_create (void);
1147 cairo_public cairo_font_options_t
*
1148 cairo_font_options_copy (const cairo_font_options_t
*original
);
1151 cairo_font_options_destroy (cairo_font_options_t
*options
);
1153 cairo_public cairo_status_t
1154 cairo_font_options_status (cairo_font_options_t
*options
);
1157 cairo_font_options_merge (cairo_font_options_t
*options
,
1158 const cairo_font_options_t
*other
);
1159 cairo_public cairo_bool_t
1160 cairo_font_options_equal (const cairo_font_options_t
*options
,
1161 const cairo_font_options_t
*other
);
1163 cairo_public
unsigned long
1164 cairo_font_options_hash (const cairo_font_options_t
*options
);
1167 cairo_font_options_set_antialias (cairo_font_options_t
*options
,
1168 cairo_antialias_t antialias
);
1169 cairo_public cairo_antialias_t
1170 cairo_font_options_get_antialias (const cairo_font_options_t
*options
);
1173 cairo_font_options_set_subpixel_order (cairo_font_options_t
*options
,
1174 cairo_subpixel_order_t subpixel_order
);
1175 cairo_public cairo_subpixel_order_t
1176 cairo_font_options_get_subpixel_order (const cairo_font_options_t
*options
);
1179 cairo_font_options_set_hint_style (cairo_font_options_t
*options
,
1180 cairo_hint_style_t hint_style
);
1181 cairo_public cairo_hint_style_t
1182 cairo_font_options_get_hint_style (const cairo_font_options_t
*options
);
1185 cairo_font_options_set_hint_metrics (cairo_font_options_t
*options
,
1186 cairo_hint_metrics_t hint_metrics
);
1187 cairo_public cairo_hint_metrics_t
1188 cairo_font_options_get_hint_metrics (const cairo_font_options_t
*options
);
1190 /* This interface is for dealing with text as text, not caring about the
1191 font object inside the the cairo_t. */
1194 cairo_select_font_face (cairo_t
*cr
,
1196 cairo_font_slant_t slant
,
1197 cairo_font_weight_t weight
);
1200 cairo_set_font_size (cairo_t
*cr
, double size
);
1203 cairo_set_font_matrix (cairo_t
*cr
,
1204 const cairo_matrix_t
*matrix
);
1207 cairo_get_font_matrix (cairo_t
*cr
,
1208 cairo_matrix_t
*matrix
);
1211 cairo_set_font_options (cairo_t
*cr
,
1212 const cairo_font_options_t
*options
);
1215 cairo_get_font_options (cairo_t
*cr
,
1216 cairo_font_options_t
*options
);
1219 cairo_set_font_face (cairo_t
*cr
, cairo_font_face_t
*font_face
);
1221 cairo_public cairo_font_face_t
*
1222 cairo_get_font_face (cairo_t
*cr
);
1225 cairo_set_scaled_font (cairo_t
*cr
,
1226 const cairo_scaled_font_t
*scaled_font
);
1228 cairo_public cairo_scaled_font_t
*
1229 cairo_get_scaled_font (cairo_t
*cr
);
1232 cairo_show_text (cairo_t
*cr
, const char *utf8
);
1235 cairo_show_glyphs (cairo_t
*cr
, const cairo_glyph_t
*glyphs
, int num_glyphs
);
1238 cairo_show_text_glyphs (cairo_t
*cr
,
1241 const cairo_glyph_t
*glyphs
,
1243 const cairo_text_cluster_t
*clusters
,
1245 cairo_text_cluster_flags_t cluster_flags
);
1248 cairo_text_path (cairo_t
*cr
, const char *utf8
);
1251 cairo_glyph_path (cairo_t
*cr
, const cairo_glyph_t
*glyphs
, int num_glyphs
);
1254 cairo_text_extents (cairo_t
*cr
,
1256 cairo_text_extents_t
*extents
);
1259 cairo_glyph_extents (cairo_t
*cr
,
1260 const cairo_glyph_t
*glyphs
,
1262 cairo_text_extents_t
*extents
);
1265 cairo_font_extents (cairo_t
*cr
,
1266 cairo_font_extents_t
*extents
);
1268 /* Generic identifier for a font style */
1270 cairo_public cairo_font_face_t
*
1271 cairo_font_face_reference (cairo_font_face_t
*font_face
);
1274 cairo_font_face_destroy (cairo_font_face_t
*font_face
);
1276 cairo_public
unsigned int
1277 cairo_font_face_get_reference_count (cairo_font_face_t
*font_face
);
1279 cairo_public cairo_status_t
1280 cairo_font_face_status (cairo_font_face_t
*font_face
);
1284 * cairo_font_type_t:
1285 * @CAIRO_FONT_TYPE_TOY: The font was created using cairo's toy font api
1286 * @CAIRO_FONT_TYPE_FT: The font is of type FreeType
1287 * @CAIRO_FONT_TYPE_WIN32: The font is of type Win32
1288 * @CAIRO_FONT_TYPE_QUARTZ: The font is of type Quartz (Since: 1.6)
1289 * @CAIRO_FONT_TYPE_USER: The font was create using cairo's user font api (Since: 1.8)
1291 * #cairo_font_type_t is used to describe the type of a given font
1292 * face or scaled font. The font types are also known as "font
1293 * backends" within cairo.
1295 * The type of a font face is determined by the function used to
1296 * create it, which will generally be of the form
1297 * cairo_<emphasis>type</emphasis>_font_face_create(). The font face type can be queried
1298 * with cairo_font_face_get_type()
1300 * The various #cairo_font_face_t functions can be used with a font face
1303 * The type of a scaled font is determined by the type of the font
1304 * face passed to cairo_scaled_font_create(). The scaled font type can
1305 * be queried with cairo_scaled_font_get_type()
1307 * The various #cairo_scaled_font_t functions can be used with scaled
1308 * fonts of any type, but some font backends also provide
1309 * type-specific functions that must only be called with a scaled font
1310 * of the appropriate type. These functions have names that begin with
1311 * cairo_<emphasis>type</emphasis>_scaled_font() such as cairo_ft_scaled_font_lock_face().
1313 * The behavior of calling a type-specific function with a scaled font
1314 * of the wrong type is undefined.
1316 * New entries may be added in future versions.
1320 typedef enum _cairo_font_type
{
1321 CAIRO_FONT_TYPE_TOY
,
1323 CAIRO_FONT_TYPE_WIN32
,
1324 CAIRO_FONT_TYPE_QUARTZ
,
1325 CAIRO_FONT_TYPE_USER
1326 } cairo_font_type_t
;
1328 cairo_public cairo_font_type_t
1329 cairo_font_face_get_type (cairo_font_face_t
*font_face
);
1332 cairo_font_face_get_user_data (cairo_font_face_t
*font_face
,
1333 const cairo_user_data_key_t
*key
);
1335 cairo_public cairo_status_t
1336 cairo_font_face_set_user_data (cairo_font_face_t
*font_face
,
1337 const cairo_user_data_key_t
*key
,
1339 cairo_destroy_func_t destroy
);
1341 /* Portable interface to general font features. */
1343 cairo_public cairo_scaled_font_t
*
1344 cairo_scaled_font_create (cairo_font_face_t
*font_face
,
1345 const cairo_matrix_t
*font_matrix
,
1346 const cairo_matrix_t
*ctm
,
1347 const cairo_font_options_t
*options
);
1349 cairo_public cairo_scaled_font_t
*
1350 cairo_scaled_font_reference (cairo_scaled_font_t
*scaled_font
);
1353 cairo_scaled_font_destroy (cairo_scaled_font_t
*scaled_font
);
1355 cairo_public
unsigned int
1356 cairo_scaled_font_get_reference_count (cairo_scaled_font_t
*scaled_font
);
1358 cairo_public cairo_status_t
1359 cairo_scaled_font_status (cairo_scaled_font_t
*scaled_font
);
1361 cairo_public cairo_font_type_t
1362 cairo_scaled_font_get_type (cairo_scaled_font_t
*scaled_font
);
1365 cairo_scaled_font_get_user_data (cairo_scaled_font_t
*scaled_font
,
1366 const cairo_user_data_key_t
*key
);
1368 cairo_public cairo_status_t
1369 cairo_scaled_font_set_user_data (cairo_scaled_font_t
*scaled_font
,
1370 const cairo_user_data_key_t
*key
,
1372 cairo_destroy_func_t destroy
);
1375 cairo_scaled_font_extents (cairo_scaled_font_t
*scaled_font
,
1376 cairo_font_extents_t
*extents
);
1379 cairo_scaled_font_text_extents (cairo_scaled_font_t
*scaled_font
,
1381 cairo_text_extents_t
*extents
);
1384 cairo_scaled_font_glyph_extents (cairo_scaled_font_t
*scaled_font
,
1385 const cairo_glyph_t
*glyphs
,
1387 cairo_text_extents_t
*extents
);
1389 cairo_public cairo_status_t
1390 cairo_scaled_font_text_to_glyphs (cairo_scaled_font_t
*scaled_font
,
1395 cairo_glyph_t
**glyphs
,
1397 cairo_text_cluster_t
**clusters
,
1399 cairo_text_cluster_flags_t
*cluster_flags
);
1401 cairo_public cairo_font_face_t
*
1402 cairo_scaled_font_get_font_face (cairo_scaled_font_t
*scaled_font
);
1405 cairo_scaled_font_get_font_matrix (cairo_scaled_font_t
*scaled_font
,
1406 cairo_matrix_t
*font_matrix
);
1409 cairo_scaled_font_get_ctm (cairo_scaled_font_t
*scaled_font
,
1410 cairo_matrix_t
*ctm
);
1413 cairo_scaled_font_get_scale_matrix (cairo_scaled_font_t
*scaled_font
,
1414 cairo_matrix_t
*scale_matrix
);
1417 cairo_scaled_font_get_font_options (cairo_scaled_font_t
*scaled_font
,
1418 cairo_font_options_t
*options
);
1423 cairo_public cairo_font_face_t
*
1424 cairo_toy_font_face_create (const char *family
,
1425 cairo_font_slant_t slant
,
1426 cairo_font_weight_t weight
);
1428 cairo_public
const char *
1429 cairo_toy_font_face_get_family (cairo_font_face_t
*font_face
);
1431 cairo_public cairo_font_slant_t
1432 cairo_toy_font_face_get_slant (cairo_font_face_t
*font_face
);
1434 cairo_public cairo_font_weight_t
1435 cairo_toy_font_face_get_weight (cairo_font_face_t
*font_face
);
1440 cairo_public cairo_font_face_t
*
1441 cairo_user_font_face_create (void);
1443 /* User-font method signatures */
1446 * cairo_user_scaled_font_init_func_t:
1447 * @scaled_font: the scaled-font being created
1448 * @cr: a cairo context, in font space
1449 * @extents: font extents to fill in, in font space
1451 * #cairo_user_scaled_font_init_func_t is the type of function which is
1452 * called when a scaled-font needs to be created for a user font-face.
1454 * The cairo context @cr is not used by the caller, but is prepared in font
1455 * space, similar to what the cairo contexts passed to the render_glyph
1456 * method will look like. The callback can use this context for extents
1457 * computation for example. After the callback is called, @cr is checked
1458 * for any error status.
1460 * The @extents argument is where the user font sets the font extents for
1461 * @scaled_font. It is in font space, which means that for most cases its
1462 * ascent and descent members should add to 1.0. @extents is preset to
1463 * hold a value of 1.0 for ascent, height, and max_x_advance, and 0.0 for
1464 * descent and max_y_advance members.
1466 * The callback is optional. If not set, default font extents as described
1467 * in the previous paragraph will be used.
1469 * Note that @scaled_font is not fully initialized at this
1470 * point and trying to use it for text operations in the callback will result
1473 * Returns: %CAIRO_STATUS_SUCCESS upon success, or an error status on error.
1477 typedef cairo_status_t (*cairo_user_scaled_font_init_func_t
) (cairo_scaled_font_t
*scaled_font
,
1479 cairo_font_extents_t
*extents
);
1482 * cairo_user_scaled_font_render_glyph_func_t:
1483 * @scaled_font: user scaled-font
1484 * @glyph: glyph code to render
1485 * @cr: cairo context to draw to, in font space
1486 * @extents: glyph extents to fill in, in font space
1488 * #cairo_user_scaled_font_render_glyph_func_t is the type of function which
1489 * is called when a user scaled-font needs to render a glyph.
1491 * The callback is mandatory, and expected to draw the glyph with code @glyph to
1492 * the cairo context @cr. @cr is prepared such that the glyph drawing is done in
1493 * font space. That is, the matrix set on @cr is the scale matrix of @scaled_font,
1494 * The @extents argument is where the user font sets the font extents for
1495 * @scaled_font. However, if user prefers to draw in user space, they can
1496 * achieve that by changing the matrix on @cr. All cairo rendering operations
1497 * to @cr are permitted, however, the result is undefined if any source other
1498 * than the default source on @cr is used. That means, glyph bitmaps should
1499 * be rendered using cairo_mask() instead of cairo_paint().
1501 * Other non-default settings on @cr include a font size of 1.0 (given that
1502 * it is set up to be in font space), and font options corresponding to
1505 * The @extents argument is preset to have <literal>x_bearing</literal>,
1506 * <literal>width</literal>, and <literal>y_advance</literal> of zero,
1507 * <literal>y_bearing</literal> set to <literal>-font_extents.ascent</literal>,
1508 * <literal>height</literal> to <literal>font_extents.ascent+font_extents.descent</literal>,
1509 * and <literal>x_advance</literal> to <literal>font_extents.max_x_advance</literal>.
1510 * The only field user needs to set in majority of cases is
1511 * <literal>x_advance</literal>.
1512 * If the <literal>width</literal> field is zero upon the callback returning
1513 * (which is its preset value), the glyph extents are automatically computed
1514 * based on the drawings done to @cr. This is in most cases exactly what the
1515 * desired behavior is. However, if for any reason the callback sets the
1516 * extents, it must be ink extents, and include the extents of all drawing
1517 * done to @cr in the callback.
1519 * Returns: %CAIRO_STATUS_SUCCESS upon success, or
1520 * %CAIRO_STATUS_USER_FONT_ERROR or any other error status on error.
1524 typedef cairo_status_t (*cairo_user_scaled_font_render_glyph_func_t
) (cairo_scaled_font_t
*scaled_font
,
1525 unsigned long glyph
,
1527 cairo_text_extents_t
*extents
);
1530 * cairo_user_scaled_font_text_to_glyphs_func_t:
1531 * @scaled_font: the scaled-font being created
1532 * @utf8: a string of text encoded in UTF-8
1533 * @utf8_len: length of @utf8 in bytes
1534 * @glyphs: pointer to array of glyphs to fill, in font space
1535 * @num_glyphs: pointer to number of glyphs
1536 * @clusters: pointer to array of cluster mapping information to fill, or %NULL
1537 * @num_clusters: pointer to number of clusters
1538 * @cluster_flags: pointer to location to store cluster flags corresponding to the
1541 * #cairo_user_scaled_font_text_to_glyphs_func_t is the type of function which
1542 * is called to convert input text to an array of glyphs. This is used by the
1543 * cairo_show_text() operation.
1545 * Using this callback the user-font has full control on glyphs and their
1546 * positions. That means, it allows for features like ligatures and kerning,
1547 * as well as complex <firstterm>shaping</firstterm> required for scripts like
1550 * The @num_glyphs argument is preset to the number of glyph entries available
1551 * in the @glyphs buffer. If the @glyphs buffer is %NULL, the value of
1552 * @num_glyphs will be zero. If the provided glyph array is too short for
1553 * the conversion (or for convenience), a new glyph array may be allocated
1554 * using cairo_glyph_allocate() and placed in @glyphs. Upon return,
1555 * @num_glyphs should contain the number of generated glyphs. If the value
1556 * @glyphs points at has changed after the call, the caller will free the
1557 * allocated glyph array using cairo_glyph_free().
1558 * The callback should populate the glyph indices and positions (in font space)
1559 * assuming that the text is to be shown at the origin.
1561 * If @clusters is not %NULL, @num_clusters and @cluster_flags are also
1562 * non-%NULL, and cluster mapping should be computed. The semantics of how
1563 * cluster array allocation works is similar to the glyph array. That is,
1564 * if @clusters initially points to a non-%NULL value, that array may be used
1565 * as a cluster buffer, and @num_clusters points to the number of cluster
1566 * entries available there. If the provided cluster array is too short for
1567 * the conversion (or for convenience), a new cluster array may be allocated
1568 * using cairo_text_cluster_allocate() and placed in @clusters. Upon return,
1569 * @num_clusters should contain the number of generated clusters.
1570 * If the value @clusters points at has changed after the call, the caller
1571 * will free the allocated cluster array using cairo_text_cluster_free().
1573 * The callback is optional. If @num_glyphs is negative upon
1574 * the callback returning or if the return value
1575 * is %CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED, the unicode_to_glyph callback
1576 * is tried. See #cairo_user_scaled_font_unicode_to_glyph_func_t.
1578 * Note: While cairo does not impose any limitation on glyph indices,
1579 * some applications may assume that a glyph index fits in a 16-bit
1580 * unsigned integer. As such, it is advised that user-fonts keep their
1581 * glyphs in the 0 to 65535 range. Furthermore, some applications may
1582 * assume that glyph 0 is a special glyph-not-found glyph. User-fonts
1583 * are advised to use glyph 0 for such purposes and do not use that
1584 * glyph value for other purposes.
1586 * Returns: %CAIRO_STATUS_SUCCESS upon success,
1587 * %CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED if fallback options should be tried,
1588 * or %CAIRO_STATUS_USER_FONT_ERROR or any other error status on error.
1592 typedef cairo_status_t (*cairo_user_scaled_font_text_to_glyphs_func_t
) (cairo_scaled_font_t
*scaled_font
,
1595 cairo_glyph_t
**glyphs
,
1597 cairo_text_cluster_t
**clusters
,
1599 cairo_text_cluster_flags_t
*cluster_flags
);
1602 * cairo_user_scaled_font_unicode_to_glyph_func_t:
1603 * @scaled_font: the scaled-font being created
1604 * @unicode: input unicode character code-point
1605 * @glyph_index: output glyph index
1607 * #cairo_user_scaled_font_unicode_to_glyph_func_t is the type of function which
1608 * is called to convert an input Unicode character to a single glyph.
1609 * This is used by the cairo_show_text() operation.
1611 * This callback is used to provide the same functionality as the
1612 * text_to_glyphs callback does (see #cairo_user_scaled_font_text_to_glyphs_func_t)
1613 * but has much less control on the output,
1614 * in exchange for increased ease of use. The inherent assumption to using
1615 * this callback is that each character maps to one glyph, and that the
1616 * mapping is context independent. It also assumes that glyphs are positioned
1617 * according to their advance width. These mean no ligatures, kerning, or
1618 * complex scripts can be implemented using this callback.
1620 * The callback is optional, and only used if text_to_glyphs callback is not
1621 * set or fails to return glyphs. If this callback is not set or if it returns
1622 * %CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED, an identity mapping from Unicode
1623 * code-points to glyph indices is assumed.
1625 * Note: While cairo does not impose any limitation on glyph indices,
1626 * some applications may assume that a glyph index fits in a 16-bit
1627 * unsigned integer. As such, it is advised that user-fonts keep their
1628 * glyphs in the 0 to 65535 range. Furthermore, some applications may
1629 * assume that glyph 0 is a special glyph-not-found glyph. User-fonts
1630 * are advised to use glyph 0 for such purposes and do not use that
1631 * glyph value for other purposes.
1633 * Returns: %CAIRO_STATUS_SUCCESS upon success,
1634 * %CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED if fallback options should be tried,
1635 * or %CAIRO_STATUS_USER_FONT_ERROR or any other error status on error.
1639 typedef cairo_status_t (*cairo_user_scaled_font_unicode_to_glyph_func_t
) (cairo_scaled_font_t
*scaled_font
,
1640 unsigned long unicode
,
1641 unsigned long *glyph_index
);
1643 /* User-font method setters */
1646 cairo_user_font_face_set_init_func (cairo_font_face_t
*font_face
,
1647 cairo_user_scaled_font_init_func_t init_func
);
1650 cairo_user_font_face_set_render_glyph_func (cairo_font_face_t
*font_face
,
1651 cairo_user_scaled_font_render_glyph_func_t render_glyph_func
);
1654 cairo_user_font_face_set_text_to_glyphs_func (cairo_font_face_t
*font_face
,
1655 cairo_user_scaled_font_text_to_glyphs_func_t text_to_glyphs_func
);
1658 cairo_user_font_face_set_unicode_to_glyph_func (cairo_font_face_t
*font_face
,
1659 cairo_user_scaled_font_unicode_to_glyph_func_t unicode_to_glyph_func
);
1661 /* User-font method getters */
1663 cairo_public cairo_user_scaled_font_init_func_t
1664 cairo_user_font_face_get_init_func (cairo_font_face_t
*font_face
);
1666 cairo_public cairo_user_scaled_font_render_glyph_func_t
1667 cairo_user_font_face_get_render_glyph_func (cairo_font_face_t
*font_face
);
1669 cairo_public cairo_user_scaled_font_text_to_glyphs_func_t
1670 cairo_user_font_face_get_text_to_glyphs_func (cairo_font_face_t
*font_face
);
1672 cairo_public cairo_user_scaled_font_unicode_to_glyph_func_t
1673 cairo_user_font_face_get_unicode_to_glyph_func (cairo_font_face_t
*font_face
);
1676 /* Query functions */
1678 cairo_public cairo_operator_t
1679 cairo_get_operator (cairo_t
*cr
);
1681 cairo_public cairo_pattern_t
*
1682 cairo_get_source (cairo_t
*cr
);
1685 cairo_get_tolerance (cairo_t
*cr
);
1687 cairo_public cairo_antialias_t
1688 cairo_get_antialias (cairo_t
*cr
);
1690 cairo_public cairo_bool_t
1691 cairo_has_current_point (cairo_t
*cr
);
1694 cairo_get_current_point (cairo_t
*cr
, double *x
, double *y
);
1696 cairo_public cairo_fill_rule_t
1697 cairo_get_fill_rule (cairo_t
*cr
);
1700 cairo_get_line_width (cairo_t
*cr
);
1702 cairo_public cairo_line_cap_t
1703 cairo_get_line_cap (cairo_t
*cr
);
1705 cairo_public cairo_line_join_t
1706 cairo_get_line_join (cairo_t
*cr
);
1709 cairo_get_miter_limit (cairo_t
*cr
);
1712 cairo_get_dash_count (cairo_t
*cr
);
1715 cairo_get_dash (cairo_t
*cr
, double *dashes
, double *offset
);
1718 cairo_get_matrix (cairo_t
*cr
, cairo_matrix_t
*matrix
);
1720 cairo_public cairo_surface_t
*
1721 cairo_get_target (cairo_t
*cr
);
1723 cairo_public cairo_surface_t
*
1724 cairo_get_group_target (cairo_t
*cr
);
1727 * cairo_path_data_type_t:
1728 * @CAIRO_PATH_MOVE_TO: A move-to operation
1729 * @CAIRO_PATH_LINE_TO: A line-to operation
1730 * @CAIRO_PATH_CURVE_TO: A curve-to operation
1731 * @CAIRO_PATH_CLOSE_PATH: A close-path operation
1733 * #cairo_path_data_t is used to describe the type of one portion
1734 * of a path when represented as a #cairo_path_t.
1735 * See #cairo_path_data_t for details.
1737 typedef enum _cairo_path_data_type
{
1740 CAIRO_PATH_CURVE_TO
,
1741 CAIRO_PATH_CLOSE_PATH
1742 } cairo_path_data_type_t
;
1745 * cairo_path_data_t:
1747 * #cairo_path_data_t is used to represent the path data inside a
1750 * The data structure is designed to try to balance the demands of
1751 * efficiency and ease-of-use. A path is represented as an array of
1752 * #cairo_path_data_t, which is a union of headers and points.
1754 * Each portion of the path is represented by one or more elements in
1755 * the array, (one header followed by 0 or more points). The length
1756 * value of the header is the number of array elements for the current
1757 * portion including the header, (ie. length == 1 + # of points), and
1758 * where the number of points for each element type is as follows:
1761 * %CAIRO_PATH_MOVE_TO: 1 point
1762 * %CAIRO_PATH_LINE_TO: 1 point
1763 * %CAIRO_PATH_CURVE_TO: 3 points
1764 * %CAIRO_PATH_CLOSE_PATH: 0 points
1767 * The semantics and ordering of the coordinate values are consistent
1768 * with cairo_move_to(), cairo_line_to(), cairo_curve_to(), and
1769 * cairo_close_path().
1771 * Here is sample code for iterating through a #cairo_path_t:
1773 * <informalexample><programlisting>
1775 * cairo_path_t *path;
1776 * cairo_path_data_t *data;
1778 * path = cairo_copy_path (cr);
1780 * for (i=0; i < path->num_data; i += path->data[i].header.length) {
1781 * data = &path->data[i];
1782 * switch (data->header.type) {
1783 * case CAIRO_PATH_MOVE_TO:
1784 * do_move_to_things (data[1].point.x, data[1].point.y);
1786 * case CAIRO_PATH_LINE_TO:
1787 * do_line_to_things (data[1].point.x, data[1].point.y);
1789 * case CAIRO_PATH_CURVE_TO:
1790 * do_curve_to_things (data[1].point.x, data[1].point.y,
1791 * data[2].point.x, data[2].point.y,
1792 * data[3].point.x, data[3].point.y);
1794 * case CAIRO_PATH_CLOSE_PATH:
1795 * do_close_path_things ();
1799 * cairo_path_destroy (path);
1800 * </programlisting></informalexample>
1802 * As of cairo 1.4, cairo does not mind if there are more elements in
1803 * a portion of the path than needed. Such elements can be used by
1804 * users of the cairo API to hold extra values in the path data
1805 * structure. For this reason, it is recommended that applications
1806 * always use <literal>data->header.length</literal> to
1807 * iterate over the path data, instead of hardcoding the number of
1808 * elements for each element type.
1810 typedef union _cairo_path_data_t cairo_path_data_t
;
1811 union _cairo_path_data_t
{
1813 cairo_path_data_type_t type
;
1823 * @status: the current error status
1824 * @data: the elements in the path
1825 * @num_data: the number of elements in the data array
1827 * A data structure for holding a path. This data structure serves as
1828 * the return value for cairo_copy_path() and
1829 * cairo_copy_path_flat() as well the input value for
1830 * cairo_append_path().
1832 * See #cairo_path_data_t for hints on how to iterate over the
1833 * actual data within the path.
1835 * The num_data member gives the number of elements in the data
1836 * array. This number is larger than the number of independent path
1837 * portions (defined in #cairo_path_data_type_t), since the data
1838 * includes both headers and coordinates for each portion.
1840 typedef struct cairo_path
{
1841 cairo_status_t status
;
1842 cairo_path_data_t
*data
;
1846 cairo_public cairo_path_t
*
1847 cairo_copy_path (cairo_t
*cr
);
1849 cairo_public cairo_path_t
*
1850 cairo_copy_path_flat (cairo_t
*cr
);
1853 cairo_append_path (cairo_t
*cr
,
1854 const cairo_path_t
*path
);
1857 cairo_path_destroy (cairo_path_t
*path
);
1859 /* Error status queries */
1861 cairo_public cairo_status_t
1862 cairo_status (cairo_t
*cr
);
1864 cairo_public
const char *
1865 cairo_status_to_string (cairo_status_t status
);
1867 /* Surface manipulation */
1869 cairo_public cairo_surface_t
*
1870 cairo_surface_create_similar (cairo_surface_t
*other
,
1871 cairo_content_t content
,
1875 cairo_public cairo_surface_t
*
1876 cairo_surface_reference (cairo_surface_t
*surface
);
1879 cairo_surface_finish (cairo_surface_t
*surface
);
1882 cairo_surface_destroy (cairo_surface_t
*surface
);
1884 cairo_public
unsigned int
1885 cairo_surface_get_reference_count (cairo_surface_t
*surface
);
1887 cairo_public cairo_status_t
1888 cairo_surface_status (cairo_surface_t
*surface
);
1891 * cairo_surface_type_t:
1892 * @CAIRO_SURFACE_TYPE_IMAGE: The surface is of type image
1893 * @CAIRO_SURFACE_TYPE_PDF: The surface is of type pdf
1894 * @CAIRO_SURFACE_TYPE_PS: The surface is of type ps
1895 * @CAIRO_SURFACE_TYPE_XLIB: The surface is of type xlib
1896 * @CAIRO_SURFACE_TYPE_XCB: The surface is of type xcb
1897 * @CAIRO_SURFACE_TYPE_GLITZ: The surface is of type glitz
1898 * @CAIRO_SURFACE_TYPE_QUARTZ: The surface is of type quartz
1899 * @CAIRO_SURFACE_TYPE_WIN32: The surface is of type win32
1900 * @CAIRO_SURFACE_TYPE_BEOS: The surface is of type beos
1901 * @CAIRO_SURFACE_TYPE_DIRECTFB: The surface is of type directfb
1902 * @CAIRO_SURFACE_TYPE_SVG: The surface is of type svg
1903 * @CAIRO_SURFACE_TYPE_OS2: The surface is of type os2
1904 * @CAIRO_SURFACE_TYPE_WIN32_PRINTING: The surface is a win32 printing surface
1905 * @CAIRO_SURFACE_TYPE_QUARTZ_IMAGE: The surface is of type quartz_image
1906 * @CAIRO_SURFACE_TYPE_SCRIPT: The surface is of type script, since 1.10
1907 * @CAIRO_SURFACE_TYPE_QT: The surface is of type Qt, since 1.10
1908 * @CAIRO_SURFACE_TYPE_GPU: The surface is a GPU surface, since 1.10
1910 * #cairo_surface_type_t is used to describe the type of a given
1911 * surface. The surface types are also known as "backends" or "surface
1912 * backends" within cairo.
1914 * The type of a surface is determined by the function used to create
1915 * it, which will generally be of the form cairo_<emphasis>type</emphasis>_surface_create(),
1916 * (though see cairo_surface_create_similar() as well).
1918 * The surface type can be queried with cairo_surface_get_type()
1920 * The various #cairo_surface_t functions can be used with surfaces of
1921 * any type, but some backends also provide type-specific functions
1922 * that must only be called with a surface of the appropriate
1923 * type. These functions have names that begin with
1924 * cairo_<emphasis>type</emphasis>_surface<!-- --> such as cairo_image_surface_get_width().
1926 * The behavior of calling a type-specific function with a surface of
1927 * the wrong type is undefined.
1929 * New entries may be added in future versions.
1933 typedef enum _cairo_surface_type
{
1934 CAIRO_SURFACE_TYPE_IMAGE
,
1935 CAIRO_SURFACE_TYPE_PDF
,
1936 CAIRO_SURFACE_TYPE_PS
,
1937 CAIRO_SURFACE_TYPE_XLIB
,
1938 CAIRO_SURFACE_TYPE_XCB
,
1939 CAIRO_SURFACE_TYPE_GLITZ
,
1940 CAIRO_SURFACE_TYPE_QUARTZ
,
1941 CAIRO_SURFACE_TYPE_WIN32
,
1942 CAIRO_SURFACE_TYPE_BEOS
,
1943 CAIRO_SURFACE_TYPE_DIRECTFB
,
1944 CAIRO_SURFACE_TYPE_SVG
,
1945 CAIRO_SURFACE_TYPE_OS2
,
1946 CAIRO_SURFACE_TYPE_WIN32_PRINTING
,
1947 CAIRO_SURFACE_TYPE_QUARTZ_IMAGE
,
1948 CAIRO_SURFACE_TYPE_SCRIPT
,
1949 CAIRO_SURFACE_TYPE_QT
,
1950 CAIRO_SURFACE_TYPE_GPU
,
1951 } cairo_surface_type_t
;
1953 cairo_public cairo_surface_type_t
1954 cairo_surface_get_type (cairo_surface_t
*surface
);
1956 cairo_public cairo_content_t
1957 cairo_surface_get_content (cairo_surface_t
*surface
);
1959 #if CAIRO_HAS_PNG_FUNCTIONS
1961 cairo_public cairo_status_t
1962 cairo_surface_write_to_png (cairo_surface_t
*surface
,
1963 const char *filename
);
1965 cairo_public cairo_status_t
1966 cairo_surface_write_to_png_stream (cairo_surface_t
*surface
,
1967 cairo_write_func_t write_func
,
1973 cairo_surface_get_user_data (cairo_surface_t
*surface
,
1974 const cairo_user_data_key_t
*key
);
1976 cairo_public cairo_status_t
1977 cairo_surface_set_user_data (cairo_surface_t
*surface
,
1978 const cairo_user_data_key_t
*key
,
1980 cairo_destroy_func_t destroy
);
1982 #define CAIRO_MIME_TYPE_JPEG "image/jpeg"
1983 #define CAIRO_MIME_TYPE_PNG "image/png"
1984 #define CAIRO_MIME_TYPE_JP2 "image/jp2"
1987 cairo_surface_get_mime_data (cairo_surface_t
*surface
,
1988 const char *mime_type
,
1989 const unsigned char **data
,
1990 unsigned int *length
);
1992 cairo_public cairo_status_t
1993 cairo_surface_set_mime_data (cairo_surface_t
*surface
,
1994 const char *mime_type
,
1995 const unsigned char *data
,
1996 unsigned int length
,
1997 cairo_destroy_func_t destroy
,
2001 cairo_surface_get_font_options (cairo_surface_t
*surface
,
2002 cairo_font_options_t
*options
);
2005 cairo_surface_flush (cairo_surface_t
*surface
);
2008 cairo_surface_mark_dirty (cairo_surface_t
*surface
);
2011 cairo_surface_mark_dirty_rectangle (cairo_surface_t
*surface
,
2018 cairo_surface_set_device_offset (cairo_surface_t
*surface
,
2023 cairo_surface_get_device_offset (cairo_surface_t
*surface
,
2028 cairo_surface_set_fallback_resolution (cairo_surface_t
*surface
,
2029 double x_pixels_per_inch
,
2030 double y_pixels_per_inch
);
2033 cairo_surface_get_fallback_resolution (cairo_surface_t
*surface
,
2034 double *x_pixels_per_inch
,
2035 double *y_pixels_per_inch
);
2038 cairo_surface_copy_page (cairo_surface_t
*surface
);
2041 cairo_surface_show_page (cairo_surface_t
*surface
);
2044 cairo_surface_swap_page (cairo_surface_t
*surface
);
2046 cairo_public cairo_bool_t
2047 cairo_surface_has_show_text_glyphs (cairo_surface_t
*surface
);
2049 /* Image-surface functions */
2053 * @CAIRO_FORMAT_ARGB32: each pixel is a 32-bit quantity, with
2054 * alpha in the upper 8 bits, then red, then green, then blue.
2055 * The 32-bit quantities are stored native-endian. Pre-multiplied
2056 * alpha is used. (That is, 50% transparent red is 0x80800000,
2058 * @CAIRO_FORMAT_RGB24: each pixel is a 32-bit quantity, with
2059 * the upper 8 bits unused. Red, Green, and Blue are stored
2060 * in the remaining 24 bits in that order.
2061 * @CAIRO_FORMAT_A8: each pixel is a 8-bit quantity holding
2063 * @CAIRO_FORMAT_A1: each pixel is a 1-bit quantity holding
2064 * an alpha value. Pixels are packed together into 32-bit
2065 * quantities. The ordering of the bits matches the
2066 * endianess of the platform. On a big-endian machine, the
2067 * first pixel is in the uppermost bit, on a little-endian
2068 * machine the first pixel is in the least-significant bit.
2069 * @CAIRO_FORMAT_RGB16_565: This format value is deprecated. It has
2070 * never been properly implemented in cairo and should not be used
2071 * by applications. (since 1.2)
2073 * #cairo_format_t is used to identify the memory format of
2076 * New entries may be added in future versions.
2078 typedef enum _cairo_format
{
2079 CAIRO_FORMAT_ARGB32
,
2083 /* The value of 4 is reserved by a deprecated enum value.
2084 * The next format added must have an explicit value of 5.
2085 CAIRO_FORMAT_RGB16_565 = 4,
2089 cairo_public cairo_surface_t
*
2090 cairo_image_surface_create (cairo_format_t format
,
2095 cairo_format_stride_for_width (cairo_format_t format
,
2098 cairo_public cairo_surface_t
*
2099 cairo_image_surface_create_for_data (unsigned char *data
,
2100 cairo_format_t format
,
2105 typedef struct _cairo_format_masks
{
2107 unsigned long alpha_mask
;
2108 unsigned long red_mask
;
2109 unsigned long green_mask
;
2110 unsigned long blue_mask
;
2111 } cairo_format_masks_t
;
2114 cairo_image_surface_create_with_masks (unsigned char *data
,
2115 cairo_format_masks_t
*masks
,
2120 cairo_public
unsigned char *
2121 cairo_image_surface_get_data (cairo_surface_t
*surface
);
2123 cairo_public cairo_format_t
2124 cairo_image_surface_get_format (cairo_surface_t
*surface
);
2127 cairo_image_surface_get_width (cairo_surface_t
*surface
);
2130 cairo_image_surface_get_height (cairo_surface_t
*surface
);
2133 cairo_image_surface_get_stride (cairo_surface_t
*surface
);
2135 #if CAIRO_HAS_PNG_FUNCTIONS
2137 cairo_public cairo_surface_t
*
2138 cairo_image_surface_create_from_png (const char *filename
);
2140 cairo_public cairo_surface_t
*
2141 cairo_image_surface_create_from_png_stream (cairo_read_func_t read_func
,
2146 /* Pattern creation functions */
2148 cairo_public cairo_pattern_t
*
2149 cairo_pattern_create_rgb (double red
, double green
, double blue
);
2151 cairo_public cairo_pattern_t
*
2152 cairo_pattern_create_rgba (double red
, double green
, double blue
,
2155 cairo_public cairo_pattern_t
*
2156 cairo_pattern_create_for_surface (cairo_surface_t
*surface
);
2158 cairo_public cairo_pattern_t
*
2159 cairo_pattern_create_linear (double x0
, double y0
,
2160 double x1
, double y1
);
2162 cairo_public cairo_pattern_t
*
2163 cairo_pattern_create_radial (double cx0
, double cy0
, double radius0
,
2164 double cx1
, double cy1
, double radius1
);
2166 cairo_public cairo_pattern_t
*
2167 cairo_pattern_reference (cairo_pattern_t
*pattern
);
2170 cairo_pattern_destroy (cairo_pattern_t
*pattern
);
2172 cairo_public
unsigned int
2173 cairo_pattern_get_reference_count (cairo_pattern_t
*pattern
);
2175 cairo_public cairo_status_t
2176 cairo_pattern_status (cairo_pattern_t
*pattern
);
2179 cairo_pattern_get_user_data (cairo_pattern_t
*pattern
,
2180 const cairo_user_data_key_t
*key
);
2182 cairo_public cairo_status_t
2183 cairo_pattern_set_user_data (cairo_pattern_t
*pattern
,
2184 const cairo_user_data_key_t
*key
,
2186 cairo_destroy_func_t destroy
);
2189 * cairo_pattern_type_t:
2190 * @CAIRO_PATTERN_TYPE_SOLID: The pattern is a solid (uniform)
2191 * color. It may be opaque or translucent.
2192 * @CAIRO_PATTERN_TYPE_SURFACE: The pattern is a based on a surface (an image).
2193 * @CAIRO_PATTERN_TYPE_LINEAR: The pattern is a linear gradient.
2194 * @CAIRO_PATTERN_TYPE_RADIAL: The pattern is a radial gradient.
2196 * #cairo_pattern_type_t is used to describe the type of a given pattern.
2198 * The type of a pattern is determined by the function used to create
2199 * it. The cairo_pattern_create_rgb() and cairo_pattern_create_rgba()
2200 * functions create SOLID patterns. The remaining
2201 * cairo_pattern_create<!-- --> functions map to pattern types in obvious
2204 * The pattern type can be queried with cairo_pattern_get_type()
2206 * Most #cairo_pattern_t functions can be called with a pattern of any
2207 * type, (though trying to change the extend or filter for a solid
2208 * pattern will have no effect). A notable exception is
2209 * cairo_pattern_add_color_stop_rgb() and
2210 * cairo_pattern_add_color_stop_rgba() which must only be called with
2211 * gradient patterns (either LINEAR or RADIAL). Otherwise the pattern
2212 * will be shutdown and put into an error state.
2214 * New entries may be added in future versions.
2218 typedef enum _cairo_pattern_type
{
2219 CAIRO_PATTERN_TYPE_SOLID
,
2220 CAIRO_PATTERN_TYPE_SURFACE
,
2221 CAIRO_PATTERN_TYPE_LINEAR
,
2222 CAIRO_PATTERN_TYPE_RADIAL
2223 } cairo_pattern_type_t
;
2225 cairo_public cairo_pattern_type_t
2226 cairo_pattern_get_type (cairo_pattern_t
*pattern
);
2229 cairo_pattern_add_color_stop_rgb (cairo_pattern_t
*pattern
,
2231 double red
, double green
, double blue
);
2234 cairo_pattern_add_color_stop_rgba (cairo_pattern_t
*pattern
,
2236 double red
, double green
, double blue
,
2240 cairo_pattern_set_matrix (cairo_pattern_t
*pattern
,
2241 const cairo_matrix_t
*matrix
);
2244 cairo_pattern_get_matrix (cairo_pattern_t
*pattern
,
2245 cairo_matrix_t
*matrix
);
2249 * @CAIRO_EXTEND_NONE: pixels outside of the source pattern
2250 * are fully transparent
2251 * @CAIRO_EXTEND_REPEAT: the pattern is tiled by repeating
2252 * @CAIRO_EXTEND_REFLECT: the pattern is tiled by reflecting
2253 * at the edges (Implemented for surface patterns since 1.6)
2254 * @CAIRO_EXTEND_PAD: pixels outside of the pattern copy
2255 * the closest pixel from the source (Since 1.2; but only
2256 * implemented for surface patterns since 1.6)
2258 * #cairo_extend_t is used to describe how pattern color/alpha will be
2259 * determined for areas "outside" the pattern's natural area, (for
2260 * example, outside the surface bounds or outside the gradient
2263 * The default extend mode is %CAIRO_EXTEND_NONE for surface patterns
2264 * and %CAIRO_EXTEND_PAD for gradient patterns.
2266 * New entries may be added in future versions.
2268 typedef enum _cairo_extend
{
2270 CAIRO_EXTEND_REPEAT
,
2271 CAIRO_EXTEND_REFLECT
,
2276 cairo_pattern_set_extend (cairo_pattern_t
*pattern
, cairo_extend_t extend
);
2278 cairo_public cairo_extend_t
2279 cairo_pattern_get_extend (cairo_pattern_t
*pattern
);
2283 * @CAIRO_FILTER_FAST: A high-performance filter, with quality similar
2284 * to %CAIRO_FILTER_NEAREST
2285 * @CAIRO_FILTER_GOOD: A reasonable-performance filter, with quality
2286 * similar to %CAIRO_FILTER_BILINEAR
2287 * @CAIRO_FILTER_BEST: The highest-quality available, performance may
2288 * not be suitable for interactive use.
2289 * @CAIRO_FILTER_NEAREST: Nearest-neighbor filtering
2290 * @CAIRO_FILTER_BILINEAR: Linear interpolation in two dimensions
2291 * @CAIRO_FILTER_GAUSSIAN: This filter value is currently
2292 * unimplemented, and should not be used in current code.
2294 * #cairo_filter_t is used to indicate what filtering should be
2295 * applied when reading pixel values from patterns. See
2296 * cairo_pattern_set_source() for indicating the desired filter to be
2297 * used with a particular pattern.
2299 typedef enum _cairo_filter
{
2303 CAIRO_FILTER_NEAREST
,
2304 CAIRO_FILTER_BILINEAR
,
2305 CAIRO_FILTER_GAUSSIAN
2309 cairo_pattern_set_filter (cairo_pattern_t
*pattern
, cairo_filter_t filter
);
2311 cairo_public cairo_filter_t
2312 cairo_pattern_get_filter (cairo_pattern_t
*pattern
);
2315 cairo_pattern_set_component_alpha (cairo_pattern_t
*pattern
, cairo_bool_t component_alpha
);
2317 cairo_public cairo_bool_t
2318 cairo_pattern_get_component_alpha (cairo_pattern_t
*pattern
);
2320 cairo_public cairo_status_t
2321 cairo_pattern_get_rgba (cairo_pattern_t
*pattern
,
2322 double *red
, double *green
,
2323 double *blue
, double *alpha
);
2325 cairo_public cairo_status_t
2326 cairo_pattern_get_surface (cairo_pattern_t
*pattern
,
2327 cairo_surface_t
**surface
);
2330 cairo_public cairo_status_t
2331 cairo_pattern_get_color_stop_rgba (cairo_pattern_t
*pattern
,
2332 int index
, double *offset
,
2333 double *red
, double *green
,
2334 double *blue
, double *alpha
);
2336 cairo_public cairo_status_t
2337 cairo_pattern_get_color_stop_count (cairo_pattern_t
*pattern
,
2340 cairo_public cairo_status_t
2341 cairo_pattern_get_linear_points (cairo_pattern_t
*pattern
,
2342 double *x0
, double *y0
,
2343 double *x1
, double *y1
);
2345 cairo_public cairo_status_t
2346 cairo_pattern_get_radial_circles (cairo_pattern_t
*pattern
,
2347 double *x0
, double *y0
, double *r0
,
2348 double *x1
, double *y1
, double *r1
);
2350 /* Matrix functions */
2353 cairo_matrix_init (cairo_matrix_t
*matrix
,
2354 double xx
, double yx
,
2355 double xy
, double yy
,
2356 double x0
, double y0
);
2359 cairo_matrix_init_identity (cairo_matrix_t
*matrix
);
2362 cairo_matrix_init_translate (cairo_matrix_t
*matrix
,
2363 double tx
, double ty
);
2366 cairo_matrix_init_scale (cairo_matrix_t
*matrix
,
2367 double sx
, double sy
);
2370 cairo_matrix_init_rotate (cairo_matrix_t
*matrix
,
2374 cairo_matrix_translate (cairo_matrix_t
*matrix
, double tx
, double ty
);
2377 cairo_matrix_scale (cairo_matrix_t
*matrix
, double sx
, double sy
);
2380 cairo_matrix_rotate (cairo_matrix_t
*matrix
, double radians
);
2382 cairo_public cairo_status_t
2383 cairo_matrix_invert (cairo_matrix_t
*matrix
);
2386 cairo_matrix_multiply (cairo_matrix_t
*result
,
2387 const cairo_matrix_t
*a
,
2388 const cairo_matrix_t
*b
);
2391 cairo_matrix_transform_distance (const cairo_matrix_t
*matrix
,
2392 double *dx
, double *dy
);
2395 cairo_matrix_transform_point (const cairo_matrix_t
*matrix
,
2396 double *x
, double *y
);
2398 /* Region functions */
2400 typedef struct _cairo_region cairo_region_t
;
2402 typedef struct _cairo_rectangle_int
{
2405 } cairo_rectangle_int_t
;
2407 typedef enum _cairo_region_overlap
{
2408 CAIRO_REGION_OVERLAP_IN
, /* completely inside region */
2409 CAIRO_REGION_OVERLAP_OUT
, /* completely outside region */
2410 CAIRO_REGION_OVERLAP_PART
/* partly inside region */
2411 } cairo_region_overlap_t
;
2413 cairo_public cairo_region_t
*
2414 cairo_region_create (void);
2416 cairo_public cairo_region_t
*
2417 cairo_region_create_rectangle (const cairo_rectangle_int_t
*rectangle
);
2419 cairo_public cairo_region_t
*
2420 cairo_region_create_rectangles (cairo_rectangle_int_t
*rects
,
2423 cairo_public cairo_region_t
*
2424 cairo_region_copy (cairo_region_t
*original
);
2427 cairo_region_destroy (cairo_region_t
*region
);
2429 cairo_public cairo_status_t
2430 cairo_region_status (cairo_region_t
*region
);
2433 cairo_region_get_extents (cairo_region_t
*region
,
2434 cairo_rectangle_int_t
*extents
);
2437 cairo_region_num_rectangles (cairo_region_t
*region
);
2440 cairo_region_get_rectangle (cairo_region_t
*region
,
2442 cairo_rectangle_int_t
*rectangle
);
2444 cairo_public cairo_bool_t
2445 cairo_region_is_empty (cairo_region_t
*region
);
2447 cairo_public cairo_region_overlap_t
2448 cairo_region_contains_rectangle (cairo_region_t
*region
,
2449 const cairo_rectangle_int_t
*rectangle
);
2451 cairo_public cairo_bool_t
2452 cairo_region_contains_point (cairo_region_t
*region
, int x
, int y
);
2455 cairo_region_translate (cairo_region_t
*region
, int dx
, int dy
);
2457 cairo_public cairo_status_t
2458 cairo_region_subtract (cairo_region_t
*dst
, cairo_region_t
*other
);
2460 cairo_public cairo_status_t
2461 cairo_region_subtract_rectangle (cairo_region_t
*dst
,
2462 const cairo_rectangle_int_t
*rectangle
);
2464 cairo_public cairo_status_t
2465 cairo_region_intersect (cairo_region_t
*dst
, cairo_region_t
*other
);
2467 cairo_public cairo_status_t
2468 cairo_region_intersect_rectangle (cairo_region_t
*dst
,
2469 const cairo_rectangle_int_t
*rectangle
);
2471 cairo_public cairo_status_t
2472 cairo_region_union (cairo_region_t
*dst
, cairo_region_t
*other
);
2474 cairo_public cairo_status_t
2475 cairo_region_union_rectangle (cairo_region_t
*dst
,
2476 const cairo_rectangle_int_t
*rectangle
);
2479 /* Functions to be used while debugging (not intended for use in production code) */
2481 cairo_debug_reset_static_data (void);
2488 typedef struct _XDisplay Display
;
2489 typedef unsigned long XID
;
2490 typedef XID Drawable
;
2492 struct xcb_connection_t
;
2493 typedef struct xcb_connection_t xcb_connection_t
;
2495 struct _cairo_space
;
2496 typedef struct _cairo_space cairo_space_t
;
2498 /* use best rendering pipeline available (-> usually GLX on the current X11 display) */
2499 cairo_public cairo_space_t
*
2500 cairo_space_create (void);
2502 /* use libX11 for rendering */
2503 /* We call it x11_xlib and not xlib because the user should normally call cairo_x11_space_create
2504 * so that it possibly gets an OpenGL/Gallium/DRM accelerated space.
2505 * The more awkward name should make obvious that this is the wrong choice usually. */
2506 cairo_public cairo_space_t
*
2507 cairo_xlib_space_wrap (Display
*dpy
, int screen
, int owns
);
2509 cairo_public cairo_space_t
*
2510 cairo_xlib_space_create (const char* str
);
2512 cairo_public cairo_space_t
*
2513 cairo_xcb_space_wrap (xcb_connection_t
* conn
, int screen
, int owns
);
2515 cairo_public cairo_space_t
*
2516 cairo_xcb_space_create (const char* str
);
2518 /* use libX11 or libXcb for rendering */
2519 cairo_public cairo_space_t
*
2520 cairo_xproto_space_create (const char* str
);
2522 /* use libX11, OpenGL or something else for rendering */
2523 cairo_public cairo_space_t
*
2524 cairo_space_create_for_display (const char* str
);
2526 /* use libX11, OpenGL or something else for rendering */
2527 cairo_public cairo_space_t
*
2528 cairo_space_wrap_xlib (Display
*dpy
, int screen
, int owns
);
2530 /* use libX11, OpenGL or something else for rendering.
2531 * Note that OpenGL is likely not supported and you should wrap a Display* or use cairo_space_create_for_display */
2532 cairo_public cairo_space_t
*
2533 cairo_space_wrap_xcb (xcb_connection_t
* conn
, int screen
, int owns
);
2535 cairo_public cairo_space_t
*
2536 cairo_space_reference (cairo_space_t
*context
);
2539 cairo_space_destroy (cairo_space_t
*context
);
2541 cairo_public cairo_status_t
2542 cairo_space_sync(cairo_space_t
* space
);
2545 cairo_space_is_software(cairo_space_t
* space
);
2547 /* If surface != 0, recreate surface as specified, otherwise create a new surface */
2548 cairo_public cairo_surface_t
*
2549 cairo_surface_create (cairo_space_t
*ctx
, cairo_surface_t
* surface
,
2550 cairo_content_t content
,
2551 double width
, double height
,
2552 int color_mantissa_bits
, int alpha_mantissa_bits
, int exponent_bits
, int shared_exponent_bits
);
2554 cairo_public cairo_surface_t
*
2555 cairo_surface_create_for_drawable (cairo_space_t
*ctx
, cairo_surface_t
* surface
, cairo_content_t content
,
2556 unsigned long drawable
, unsigned long visualid
, cairo_bool_t double_buffered
,
2557 int width
, int height
);
2559 /* does not reference the returned space */
2560 cairo_public cairo_space_t
*
2561 cairo_surface_get_space (cairo_surface_t
*surface
);
2564 cairo_surface_set_drawable(cairo_surface_t
* surface
, cairo_content_t content
, unsigned long drawable
, unsigned long visualid
, cairo_bool_t double_buffered
, int width
, int height
, cairo_bool_t keep_contents
);
2567 cairo_surface_swap_buffers (cairo_surface_t
*surface
);
2569 /* msaa_quality is the quality we attribute to these settings
2573 cairo_surface_set_samples(cairo_surface_t
* surface
, unsigned coverage_samples
, unsigned color_samples
);
2576 cairo_surface_enable_multisampling(cairo_surface_t
* surface
, int want_msaa
);
2580 #endif /* CAIRO_H */