You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

2685 lines
91 KiB

  1. /* cairo - a vector graphics library with display and print output
  2. *
  3. * Copyright © 2002 University of Southern California
  4. * Copyright © 2005 Red Hat, Inc.
  5. *
  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.
  13. *
  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., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
  17. * You should have received a copy of the MPL along with this library
  18. * in the file COPYING-MPL-1.1
  19. *
  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/
  24. *
  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.
  28. *
  29. * The Original Code is the cairo graphics library.
  30. *
  31. * The Initial Developer of the Original Code is University of Southern
  32. * California.
  33. *
  34. * Contributor(s):
  35. * Carl D. Worth <cworth@cworth.org>
  36. */
  37. #ifndef CAIRO_H
  38. #define CAIRO_H
  39. #include "cairo-version.h"
  40. #include "cairo-features.h"
  41. #include "cairo-deprecated.h"
  42. #ifdef __cplusplus
  43. # define CAIRO_BEGIN_DECLS extern "C" {
  44. # define CAIRO_END_DECLS }
  45. #else
  46. # define CAIRO_BEGIN_DECLS
  47. # define CAIRO_END_DECLS
  48. #endif
  49. #ifndef cairo_public
  50. # if defined (_MSC_VER) && ! defined (CAIRO_WIN32_STATIC_BUILD)
  51. # define cairo_public __declspec(dllimport)
  52. # else
  53. # define cairo_public
  54. # endif
  55. #endif
  56. CAIRO_BEGIN_DECLS
  57. #define CAIRO_VERSION_ENCODE(major, minor, micro) ( \
  58. ((major) * 10000) \
  59. + ((minor) * 100) \
  60. + ((micro) * 1))
  61. #define CAIRO_VERSION CAIRO_VERSION_ENCODE( \
  62. CAIRO_VERSION_MAJOR, \
  63. CAIRO_VERSION_MINOR, \
  64. CAIRO_VERSION_MICRO)
  65. #define CAIRO_VERSION_STRINGIZE_(major, minor, micro) \
  66. #major"."#minor"."#micro
  67. #define CAIRO_VERSION_STRINGIZE(major, minor, micro) \
  68. CAIRO_VERSION_STRINGIZE_(major, minor, micro)
  69. #define CAIRO_VERSION_STRING CAIRO_VERSION_STRINGIZE( \
  70. CAIRO_VERSION_MAJOR, \
  71. CAIRO_VERSION_MINOR, \
  72. CAIRO_VERSION_MICRO)
  73. cairo_public int
  74. cairo_version (void);
  75. cairo_public const char*
  76. cairo_version_string (void);
  77. /**
  78. * cairo_bool_t:
  79. *
  80. * #cairo_bool_t is used for boolean values. Returns of type
  81. * #cairo_bool_t will always be either 0 or 1, but testing against
  82. * these values explicitly is not encouraged; just use the
  83. * value as a boolean condition.
  84. *
  85. * <informalexample><programlisting>
  86. * if (cairo_in_stroke (cr, x, y)) {
  87. * /<!-- -->* do something *<!-- -->/
  88. * }
  89. * </programlisting></informalexample>
  90. **/
  91. typedef int cairo_bool_t;
  92. /**
  93. * cairo_t:
  94. *
  95. * A #cairo_t contains the current state of the rendering device,
  96. * including coordinates of yet to be drawn shapes.
  97. *
  98. * Cairo contexts, as #cairo_t objects are named, are central to
  99. * cairo and all drawing with cairo is always done to a #cairo_t
  100. * object.
  101. *
  102. * Memory management of #cairo_t is done with
  103. * cairo_reference() and cairo_destroy().
  104. **/
  105. typedef struct _cairo cairo_t;
  106. /**
  107. * cairo_surface_t:
  108. *
  109. * A #cairo_surface_t represents an image, either as the destination
  110. * of a drawing operation or as source when drawing onto another
  111. * surface. To draw to a #cairo_surface_t, create a cairo context
  112. * with the surface as the target, using cairo_create().
  113. *
  114. * There are different subtypes of #cairo_surface_t for
  115. * different drawing backends; for example, cairo_image_surface_create()
  116. * creates a bitmap image in memory.
  117. * The type of a surface can be queried with cairo_surface_get_type().
  118. *
  119. * The initial contents of a surface after creation depend upon the manner
  120. * of its creation. If cairo creates the surface and backing storage for
  121. * the user, it will be initially cleared; for example,
  122. * cairo_image_surface_create() and cairo_surface_create_similar().
  123. * Alternatively, if the user passes in a reference to some backing storage
  124. * and asks cairo to wrap that in a #cairo_surface_t, then the contents are
  125. * not modified; for example, cairo_image_surface_create_for_data() and
  126. * cairo_xlib_surface_create().
  127. *
  128. * Memory management of #cairo_surface_t is done with
  129. * cairo_surface_reference() and cairo_surface_destroy().
  130. **/
  131. typedef struct _cairo_surface cairo_surface_t;
  132. /**
  133. * cairo_device_t:
  134. *
  135. * A #cairo_device_t represents the driver interface for drawing
  136. * operations to a #cairo_surface_t. There are different subtypes of
  137. * #cairo_device_t for different drawing backends; for example,
  138. * cairo_xcb_device_create() creates a device that wraps the connection
  139. * to an X Windows System using the XCB library.
  140. *
  141. * The type of a device can be queried with cairo_device_get_type().
  142. *
  143. * Memory management of #cairo_device_t is done with
  144. * cairo_device_reference() and cairo_device_destroy().
  145. *
  146. * Since: 1.10
  147. **/
  148. typedef struct _cairo_device cairo_device_t;
  149. /**
  150. * cairo_matrix_t:
  151. * @xx: xx component of the affine transformation
  152. * @yx: yx component of the affine transformation
  153. * @xy: xy component of the affine transformation
  154. * @yy: yy component of the affine transformation
  155. * @x0: X translation component of the affine transformation
  156. * @y0: Y translation component of the affine transformation
  157. *
  158. * A #cairo_matrix_t holds an affine transformation, such as a scale,
  159. * rotation, shear, or a combination of those. The transformation of
  160. * a point (x, y) is given by:
  161. * <programlisting>
  162. * x_new = xx * x + xy * y + x0;
  163. * y_new = yx * x + yy * y + y0;
  164. * </programlisting>
  165. **/
  166. typedef struct _cairo_matrix {
  167. double xx; double yx;
  168. double xy; double yy;
  169. double x0; double y0;
  170. } cairo_matrix_t;
  171. /**
  172. * cairo_pattern_t:
  173. *
  174. * A #cairo_pattern_t represents a source when drawing onto a
  175. * surface. There are different subtypes of #cairo_pattern_t,
  176. * for different types of sources; for example,
  177. * cairo_pattern_create_rgb() creates a pattern for a solid
  178. * opaque color.
  179. *
  180. * Other than various cairo_pattern_create_<emphasis>type</emphasis>()
  181. * functions, some of the pattern types can be implicitly created
  182. * using various cairo_set_source_<emphasis>type</emphasis>() functions;
  183. * for example cairo_set_source_rgb().
  184. *
  185. * The type of a pattern can be queried with cairo_pattern_get_type().
  186. *
  187. * Memory management of #cairo_pattern_t is done with
  188. * cairo_pattern_reference() and cairo_pattern_destroy().
  189. **/
  190. typedef struct _cairo_pattern cairo_pattern_t;
  191. /**
  192. * cairo_destroy_func_t:
  193. * @data: The data element being destroyed.
  194. *
  195. * #cairo_destroy_func_t the type of function which is called when a
  196. * data element is destroyed. It is passed the pointer to the data
  197. * element and should free any memory and resources allocated for it.
  198. **/
  199. typedef void (*cairo_destroy_func_t) (void *data);
  200. /**
  201. * cairo_user_data_key_t:
  202. * @unused: not used; ignore.
  203. *
  204. * #cairo_user_data_key_t is used for attaching user data to cairo
  205. * data structures. The actual contents of the struct is never used,
  206. * and there is no need to initialize the object; only the unique
  207. * address of a #cairo_data_key_t object is used. Typically, you
  208. * would just use the address of a static #cairo_data_key_t object.
  209. **/
  210. typedef struct _cairo_user_data_key {
  211. int unused;
  212. } cairo_user_data_key_t;
  213. /**
  214. * cairo_status_t:
  215. * @CAIRO_STATUS_SUCCESS: no error has occurred
  216. * @CAIRO_STATUS_NO_MEMORY: out of memory
  217. * @CAIRO_STATUS_INVALID_RESTORE: cairo_restore() called without matching cairo_save()
  218. * @CAIRO_STATUS_INVALID_POP_GROUP: no saved group to pop, i.e. cairo_pop_group() without matching cairo_push_group()
  219. * @CAIRO_STATUS_NO_CURRENT_POINT: no current point defined
  220. * @CAIRO_STATUS_INVALID_MATRIX: invalid matrix (not invertible)
  221. * @CAIRO_STATUS_INVALID_STATUS: invalid value for an input #cairo_status_t
  222. * @CAIRO_STATUS_NULL_POINTER: %NULL pointer
  223. * @CAIRO_STATUS_INVALID_STRING: input string not valid UTF-8
  224. * @CAIRO_STATUS_INVALID_PATH_DATA: input path data not valid
  225. * @CAIRO_STATUS_READ_ERROR: error while reading from input stream
  226. * @CAIRO_STATUS_WRITE_ERROR: error while writing to output stream
  227. * @CAIRO_STATUS_SURFACE_FINISHED: target surface has been finished
  228. * @CAIRO_STATUS_SURFACE_TYPE_MISMATCH: the surface type is not appropriate for the operation
  229. * @CAIRO_STATUS_PATTERN_TYPE_MISMATCH: the pattern type is not appropriate for the operation
  230. * @CAIRO_STATUS_INVALID_CONTENT: invalid value for an input #cairo_content_t
  231. * @CAIRO_STATUS_INVALID_FORMAT: invalid value for an input #cairo_format_t
  232. * @CAIRO_STATUS_INVALID_VISUAL: invalid value for an input Visual*
  233. * @CAIRO_STATUS_FILE_NOT_FOUND: file not found
  234. * @CAIRO_STATUS_INVALID_DASH: invalid value for a dash setting
  235. * @CAIRO_STATUS_INVALID_DSC_COMMENT: invalid value for a DSC comment (Since 1.2)
  236. * @CAIRO_STATUS_INVALID_INDEX: invalid index passed to getter (Since 1.4)
  237. * @CAIRO_STATUS_CLIP_NOT_REPRESENTABLE: clip region not representable in desired format (Since 1.4)
  238. * @CAIRO_STATUS_TEMP_FILE_ERROR: error creating or writing to a temporary file (Since 1.6)
  239. * @CAIRO_STATUS_INVALID_STRIDE: invalid value for stride (Since 1.6)
  240. * @CAIRO_STATUS_FONT_TYPE_MISMATCH: the font type is not appropriate for the operation (Since 1.8)
  241. * @CAIRO_STATUS_USER_FONT_IMMUTABLE: the user-font is immutable (Since 1.8)
  242. * @CAIRO_STATUS_USER_FONT_ERROR: error occurred in a user-font callback function (Since 1.8)
  243. * @CAIRO_STATUS_NEGATIVE_COUNT: negative number used where it is not allowed (Since 1.8)
  244. * @CAIRO_STATUS_INVALID_CLUSTERS: input clusters do not represent the accompanying text and glyph array (Since 1.8)
  245. * @CAIRO_STATUS_INVALID_SLANT: invalid value for an input #cairo_font_slant_t (Since 1.8)
  246. * @CAIRO_STATUS_INVALID_WEIGHT: invalid value for an input #cairo_font_weight_t (Since 1.8)
  247. * @CAIRO_STATUS_INVALID_SIZE: invalid value (typically too big) for the size of the input (surface, pattern, etc.) (Since 1.10)
  248. * @CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED: user-font method not implemented (Since 1.10)
  249. * @CAIRO_STATUS_DEVICE_TYPE_MISMATCH: the device type is not appropriate for the operation (Since 1.10)
  250. * @CAIRO_STATUS_DEVICE_ERROR: an operation to the device caused an unspecified error (Since 1.10)
  251. * @CAIRO_STATUS_LAST_STATUS: this is a special value indicating the number of
  252. * status values defined in this enumeration. When using this value, note
  253. * that the version of cairo at run-time may have additional status values
  254. * defined than the value of this symbol at compile-time. (Since 1.10)
  255. *
  256. * #cairo_status_t is used to indicate errors that can occur when
  257. * using Cairo. In some cases it is returned directly by functions.
  258. * but when using #cairo_t, the last error, if any, is stored in
  259. * the context and can be retrieved with cairo_status().
  260. *
  261. * New entries may be added in future versions. Use cairo_status_to_string()
  262. * to get a human-readable representation of an error message.
  263. **/
  264. typedef enum _cairo_status {
  265. CAIRO_STATUS_SUCCESS = 0,
  266. CAIRO_STATUS_NO_MEMORY,
  267. CAIRO_STATUS_INVALID_RESTORE,
  268. CAIRO_STATUS_INVALID_POP_GROUP,
  269. CAIRO_STATUS_NO_CURRENT_POINT,
  270. CAIRO_STATUS_INVALID_MATRIX,
  271. CAIRO_STATUS_INVALID_STATUS,
  272. CAIRO_STATUS_NULL_POINTER,
  273. CAIRO_STATUS_INVALID_STRING,
  274. CAIRO_STATUS_INVALID_PATH_DATA,
  275. CAIRO_STATUS_READ_ERROR,
  276. CAIRO_STATUS_WRITE_ERROR,
  277. CAIRO_STATUS_SURFACE_FINISHED,
  278. CAIRO_STATUS_SURFACE_TYPE_MISMATCH,
  279. CAIRO_STATUS_PATTERN_TYPE_MISMATCH,
  280. CAIRO_STATUS_INVALID_CONTENT,
  281. CAIRO_STATUS_INVALID_FORMAT,
  282. CAIRO_STATUS_INVALID_VISUAL,
  283. CAIRO_STATUS_FILE_NOT_FOUND,
  284. CAIRO_STATUS_INVALID_DASH,
  285. CAIRO_STATUS_INVALID_DSC_COMMENT,
  286. CAIRO_STATUS_INVALID_INDEX,
  287. CAIRO_STATUS_CLIP_NOT_REPRESENTABLE,
  288. CAIRO_STATUS_TEMP_FILE_ERROR,
  289. CAIRO_STATUS_INVALID_STRIDE,
  290. CAIRO_STATUS_FONT_TYPE_MISMATCH,
  291. CAIRO_STATUS_USER_FONT_IMMUTABLE,
  292. CAIRO_STATUS_USER_FONT_ERROR,
  293. CAIRO_STATUS_NEGATIVE_COUNT,
  294. CAIRO_STATUS_INVALID_CLUSTERS,
  295. CAIRO_STATUS_INVALID_SLANT,
  296. CAIRO_STATUS_INVALID_WEIGHT,
  297. CAIRO_STATUS_INVALID_SIZE,
  298. CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED,
  299. CAIRO_STATUS_DEVICE_TYPE_MISMATCH,
  300. CAIRO_STATUS_DEVICE_ERROR,
  301. CAIRO_STATUS_LAST_STATUS
  302. } cairo_status_t;
  303. /**
  304. * cairo_content_t:
  305. * @CAIRO_CONTENT_COLOR: The surface will hold color content only.
  306. * @CAIRO_CONTENT_ALPHA: The surface will hold alpha content only.
  307. * @CAIRO_CONTENT_COLOR_ALPHA: The surface will hold color and alpha content.
  308. *
  309. * #cairo_content_t is used to describe the content that a surface will
  310. * contain, whether color information, alpha information (translucence
  311. * vs. opacity), or both.
  312. *
  313. * Note: The large values here are designed to keep #cairo_content_t
  314. * values distinct from #cairo_format_t values so that the
  315. * implementation can detect the error if users confuse the two types.
  316. **/
  317. typedef enum _cairo_content {
  318. CAIRO_CONTENT_COLOR = 0x1000,
  319. CAIRO_CONTENT_ALPHA = 0x2000,
  320. CAIRO_CONTENT_COLOR_ALPHA = 0x3000
  321. } cairo_content_t;
  322. /**
  323. * cairo_write_func_t:
  324. * @closure: the output closure
  325. * @data: the buffer containing the data to write
  326. * @length: the amount of data to write
  327. *
  328. * #cairo_write_func_t is the type of function which is called when a
  329. * backend needs to write data to an output stream. It is passed the
  330. * closure which was specified by the user at the time the write
  331. * function was registered, the data to write and the length of the
  332. * data in bytes. The write function should return
  333. * %CAIRO_STATUS_SUCCESS if all the data was successfully written,
  334. * %CAIRO_STATUS_WRITE_ERROR otherwise.
  335. *
  336. * Returns: the status code of the write operation
  337. **/
  338. typedef cairo_status_t (*cairo_write_func_t) (void *closure,
  339. const unsigned char *data,
  340. unsigned int length);
  341. /**
  342. * cairo_read_func_t:
  343. * @closure: the input closure
  344. * @data: the buffer into which to read the data
  345. * @length: the amount of data to read
  346. *
  347. * #cairo_read_func_t is the type of function which is called when a
  348. * backend needs to read data from an input stream. It is passed the
  349. * closure which was specified by the user at the time the read
  350. * function was registered, the buffer to read the data into and the
  351. * length of the data in bytes. The read function should return
  352. * %CAIRO_STATUS_SUCCESS if all the data was successfully read,
  353. * %CAIRO_STATUS_READ_ERROR otherwise.
  354. *
  355. * Returns: the status code of the read operation
  356. **/
  357. typedef cairo_status_t (*cairo_read_func_t) (void *closure,
  358. unsigned char *data,
  359. unsigned int length);
  360. /* Functions for manipulating state objects */
  361. cairo_public cairo_t *
  362. cairo_create (cairo_surface_t *target);
  363. cairo_public cairo_t *
  364. cairo_reference (cairo_t *cr);
  365. cairo_public void
  366. cairo_destroy (cairo_t *cr);
  367. cairo_public unsigned int
  368. cairo_get_reference_count (cairo_t *cr);
  369. cairo_public void *
  370. cairo_get_user_data (cairo_t *cr,
  371. const cairo_user_data_key_t *key);
  372. cairo_public cairo_status_t
  373. cairo_set_user_data (cairo_t *cr,
  374. const cairo_user_data_key_t *key,
  375. void *user_data,
  376. cairo_destroy_func_t destroy);
  377. cairo_public void
  378. cairo_save (cairo_t *cr);
  379. cairo_public void
  380. cairo_restore (cairo_t *cr);
  381. cairo_public void
  382. cairo_push_group (cairo_t *cr);
  383. cairo_public void
  384. cairo_push_group_with_content (cairo_t *cr, cairo_content_t content);
  385. cairo_public cairo_pattern_t *
  386. cairo_pop_group (cairo_t *cr);
  387. cairo_public void
  388. cairo_pop_group_to_source (cairo_t *cr);
  389. /* Modify state */
  390. /**
  391. * cairo_operator_t:
  392. * @CAIRO_OPERATOR_CLEAR: clear destination layer (bounded)
  393. * @CAIRO_OPERATOR_SOURCE: replace destination layer (bounded)
  394. * @CAIRO_OPERATOR_OVER: draw source layer on top of destination layer
  395. * (bounded)
  396. * @CAIRO_OPERATOR_IN: draw source where there was destination content
  397. * (unbounded)
  398. * @CAIRO_OPERATOR_OUT: draw source where there was no destination
  399. * content (unbounded)
  400. * @CAIRO_OPERATOR_ATOP: draw source on top of destination content and
  401. * only there
  402. * @CAIRO_OPERATOR_DEST: ignore the source
  403. * @CAIRO_OPERATOR_DEST_OVER: draw destination on top of source
  404. * @CAIRO_OPERATOR_DEST_IN: leave destination only where there was
  405. * source content (unbounded)
  406. * @CAIRO_OPERATOR_DEST_OUT: leave destination only where there was no
  407. * source content
  408. * @CAIRO_OPERATOR_DEST_ATOP: leave destination on top of source content
  409. * and only there (unbounded)
  410. * @CAIRO_OPERATOR_XOR: source and destination are shown where there is only
  411. * one of them
  412. * @CAIRO_OPERATOR_ADD: source and destination layers are accumulated
  413. * @CAIRO_OPERATOR_SATURATE: like over, but assuming source and dest are
  414. * disjoint geometries
  415. * @CAIRO_OPERATOR_MULTIPLY: source and destination layers are multiplied.
  416. * This causes the result to be at least as dark as the darker inputs.
  417. * @CAIRO_OPERATOR_SCREEN: source and destination are complemented and
  418. * multiplied. This causes the result to be at least as light as the lighter
  419. * inputs.
  420. * @CAIRO_OPERATOR_OVERLAY: multiplies or screens, depending on the
  421. * lightness of the destination color.
  422. * @CAIRO_OPERATOR_DARKEN: replaces the destination with the source if it
  423. * is darker, otherwise keeps the source.
  424. * @CAIRO_OPERATOR_LIGHTEN: replaces the destination with the source if it
  425. * is lighter, otherwise keeps the source.
  426. * @CAIRO_OPERATOR_COLOR_DODGE: brightens the destination color to reflect
  427. * the source color.
  428. * @CAIRO_OPERATOR_COLOR_BURN: darkens the destination color to reflect
  429. * the source color.
  430. * @CAIRO_OPERATOR_HARD_LIGHT: Multiplies or screens, dependant on source
  431. * color.
  432. * @CAIRO_OPERATOR_SOFT_LIGHT: Darkens or lightens, dependant on source
  433. * color.
  434. * @CAIRO_OPERATOR_DIFFERENCE: Takes the difference of the source and
  435. * destination color.
  436. * @CAIRO_OPERATOR_EXCLUSION: Produces an effect similar to difference, but
  437. * with lower contrast.
  438. * @CAIRO_OPERATOR_HSL_HUE: Creates a color with the hue of the source
  439. * and the saturation and luminosity of the target.
  440. * @CAIRO_OPERATOR_HSL_SATURATION: Creates a color with the saturation
  441. * of the source and the hue and luminosity of the target. Painting with
  442. * this mode onto a gray area prduces no change.
  443. * @CAIRO_OPERATOR_HSL_COLOR: Creates a color with the hue and saturation
  444. * of the source and the luminosity of the target. This preserves the gray
  445. * levels of the target and is useful for coloring monochrome images or
  446. * tinting color images.
  447. * @CAIRO_OPERATOR_HSL_LUMINOSITY: Creates a color with the luminosity of
  448. * the source and the hue and saturation of the target. This produces an
  449. * inverse effect to @CAIRO_OPERATOR_HSL_COLOR.
  450. *
  451. * #cairo_operator_t is used to set the compositing operator for all cairo
  452. * drawing operations.
  453. *
  454. * The default operator is %CAIRO_OPERATOR_OVER.
  455. *
  456. * The operators marked as <firstterm>unbounded</firstterm> modify their
  457. * destination even outside of the mask layer (that is, their effect is not
  458. * bound by the mask layer). However, their effect can still be limited by
  459. * way of clipping.
  460. *
  461. * To keep things simple, the operator descriptions here
  462. * document the behavior for when both source and destination are either fully
  463. * transparent or fully opaque. The actual implementation works for
  464. * translucent layers too.
  465. * For a more detailed explanation of the effects of each operator, including
  466. * the mathematical definitions, see
  467. * <ulink url="http://cairographics.org/operators/">http://cairographics.org/operators/</ulink>.
  468. **/
  469. typedef enum _cairo_operator {
  470. CAIRO_OPERATOR_CLEAR,
  471. CAIRO_OPERATOR_SOURCE,
  472. CAIRO_OPERATOR_OVER,
  473. CAIRO_OPERATOR_IN,
  474. CAIRO_OPERATOR_OUT,
  475. CAIRO_OPERATOR_ATOP,
  476. CAIRO_OPERATOR_DEST,
  477. CAIRO_OPERATOR_DEST_OVER,
  478. CAIRO_OPERATOR_DEST_IN,
  479. CAIRO_OPERATOR_DEST_OUT,
  480. CAIRO_OPERATOR_DEST_ATOP,
  481. CAIRO_OPERATOR_XOR,
  482. CAIRO_OPERATOR_ADD,
  483. CAIRO_OPERATOR_SATURATE,
  484. CAIRO_OPERATOR_MULTIPLY,
  485. CAIRO_OPERATOR_SCREEN,
  486. CAIRO_OPERATOR_OVERLAY,
  487. CAIRO_OPERATOR_DARKEN,
  488. CAIRO_OPERATOR_LIGHTEN,
  489. CAIRO_OPERATOR_COLOR_DODGE,
  490. CAIRO_OPERATOR_COLOR_BURN,
  491. CAIRO_OPERATOR_HARD_LIGHT,
  492. CAIRO_OPERATOR_SOFT_LIGHT,
  493. CAIRO_OPERATOR_DIFFERENCE,
  494. CAIRO_OPERATOR_EXCLUSION,
  495. CAIRO_OPERATOR_HSL_HUE,
  496. CAIRO_OPERATOR_HSL_SATURATION,
  497. CAIRO_OPERATOR_HSL_COLOR,
  498. CAIRO_OPERATOR_HSL_LUMINOSITY
  499. } cairo_operator_t;
  500. cairo_public void
  501. cairo_set_operator (cairo_t *cr, cairo_operator_t op);
  502. cairo_public void
  503. cairo_set_source (cairo_t *cr, cairo_pattern_t *source);
  504. cairo_public void
  505. cairo_set_source_rgb (cairo_t *cr, double red, double green, double blue);
  506. cairo_public void
  507. cairo_set_source_rgba (cairo_t *cr,
  508. double red, double green, double blue,
  509. double alpha);
  510. cairo_public void
  511. cairo_set_source_surface (cairo_t *cr,
  512. cairo_surface_t *surface,
  513. double x,
  514. double y);
  515. cairo_public void
  516. cairo_set_tolerance (cairo_t *cr, double tolerance);
  517. /**
  518. * cairo_antialias_t:
  519. * @CAIRO_ANTIALIAS_DEFAULT: Use the default antialiasing for
  520. * the subsystem and target device
  521. * @CAIRO_ANTIALIAS_NONE: Use a bilevel alpha mask
  522. * @CAIRO_ANTIALIAS_GRAY: Perform single-color antialiasing (using
  523. * shades of gray for black text on a white background, for example).
  524. * @CAIRO_ANTIALIAS_SUBPIXEL: Perform antialiasing by taking
  525. * advantage of the order of subpixel elements on devices
  526. * such as LCD panels
  527. *
  528. * Specifies the type of antialiasing to do when rendering text or shapes.
  529. **/
  530. typedef enum _cairo_antialias {
  531. CAIRO_ANTIALIAS_DEFAULT,
  532. CAIRO_ANTIALIAS_NONE,
  533. CAIRO_ANTIALIAS_GRAY,
  534. CAIRO_ANTIALIAS_SUBPIXEL
  535. } cairo_antialias_t;
  536. cairo_public void
  537. cairo_set_antialias (cairo_t *cr, cairo_antialias_t antialias);
  538. /**
  539. * cairo_fill_rule_t:
  540. * @CAIRO_FILL_RULE_WINDING: If the path crosses the ray from
  541. * left-to-right, counts +1. If the path crosses the ray
  542. * from right to left, counts -1. (Left and right are determined
  543. * from the perspective of looking along the ray from the starting
  544. * point.) If the total count is non-zero, the point will be filled.
  545. * @CAIRO_FILL_RULE_EVEN_ODD: Counts the total number of
  546. * intersections, without regard to the orientation of the contour. If
  547. * the total number of intersections is odd, the point will be
  548. * filled.
  549. *
  550. * #cairo_fill_rule_t is used to select how paths are filled. For both
  551. * fill rules, whether or not a point is included in the fill is
  552. * determined by taking a ray from that point to infinity and looking
  553. * at intersections with the path. The ray can be in any direction,
  554. * as long as it doesn't pass through the end point of a segment
  555. * or have a tricky intersection such as intersecting tangent to the path.
  556. * (Note that filling is not actually implemented in this way. This
  557. * is just a description of the rule that is applied.)
  558. *
  559. * The default fill rule is %CAIRO_FILL_RULE_WINDING.
  560. *
  561. * New entries may be added in future versions.
  562. **/
  563. typedef enum _cairo_fill_rule {
  564. CAIRO_FILL_RULE_WINDING,
  565. CAIRO_FILL_RULE_EVEN_ODD
  566. } cairo_fill_rule_t;
  567. cairo_public void
  568. cairo_set_fill_rule (cairo_t *cr, cairo_fill_rule_t fill_rule);
  569. cairo_public void
  570. cairo_set_line_width (cairo_t *cr, double width);
  571. /**
  572. * cairo_line_cap_t:
  573. * @CAIRO_LINE_CAP_BUTT: start(stop) the line exactly at the start(end) point
  574. * @CAIRO_LINE_CAP_ROUND: use a round ending, the center of the circle is the end point
  575. * @CAIRO_LINE_CAP_SQUARE: use squared ending, the center of the square is the end point
  576. *
  577. * Specifies how to render the endpoints of the path when stroking.
  578. *
  579. * The default line cap style is %CAIRO_LINE_CAP_BUTT.
  580. **/
  581. typedef enum _cairo_line_cap {
  582. CAIRO_LINE_CAP_BUTT,
  583. CAIRO_LINE_CAP_ROUND,
  584. CAIRO_LINE_CAP_SQUARE
  585. } cairo_line_cap_t;
  586. cairo_public void
  587. cairo_set_line_cap (cairo_t *cr, cairo_line_cap_t line_cap);
  588. /**
  589. * cairo_line_join_t:
  590. * @CAIRO_LINE_JOIN_MITER: use a sharp (angled) corner, see
  591. * cairo_set_miter_limit()
  592. * @CAIRO_LINE_JOIN_ROUND: use a rounded join, the center of the circle is the
  593. * joint point
  594. * @CAIRO_LINE_JOIN_BEVEL: use a cut-off join, the join is cut off at half
  595. * the line width from the joint point
  596. *
  597. * Specifies how to render the junction of two lines when stroking.
  598. *
  599. * The default line join style is %CAIRO_LINE_JOIN_MITER.
  600. **/
  601. typedef enum _cairo_line_join {
  602. CAIRO_LINE_JOIN_MITER,
  603. CAIRO_LINE_JOIN_ROUND,
  604. CAIRO_LINE_JOIN_BEVEL
  605. } cairo_line_join_t;
  606. cairo_public void
  607. cairo_set_line_join (cairo_t *cr, cairo_line_join_t line_join);
  608. cairo_public void
  609. cairo_set_dash (cairo_t *cr,
  610. const double *dashes,
  611. int num_dashes,
  612. double offset);
  613. cairo_public void
  614. cairo_set_miter_limit (cairo_t *cr, double limit);
  615. cairo_public void
  616. cairo_translate (cairo_t *cr, double tx, double ty);
  617. cairo_public void
  618. cairo_scale (cairo_t *cr, double sx, double sy);
  619. cairo_public void
  620. cairo_rotate (cairo_t *cr, double angle);
  621. cairo_public void
  622. cairo_transform (cairo_t *cr,
  623. const cairo_matrix_t *matrix);
  624. cairo_public void
  625. cairo_set_matrix (cairo_t *cr,
  626. const cairo_matrix_t *matrix);
  627. cairo_public void
  628. cairo_identity_matrix (cairo_t *cr);
  629. cairo_public void
  630. cairo_user_to_device (cairo_t *cr, double *x, double *y);
  631. cairo_public void
  632. cairo_user_to_device_distance (cairo_t *cr, double *dx, double *dy);
  633. cairo_public void
  634. cairo_device_to_user (cairo_t *cr, double *x, double *y);
  635. cairo_public void
  636. cairo_device_to_user_distance (cairo_t *cr, double *dx, double *dy);
  637. /* Path creation functions */
  638. cairo_public void
  639. cairo_new_path (cairo_t *cr);
  640. cairo_public void
  641. cairo_move_to (cairo_t *cr, double x, double y);
  642. cairo_public void
  643. cairo_new_sub_path (cairo_t *cr);
  644. cairo_public void
  645. cairo_line_to (cairo_t *cr, double x, double y);
  646. cairo_public void
  647. cairo_curve_to (cairo_t *cr,
  648. double x1, double y1,
  649. double x2, double y2,
  650. double x3, double y3);
  651. cairo_public void
  652. cairo_arc (cairo_t *cr,
  653. double xc, double yc,
  654. double radius,
  655. double angle1, double angle2);
  656. cairo_public void
  657. cairo_arc_negative (cairo_t *cr,
  658. double xc, double yc,
  659. double radius,
  660. double angle1, double angle2);
  661. /* XXX: NYI
  662. cairo_public void
  663. cairo_arc_to (cairo_t *cr,
  664. double x1, double y1,
  665. double x2, double y2,
  666. double radius);
  667. */
  668. cairo_public void
  669. cairo_rel_move_to (cairo_t *cr, double dx, double dy);
  670. cairo_public void
  671. cairo_rel_line_to (cairo_t *cr, double dx, double dy);
  672. cairo_public void
  673. cairo_rel_curve_to (cairo_t *cr,
  674. double dx1, double dy1,
  675. double dx2, double dy2,
  676. double dx3, double dy3);
  677. cairo_public void
  678. cairo_rectangle (cairo_t *cr,
  679. double x, double y,
  680. double width, double height);
  681. /* XXX: NYI
  682. cairo_public void
  683. cairo_stroke_to_path (cairo_t *cr);
  684. */
  685. cairo_public void
  686. cairo_close_path (cairo_t *cr);
  687. cairo_public void
  688. cairo_path_extents (cairo_t *cr,
  689. double *x1, double *y1,
  690. double *x2, double *y2);
  691. /* Painting functions */
  692. cairo_public void
  693. cairo_paint (cairo_t *cr);
  694. cairo_public void
  695. cairo_paint_with_alpha (cairo_t *cr,
  696. double alpha);
  697. cairo_public void
  698. cairo_mask (cairo_t *cr,
  699. cairo_pattern_t *pattern);
  700. cairo_public void
  701. cairo_mask_surface (cairo_t *cr,
  702. cairo_surface_t *surface,
  703. double surface_x,
  704. double surface_y);
  705. cairo_public void
  706. cairo_stroke (cairo_t *cr);
  707. cairo_public void
  708. cairo_stroke_preserve (cairo_t *cr);
  709. cairo_public void
  710. cairo_fill (cairo_t *cr);
  711. cairo_public void
  712. cairo_fill_preserve (cairo_t *cr);
  713. cairo_public void
  714. cairo_copy_page (cairo_t *cr);
  715. cairo_public void
  716. cairo_show_page (cairo_t *cr);
  717. /* Insideness testing */
  718. cairo_public cairo_bool_t
  719. cairo_in_stroke (cairo_t *cr, double x, double y);
  720. cairo_public cairo_bool_t
  721. cairo_in_fill (cairo_t *cr, double x, double y);
  722. cairo_public cairo_bool_t
  723. cairo_in_clip (cairo_t *cr, double x, double y);
  724. /* Rectangular extents */
  725. cairo_public void
  726. cairo_stroke_extents (cairo_t *cr,
  727. double *x1, double *y1,
  728. double *x2, double *y2);
  729. cairo_public void
  730. cairo_fill_extents (cairo_t *cr,
  731. double *x1, double *y1,
  732. double *x2, double *y2);
  733. /* Clipping */
  734. cairo_public void
  735. cairo_reset_clip (cairo_t *cr);
  736. cairo_public void
  737. cairo_clip (cairo_t *cr);
  738. cairo_public void
  739. cairo_clip_preserve (cairo_t *cr);
  740. cairo_public void
  741. cairo_clip_extents (cairo_t *cr,
  742. double *x1, double *y1,
  743. double *x2, double *y2);
  744. /**
  745. * cairo_rectangle_t:
  746. * @x: X coordinate of the left side of the rectangle
  747. * @y: Y coordinate of the the top side of the rectangle
  748. * @width: width of the rectangle
  749. * @height: height of the rectangle
  750. *
  751. * A data structure for holding a rectangle.
  752. *
  753. * Since: 1.4
  754. **/
  755. typedef struct _cairo_rectangle {
  756. double x, y, width, height;
  757. } cairo_rectangle_t;
  758. /**
  759. * cairo_rectangle_list_t:
  760. * @status: Error status of the rectangle list
  761. * @rectangles: Array containing the rectangles
  762. * @num_rectangles: Number of rectangles in this list
  763. *
  764. * A data structure for holding a dynamically allocated
  765. * array of rectangles.
  766. *
  767. * Since: 1.4
  768. **/
  769. typedef struct _cairo_rectangle_list {
  770. cairo_status_t status;
  771. cairo_rectangle_t *rectangles;
  772. int num_rectangles;
  773. } cairo_rectangle_list_t;
  774. cairo_public cairo_rectangle_list_t *
  775. cairo_copy_clip_rectangle_list (cairo_t *cr);
  776. cairo_public void
  777. cairo_rectangle_list_destroy (cairo_rectangle_list_t *rectangle_list);
  778. /* Font/Text functions */
  779. /**
  780. * cairo_scaled_font_t:
  781. *
  782. * A #cairo_scaled_font_t is a font scaled to a particular size and device
  783. * resolution. A #cairo_scaled_font_t is most useful for low-level font
  784. * usage where a library or application wants to cache a reference
  785. * to a scaled font to speed up the computation of metrics.
  786. *
  787. * There are various types of scaled fonts, depending on the
  788. * <firstterm>font backend</firstterm> they use. The type of a
  789. * scaled font can be queried using cairo_scaled_font_get_type().
  790. *
  791. * Memory management of #cairo_scaled_font_t is done with
  792. * cairo_scaled_font_reference() and cairo_scaled_font_destroy().
  793. **/
  794. typedef struct _cairo_scaled_font cairo_scaled_font_t;
  795. /**
  796. * cairo_font_face_t:
  797. *
  798. * A #cairo_font_face_t specifies all aspects of a font other
  799. * than the size or font matrix (a font matrix is used to distort
  800. * a font by sheering it or scaling it unequally in the two
  801. * directions) . A font face can be set on a #cairo_t by using
  802. * cairo_set_font_face(); the size and font matrix are set with
  803. * cairo_set_font_size() and cairo_set_font_matrix().
  804. *
  805. * There are various types of font faces, depending on the
  806. * <firstterm>font backend</firstterm> they use. The type of a
  807. * font face can be queried using cairo_font_face_get_type().
  808. *
  809. * Memory management of #cairo_font_face_t is done with
  810. * cairo_font_face_reference() and cairo_font_face_destroy().
  811. **/
  812. typedef struct _cairo_font_face cairo_font_face_t;
  813. /**
  814. * cairo_glyph_t:
  815. * @index: glyph index in the font. The exact interpretation of the
  816. * glyph index depends on the font technology being used.
  817. * @x: the offset in the X direction between the origin used for
  818. * drawing or measuring the string and the origin of this glyph.
  819. * @y: the offset in the Y direction between the origin used for
  820. * drawing or measuring the string and the origin of this glyph.
  821. *
  822. * The #cairo_glyph_t structure holds information about a single glyph
  823. * when drawing or measuring text. A font is (in simple terms) a
  824. * collection of shapes used to draw text. A glyph is one of these
  825. * shapes. There can be multiple glyphs for a single character
  826. * (alternates to be used in different contexts, for example), or a
  827. * glyph can be a <firstterm>ligature</firstterm> of multiple
  828. * characters. Cairo doesn't expose any way of converting input text
  829. * into glyphs, so in order to use the Cairo interfaces that take
  830. * arrays of glyphs, you must directly access the appropriate
  831. * underlying font system.
  832. *
  833. * Note that the offsets given by @x and @y are not cumulative. When
  834. * drawing or measuring text, each glyph is individually positioned
  835. * with respect to the overall origin
  836. **/
  837. typedef struct {
  838. unsigned long index;
  839. double x;
  840. double y;
  841. } cairo_glyph_t;
  842. cairo_public cairo_glyph_t *
  843. cairo_glyph_allocate (int num_glyphs);
  844. cairo_public void
  845. cairo_glyph_free (cairo_glyph_t *glyphs);
  846. /**
  847. * cairo_text_cluster_t:
  848. * @num_bytes: the number of bytes of UTF-8 text covered by cluster
  849. * @num_glyphs: the number of glyphs covered by cluster
  850. *
  851. * The #cairo_text_cluster_t structure holds information about a single
  852. * <firstterm>text cluster</firstterm>. A text cluster is a minimal
  853. * mapping of some glyphs corresponding to some UTF-8 text.
  854. *
  855. * For a cluster to be valid, both @num_bytes and @num_glyphs should
  856. * be non-negative, and at least one should be non-zero.
  857. * Note that clusters with zero glyphs are not as well supported as
  858. * normal clusters. For example, PDF rendering applications typically
  859. * ignore those clusters when PDF text is being selected.
  860. *
  861. * See cairo_show_text_glyphs() for how clusters are used in advanced
  862. * text operations.
  863. *
  864. * Since: 1.8
  865. **/
  866. typedef struct {
  867. int num_bytes;
  868. int num_glyphs;
  869. } cairo_text_cluster_t;
  870. cairo_public cairo_text_cluster_t *
  871. cairo_text_cluster_allocate (int num_clusters);
  872. cairo_public void
  873. cairo_text_cluster_free (cairo_text_cluster_t *clusters);
  874. /**
  875. * cairo_text_cluster_flags_t:
  876. * @CAIRO_TEXT_CLUSTER_FLAG_BACKWARD: The clusters in the cluster array
  877. * map to glyphs in the glyph array from end to start.
  878. *
  879. * Specifies properties of a text cluster mapping.
  880. *
  881. * Since: 1.8
  882. **/
  883. typedef enum _cairo_text_cluster_flags {
  884. CAIRO_TEXT_CLUSTER_FLAG_BACKWARD = 0x00000001
  885. } cairo_text_cluster_flags_t;
  886. /**
  887. * cairo_text_extents_t:
  888. * @x_bearing: the horizontal distance from the origin to the
  889. * leftmost part of the glyphs as drawn. Positive if the
  890. * glyphs lie entirely to the right of the origin.
  891. * @y_bearing: the vertical distance from the origin to the
  892. * topmost part of the glyphs as drawn. Positive only if the
  893. * glyphs lie completely below the origin; will usually be
  894. * negative.
  895. * @width: width of the glyphs as drawn
  896. * @height: height of the glyphs as drawn
  897. * @x_advance:distance to advance in the X direction
  898. * after drawing these glyphs
  899. * @y_advance: distance to advance in the Y direction
  900. * after drawing these glyphs. Will typically be zero except
  901. * for vertical text layout as found in East-Asian languages.
  902. *
  903. * The #cairo_text_extents_t structure stores the extents of a single
  904. * glyph or a string of glyphs in user-space coordinates. Because text
  905. * extents are in user-space coordinates, they are mostly, but not
  906. * entirely, independent of the current transformation matrix. If you call
  907. * <literal>cairo_scale(cr, 2.0, 2.0)</literal>, text will
  908. * be drawn twice as big, but the reported text extents will not be
  909. * doubled. They will change slightly due to hinting (so you can't
  910. * assume that metrics are independent of the transformation matrix),
  911. * but otherwise will remain unchanged.
  912. **/
  913. typedef struct {
  914. double x_bearing;
  915. double y_bearing;
  916. double width;
  917. double height;
  918. double x_advance;
  919. double y_advance;
  920. } cairo_text_extents_t;
  921. /**
  922. * cairo_font_extents_t:
  923. * @ascent: the distance that the font extends above the baseline.
  924. * Note that this is not always exactly equal to the maximum
  925. * of the extents of all the glyphs in the font, but rather
  926. * is picked to express the font designer's intent as to
  927. * how the font should align with elements above it.
  928. * @descent: the distance that the font extends below the baseline.
  929. * This value is positive for typical fonts that include
  930. * portions below the baseline. Note that this is not always
  931. * exactly equal to the maximum of the extents of all the
  932. * glyphs in the font, but rather is picked to express the
  933. * font designer's intent as to how the the font should
  934. * align with elements below it.
  935. * @height: the recommended vertical distance between baselines when
  936. * setting consecutive lines of text with the font. This
  937. * is greater than @ascent+@descent by a
  938. * quantity known as the <firstterm>line spacing</firstterm>
  939. * or <firstterm>external leading</firstterm>. When space
  940. * is at a premium, most fonts can be set with only
  941. * a distance of @ascent+@descent between lines.
  942. * @max_x_advance: the maximum distance in the X direction that
  943. * the the origin is advanced for any glyph in the font.
  944. * @max_y_advance: the maximum distance in the Y direction that
  945. * the the origin is advanced for any glyph in the font.
  946. * this will be zero for normal fonts used for horizontal
  947. * writing. (The scripts of East Asia are sometimes written
  948. * vertically.)
  949. *
  950. * The #cairo_font_extents_t structure stores metric information for
  951. * a font. Values are given in the current user-space coordinate
  952. * system.
  953. *
  954. * Because font metrics are in user-space coordinates, they are
  955. * mostly, but not entirely, independent of the current transformation
  956. * matrix. If you call <literal>cairo_scale(cr, 2.0, 2.0)</literal>,
  957. * text will be drawn twice as big, but the reported text extents will
  958. * not be doubled. They will change slightly due to hinting (so you
  959. * can't assume that metrics are independent of the transformation
  960. * matrix), but otherwise will remain unchanged.
  961. **/
  962. typedef struct {
  963. double ascent;
  964. double descent;
  965. double height;
  966. double max_x_advance;
  967. double max_y_advance;
  968. } cairo_font_extents_t;
  969. /**
  970. * cairo_font_slant_t:
  971. * @CAIRO_FONT_SLANT_NORMAL: Upright font style
  972. * @CAIRO_FONT_SLANT_ITALIC: Italic font style
  973. * @CAIRO_FONT_SLANT_OBLIQUE: Oblique font style
  974. *
  975. * Specifies variants of a font face based on their slant.
  976. **/
  977. typedef enum _cairo_font_slant {
  978. CAIRO_FONT_SLANT_NORMAL,
  979. CAIRO_FONT_SLANT_ITALIC,
  980. CAIRO_FONT_SLANT_OBLIQUE
  981. } cairo_font_slant_t;
  982. /**
  983. * cairo_font_weight_t:
  984. * @CAIRO_FONT_WEIGHT_NORMAL: Normal font weight
  985. * @CAIRO_FONT_WEIGHT_BOLD: Bold font weight
  986. *
  987. * Specifies variants of a font face based on their weight.
  988. **/
  989. typedef enum _cairo_font_weight {
  990. CAIRO_FONT_WEIGHT_NORMAL,
  991. CAIRO_FONT_WEIGHT_BOLD
  992. } cairo_font_weight_t;
  993. /**
  994. * cairo_subpixel_order_t:
  995. * @CAIRO_SUBPIXEL_ORDER_DEFAULT: Use the default subpixel order for
  996. * for the target device
  997. * @CAIRO_SUBPIXEL_ORDER_RGB: Subpixel elements are arranged horizontally
  998. * with red at the left
  999. * @CAIRO_SUBPIXEL_ORDER_BGR: Subpixel elements are arranged horizontally
  1000. * with blue at the left
  1001. * @CAIRO_SUBPIXEL_ORDER_VRGB: Subpixel elements are arranged vertically
  1002. * with red at the top
  1003. * @CAIRO_SUBPIXEL_ORDER_VBGR: Subpixel elements are arranged vertically
  1004. * with blue at the top
  1005. *
  1006. * The subpixel order specifies the order of color elements within
  1007. * each pixel on the display device when rendering with an
  1008. * antialiasing mode of %CAIRO_ANTIALIAS_SUBPIXEL.
  1009. **/
  1010. typedef enum _cairo_subpixel_order {
  1011. CAIRO_SUBPIXEL_ORDER_DEFAULT,
  1012. CAIRO_SUBPIXEL_ORDER_RGB,
  1013. CAIRO_SUBPIXEL_ORDER_BGR,
  1014. CAIRO_SUBPIXEL_ORDER_VRGB,
  1015. CAIRO_SUBPIXEL_ORDER_VBGR
  1016. } cairo_subpixel_order_t;
  1017. /**
  1018. * cairo_hint_style_t:
  1019. * @CAIRO_HINT_STYLE_DEFAULT: Use the default hint style for
  1020. * font backend and target device
  1021. * @CAIRO_HINT_STYLE_NONE: Do not hint outlines
  1022. * @CAIRO_HINT_STYLE_SLIGHT: Hint outlines slightly to improve
  1023. * contrast while retaining good fidelity to the original
  1024. * shapes.
  1025. * @CAIRO_HINT_STYLE_MEDIUM: Hint outlines with medium strength
  1026. * giving a compromise between fidelity to the original shapes
  1027. * and contrast
  1028. * @CAIRO_HINT_STYLE_FULL: Hint outlines to maximize contrast
  1029. *
  1030. * Specifies the type of hinting to do on font outlines. Hinting
  1031. * is the process of fitting outlines to the pixel grid in order
  1032. * to improve the appearance of the result. Since hinting outlines
  1033. * involves distorting them, it also reduces the faithfulness
  1034. * to the original outline shapes. Not all of the outline hinting
  1035. * styles are supported by all font backends.
  1036. *
  1037. * New entries may be added in future versions.
  1038. **/
  1039. typedef enum _cairo_hint_style {
  1040. CAIRO_HINT_STYLE_DEFAULT,
  1041. CAIRO_HINT_STYLE_NONE,
  1042. CAIRO_HINT_STYLE_SLIGHT,
  1043. CAIRO_HINT_STYLE_MEDIUM,
  1044. CAIRO_HINT_STYLE_FULL
  1045. } cairo_hint_style_t;
  1046. /**
  1047. * cairo_hint_metrics_t:
  1048. * @CAIRO_HINT_METRICS_DEFAULT: Hint metrics in the default
  1049. * manner for the font backend and target device
  1050. * @CAIRO_HINT_METRICS_OFF: Do not hint font metrics
  1051. * @CAIRO_HINT_METRICS_ON: Hint font metrics
  1052. *
  1053. * Specifies whether to hint font metrics; hinting font metrics
  1054. * means quantizing them so that they are integer values in
  1055. * device space. Doing this improves the consistency of
  1056. * letter and line spacing, however it also means that text
  1057. * will be laid out differently at different zoom factors.
  1058. **/
  1059. typedef enum _cairo_hint_metrics {
  1060. CAIRO_HINT_METRICS_DEFAULT,
  1061. CAIRO_HINT_METRICS_OFF,
  1062. CAIRO_HINT_METRICS_ON
  1063. } cairo_hint_metrics_t;
  1064. /**
  1065. * cairo_font_options_t:
  1066. *
  1067. * An opaque structure holding all options that are used when
  1068. * rendering fonts.
  1069. *
  1070. * Individual features of a #cairo_font_options_t can be set or
  1071. * accessed using functions named
  1072. * cairo_font_options_set_<emphasis>feature_name</emphasis> and
  1073. * cairo_font_options_get_<emphasis>feature_name</emphasis>, like
  1074. * cairo_font_options_set_antialias() and
  1075. * cairo_font_options_get_antialias().
  1076. *
  1077. * New features may be added to a #cairo_font_options_t in the
  1078. * future. For this reason, cairo_font_options_copy(),
  1079. * cairo_font_options_equal(), cairo_font_options_merge(), and
  1080. * cairo_font_options_hash() should be used to copy, check
  1081. * for equality, merge, or compute a hash value of
  1082. * #cairo_font_options_t objects.
  1083. **/
  1084. typedef struct _cairo_font_options cairo_font_options_t;
  1085. cairo_public cairo_font_options_t *
  1086. cairo_font_options_create (void);
  1087. cairo_public cairo_font_options_t *
  1088. cairo_font_options_copy (const cairo_font_options_t *original);
  1089. cairo_public void
  1090. cairo_font_options_destroy (cairo_font_options_t *options);
  1091. cairo_public cairo_status_t
  1092. cairo_font_options_status (cairo_font_options_t *options);
  1093. cairo_public void
  1094. cairo_font_options_merge (cairo_font_options_t *options,
  1095. const cairo_font_options_t *other);
  1096. cairo_public cairo_bool_t
  1097. cairo_font_options_equal (const cairo_font_options_t *options,
  1098. const cairo_font_options_t *other);
  1099. cairo_public unsigned long
  1100. cairo_font_options_hash (const cairo_font_options_t *options);
  1101. cairo_public void
  1102. cairo_font_options_set_antialias (cairo_font_options_t *options,
  1103. cairo_antialias_t antialias);
  1104. cairo_public cairo_antialias_t
  1105. cairo_font_options_get_antialias (const cairo_font_options_t *options);
  1106. cairo_public void
  1107. cairo_font_options_set_subpixel_order (cairo_font_options_t *options,
  1108. cairo_subpixel_order_t subpixel_order);
  1109. cairo_public cairo_subpixel_order_t
  1110. cairo_font_options_get_subpixel_order (const cairo_font_options_t *options);
  1111. cairo_public void
  1112. cairo_font_options_set_hint_style (cairo_font_options_t *options,
  1113. cairo_hint_style_t hint_style);
  1114. cairo_public cairo_hint_style_t
  1115. cairo_font_options_get_hint_style (const cairo_font_options_t *options);
  1116. cairo_public void
  1117. cairo_font_options_set_hint_metrics (cairo_font_options_t *options,
  1118. cairo_hint_metrics_t hint_metrics);
  1119. cairo_public cairo_hint_metrics_t
  1120. cairo_font_options_get_hint_metrics (const cairo_font_options_t *options);
  1121. /* This interface is for dealing with text as text, not caring about the
  1122. font object inside the the cairo_t. */
  1123. cairo_public void
  1124. cairo_select_font_face (cairo_t *cr,
  1125. const char *family,
  1126. cairo_font_slant_t slant,
  1127. cairo_font_weight_t weight);
  1128. cairo_public void
  1129. cairo_set_font_size (cairo_t *cr, double size);
  1130. cairo_public void
  1131. cairo_set_font_matrix (cairo_t *cr,
  1132. const cairo_matrix_t *matrix);
  1133. cairo_public void
  1134. cairo_get_font_matrix (cairo_t *cr,
  1135. cairo_matrix_t *matrix);
  1136. cairo_public void
  1137. cairo_set_font_options (cairo_t *cr,
  1138. const cairo_font_options_t *options);
  1139. cairo_public void
  1140. cairo_get_font_options (cairo_t *cr,
  1141. cairo_font_options_t *options);
  1142. cairo_public void
  1143. cairo_set_font_face (cairo_t *cr, cairo_font_face_t *font_face);
  1144. cairo_public cairo_font_face_t *
  1145. cairo_get_font_face (cairo_t *cr);
  1146. cairo_public void
  1147. cairo_set_scaled_font (cairo_t *cr,
  1148. const cairo_scaled_font_t *scaled_font);
  1149. cairo_public cairo_scaled_font_t *
  1150. cairo_get_scaled_font (cairo_t *cr);
  1151. cairo_public void
  1152. cairo_show_text (cairo_t *cr, const char *utf8);
  1153. cairo_public void
  1154. cairo_show_glyphs (cairo_t *cr, const cairo_glyph_t *glyphs, int num_glyphs);
  1155. cairo_public void
  1156. cairo_show_text_glyphs (cairo_t *cr,
  1157. const char *utf8,
  1158. int utf8_len,
  1159. const cairo_glyph_t *glyphs,
  1160. int num_glyphs,
  1161. const cairo_text_cluster_t *clusters,
  1162. int num_clusters,
  1163. cairo_text_cluster_flags_t cluster_flags);
  1164. cairo_public void
  1165. cairo_text_path (cairo_t *cr, const char *utf8);
  1166. cairo_public void
  1167. cairo_glyph_path (cairo_t *cr, const cairo_glyph_t *glyphs, int num_glyphs);
  1168. cairo_public void
  1169. cairo_text_extents (cairo_t *cr,
  1170. const char *utf8,
  1171. cairo_text_extents_t *extents);
  1172. cairo_public void
  1173. cairo_glyph_extents (cairo_t *cr,
  1174. const cairo_glyph_t *glyphs,
  1175. int num_glyphs,
  1176. cairo_text_extents_t *extents);
  1177. cairo_public void
  1178. cairo_font_extents (cairo_t *cr,
  1179. cairo_font_extents_t *extents);
  1180. /* Generic identifier for a font style */
  1181. cairo_public cairo_font_face_t *
  1182. cairo_font_face_reference (cairo_font_face_t *font_face);
  1183. cairo_public void
  1184. cairo_font_face_destroy (cairo_font_face_t *font_face);
  1185. cairo_public unsigned int
  1186. cairo_font_face_get_reference_count (cairo_font_face_t *font_face);
  1187. cairo_public cairo_status_t
  1188. cairo_font_face_status (cairo_font_face_t *font_face);
  1189. /**
  1190. * cairo_font_type_t:
  1191. * @CAIRO_FONT_TYPE_TOY: The font was created using cairo's toy font api
  1192. * @CAIRO_FONT_TYPE_FT: The font is of type FreeType
  1193. * @CAIRO_FONT_TYPE_WIN32: The font is of type Win32
  1194. * @CAIRO_FONT_TYPE_QUARTZ: The font is of type Quartz (Since: 1.6)
  1195. * @CAIRO_FONT_TYPE_USER: The font was create using cairo's user font api (Since: 1.8)
  1196. *
  1197. * #cairo_font_type_t is used to describe the type of a given font
  1198. * face or scaled font. The font types are also known as "font
  1199. * backends" within cairo.
  1200. *
  1201. * The type of a font face is determined by the function used to
  1202. * create it, which will generally be of the form
  1203. * cairo_<emphasis>type</emphasis>_font_face_create(). The font face type can be queried
  1204. * with cairo_font_face_get_type()
  1205. *
  1206. * The various #cairo_font_face_t functions can be used with a font face
  1207. * of any type.
  1208. *
  1209. * The type of a scaled font is determined by the type of the font
  1210. * face passed to cairo_scaled_font_create(). The scaled font type can
  1211. * be queried with cairo_scaled_font_get_type()
  1212. *
  1213. * The various #cairo_scaled_font_t functions can be used with scaled
  1214. * fonts of any type, but some font backends also provide
  1215. * type-specific functions that must only be called with a scaled font
  1216. * of the appropriate type. These functions have names that begin with
  1217. * cairo_<emphasis>type</emphasis>_scaled_font() such as cairo_ft_scaled_font_lock_face().
  1218. *
  1219. * The behavior of calling a type-specific function with a scaled font
  1220. * of the wrong type is undefined.
  1221. *
  1222. * New entries may be added in future versions.
  1223. *
  1224. * Since: 1.2
  1225. **/
  1226. typedef enum _cairo_font_type {
  1227. CAIRO_FONT_TYPE_TOY,
  1228. CAIRO_FONT_TYPE_FT,
  1229. CAIRO_FONT_TYPE_WIN32,
  1230. CAIRO_FONT_TYPE_QUARTZ,
  1231. CAIRO_FONT_TYPE_USER
  1232. } cairo_font_type_t;
  1233. cairo_public cairo_font_type_t
  1234. cairo_font_face_get_type (cairo_font_face_t *font_face);
  1235. cairo_public void *
  1236. cairo_font_face_get_user_data (cairo_font_face_t *font_face,
  1237. const cairo_user_data_key_t *key);
  1238. cairo_public cairo_status_t
  1239. cairo_font_face_set_user_data (cairo_font_face_t *font_face,
  1240. const cairo_user_data_key_t *key,
  1241. void *user_data,
  1242. cairo_destroy_func_t destroy);
  1243. /* Portable interface to general font features. */
  1244. cairo_public cairo_scaled_font_t *
  1245. cairo_scaled_font_create (cairo_font_face_t *font_face,
  1246. const cairo_matrix_t *font_matrix,
  1247. const cairo_matrix_t *ctm,
  1248. const cairo_font_options_t *options);
  1249. cairo_public cairo_scaled_font_t *
  1250. cairo_scaled_font_reference (cairo_scaled_font_t *scaled_font);
  1251. cairo_public void
  1252. cairo_scaled_font_destroy (cairo_scaled_font_t *scaled_font);
  1253. cairo_public unsigned int
  1254. cairo_scaled_font_get_reference_count (cairo_scaled_font_t *scaled_font);
  1255. cairo_public cairo_status_t
  1256. cairo_scaled_font_status (cairo_scaled_font_t *scaled_font);
  1257. cairo_public cairo_font_type_t
  1258. cairo_scaled_font_get_type (cairo_scaled_font_t *scaled_font);
  1259. cairo_public void *
  1260. cairo_scaled_font_get_user_data (cairo_scaled_font_t *scaled_font,
  1261. const cairo_user_data_key_t *key);
  1262. cairo_public cairo_status_t
  1263. cairo_scaled_font_set_user_data (cairo_scaled_font_t *scaled_font,
  1264. const cairo_user_data_key_t *key,
  1265. void *user_data,
  1266. cairo_destroy_func_t destroy);
  1267. cairo_public void
  1268. cairo_scaled_font_extents (cairo_scaled_font_t *scaled_font,
  1269. cairo_font_extents_t *extents);
  1270. cairo_public void
  1271. cairo_scaled_font_text_extents (cairo_scaled_font_t *scaled_font,
  1272. const char *utf8,
  1273. cairo_text_extents_t *extents);
  1274. cairo_public void
  1275. cairo_scaled_font_glyph_extents (cairo_scaled_font_t *scaled_font,
  1276. const cairo_glyph_t *glyphs,
  1277. int num_glyphs,
  1278. cairo_text_extents_t *extents);
  1279. cairo_public cairo_status_t
  1280. cairo_scaled_font_text_to_glyphs (cairo_scaled_font_t *scaled_font,
  1281. double x,
  1282. double y,
  1283. const char *utf8,
  1284. int utf8_len,
  1285. cairo_glyph_t **glyphs,
  1286. int *num_glyphs,
  1287. cairo_text_cluster_t **clusters,
  1288. int *num_clusters,
  1289. cairo_text_cluster_flags_t *cluster_flags);
  1290. cairo_public cairo_font_face_t *
  1291. cairo_scaled_font_get_font_face (cairo_scaled_font_t *scaled_font);
  1292. cairo_public void
  1293. cairo_scaled_font_get_font_matrix (cairo_scaled_font_t *scaled_font,
  1294. cairo_matrix_t *font_matrix);
  1295. cairo_public void
  1296. cairo_scaled_font_get_ctm (cairo_scaled_font_t *scaled_font,
  1297. cairo_matrix_t *ctm);
  1298. cairo_public void
  1299. cairo_scaled_font_get_scale_matrix (cairo_scaled_font_t *scaled_font,
  1300. cairo_matrix_t *scale_matrix);
  1301. cairo_public void
  1302. cairo_scaled_font_get_font_options (cairo_scaled_font_t *scaled_font,
  1303. cairo_font_options_t *options);
  1304. /* Toy fonts */
  1305. cairo_public cairo_font_face_t *
  1306. cairo_toy_font_face_create (const char *family,
  1307. cairo_font_slant_t slant,
  1308. cairo_font_weight_t weight);
  1309. cairo_public const char *
  1310. cairo_toy_font_face_get_family (cairo_font_face_t *font_face);
  1311. cairo_public cairo_font_slant_t
  1312. cairo_toy_font_face_get_slant (cairo_font_face_t *font_face);
  1313. cairo_public cairo_font_weight_t
  1314. cairo_toy_font_face_get_weight (cairo_font_face_t *font_face);
  1315. /* User fonts */
  1316. cairo_public cairo_font_face_t *
  1317. cairo_user_font_face_create (void);
  1318. /* User-font method signatures */
  1319. /**
  1320. * cairo_user_scaled_font_init_func_t:
  1321. * @scaled_font: the scaled-font being created
  1322. * @cr: a cairo context, in font space
  1323. * @extents: font extents to fill in, in font space
  1324. *
  1325. * #cairo_user_scaled_font_init_func_t is the type of function which is
  1326. * called when a scaled-font needs to be created for a user font-face.
  1327. *
  1328. * The cairo context @cr is not used by the caller, but is prepared in font
  1329. * space, similar to what the cairo contexts passed to the render_glyph
  1330. * method will look like. The callback can use this context for extents
  1331. * computation for example. After the callback is called, @cr is checked
  1332. * for any error status.
  1333. *
  1334. * The @extents argument is where the user font sets the font extents for
  1335. * @scaled_font. It is in font space, which means that for most cases its
  1336. * ascent and descent members should add to 1.0. @extents is preset to
  1337. * hold a value of 1.0 for ascent, height, and max_x_advance, and 0.0 for
  1338. * descent and max_y_advance members.
  1339. *
  1340. * The callback is optional. If not set, default font extents as described
  1341. * in the previous paragraph will be used.
  1342. *
  1343. * Note that @scaled_font is not fully initialized at this
  1344. * point and trying to use it for text operations in the callback will result
  1345. * in deadlock.
  1346. *
  1347. * Returns: %CAIRO_STATUS_SUCCESS upon success, or an error status on error.
  1348. *
  1349. * Since: 1.8
  1350. **/
  1351. typedef cairo_status_t (*cairo_user_scaled_font_init_func_t) (cairo_scaled_font_t *scaled_font,
  1352. cairo_t *cr,
  1353. cairo_font_extents_t *extents);
  1354. /**
  1355. * cairo_user_scaled_font_render_glyph_func_t:
  1356. * @scaled_font: user scaled-font
  1357. * @glyph: glyph code to render
  1358. * @cr: cairo context to draw to, in font space
  1359. * @extents: glyph extents to fill in, in font space
  1360. *
  1361. * #cairo_user_scaled_font_render_glyph_func_t is the type of function which
  1362. * is called when a user scaled-font needs to render a glyph.
  1363. *
  1364. * The callback is mandatory, and expected to draw the glyph with code @glyph to
  1365. * the cairo context @cr. @cr is prepared such that the glyph drawing is done in
  1366. * font space. That is, the matrix set on @cr is the scale matrix of @scaled_font,
  1367. * The @extents argument is where the user font sets the font extents for
  1368. * @scaled_font. However, if user prefers to draw in user space, they can
  1369. * achieve that by changing the matrix on @cr. All cairo rendering operations
  1370. * to @cr are permitted, however, the result is undefined if any source other
  1371. * than the default source on @cr is used. That means, glyph bitmaps should
  1372. * be rendered using cairo_mask() instead of cairo_paint().
  1373. *
  1374. * Other non-default settings on @cr include a font size of 1.0 (given that
  1375. * it is set up to be in font space), and font options corresponding to
  1376. * @scaled_font.
  1377. *
  1378. * The @extents argument is preset to have <literal>x_bearing</literal>,
  1379. * <literal>width</literal>, and <literal>y_advance</literal> of zero,
  1380. * <literal>y_bearing</literal> set to <literal>-font_extents.ascent</literal>,
  1381. * <literal>height</literal> to <literal>font_extents.ascent+font_extents.descent</literal>,
  1382. * and <literal>x_advance</literal> to <literal>font_extents.max_x_advance</literal>.
  1383. * The only field user needs to set in majority of cases is
  1384. * <literal>x_advance</literal>.
  1385. * If the <literal>width</literal> field is zero upon the callback returning
  1386. * (which is its preset value), the glyph extents are automatically computed
  1387. * based on the drawings done to @cr. This is in most cases exactly what the
  1388. * desired behavior is. However, if for any reason the callback sets the
  1389. * extents, it must be ink extents, and include the extents of all drawing
  1390. * done to @cr in the callback.
  1391. *
  1392. * Returns: %CAIRO_STATUS_SUCCESS upon success, or
  1393. * %CAIRO_STATUS_USER_FONT_ERROR or any other error status on error.
  1394. *
  1395. * Since: 1.8
  1396. **/
  1397. typedef cairo_status_t (*cairo_user_scaled_font_render_glyph_func_t) (cairo_scaled_font_t *scaled_font,
  1398. unsigned long glyph,
  1399. cairo_t *cr,
  1400. cairo_text_extents_t *extents);
  1401. /**
  1402. * cairo_user_scaled_font_text_to_glyphs_func_t:
  1403. * @scaled_font: the scaled-font being created
  1404. * @utf8: a string of text encoded in UTF-8
  1405. * @utf8_len: length of @utf8 in bytes
  1406. * @glyphs: pointer to array of glyphs to fill, in font space
  1407. * @num_glyphs: pointer to number of glyphs
  1408. * @clusters: pointer to array of cluster mapping information to fill, or %NULL
  1409. * @num_clusters: pointer to number of clusters
  1410. * @cluster_flags: pointer to location to store cluster flags corresponding to the
  1411. * output @clusters
  1412. *
  1413. * #cairo_user_scaled_font_text_to_glyphs_func_t is the type of function which
  1414. * is called to convert input text to an array of glyphs. This is used by the
  1415. * cairo_show_text() operation.
  1416. *
  1417. * Using this callback the user-font has full control on glyphs and their
  1418. * positions. That means, it allows for features like ligatures and kerning,
  1419. * as well as complex <firstterm>shaping</firstterm> required for scripts like
  1420. * Arabic and Indic.
  1421. *
  1422. * The @num_glyphs argument is preset to the number of glyph entries available
  1423. * in the @glyphs buffer. If the @glyphs buffer is %NULL, the value of
  1424. * @num_glyphs will be zero. If the provided glyph array is too short for
  1425. * the conversion (or for convenience), a new glyph array may be allocated
  1426. * using cairo_glyph_allocate() and placed in @glyphs. Upon return,
  1427. * @num_glyphs should contain the number of generated glyphs. If the value
  1428. * @glyphs points at has changed after the call, the caller will free the
  1429. * allocated glyph array using cairo_glyph_free().
  1430. * The callback should populate the glyph indices and positions (in font space)
  1431. * assuming that the text is to be shown at the origin.
  1432. *
  1433. * If @clusters is not %NULL, @num_clusters and @cluster_flags are also
  1434. * non-%NULL, and cluster mapping should be computed. The semantics of how
  1435. * cluster array allocation works is similar to the glyph array. That is,
  1436. * if @clusters initially points to a non-%NULL value, that array may be used
  1437. * as a cluster buffer, and @num_clusters points to the number of cluster
  1438. * entries available there. If the provided cluster array is too short for
  1439. * the conversion (or for convenience), a new cluster array may be allocated
  1440. * using cairo_text_cluster_allocate() and placed in @clusters. Upon return,
  1441. * @num_clusters should contain the number of generated clusters.
  1442. * If the value @clusters points at has changed after the call, the caller
  1443. * will free the allocated cluster array using cairo_text_cluster_free().
  1444. *
  1445. * The callback is optional. If @num_glyphs is negative upon
  1446. * the callback returning or if the return value
  1447. * is %CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED, the unicode_to_glyph callback
  1448. * is tried. See #cairo_user_scaled_font_unicode_to_glyph_func_t.
  1449. *
  1450. * Note: While cairo does not impose any limitation on glyph indices,
  1451. * some applications may assume that a glyph index fits in a 16-bit
  1452. * unsigned integer. As such, it is advised that user-fonts keep their
  1453. * glyphs in the 0 to 65535 range. Furthermore, some applications may
  1454. * assume that glyph 0 is a special glyph-not-found glyph. User-fonts
  1455. * are advised to use glyph 0 for such purposes and do not use that
  1456. * glyph value for other purposes.
  1457. *
  1458. * Returns: %CAIRO_STATUS_SUCCESS upon success,
  1459. * %CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED if fallback options should be tried,
  1460. * or %CAIRO_STATUS_USER_FONT_ERROR or any other error status on error.
  1461. *
  1462. * Since: 1.8
  1463. **/
  1464. typedef cairo_status_t (*cairo_user_scaled_font_text_to_glyphs_func_t) (cairo_scaled_font_t *scaled_font,
  1465. const char *utf8,
  1466. int utf8_len,
  1467. cairo_glyph_t **glyphs,
  1468. int *num_glyphs,
  1469. cairo_text_cluster_t **clusters,
  1470. int *num_clusters,
  1471. cairo_text_cluster_flags_t *cluster_flags);
  1472. /**
  1473. * cairo_user_scaled_font_unicode_to_glyph_func_t:
  1474. * @scaled_font: the scaled-font being created
  1475. * @unicode: input unicode character code-point
  1476. * @glyph_index: output glyph index
  1477. *
  1478. * #cairo_user_scaled_font_unicode_to_glyph_func_t is the type of function which
  1479. * is called to convert an input Unicode character to a single glyph.
  1480. * This is used by the cairo_show_text() operation.
  1481. *
  1482. * This callback is used to provide the same functionality as the
  1483. * text_to_glyphs callback does (see #cairo_user_scaled_font_text_to_glyphs_func_t)
  1484. * but has much less control on the output,
  1485. * in exchange for increased ease of use. The inherent assumption to using
  1486. * this callback is that each character maps to one glyph, and that the
  1487. * mapping is context independent. It also assumes that glyphs are positioned
  1488. * according to their advance width. These mean no ligatures, kerning, or
  1489. * complex scripts can be implemented using this callback.
  1490. *
  1491. * The callback is optional, and only used if text_to_glyphs callback is not
  1492. * set or fails to return glyphs. If this callback is not set or if it returns
  1493. * %CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED, an identity mapping from Unicode
  1494. * code-points to glyph indices is assumed.
  1495. *
  1496. * Note: While cairo does not impose any limitation on glyph indices,
  1497. * some applications may assume that a glyph index fits in a 16-bit
  1498. * unsigned integer. As such, it is advised that user-fonts keep their
  1499. * glyphs in the 0 to 65535 range. Furthermore, some applications may
  1500. * assume that glyph 0 is a special glyph-not-found glyph. User-fonts
  1501. * are advised to use glyph 0 for such purposes and do not use that
  1502. * glyph value for other purposes.
  1503. *
  1504. * Returns: %CAIRO_STATUS_SUCCESS upon success,
  1505. * %CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED if fallback options should be tried,
  1506. * or %CAIRO_STATUS_USER_FONT_ERROR or any other error status on error.
  1507. *
  1508. * Since: 1.8
  1509. **/
  1510. typedef cairo_status_t (*cairo_user_scaled_font_unicode_to_glyph_func_t) (cairo_scaled_font_t *scaled_font,
  1511. unsigned long unicode,
  1512. unsigned long *glyph_index);
  1513. /* User-font method setters */
  1514. cairo_public void
  1515. cairo_user_font_face_set_init_func (cairo_font_face_t *font_face,
  1516. cairo_user_scaled_font_init_func_t init_func);
  1517. cairo_public void
  1518. cairo_user_font_face_set_render_glyph_func (cairo_font_face_t *font_face,
  1519. cairo_user_scaled_font_render_glyph_func_t render_glyph_func);
  1520. cairo_public void
  1521. cairo_user_font_face_set_text_to_glyphs_func (cairo_font_face_t *font_face,
  1522. cairo_user_scaled_font_text_to_glyphs_func_t text_to_glyphs_func);
  1523. cairo_public void
  1524. cairo_user_font_face_set_unicode_to_glyph_func (cairo_font_face_t *font_face,
  1525. cairo_user_scaled_font_unicode_to_glyph_func_t unicode_to_glyph_func);
  1526. /* User-font method getters */
  1527. cairo_public cairo_user_scaled_font_init_func_t
  1528. cairo_user_font_face_get_init_func (cairo_font_face_t *font_face);
  1529. cairo_public cairo_user_scaled_font_render_glyph_func_t
  1530. cairo_user_font_face_get_render_glyph_func (cairo_font_face_t *font_face);
  1531. cairo_public cairo_user_scaled_font_text_to_glyphs_func_t
  1532. cairo_user_font_face_get_text_to_glyphs_func (cairo_font_face_t *font_face);
  1533. cairo_public cairo_user_scaled_font_unicode_to_glyph_func_t
  1534. cairo_user_font_face_get_unicode_to_glyph_func (cairo_font_face_t *font_face);
  1535. /* Query functions */
  1536. cairo_public cairo_operator_t
  1537. cairo_get_operator (cairo_t *cr);
  1538. cairo_public cairo_pattern_t *
  1539. cairo_get_source (cairo_t *cr);
  1540. cairo_public double
  1541. cairo_get_tolerance (cairo_t *cr);
  1542. cairo_public cairo_antialias_t
  1543. cairo_get_antialias (cairo_t *cr);
  1544. cairo_public cairo_bool_t
  1545. cairo_has_current_point (cairo_t *cr);
  1546. cairo_public void
  1547. cairo_get_current_point (cairo_t *cr, double *x, double *y);
  1548. cairo_public cairo_fill_rule_t
  1549. cairo_get_fill_rule (cairo_t *cr);
  1550. cairo_public double
  1551. cairo_get_line_width (cairo_t *cr);
  1552. cairo_public cairo_line_cap_t
  1553. cairo_get_line_cap (cairo_t *cr);
  1554. cairo_public cairo_line_join_t
  1555. cairo_get_line_join (cairo_t *cr);
  1556. cairo_public double
  1557. cairo_get_miter_limit (cairo_t *cr);
  1558. cairo_public int
  1559. cairo_get_dash_count (cairo_t *cr);
  1560. cairo_public void
  1561. cairo_get_dash (cairo_t *cr, double *dashes, double *offset);
  1562. cairo_public void
  1563. cairo_get_matrix (cairo_t *cr, cairo_matrix_t *matrix);
  1564. cairo_public cairo_surface_t *
  1565. cairo_get_target (cairo_t *cr);
  1566. cairo_public cairo_surface_t *
  1567. cairo_get_group_target (cairo_t *cr);
  1568. /**
  1569. * cairo_path_data_type_t:
  1570. * @CAIRO_PATH_MOVE_TO: A move-to operation
  1571. * @CAIRO_PATH_LINE_TO: A line-to operation
  1572. * @CAIRO_PATH_CURVE_TO: A curve-to operation
  1573. * @CAIRO_PATH_CLOSE_PATH: A close-path operation
  1574. *
  1575. * #cairo_path_data_t is used to describe the type of one portion
  1576. * of a path when represented as a #cairo_path_t.
  1577. * See #cairo_path_data_t for details.
  1578. **/
  1579. typedef enum _cairo_path_data_type {
  1580. CAIRO_PATH_MOVE_TO,
  1581. CAIRO_PATH_LINE_TO,
  1582. CAIRO_PATH_CURVE_TO,
  1583. CAIRO_PATH_CLOSE_PATH
  1584. } cairo_path_data_type_t;
  1585. /**
  1586. * cairo_path_data_t:
  1587. *
  1588. * #cairo_path_data_t is used to represent the path data inside a
  1589. * #cairo_path_t.
  1590. *
  1591. * The data structure is designed to try to balance the demands of
  1592. * efficiency and ease-of-use. A path is represented as an array of
  1593. * #cairo_path_data_t, which is a union of headers and points.
  1594. *
  1595. * Each portion of the path is represented by one or more elements in
  1596. * the array, (one header followed by 0 or more points). The length
  1597. * value of the header is the number of array elements for the current
  1598. * portion including the header, (ie. length == 1 + # of points), and
  1599. * where the number of points for each element type is as follows:
  1600. *
  1601. * <programlisting>
  1602. * %CAIRO_PATH_MOVE_TO: 1 point
  1603. * %CAIRO_PATH_LINE_TO: 1 point
  1604. * %CAIRO_PATH_CURVE_TO: 3 points
  1605. * %CAIRO_PATH_CLOSE_PATH: 0 points
  1606. * </programlisting>
  1607. *
  1608. * The semantics and ordering of the coordinate values are consistent
  1609. * with cairo_move_to(), cairo_line_to(), cairo_curve_to(), and
  1610. * cairo_close_path().
  1611. *
  1612. * Here is sample code for iterating through a #cairo_path_t:
  1613. *
  1614. * <informalexample><programlisting>
  1615. * int i;
  1616. * cairo_path_t *path;
  1617. * cairo_path_data_t *data;
  1618. * &nbsp;
  1619. * path = cairo_copy_path (cr);
  1620. * &nbsp;
  1621. * for (i=0; i < path->num_data; i += path->data[i].header.length) {
  1622. * data = &amp;path->data[i];
  1623. * switch (data->header.type) {
  1624. * case CAIRO_PATH_MOVE_TO:
  1625. * do_move_to_things (data[1].point.x, data[1].point.y);
  1626. * break;
  1627. * case CAIRO_PATH_LINE_TO:
  1628. * do_line_to_things (data[1].point.x, data[1].point.y);
  1629. * break;
  1630. * case CAIRO_PATH_CURVE_TO:
  1631. * do_curve_to_things (data[1].point.x, data[1].point.y,
  1632. * data[2].point.x, data[2].point.y,
  1633. * data[3].point.x, data[3].point.y);
  1634. * break;
  1635. * case CAIRO_PATH_CLOSE_PATH:
  1636. * do_close_path_things ();
  1637. * break;
  1638. * }
  1639. * }
  1640. * cairo_path_destroy (path);
  1641. * </programlisting></informalexample>
  1642. *
  1643. * As of cairo 1.4, cairo does not mind if there are more elements in
  1644. * a portion of the path than needed. Such elements can be used by
  1645. * users of the cairo API to hold extra values in the path data
  1646. * structure. For this reason, it is recommended that applications
  1647. * always use <literal>data->header.length</literal> to
  1648. * iterate over the path data, instead of hardcoding the number of
  1649. * elements for each element type.
  1650. **/
  1651. typedef union _cairo_path_data_t cairo_path_data_t;
  1652. union _cairo_path_data_t {
  1653. struct {
  1654. cairo_path_data_type_t type;
  1655. int length;
  1656. } header;
  1657. struct {
  1658. double x, y;
  1659. } point;
  1660. };
  1661. /**
  1662. * cairo_path_t:
  1663. * @status: the current error status
  1664. * @data: the elements in the path
  1665. * @num_data: the number of elements in the data array
  1666. *
  1667. * A data structure for holding a path. This data structure serves as
  1668. * the return value for cairo_copy_path() and
  1669. * cairo_copy_path_flat() as well the input value for
  1670. * cairo_append_path().
  1671. *
  1672. * See #cairo_path_data_t for hints on how to iterate over the
  1673. * actual data within the path.
  1674. *
  1675. * The num_data member gives the number of elements in the data
  1676. * array. This number is larger than the number of independent path
  1677. * portions (defined in #cairo_path_data_type_t), since the data
  1678. * includes both headers and coordinates for each portion.
  1679. **/
  1680. typedef struct cairo_path {
  1681. cairo_status_t status;
  1682. cairo_path_data_t *data;
  1683. int num_data;
  1684. } cairo_path_t;
  1685. cairo_public cairo_path_t *
  1686. cairo_copy_path (cairo_t *cr);
  1687. cairo_public cairo_path_t *
  1688. cairo_copy_path_flat (cairo_t *cr);
  1689. cairo_public void
  1690. cairo_append_path (cairo_t *cr,
  1691. const cairo_path_t *path);
  1692. cairo_public void
  1693. cairo_path_destroy (cairo_path_t *path);
  1694. /* Error status queries */
  1695. cairo_public cairo_status_t
  1696. cairo_status (cairo_t *cr);
  1697. cairo_public const char *
  1698. cairo_status_to_string (cairo_status_t status);
  1699. /* Backend device manipulation */
  1700. cairo_public cairo_device_t *
  1701. cairo_device_reference (cairo_device_t *device);
  1702. /**
  1703. * cairo_device_type_t:
  1704. * @CAIRO_DEVICE_TYPE_DRM: The surface is of type Direct Render Manager
  1705. * @CAIRO_DEVICE_TYPE_GL: The surface is of type OpenGL
  1706. * @CAIRO_DEVICE_TYPE_SCRIPT: The surface is of type script
  1707. * @CAIRO_DEVICE_TYPE_XCB: The surface is of type xcb
  1708. * @CAIRO_DEVICE_TYPE_XLIB: The surface is of type xlib
  1709. * @CAIRO_DEVICE_TYPE_XML: The surface is of type XML
  1710. * cairo_surface_create_for_rectangle()
  1711. *
  1712. * #cairo_device_type_t is used to describe the type of a given
  1713. * device. The devices types are also known as "backends" within cairo.
  1714. *
  1715. * The device type can be queried with cairo_device_get_type()
  1716. *
  1717. * The various #cairo_device_t functions can be used with surfaces of
  1718. * any type, but some backends also provide type-specific functions
  1719. * that must only be called with a device of the appropriate
  1720. * type. These functions have names that begin with
  1721. * cairo_<emphasis>type</emphasis>_device<!-- --> such as cairo_xcb_device_debug_set_render_version().
  1722. *
  1723. * The behavior of calling a type-specific function with a surface of
  1724. * the wrong type is undefined.
  1725. *
  1726. * New entries may be added in future versions.
  1727. *
  1728. * Since: 1.10
  1729. **/
  1730. typedef enum _cairo_device_type {
  1731. CAIRO_DEVICE_TYPE_DRM,
  1732. CAIRO_DEVICE_TYPE_GL,
  1733. CAIRO_DEVICE_TYPE_SCRIPT,
  1734. CAIRO_DEVICE_TYPE_XCB,
  1735. CAIRO_DEVICE_TYPE_XLIB,
  1736. CAIRO_DEVICE_TYPE_XML
  1737. } cairo_device_type_t;
  1738. cairo_public cairo_device_type_t
  1739. cairo_device_get_type (cairo_device_t *device);
  1740. cairo_public cairo_status_t
  1741. cairo_device_status (cairo_device_t *device);
  1742. cairo_public cairo_status_t
  1743. cairo_device_acquire (cairo_device_t *device);
  1744. cairo_public void
  1745. cairo_device_release (cairo_device_t *device);
  1746. cairo_public void
  1747. cairo_device_flush (cairo_device_t *device);
  1748. cairo_public void
  1749. cairo_device_finish (cairo_device_t *device);
  1750. cairo_public void
  1751. cairo_device_destroy (cairo_device_t *device);
  1752. cairo_public unsigned int
  1753. cairo_device_get_reference_count (cairo_device_t *device);
  1754. cairo_public void *
  1755. cairo_device_get_user_data (cairo_device_t *device,
  1756. const cairo_user_data_key_t *key);
  1757. cairo_public cairo_status_t
  1758. cairo_device_set_user_data (cairo_device_t *device,
  1759. const cairo_user_data_key_t *key,
  1760. void *user_data,
  1761. cairo_destroy_func_t destroy);
  1762. /* Surface manipulation */
  1763. cairo_public cairo_surface_t *
  1764. cairo_surface_create_similar (cairo_surface_t *other,
  1765. cairo_content_t content,
  1766. int width,
  1767. int height);
  1768. cairo_public cairo_surface_t *
  1769. cairo_surface_create_for_rectangle (cairo_surface_t *target,
  1770. double x,
  1771. double y,
  1772. double width,
  1773. double height);
  1774. cairo_public cairo_surface_t *
  1775. cairo_surface_reference (cairo_surface_t *surface);
  1776. cairo_public void
  1777. cairo_surface_finish (cairo_surface_t *surface);
  1778. cairo_public void
  1779. cairo_surface_destroy (cairo_surface_t *surface);
  1780. cairo_public cairo_device_t *
  1781. cairo_surface_get_device (cairo_surface_t *surface);
  1782. cairo_public unsigned int
  1783. cairo_surface_get_reference_count (cairo_surface_t *surface);
  1784. cairo_public cairo_status_t
  1785. cairo_surface_status (cairo_surface_t *surface);
  1786. /**
  1787. * cairo_surface_type_t:
  1788. * @CAIRO_SURFACE_TYPE_IMAGE: The surface is of type image
  1789. * @CAIRO_SURFACE_TYPE_PDF: The surface is of type pdf
  1790. * @CAIRO_SURFACE_TYPE_PS: The surface is of type ps
  1791. * @CAIRO_SURFACE_TYPE_XLIB: The surface is of type xlib
  1792. * @CAIRO_SURFACE_TYPE_XCB: The surface is of type xcb
  1793. * @CAIRO_SURFACE_TYPE_GLITZ: The surface is of type glitz
  1794. * @CAIRO_SURFACE_TYPE_QUARTZ: The surface is of type quartz
  1795. * @CAIRO_SURFACE_TYPE_WIN32: The surface is of type win32
  1796. * @CAIRO_SURFACE_TYPE_BEOS: The surface is of type beos
  1797. * @CAIRO_SURFACE_TYPE_DIRECTFB: The surface is of type directfb
  1798. * @CAIRO_SURFACE_TYPE_SVG: The surface is of type svg
  1799. * @CAIRO_SURFACE_TYPE_OS2: The surface is of type os2
  1800. * @CAIRO_SURFACE_TYPE_WIN32_PRINTING: The surface is a win32 printing surface
  1801. * @CAIRO_SURFACE_TYPE_QUARTZ_IMAGE: The surface is of type quartz_image
  1802. * @CAIRO_SURFACE_TYPE_SCRIPT: The surface is of type script, since 1.10
  1803. * @CAIRO_SURFACE_TYPE_QT: The surface is of type Qt, since 1.10
  1804. * @CAIRO_SURFACE_TYPE_RECORDING: The surface is of type recording, since 1.10
  1805. * @CAIRO_SURFACE_TYPE_VG: The surface is a OpenVG surface, since 1.10
  1806. * @CAIRO_SURFACE_TYPE_GL: The surface is of type OpenGL, since 1.10
  1807. * @CAIRO_SURFACE_TYPE_DRM: The surface is of type Direct Render Manager, since 1.10
  1808. * @CAIRO_SURFACE_TYPE_TEE: The surface is of type 'tee' (a multiplexing surface), since 1.10
  1809. * @CAIRO_SURFACE_TYPE_XML: The surface is of type XML (for debugging), since 1.10
  1810. * @CAIRO_SURFACE_TYPE_SKIA: The surface is of type Skia, since 1.10
  1811. * @CAIRO_SURFACE_TYPE_SUBSURFACE: The surface is a subsurface created with
  1812. * cairo_surface_create_for_rectangle(), since 1.10
  1813. *
  1814. * #cairo_surface_type_t is used to describe the type of a given
  1815. * surface. The surface types are also known as "backends" or "surface
  1816. * backends" within cairo.
  1817. *
  1818. * The type of a surface is determined by the function used to create
  1819. * it, which will generally be of the form cairo_<emphasis>type</emphasis>_surface_create(),
  1820. * (though see cairo_surface_create_similar() as well).
  1821. *
  1822. * The surface type can be queried with cairo_surface_get_type()
  1823. *
  1824. * The various #cairo_surface_t functions can be used with surfaces of
  1825. * any type, but some backends also provide type-specific functions
  1826. * that must only be called with a surface of the appropriate
  1827. * type. These functions have names that begin with
  1828. * cairo_<emphasis>type</emphasis>_surface<!-- --> such as cairo_image_surface_get_width().
  1829. *
  1830. * The behavior of calling a type-specific function with a surface of
  1831. * the wrong type is undefined.
  1832. *
  1833. * New entries may be added in future versions.
  1834. *
  1835. * Since: 1.2
  1836. **/
  1837. typedef enum _cairo_surface_type {
  1838. CAIRO_SURFACE_TYPE_IMAGE,
  1839. CAIRO_SURFACE_TYPE_PDF,
  1840. CAIRO_SURFACE_TYPE_PS,
  1841. CAIRO_SURFACE_TYPE_XLIB,
  1842. CAIRO_SURFACE_TYPE_XCB,
  1843. CAIRO_SURFACE_TYPE_GLITZ,
  1844. CAIRO_SURFACE_TYPE_QUARTZ,
  1845. CAIRO_SURFACE_TYPE_WIN32,
  1846. CAIRO_SURFACE_TYPE_BEOS,
  1847. CAIRO_SURFACE_TYPE_DIRECTFB,
  1848. CAIRO_SURFACE_TYPE_SVG,
  1849. CAIRO_SURFACE_TYPE_OS2,
  1850. CAIRO_SURFACE_TYPE_WIN32_PRINTING,
  1851. CAIRO_SURFACE_TYPE_QUARTZ_IMAGE,
  1852. CAIRO_SURFACE_TYPE_SCRIPT,
  1853. CAIRO_SURFACE_TYPE_QT,
  1854. CAIRO_SURFACE_TYPE_RECORDING,
  1855. CAIRO_SURFACE_TYPE_VG,
  1856. CAIRO_SURFACE_TYPE_GL,
  1857. CAIRO_SURFACE_TYPE_DRM,
  1858. CAIRO_SURFACE_TYPE_TEE,
  1859. CAIRO_SURFACE_TYPE_XML,
  1860. CAIRO_SURFACE_TYPE_SKIA,
  1861. CAIRO_SURFACE_TYPE_SUBSURFACE
  1862. } cairo_surface_type_t;
  1863. cairo_public cairo_surface_type_t
  1864. cairo_surface_get_type (cairo_surface_t *surface);
  1865. cairo_public cairo_content_t
  1866. cairo_surface_get_content (cairo_surface_t *surface);
  1867. #if CAIRO_HAS_PNG_FUNCTIONS
  1868. cairo_public cairo_status_t
  1869. cairo_surface_write_to_png (cairo_surface_t *surface,
  1870. const char *filename);
  1871. cairo_public cairo_status_t
  1872. cairo_surface_write_to_png_stream (cairo_surface_t *surface,
  1873. cairo_write_func_t write_func,
  1874. void *closure);
  1875. #endif
  1876. cairo_public void *
  1877. cairo_surface_get_user_data (cairo_surface_t *surface,
  1878. const cairo_user_data_key_t *key);
  1879. cairo_public cairo_status_t
  1880. cairo_surface_set_user_data (cairo_surface_t *surface,
  1881. const cairo_user_data_key_t *key,
  1882. void *user_data,
  1883. cairo_destroy_func_t destroy);
  1884. #define CAIRO_MIME_TYPE_JPEG "image/jpeg"
  1885. #define CAIRO_MIME_TYPE_PNG "image/png"
  1886. #define CAIRO_MIME_TYPE_JP2 "image/jp2"
  1887. #define CAIRO_MIME_TYPE_URI "text/x-uri"
  1888. cairo_public void
  1889. cairo_surface_get_mime_data (cairo_surface_t *surface,
  1890. const char *mime_type,
  1891. const unsigned char **data,
  1892. unsigned long *length);
  1893. cairo_public cairo_status_t
  1894. cairo_surface_set_mime_data (cairo_surface_t *surface,
  1895. const char *mime_type,
  1896. const unsigned char *data,
  1897. unsigned long length,
  1898. cairo_destroy_func_t destroy,
  1899. void *closure);
  1900. cairo_public void
  1901. cairo_surface_get_font_options (cairo_surface_t *surface,
  1902. cairo_font_options_t *options);
  1903. cairo_public void
  1904. cairo_surface_flush (cairo_surface_t *surface);
  1905. cairo_public void
  1906. cairo_surface_mark_dirty (cairo_surface_t *surface);
  1907. cairo_public void
  1908. cairo_surface_mark_dirty_rectangle (cairo_surface_t *surface,
  1909. int x,
  1910. int y,
  1911. int width,
  1912. int height);
  1913. cairo_public void
  1914. cairo_surface_set_device_offset (cairo_surface_t *surface,
  1915. double x_offset,
  1916. double y_offset);
  1917. cairo_public void
  1918. cairo_surface_get_device_offset (cairo_surface_t *surface,
  1919. double *x_offset,
  1920. double *y_offset);
  1921. cairo_public void
  1922. cairo_surface_set_fallback_resolution (cairo_surface_t *surface,
  1923. double x_pixels_per_inch,
  1924. double y_pixels_per_inch);
  1925. cairo_public void
  1926. cairo_surface_get_fallback_resolution (cairo_surface_t *surface,
  1927. double *x_pixels_per_inch,
  1928. double *y_pixels_per_inch);
  1929. cairo_public void
  1930. cairo_surface_copy_page (cairo_surface_t *surface);
  1931. cairo_public void
  1932. cairo_surface_show_page (cairo_surface_t *surface);
  1933. cairo_public cairo_bool_t
  1934. cairo_surface_has_show_text_glyphs (cairo_surface_t *surface);
  1935. /* Image-surface functions */
  1936. /**
  1937. * cairo_format_t:
  1938. * @CAIRO_FORMAT_INVALID: no such format exists or is supported.
  1939. * @CAIRO_FORMAT_ARGB32: each pixel is a 32-bit quantity, with
  1940. * alpha in the upper 8 bits, then red, then green, then blue.
  1941. * The 32-bit quantities are stored native-endian. Pre-multiplied
  1942. * alpha is used. (That is, 50% transparent red is 0x80800000,
  1943. * not 0x80ff0000.)
  1944. * @CAIRO_FORMAT_RGB24: each pixel is a 32-bit quantity, with
  1945. * the upper 8 bits unused. Red, Green, and Blue are stored
  1946. * in the remaining 24 bits in that order.
  1947. * @CAIRO_FORMAT_A8: each pixel is a 8-bit quantity holding
  1948. * an alpha value.
  1949. * @CAIRO_FORMAT_A1: each pixel is a 1-bit quantity holding
  1950. * an alpha value. Pixels are packed together into 32-bit
  1951. * quantities. The ordering of the bits matches the
  1952. * endianess of the platform. On a big-endian machine, the
  1953. * first pixel is in the uppermost bit, on a little-endian
  1954. * machine the first pixel is in the least-significant bit.
  1955. * @CAIRO_FORMAT_RGB16_565: each pixel is a 16-bit quantity
  1956. * with red in the upper 5 bits, then green in the middle
  1957. * 6 bits, and blue in the lower 5 bits.
  1958. *
  1959. * #cairo_format_t is used to identify the memory format of
  1960. * image data.
  1961. *
  1962. * New entries may be added in future versions.
  1963. **/
  1964. typedef enum _cairo_format {
  1965. CAIRO_FORMAT_INVALID = -1,
  1966. CAIRO_FORMAT_ARGB32 = 0,
  1967. CAIRO_FORMAT_RGB24 = 1,
  1968. CAIRO_FORMAT_A8 = 2,
  1969. CAIRO_FORMAT_A1 = 3,
  1970. CAIRO_FORMAT_RGB16_565 = 4
  1971. } cairo_format_t;
  1972. cairo_public cairo_surface_t *
  1973. cairo_image_surface_create (cairo_format_t format,
  1974. int width,
  1975. int height);
  1976. cairo_public int
  1977. cairo_format_stride_for_width (cairo_format_t format,
  1978. int width);
  1979. cairo_public cairo_surface_t *
  1980. cairo_image_surface_create_for_data (unsigned char *data,
  1981. cairo_format_t format,
  1982. int width,
  1983. int height,
  1984. int stride);
  1985. cairo_public unsigned char *
  1986. cairo_image_surface_get_data (cairo_surface_t *surface);
  1987. cairo_public cairo_format_t
  1988. cairo_image_surface_get_format (cairo_surface_t *surface);
  1989. cairo_public int
  1990. cairo_image_surface_get_width (cairo_surface_t *surface);
  1991. cairo_public int
  1992. cairo_image_surface_get_height (cairo_surface_t *surface);
  1993. cairo_public int
  1994. cairo_image_surface_get_stride (cairo_surface_t *surface);
  1995. #if CAIRO_HAS_PNG_FUNCTIONS
  1996. cairo_public cairo_surface_t *
  1997. cairo_image_surface_create_from_png (const char *filename);
  1998. cairo_public cairo_surface_t *
  1999. cairo_image_surface_create_from_png_stream (cairo_read_func_t read_func,
  2000. void *closure);
  2001. #endif
  2002. /* Recording-surface functions */
  2003. cairo_public cairo_surface_t *
  2004. cairo_recording_surface_create (cairo_content_t content,
  2005. const cairo_rectangle_t *extents);
  2006. cairo_public void
  2007. cairo_recording_surface_ink_extents (cairo_surface_t *surface,
  2008. double *x0,
  2009. double *y0,
  2010. double *width,
  2011. double *height);
  2012. /* Pattern creation functions */
  2013. cairo_public cairo_pattern_t *
  2014. cairo_pattern_create_rgb (double red, double green, double blue);
  2015. cairo_public cairo_pattern_t *
  2016. cairo_pattern_create_rgba (double red, double green, double blue,
  2017. double alpha);
  2018. cairo_public cairo_pattern_t *
  2019. cairo_pattern_create_for_surface (cairo_surface_t *surface);
  2020. cairo_public cairo_pattern_t *
  2021. cairo_pattern_create_linear (double x0, double y0,
  2022. double x1, double y1);
  2023. cairo_public cairo_pattern_t *
  2024. cairo_pattern_create_radial (double cx0, double cy0, double radius0,
  2025. double cx1, double cy1, double radius1);
  2026. cairo_public cairo_pattern_t *
  2027. cairo_pattern_reference (cairo_pattern_t *pattern);
  2028. cairo_public void
  2029. cairo_pattern_destroy (cairo_pattern_t *pattern);
  2030. cairo_public unsigned int
  2031. cairo_pattern_get_reference_count (cairo_pattern_t *pattern);
  2032. cairo_public cairo_status_t
  2033. cairo_pattern_status (cairo_pattern_t *pattern);
  2034. cairo_public void *
  2035. cairo_pattern_get_user_data (cairo_pattern_t *pattern,
  2036. const cairo_user_data_key_t *key);
  2037. cairo_public cairo_status_t
  2038. cairo_pattern_set_user_data (cairo_pattern_t *pattern,
  2039. const cairo_user_data_key_t *key,
  2040. void *user_data,
  2041. cairo_destroy_func_t destroy);
  2042. /**
  2043. * cairo_pattern_type_t:
  2044. * @CAIRO_PATTERN_TYPE_SOLID: The pattern is a solid (uniform)
  2045. * color. It may be opaque or translucent.
  2046. * @CAIRO_PATTERN_TYPE_SURFACE: The pattern is a based on a surface (an image).
  2047. * @CAIRO_PATTERN_TYPE_LINEAR: The pattern is a linear gradient.
  2048. * @CAIRO_PATTERN_TYPE_RADIAL: The pattern is a radial gradient.
  2049. *
  2050. * #cairo_pattern_type_t is used to describe the type of a given pattern.
  2051. *
  2052. * The type of a pattern is determined by the function used to create
  2053. * it. The cairo_pattern_create_rgb() and cairo_pattern_create_rgba()
  2054. * functions create SOLID patterns. The remaining
  2055. * cairo_pattern_create<!-- --> functions map to pattern types in obvious
  2056. * ways.
  2057. *
  2058. * The pattern type can be queried with cairo_pattern_get_type()
  2059. *
  2060. * Most #cairo_pattern_t functions can be called with a pattern of any
  2061. * type, (though trying to change the extend or filter for a solid
  2062. * pattern will have no effect). A notable exception is
  2063. * cairo_pattern_add_color_stop_rgb() and
  2064. * cairo_pattern_add_color_stop_rgba() which must only be called with
  2065. * gradient patterns (either LINEAR or RADIAL). Otherwise the pattern
  2066. * will be shutdown and put into an error state.
  2067. *
  2068. * New entries may be added in future versions.
  2069. *
  2070. * Since: 1.2
  2071. **/
  2072. typedef enum _cairo_pattern_type {
  2073. CAIRO_PATTERN_TYPE_SOLID,
  2074. CAIRO_PATTERN_TYPE_SURFACE,
  2075. CAIRO_PATTERN_TYPE_LINEAR,
  2076. CAIRO_PATTERN_TYPE_RADIAL
  2077. } cairo_pattern_type_t;
  2078. cairo_public cairo_pattern_type_t
  2079. cairo_pattern_get_type (cairo_pattern_t *pattern);
  2080. cairo_public void
  2081. cairo_pattern_add_color_stop_rgb (cairo_pattern_t *pattern,
  2082. double offset,
  2083. double red, double green, double blue);
  2084. cairo_public void
  2085. cairo_pattern_add_color_stop_rgba (cairo_pattern_t *pattern,
  2086. double offset,
  2087. double red, double green, double blue,
  2088. double alpha);
  2089. cairo_public void
  2090. cairo_pattern_set_matrix (cairo_pattern_t *pattern,
  2091. const cairo_matrix_t *matrix);
  2092. cairo_public void
  2093. cairo_pattern_get_matrix (cairo_pattern_t *pattern,
  2094. cairo_matrix_t *matrix);
  2095. /**
  2096. * cairo_extend_t:
  2097. * @CAIRO_EXTEND_NONE: pixels outside of the source pattern
  2098. * are fully transparent
  2099. * @CAIRO_EXTEND_REPEAT: the pattern is tiled by repeating
  2100. * @CAIRO_EXTEND_REFLECT: the pattern is tiled by reflecting
  2101. * at the edges (Implemented for surface patterns since 1.6)
  2102. * @CAIRO_EXTEND_PAD: pixels outside of the pattern copy
  2103. * the closest pixel from the source (Since 1.2; but only
  2104. * implemented for surface patterns since 1.6)
  2105. *
  2106. * #cairo_extend_t is used to describe how pattern color/alpha will be
  2107. * determined for areas "outside" the pattern's natural area, (for
  2108. * example, outside the surface bounds or outside the gradient
  2109. * geometry).
  2110. *
  2111. * The default extend mode is %CAIRO_EXTEND_NONE for surface patterns
  2112. * and %CAIRO_EXTEND_PAD for gradient patterns.
  2113. *
  2114. * New entries may be added in future versions.
  2115. **/
  2116. typedef enum _cairo_extend {
  2117. CAIRO_EXTEND_NONE,
  2118. CAIRO_EXTEND_REPEAT,
  2119. CAIRO_EXTEND_REFLECT,
  2120. CAIRO_EXTEND_PAD
  2121. } cairo_extend_t;
  2122. cairo_public void
  2123. cairo_pattern_set_extend (cairo_pattern_t *pattern, cairo_extend_t extend);
  2124. cairo_public cairo_extend_t
  2125. cairo_pattern_get_extend (cairo_pattern_t *pattern);
  2126. /**
  2127. * cairo_filter_t:
  2128. * @CAIRO_FILTER_FAST: A high-performance filter, with quality similar
  2129. * to %CAIRO_FILTER_NEAREST
  2130. * @CAIRO_FILTER_GOOD: A reasonable-performance filter, with quality
  2131. * similar to %CAIRO_FILTER_BILINEAR
  2132. * @CAIRO_FILTER_BEST: The highest-quality available, performance may
  2133. * not be suitable for interactive use.
  2134. * @CAIRO_FILTER_NEAREST: Nearest-neighbor filtering
  2135. * @CAIRO_FILTER_BILINEAR: Linear interpolation in two dimensions
  2136. * @CAIRO_FILTER_GAUSSIAN: This filter value is currently
  2137. * unimplemented, and should not be used in current code.
  2138. *
  2139. * #cairo_filter_t is used to indicate what filtering should be
  2140. * applied when reading pixel values from patterns. See
  2141. * cairo_pattern_set_source() for indicating the desired filter to be
  2142. * used with a particular pattern.
  2143. */
  2144. typedef enum _cairo_filter {
  2145. CAIRO_FILTER_FAST,
  2146. CAIRO_FILTER_GOOD,
  2147. CAIRO_FILTER_BEST,
  2148. CAIRO_FILTER_NEAREST,
  2149. CAIRO_FILTER_BILINEAR,
  2150. CAIRO_FILTER_GAUSSIAN
  2151. } cairo_filter_t;
  2152. cairo_public void
  2153. cairo_pattern_set_filter (cairo_pattern_t *pattern, cairo_filter_t filter);
  2154. cairo_public cairo_filter_t
  2155. cairo_pattern_get_filter (cairo_pattern_t *pattern);
  2156. cairo_public cairo_status_t
  2157. cairo_pattern_get_rgba (cairo_pattern_t *pattern,
  2158. double *red, double *green,
  2159. double *blue, double *alpha);
  2160. cairo_public cairo_status_t
  2161. cairo_pattern_get_surface (cairo_pattern_t *pattern,
  2162. cairo_surface_t **surface);
  2163. cairo_public cairo_status_t
  2164. cairo_pattern_get_color_stop_rgba (cairo_pattern_t *pattern,
  2165. int index, double *offset,
  2166. double *red, double *green,
  2167. double *blue, double *alpha);
  2168. cairo_public cairo_status_t
  2169. cairo_pattern_get_color_stop_count (cairo_pattern_t *pattern,
  2170. int *count);
  2171. cairo_public cairo_status_t
  2172. cairo_pattern_get_linear_points (cairo_pattern_t *pattern,
  2173. double *x0, double *y0,
  2174. double *x1, double *y1);
  2175. cairo_public cairo_status_t
  2176. cairo_pattern_get_radial_circles (cairo_pattern_t *pattern,
  2177. double *x0, double *y0, double *r0,
  2178. double *x1, double *y1, double *r1);
  2179. /* Matrix functions */
  2180. cairo_public void
  2181. cairo_matrix_init (cairo_matrix_t *matrix,
  2182. double xx, double yx,
  2183. double xy, double yy,
  2184. double x0, double y0);
  2185. cairo_public void
  2186. cairo_matrix_init_identity (cairo_matrix_t *matrix);
  2187. cairo_public void
  2188. cairo_matrix_init_translate (cairo_matrix_t *matrix,
  2189. double tx, double ty);
  2190. cairo_public void
  2191. cairo_matrix_init_scale (cairo_matrix_t *matrix,
  2192. double sx, double sy);
  2193. cairo_public void
  2194. cairo_matrix_init_rotate (cairo_matrix_t *matrix,
  2195. double radians);
  2196. cairo_public void
  2197. cairo_matrix_translate (cairo_matrix_t *matrix, double tx, double ty);
  2198. cairo_public void
  2199. cairo_matrix_scale (cairo_matrix_t *matrix, double sx, double sy);
  2200. cairo_public void
  2201. cairo_matrix_rotate (cairo_matrix_t *matrix, double radians);
  2202. cairo_public cairo_status_t
  2203. cairo_matrix_invert (cairo_matrix_t *matrix);
  2204. cairo_public void
  2205. cairo_matrix_multiply (cairo_matrix_t *result,
  2206. const cairo_matrix_t *a,
  2207. const cairo_matrix_t *b);
  2208. cairo_public void
  2209. cairo_matrix_transform_distance (const cairo_matrix_t *matrix,
  2210. double *dx, double *dy);
  2211. cairo_public void
  2212. cairo_matrix_transform_point (const cairo_matrix_t *matrix,
  2213. double *x, double *y);
  2214. /* Region functions */
  2215. /**
  2216. * cairo_region_t:
  2217. *
  2218. * A #cairo_region_t represents a set of integer-aligned rectangles.
  2219. *
  2220. * It allows set-theoretical operations like cairo_region_union() and
  2221. * cairo_region_intersect() to be performed on them.
  2222. *
  2223. * Memory management of #cairo_region_t is done with
  2224. * cairo_region_reference() and cairo_region_destroy().
  2225. *
  2226. * Since: 1.10
  2227. **/
  2228. typedef struct _cairo_region cairo_region_t;
  2229. /**
  2230. * cairo_rectangle_int_t:
  2231. * @x: X coordinate of the left side of the rectangle
  2232. * @y: Y coordinate of the the top side of the rectangle
  2233. * @width: width of the rectangle
  2234. * @height: height of the rectangle
  2235. *
  2236. * A data structure for holding a rectangle with integer coordinates.
  2237. *
  2238. * Since: 1.10
  2239. **/
  2240. typedef struct _cairo_rectangle_int {
  2241. int x, y;
  2242. int width, height;
  2243. } cairo_rectangle_int_t;
  2244. typedef enum _cairo_region_overlap {
  2245. CAIRO_REGION_OVERLAP_IN, /* completely inside region */
  2246. CAIRO_REGION_OVERLAP_OUT, /* completely outside region */
  2247. CAIRO_REGION_OVERLAP_PART /* partly inside region */
  2248. } cairo_region_overlap_t;
  2249. cairo_public cairo_region_t *
  2250. cairo_region_create (void);
  2251. cairo_public cairo_region_t *
  2252. cairo_region_create_rectangle (const cairo_rectangle_int_t *rectangle);
  2253. cairo_public cairo_region_t *
  2254. cairo_region_create_rectangles (const cairo_rectangle_int_t *rects,
  2255. int count);
  2256. cairo_public cairo_region_t *
  2257. cairo_region_copy (const cairo_region_t *original);
  2258. cairo_public cairo_region_t *
  2259. cairo_region_reference (cairo_region_t *region);
  2260. cairo_public void
  2261. cairo_region_destroy (cairo_region_t *region);
  2262. cairo_public cairo_bool_t
  2263. cairo_region_equal (const cairo_region_t *a, const cairo_region_t *b);
  2264. cairo_public cairo_status_t
  2265. cairo_region_status (const cairo_region_t *region);
  2266. cairo_public void
  2267. cairo_region_get_extents (const cairo_region_t *region,
  2268. cairo_rectangle_int_t *extents);
  2269. cairo_public int
  2270. cairo_region_num_rectangles (const cairo_region_t *region);
  2271. cairo_public void
  2272. cairo_region_get_rectangle (const cairo_region_t *region,
  2273. int nth,
  2274. cairo_rectangle_int_t *rectangle);
  2275. cairo_public cairo_bool_t
  2276. cairo_region_is_empty (const cairo_region_t *region);
  2277. cairo_public cairo_region_overlap_t
  2278. cairo_region_contains_rectangle (const cairo_region_t *region,
  2279. const cairo_rectangle_int_t *rectangle);
  2280. cairo_public cairo_bool_t
  2281. cairo_region_contains_point (const cairo_region_t *region, int x, int y);
  2282. cairo_public void
  2283. cairo_region_translate (cairo_region_t *region, int dx, int dy);
  2284. cairo_public cairo_status_t
  2285. cairo_region_subtract (cairo_region_t *dst, const cairo_region_t *other);
  2286. cairo_public cairo_status_t
  2287. cairo_region_subtract_rectangle (cairo_region_t *dst,
  2288. const cairo_rectangle_int_t *rectangle);
  2289. cairo_public cairo_status_t
  2290. cairo_region_intersect (cairo_region_t *dst, const cairo_region_t *other);
  2291. cairo_public cairo_status_t
  2292. cairo_region_intersect_rectangle (cairo_region_t *dst,
  2293. const cairo_rectangle_int_t *rectangle);
  2294. cairo_public cairo_status_t
  2295. cairo_region_union (cairo_region_t *dst, const cairo_region_t *other);
  2296. cairo_public cairo_status_t
  2297. cairo_region_union_rectangle (cairo_region_t *dst,
  2298. const cairo_rectangle_int_t *rectangle);
  2299. cairo_public cairo_status_t
  2300. cairo_region_xor (cairo_region_t *dst, const cairo_region_t *other);
  2301. cairo_public cairo_status_t
  2302. cairo_region_xor_rectangle (cairo_region_t *dst,
  2303. const cairo_rectangle_int_t *rectangle);
  2304. /* Functions to be used while debugging (not intended for use in production code) */
  2305. cairo_public void
  2306. cairo_debug_reset_static_data (void);
  2307. CAIRO_END_DECLS
  2308. #endif /* CAIRO_H */