1------------------------------------------------------------------------------
2--                  GtkAda - Ada95 binding for Gtk+/Gnome                   --
3--                                                                          --
4--                     Copyright (C) 2010-2015, AdaCore                     --
5--                                                                          --
6-- This library is free software;  you can redistribute it and/or modify it --
7-- under terms of the  GNU General Public License  as published by the Free --
8-- Software  Foundation;  either version 3,  or (at your  option) any later --
9-- version. This library is distributed in the hope that it will be useful, --
10-- but WITHOUT ANY WARRANTY;  without even the implied warranty of MERCHAN- --
11-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE.                            --
12--                                                                          --
13-- As a special exception under Section 7 of GPL version 3, you are granted --
14-- additional permissions described in the GCC Runtime Library Exception,   --
15-- version 3.1, as published by the Free Software Foundation.               --
16--                                                                          --
17-- You should have received a copy of the GNU General Public License and    --
18-- a copy of the GCC Runtime Library Exception along with this program;     --
19-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
20-- <http://www.gnu.org/licenses/>.                                          --
21--                                                                          --
22------------------------------------------------------------------------------
23
24--  <description>
25--  Bindings to the Cairo 2D graphics library.
26--  The Cairo_Context is the main object used when drawing with cairo. To draw
27--  with Cairo, you create a Context, set the target surface, and drawing
28--  options for the Cairo_Context, create shapes with functions like Move_To
29--  and Line_To, and then draw shapes with Stroke or Fill.
30--
31--  All drawing in Cairo is done on a Cairo_Context.
32--
33--  Drawing on on-screen Gtk widgets should be done in a callback to the
34--  "expose" event:
35--
36--  When the widget has been created, connect a drawing function:
37--
38--  <code>
39--     declare
40--        Area : Gtk_Drawing_Area;
41--
42--        package Event_Cb is new Gtk.Handlers.Return_Callback
43--            (Gtk_Drawing_Area_Record, Boolean);
44--     begin
45--        Gtk_New (Area);
46--        Event_Cb.Connect (Area, "expose_event",
47--                          Event_Cb.To_Marshaller (Expose_Cb'Access));
48--     end;
49--  </code>
50--
51--  In the callback, first get the context of the drawable on which you
52--  need to draw, using Gdk.Cairo.Create. Then do the drawing operations, and
53--  release the memory allocated to Cr using Cairo.Destroy.
54--
55--  In addition to drawing on on-screen widgets, drawing can also be done using
56--  the same Cairo calls to pixbufs (see Gdk.Cairo) to memory
57--  (see Cairo.Image_Surface), and to PNG or PDF files (see Cairo.Png and
58--  Cairo.Pdf).
59--
60--  Code samples demonstrating how to use various functionalities of Cairo
61--  can be found in the testcairo example, shipped with GtkAda.
62--  </description>
63--
64--  <c_version>1.8.8</c_version>
65--  <group>Cairo</group>
66
67with Ada.Unchecked_Deallocation;
68
69with System;
70with Interfaces.C.Strings;
71
72with Glib; use Glib;
73with Glib.Values;
74
75package Cairo is
76
77   type Cairo_Context is private;
78   --  A Cairo_Context contains the current state of the rendering device,
79   --  including coordinates of yet to be drawn shapes.
80   --
81   --  Cairo contexts, as Cairo_Context objects are named, are central to
82   --  cairo and all drawing with cairo is always done to a Cairo_Context
83   --  object.
84   --
85   --  Memory management of Cairo_Context is done with subprograms
86   --  Reference and Destroy, see below.
87
88   function Get_Context
89      (Value : Glib.Values.GValue) return Cairo_Context;
90   --  Support for callbacks that receive a Cairo_Context as parameter.
91
92   type Cairo_Surface is private;
93   --  A Cairo_Surface represents an image, either as the destination
94   --  of a drawing operation or as source when drawing onto another
95   --  surface.  To draw to a Cairo_Surface, create a cairo context
96   --  with the surface as the target, using Create.
97   --
98   --  There are different subtypes of Cairo_Surface for
99   --  different drawing backends; for example, Cairo.Image_Surface.Create
100   --  creates a bitmap image in memory.
101   --  The type of a surface can be queried with Cairo.Surface.Get_Type.
102   --
103   --  Memory management of Cairo_Surface is done with
104   --  Cairo.Surface.Reference and Cairo.Surface.Destroy.
105
106   type Cairo_Matrix is record
107      Xx : aliased Gdouble;
108      Yx : aliased Gdouble;
109      Xy : aliased Gdouble;
110      Yy : aliased Gdouble;
111      X0 : aliased Gdouble;
112      Y0 : aliased Gdouble;
113   end record;
114   --  Xx: Xx component of the affine transformation
115   --  Yx: Yx component of the affine transformation
116   --  Xy: Xy component of the affine transformation
117   --  Yy: Yy component of the affine transformation
118   --  X0: X translation component of the affine transformation
119   --  Y0: Y translation component of the affine transformation
120   --
121   --  A Cairo_Matrix holds an affine transformation, such as a scale,
122   --  rotation, shear, or a combination of those. The transformation of
123   --  a point (X, Y) is given by:
124   --
125   --      X_New = Xx * X + Xy * Y + X0;
126   --      Y_New = Yx * X + Yy * Y + Y0;
127   pragma Convention (C_Pass_By_Copy, Cairo_Matrix);
128
129   type Cairo_Matrix_Access is access Cairo_Matrix;
130   procedure Unchecked_Free is new Ada.Unchecked_Deallocation
131     (Cairo_Matrix, Cairo_Matrix_Access);
132
133   type Cairo_Format is (
134      Format_Invalid,
135      Format_ARGB32,
136      Format_RGB24,
137      Format_A8,
138      Format_A1,
139      Format_RGB16_565,
140      Format_RGB30);
141   for Cairo_Format use (
142      Format_Invalid   => -1,
143      Format_ARGB32    => 0,
144      Format_RGB24     => 1,
145      Format_A8        => 2,
146      Format_A1        => 3,
147      Format_RGB16_565 => 4,
148      Format_RGB30     => 5);
149   --  Used to identify the memory format of image data
150   --
151   --  Format_ARGB32: each pixel is a 32-bit quantity, with
152   --    alpha in the upper 8 bits, then red, then green, then blue.
153   --    The 32-bit quantities are stored native-endian. Pre-multiplied
154   --    alpha is used. (That is, 50% transparent red is 0x80800000,
155   --    not 0x80ff0000.) (Since 1.0)
156   --  Format_RGB_24: each pixel is a 32-bit quantity, with
157   --    the upper 8 bits unused. Red, Green, and Blue are stored
158   --    in the remaining 24 bits in that order. (Since 1.0)
159   --  Format_A8: each pixel is a 8-bit quantity holding
160   --    an alpha value. (Since 1.0)
161   --  Format_A1: each pixel is a 1-bit quantity holding
162   --    an alpha value. Pixels are packed together into 32-bit
163   --    quantities. The ordering of the bits matches the
164   --    endianess of the platform. On a big-endian machine, the
165   --    first pixel is in the uppermost bit, on a little-endian
166   --    machine the first pixel is in the least-significant bit. (Since 1.0)
167   --  Format_RGB16_565: each pixel is a 16-bit quantity
168   --    with red in the upper 5 bits, then green in the middle
169   --    6 bits, and blue in the lower 5 bits. (Since 1.2)
170   --  Format_RGB30: like RGB24 but with 10bpc. (Since 1.12)
171
172   type Cairo_Pattern is private;
173   --  A Cairo_Pattern represents a source when drawing onto a
174   --  surface. There are different subtypes of Cairo_Pattern,
175   --  for different types of sources; for example,
176   --  Cairo.Pattern.Create_Rgb creates a pattern for a solid
177   --  opaque color.
178   --
179   --  Other than various Cairo.Pattern.Create_<type>
180   --  functions, some of the pattern types can be implicitly created
181   --  using various Set_Source_<type> functions; for example Set_Source_Rgb.
182   --
183   --  The type of a pattern can be queried with Cairo.Pattern.Get_Type.
184   --
185   --  Memory management of Cairo_Pattern is done with
186   --  Cairo.Pattern.Reference and Cairo.Pattern.Destroy.
187
188   type Cairo_Destroy_Func is access procedure (Arg1 : System.Address);
189   --  Data: The Data element being destroyed.
190   --
191   --  Cairo_destroy_func the type of function which is called when a
192   --  data element is destroyed. It is passed the pointer to the data
193   --  element and should free any memory and resources allocated for it.
194
195   type Cairo_User_Data_Key is record
196      Unused : aliased Gint;
197   end record;
198   --  Unused: not used; ignore.
199   --
200   --  Cairo_User_Data_Key is used for attaching user data to cairo
201   --  data structures.  The actual contents of the struct is never used,
202   --  and there is no need to initialize the object; only the unique
203   --  address of a Cairo_User_Data_Key object is used.  Typically, you
204   --  would just use the address of a static Cairo_User_Data_Key object.
205
206   pragma Convention (C_Pass_By_Copy, Cairo_User_Data_Key);
207
208   --  Cairo_Status is used to indicate errors that can occur when
209   --  using Cairo. In some cases it is returned directly by functions.
210   --  but when using Cairo_T, the last error, if any, is stored in
211   --  the context and can be retrieved with Cairo_Status.
212   --
213   --  New entries may be added in future versions.  Use
214   --  Cairo_Status_To_String
215   --  to get a human-readable representation of an error message.
216   type Cairo_Status is
217     (
218      Cairo_Status_Success,
219      --  no error has occurred
220
221      Cairo_Status_No_Memory,
222      --  out of memory
223
224      Cairo_Status_Invalid_Restore,
225      --  Cairo_Restore called without matching Cairo_Save
226
227      Cairo_Status_Invalid_Pop_Group,
228      --  no saved group to pop
229
230      Cairo_Status_No_Current_Point,
231      --  no current point defined
232
233      Cairo_Status_Invalid_Matrix,
234      --  invalid matrix (not invertible)
235
236      Cairo_Status_Invalid_Status,
237      --  invalid value for an input Cairo_status
238
239      Cairo_Status_Null_Pointer,
240      --  NULL pointer
241
242      Cairo_Status_Invalid_String,
243      --  input string not valid UTF-8
244
245      Cairo_Status_Invalid_Path_Data,
246      --  input path data not valid
247
248      Cairo_Status_Read_Error,
249      --  error while reading from input stream
250
251      Cairo_Status_Write_Error,
252      --  error while writing to output stream
253
254      Cairo_Status_Surface_Finished,
255      --  target surface has been finished
256
257      Cairo_Status_Surface_Type_Mismatch,
258      --  the surface type is not appropriate for the operation
259
260      Cairo_Status_Pattern_Type_Mismatch,
261      --  the pattern type is not appropriate for the operation
262
263      Cairo_Status_Invalid_Content,
264      --  invalid value for an input Cairo_content
265
266      Cairo_Status_Invalid_Format,
267      --  invalid value for an input Cairo_format
268
269      Cairo_Status_Invalid_Visual,
270      --  invalid value for an input Visual*
271
272      Cairo_Status_File_Not_Found,
273      --  file not found
274
275      Cairo_Status_Invalid_Dash,
276      --  invalid value for a dash setting
277
278      Cairo_Status_Invalid_Dsc_Comment,
279      --  invalid value for a DSC comment (Since 1.2)
280
281      Cairo_Status_Invalid_Index,
282      --  invalid index passed to getter (Since 1.4)
283
284      Cairo_Status_Clip_Not_Representable,
285      --  clip region not representable in desired format (Since 1.4)
286
287      Cairo_Status_Temp_File_Error,
288      --  error creating or writing to a temporary file (Since 1.6)
289
290      Cairo_Status_Invalid_Stride,
291      --  invalid value for stride (Since 1.6)
292
293      Cairo_Status_Font_Type_Mismatch,
294      --  the font type is not appropriate for the operation (Since 1.8)
295
296      Cairo_Status_User_Font_Immutable,
297      --  the user-font is immutable (Since 1.8)
298
299      Cairo_Status_User_Font_Error,
300      --  error occurred in a user-font callback function (Since 1.8)
301
302      Cairo_Status_Negative_Count,
303      --  negative number used where it is not allowed (Since 1.8)
304
305      Cairo_Status_Invalid_Clusters,
306      --  input clusters do not represent the accompanying text and glyph
307      --  array (Since 1.8)
308
309      Cairo_Status_Invalid_Slant,
310      --  invalid value for an input Cairo_Font_Slant (Since 1.8)
311
312      Cairo_Status_Invalid_Weight
313      --  invalid value for an input Cairo_Font_Weight (Since 1.8)
314     );
315
316   subtype Cairo_Content is Guint;
317   --  Cairo_content is used to describe the content that a surface will
318   --  contain, whether color information, alpha information (translucence
319   --  vs. opacity), or both.
320   --
321   --  Note: The large values here are designed to keep Cairo_Content
322   --  values distinct from Cairo_Format values so that the
323   --  implementation can detect the error if users confuse the two types.
324
325   Cairo_Content_Color       : constant Cairo_Content := 4096;
326   --  The surface will hold color content only.
327
328   Cairo_Content_Alpha       : constant Cairo_Content := 8192;
329   --  CAIRO_CONTENT_ALPHA: The surface will hold alpha content only.
330
331   Cairo_Content_Color_Alpha : constant Cairo_Content := 12288;
332   --  CAIRO_CONTENT_COLOR_ALPHA: The surface will hold color and alpha
333   --  content.
334
335   function Create (Target : Cairo_Surface) return Cairo_Context;
336   --  Target: Target surface for the context
337   --
338   --  Creates a new Cairo_Context with all graphics state parameters set to
339   --  default values and with target as a target surface. The target
340   --  surface should be constructed with a backend-specific function such
341   --  as Cairo.Image_Surface.Create.
342   --
343   --  This function references target, so you can immediately
344   --  call Cairo.Surface.Destroy on it if you don't need to
345   --  maintain a separate reference to it.
346   --
347   --  Return value: a newly allocated Cairo_Context with a reference
348   --  count of 1. The initial reference count should be released
349   --  with Destroy when you are done using the Cairo_Context.
350   --  This function never returns NULL. If memory cannot be
351   --  allocated, a special Cairo_Context object will be returned on
352   --  which Status returns Cairo_Status_No_Memory.
353   --  You can use this object normally, but no drawing will
354   --  be done.
355
356   function Reference (Cr : Cairo_Context) return Cairo_Context;
357   --  Cr: a Cairo_Context
358   --
359   --  Increases the reference count on cr by one. This prevents
360   --  cr from being destroyed until a matching call to Destroy
361   --  is made.
362   --
363   --  The number of references to a Cairo_Context can be retrieved using
364   --  Get_Reference_Count.
365   --
366   --  Return value: the referenced Cairo_Context.
367
368   procedure Destroy (Cr : Cairo_Context);
369   pragma Import (C, Destroy, "cairo_destroy");
370   --  Cr: a Cairo_Context
371   --
372   --  Decreases the reference count on cr by one. If the result
373   --  is zero, then cr and all associated resources are freed.
374   --  See Reference.
375
376   procedure Surface_Destroy (Surface : Cairo_Surface);
377   pragma Import (C, Surface_Destroy, "cairo_surface_destroy");
378   --  Free the memory used by the surface
379
380   function Get_Reference_Count (Cr : Cairo_Context) return Guint;
381   --  Cr: a Cairo_Context
382   --
383   --  Returns the current reference count of cr.
384   --
385   --  Return value: the current reference count of cr.  If the
386   --  object is a nil object, 0 will be returned.
387   --
388   --  Since: 1.4
389
390   function Get_User_Data
391     (Cr   : Cairo_Context;
392      Key  : access Cairo_User_Data_Key)
393      return System.Address;
394   --  Cr: a Cairo_Context
395   --  Key: the address of the Cairo_User_Data_Key the user data was
396   --  attached to
397   --
398   --  Return user data previously attached to cr using the specified
399   --  key.  If no user data has been attached with the given key this
400   --  function returns NULL.
401   --
402   --  Return value: the user data previously attached or NULL.
403   --
404   --  Since: 1.4
405
406   function Set_User_Data
407     (Cr        : Cairo_Context;
408      Key       : access Cairo_User_Data_Key;
409      User_Data : System.Address;
410      Destroy   : Cairo_Destroy_Func)
411      return      Cairo_Status;
412   --  Cr: a Cairo_Context
413   --  Key: the address of a Cairo_User_Data_Key to attach the user data to
414   --  User_Data: the user data to attach to the Cairo_Context
415   --  Destroy: a Cairo_Destroy_Func which will be called when the
416   --  Cairo_Context is destroyed or when new user data is attached using the
417   --  same key.
418   --
419   --  Attach user data to cr.  To remove user data from a surface,
420   --  call this function with the key that was used to set it and NULL
421   --  for data.
422   --
423   --  Return value: CAIRO_STATUS_SUCCESS or CAIRO_STATUS_NO_MEMORY if a
424   --  slot could not be allocated for the user data.
425   --
426   --  Since: 1.4
427
428   procedure Save (Cr : Cairo_Context);
429   --  Cr: a Cairo_Context
430   --
431   --  Makes a copy of the current state of cr and saves it
432   --  on an internal stack of saved states for cr. When
433   --  Cairo_Restore is called, cr will be restored to
434   --  the saved state. Multiple calls to Cairo_Save and
435   --  Cairo_Restore can be nested; each call to Cairo_Restore
436   --  restores the state from the matching paired Cairo_Save.
437   --
438   --  It isn't necessary to clear all saved states before
439   --  a Cairo_Context is freed. If the reference count of a Cairo_Context
440   --  drops to zero in response to a call to Cairo_Destroy,
441   --  any saved states will be freed along with the Cairo_Context.
442
443   procedure Restore (Cr : Cairo_Context);
444   --  Cr: a Cairo_Context
445   --
446   --  Restores cr to the state saved by a preceding call to
447   --  Cairo_Save and removes that state from the stack of
448   --  saved states.
449
450   procedure Push_Group (Cr : Cairo_Context);
451   --  Cr: a cairo context
452   --
453   --  Temporarily redirects drawing to an intermediate surface known as a
454   --  group. The redirection lasts until the group is completed by a call
455   --  to Pop_Group or Pop_Group_To_Source.
456   --
457   --  These calls provide the result of any drawing to the group as a pattern,
458   --  (either as an explicit object, or set as the source pattern).
459   --
460   --  This group functionality can be convenient for performing
461   --  intermediate compositing. One common use of a group is to render
462   --  objects as opaque within the group, (so that they occlude each
463   --  other), and then blend the result with translucence onto the
464   --  destination.
465   --
466   --  Groups can be nested arbitrarily deep by making balanced calls to
467   --  Push_Group/Pop_Group. Each call pushes/pops the new target group
468   --  onto/from a stack.
469   --
470   --  The Push_Group function calls Save so that any changes to the graphics
471   --  state will not be visible outside the group, (the pop_group functions
472   --  call Restore).
473   --
474   --  By default the intermediate group will have a content type of
475   --  Cairo_Content_Color_Alphe. Other content types can be chosen for
476   --  the group by using Push_Group_With_Content instead.
477   --
478   --  As an example, here is how one might fill and stroke a path with
479   --  translucence, but without any portion of the fill being visible
480   --  under the stroke:
481   --
482   --      Push_Group (Cr);
483   --      Set_Source (Cr, Fill_Pattern);
484   --      Fill_Preserve (Cr);
485   --      Set_Source (Cr, Stroke_Pattern);
486   --      Stroke (Cr);
487   --      Pop_Group_To_Source (Cr);
488   --      Paint_With_Alpha (Cr, Alpha);
489   --
490   --  Since: 1.2
491
492   procedure Push_Group_With_Content
493     (Cr      : Cairo_Context;
494      Content : Cairo_Content);
495   --  Cr: a cairo context
496   --  Content: a Cairo_Content indicating the type of group that
497   --            will be created
498   --
499   --  Temporarily redirects drawing to an intermediate surface known as a
500   --  group. The redirection lasts until the group is completed by a call to
501   --  Pop_Group or Pop_Group_To_Source. These calls provide the result of any
502   --  drawing to the group as a pattern, (either as an explicit object, or set
503   --  as the source pattern).
504   --
505   --  The group will have a content type of content. The ability to control
506   --  this content type is the only distinction between this function and
507   --  Push_Group which you should see for a more detailed description of group
508   --  rendering.
509   --
510   --  Since: 1.2
511
512   function Pop_Group (Cr : Cairo_Context) return Cairo_Pattern;
513   --  Cr: a cairo context
514   --
515   --  Terminates the redirection begun by a call to Push_Group or
516   --  Push_Group_With_Content and returns a new pattern containing the results
517   --  of all drawing operations performed to the group.
518   --
519   --  The Pop_Group function calls Restore, (balancing a call to Save by the
520   --  Push_Group function), so that any changes to the graphics state will not
521   --  be visible outside the group.
522   --
523   --  Return value: a newly created (surface) pattern containing the
524   --  results of all drawing operations performed to the group. The
525   --  caller owns the returned object and should call
526   --  Cairo.Pattern.Destroy when finished with it.
527   --
528   --  Since: 1.2
529
530   procedure Pop_Group_To_Source (Cr : Cairo_Context);
531   --  Cr: a cairo context
532   --
533   --  Terminates the redirection begun by a call to Push_Group or
534   --  Push_Group_With_Content and installs the resulting pattern as the source
535   --  pattern in the given cairo context.
536   --
537   --  The behavior of this function is equivalent to the sequence of
538   --  operations:
539   --
540   --  declare
541   --     Group: Cairo_Pattern := Pop_Group (Cr);
542   --  begin
543   --     Set_Source (Cr, Group);
544   --     Cairo.Pattern.Destroy (Group);
545   --  end;
546   --
547   --  but is more convenient as their is no need for a variable to store
548   --  the short-lived pointer to the pattern.
549   --
550   --  The Pop_Group function calls Restore, (balancing a call to Save by the
551   --  push_group function), so that any changes to the graphics state will not
552   --  be visible outside the group.
553   --
554   --  Since: 1.2
555
556   --  Cairo_operator is used to set the compositing operator for all cairo
557   --  drawing operations.
558   --
559   --  The default operator is Cairo_Operator_Over.
560   --
561   --  The operators marked as "unbounded" modify their destination even
562   --  outside of the mask layer (that is, their effect is not bound by the
563   --  mask layer). However, their effect can still be limited by way of
564   --  clipping.
565   --
566   --  To keep things simple, the operator descriptions here document the
567   --  behavior for when both source and destination are either fully
568   --  transparent or fully opaque. The actual implementation works for
569   --  translucent layers too.
570   --
571   --  For a more detailed explanation of the effects of each operator,
572   --  including the mathematical definitions, see
573   --  http://cairographics.org/operators/
574   type Cairo_Operator is
575     (Cairo_Operator_Clear,
576      --  clear destination layer (bounded)
577
578      Cairo_Operator_Source,
579      --  replace destination layer (bounded)
580
581      Cairo_Operator_Over,
582      --  draw source layer on top of destination layer (bounded)
583
584      Cairo_Operator_In,
585      --  draw source where there was destination content (unbounded)
586
587      Cairo_Operator_Out,
588      --  draw source where there was no destination content (unbounded)
589
590      Cairo_Operator_Atop,
591      --  draw source on top of destination content and only there
592
593      Cairo_Operator_Dest,
594      --  ignore the source
595
596      Cairo_Operator_Dest_Over,
597      --  draw destination on top of source
598
599      Cairo_Operator_Dest_In,
600      --  leave destination only where there was source content (unbounded)
601
602      Cairo_Operator_Dest_Out,
603      --  leave destination only where there was no source content
604
605      Cairo_Operator_Dest_Atop,
606      --  leave destination on top of source content and only there (unbounded)
607
608      Cairo_Operator_Xor,
609      --  source and destination are shown where there is only one of them
610
611      Cairo_Operator_Add,
612      --  source and destination layers are accumulated
613
614      Cairo_Operator_Saturate
615      --  like over, but assuming source and dest are disjoint geometries
616     );
617
618   procedure Set_Operator (Cr : Cairo_Context; Op : Cairo_Operator);
619   --  Cr: a Cairo_Context
620   --  Op: a compositing Operator, specified as a Cairo_Operator
621   --
622   --  Sets the compositing operator to be used for all drawing
623   --  operations. See Cairo_Operator for details on the semantics of
624   --  each available compositing operator.
625   --
626   --  The default operator is Cairo_Operator_Over.
627
628   function Pattern_Create_Rgb
629     (Red, Green, Blue : Gdouble) return Cairo_Pattern;
630   pragma Import (C, Pattern_Create_Rgb, "cairo_pattern_create_rgb");
631
632   function Pattern_Create_Rgba
633     (Red, Green, Blue, Alpha : Gdouble) return Cairo_Pattern;
634   pragma Import (C, Pattern_Create_Rgba, "cairo_pattern_create_rgba");
635
636   function Pattern_Create_For_Surface
637     (Surface : Cairo_Surface) return Cairo_Pattern;
638   pragma Import (C, Pattern_Create_For_Surface,
639                  "cairo_pattern_create_for_surface");
640
641   function Pattern_Create_Linear
642     (X0, Y0, X1, Y1 : Gdouble) return Cairo_Pattern;
643   pragma Import (C, Pattern_Create_Linear, "cairo_pattern_create_linear");
644   --  See Pattern_Add_Color_Stop to specify the colors
645
646   function Pattern_Create_Radial
647     (Cx0, Cy0, Radius0, Cx1, Cy1, Radius1 : Gdouble) return Cairo_Pattern;
648   pragma Import (C, Pattern_Create_Radial, "cairo_pattern_create_radial");
649
650   procedure Pattern_Destroy (Pattern : Cairo_Pattern);
651   pragma Import (C, Pattern_Destroy, "cairo_pattern_destroy");
652
653   procedure Pattern_Add_Color_Stop_Rgb
654     (Pattern : Cairo_Pattern;
655      Offset  : Gdouble;
656      Red, Green, Blue : Gdouble);
657   pragma Import
658     (C, Pattern_Add_Color_Stop_Rgb, "cairo_pattern_add_color_stop_rgb");
659
660   procedure Pattern_Add_Color_Stop_Rgba
661     (Pattern : Cairo_Pattern;
662      Offset  : Gdouble;
663      Red, Green, Blue, Alpha : Gdouble);
664   pragma Import
665     (C, Pattern_Add_Color_Stop_Rgba, "cairo_pattern_add_color_stop_rgba");
666
667   procedure Set_Source (Cr : Cairo_Context; Source : Cairo_Pattern);
668   --  Cr: a cairo context
669   --  Source: a Cairo_Pattern to be used as the Source for
670   --  subsequent drawing operations.
671   --
672   --  Sets the source pattern within Cr to source. This pattern
673   --  will then be used for any subsequent drawing operation until a new
674   --  source pattern is set.
675   --
676   --  Note: The pattern's transformation matrix will be locked to the user
677   --  space in effect at the time of Set_Source. This means that further
678   --  modifications of the current transformation matrix will not affect the
679   --  source pattern. See Cairo.Pattern.Set_Matrix.
680   --
681   --  The default source pattern is a solid pattern that is opaque black,
682   --  (that is, it is equivalent to Set_Source_Rgb (Cr, 0.0, 0.0, 0.0)).
683
684   subtype Color_Range is Gdouble range 0.0 .. 1.0;
685
686   procedure Set_Source_Rgb
687     (Cr    : Cairo_Context;
688      Red   : Color_Range;
689      Green : Color_Range;
690      Blue  : Color_Range);
691   --  Cr    : a cairo context
692   --  Red   : Red component of color
693   --  Green : Green component of color
694   --  Blue  : Blue component of color
695   --
696   --  Sets the source pattern within Cr to an opaque color. This opaque
697   --  color will then be used for any subsequent drawing operation until
698   --  a new source pattern is set.
699   --
700   --  The color components are floating point numbers in the range 0 to
701   --  1. If the values passed in are outside that range, they will be
702   --  clamped.
703   --
704   --  The default source pattern is opaque black, (that is, it is
705   --  equivalent to Set_Source_Rgb (Cr, 0.0, 0.0, 0.0)).
706
707   procedure Set_Source_Rgba
708     (Cr    : Cairo_Context;
709      Red   : Color_Range;
710      Green : Color_Range;
711      Blue  : Color_Range;
712      Alpha : Color_Range);
713   --  Cr    : a cairo context
714   --  Red   : Red component of color
715   --  Green : Green component of color
716   --  Blue  : Blue component of color
717   --  Alpha : Alpha component of color
718   --
719   --  Sets the source pattern within Cr to a translucent color. This
720   --  color will then be used for any subsequent drawing operation until
721   --  a new source pattern is set.
722   --
723   --  The color and alpha components are floating point numbers in the
724   --  range 0 to 1. If the values passed in are outside that range, they
725   --  will be clamped.
726   --
727   --  The default source pattern is opaque black, (that is, it is
728   --  equivalent to Set_Source_Rgba (Cr, 0.0, 0.0, 0.0, 1.0)).
729
730   procedure Set_Source_Surface
731     (Cr      : Cairo_Context;
732      Surface : Cairo_Surface;
733      X       : Gdouble;
734      Y       : Gdouble);
735   --  Cr      : a cairo context
736   --  Surface : a Surface to be used to set the source pattern
737   --  X       : User-space X coordinate for surface origin
738   --  Y       : User-space Y coordinate for surface origin
739   --
740   --  This is a convenience function for creating a pattern from surface
741   --  and setting it as the source in Cr with Set_Source.
742   --
743   --  The X and Y parameters give the user-space coordinate at which
744   --  the surface origin should appear. (The surface origin is its
745   --  upper-left corner before any transformation has been applied.) The
746   --  X and Y patterns are negated and then set as translation values
747   --  in the pattern matrix.
748   --
749   --  Other than the initial translation pattern matrix, as described
750   --  above, all other pattern attributes, (such as its extend mode), are
751   --  set to the default values as in Cairo.Pattern.Create_For_Surface.
752   --  The resulting pattern can be queried with Get_Source so that these
753   --  attributes can be modified if desired, (eg. to create a
754   --  repeating pattern with Cairo.Pattern.Set_Extend).
755
756   procedure Set_Tolerance (Cr : Cairo_Context; Tolerance : Gdouble);
757   --  Cr: a Cairo_Context
758   --  Tolerance: the Tolerance, in device units (typically pixels)
759   --
760   --  Sets the tolerance used when converting paths into trapezoids.
761   --  Curved segments of the path will be subdivided until the maximum
762   --  deviation between the original path and the polygonal approximation
763   --  is less than tolerance. The default value is 0.1. A larger
764   --  value will give better performance, a smaller value, better
765   --  appearance. (Reducing the value from the default value of 0.1
766   --  is unlikely to improve appearance significantly.)  The accuracy of paths
767   --  within Cairo is limited by the precision of its internal arithmetic, and
768   --  the prescribed tolerance is restricted to the smallest
769   --  representable internal value.
770
771   --  Specifies the type of antialiasing to do when rendering text or shapes.
772   type Cairo_Antialias is
773     (
774      Cairo_Antialias_Default,
775      --  Use the default antialiasing for the subsystem and target device
776
777      Cairo_Antialias_None,
778      --  Use a bilevel alpha mask
779
780      Cairo_Antialias_Gray,
781      --  Perform single-color antialiasing (using shades of gray for black
782      --  text on a white background, for example).
783
784      Cairo_Antialias_Subpixel
785      --  Perform antialiasing by taking advantage of the order of subpixel
786      --  elements on devices such as LCD panels
787     );
788
789   procedure Set_Antialias
790     (Cr        : Cairo_Context;
791      Antialias : Cairo_Antialias);
792   --  Cr: a Cairo_Context
793   --  Antialias: the new Antialiasing mode
794   --
795   --  Set the antialiasing mode of the rasterizer used for drawing shapes.
796   --  This value is a hint, and a particular backend may or may not support
797   --  a particular value.  At the current time, no backend supports
798   --  Cairo_Antialias_Subpixel when drawing shapes.
799   --
800   --  Note that this option does not affect text rendering, instead see
801   --  Cairo.Font_Options.Set_Antialias.
802
803   --  Cairo_Fill_Rule is used to select how paths are filled. For both
804   --  fill rules, whether or not a point is included in the fill is
805   --  determined by taking a ray from that point to infinity and looking
806   --  at intersections with the path. The ray can be in any direction,
807   --  as long as it doesn't pass through the end point of a segment
808   --  or have a tricky intersection such as intersecting tangent to the path.
809   --  (Note that filling is not actually implemented in this way. This
810   --  is just a description of the rule that is applied.)
811   --
812   --  The default fill rule is Cairo_Fill_Rule_Winding.
813   --
814   --  New entries may be added in future versions.
815   type Cairo_Fill_Rule is
816     (Cairo_Fill_Rule_Winding,
817      --  If the path crosses the ray from left-to-right, counts +1. If the
818      --  path crosses the ray from right to left, counts -1. (Left and right
819      --  are determined from the perspective of looking along the ray from
820      --  the starting point). If the total count is non-zero, the point will
821      --  be filled.
822
823      Cairo_Fill_Rule_Even_Odd
824      --  Counts the total number of
825      --  intersections, without regard to the orientation of the contour. If
826      --  the total number of intersections is odd, the point will be filled.
827     );
828
829   procedure Set_Fill_Rule
830     (Cr        : Cairo_Context;
831      Fill_Rule : Cairo_Fill_Rule);
832   --  Cr: a Cairo_Context
833   --  Fill_Rule: a fill rule
834   --
835   --  Set the current fill rule within the cairo context. The fill rule is
836   --  used to determine which regions are inside or outside a complex
837   --  (potentially self-intersecting) path. The current fill rule affects both
838   --  Fill and Clip. See Cairo_Fill_Rule for details on the semantics of each
839   --  available fill rule.
840   --
841   --  The default fill rule is Cairo_Fill_Rule_Winding.
842
843   procedure Set_Line_Width (Cr : Cairo_Context; Width : Gdouble);
844   --  Cr: a Cairo_Context
845   --  Width: a line Width
846   --
847   --  Sets the current line width within the cairo context. The line
848   --  width value specifies the diameter of a pen that is circular in
849   --  user space, (though device-space pen may be an ellipse in general
850   --  due to scaling/shear/rotation of the CTM).
851   --
852   --  Note: When the description above refers to user space and CTM it
853   --  refers to the user space and CTM in effect at the time of the
854   --  stroking operation, not the user space and CTM in effect at the
855   --  time of the call to Set_Line_Width. The simplest usage
856   --  makes both of these spaces identical. That is, if there is no
857   --  change to the CTM between a call to Set_Line_Width and the
858   --  stroking operation, then one can just pass user-space values to
859   --  Set_Line_Width and ignore this note.
860   --
861   --  As with the other stroke parameters, the current line width is examined
862   --  by Stroke, Stroke_Extents, and Stroke_To_Path, but does not have any
863   --  effect during path construction.
864   --
865   --  The default line width value is 2.0.
866
867   type Cairo_Line_Cap is
868     (Cairo_Line_Cap_Butt,
869      --  start(stop) the line exactly at the start(end) point
870
871      Cairo_Line_Cap_Round,
872      --  use a round ending, the center of the circle is the end point
873
874      Cairo_Line_Cap_Square
875      --  use squared ending, the center of the square is the end point
876     );
877   --  Specifies how to render the endpoints of the path when stroking.
878   --
879   --  The default line cap style is Cairo_Line_Cap_Butt.
880
881   procedure Set_Line_Cap (Cr : Cairo_Context; Line_Cap : Cairo_Line_Cap);
882   --  Cr: a cairo context
883   --  Line_Cap: a line cap style
884   --
885   --  Sets the current line cap style within the cairo context. See
886   --  Cairo_Line_Cap for details about how the available line cap
887   --  styles are drawn.
888   --
889   --  As with the other stroke parameters, the current line cap style is
890   --  examined by Stroke, Stroke_Extents, and Stroke_To_Path, but does not
891   --  have any effect during path construction.
892   --
893   --  The default line cap style is Cairo_Line_Cap_Butt.
894
895   type Cairo_Line_Join is
896     (Cairo_Line_Join_Miter,
897      --  use a sharp (angled) corner, see Set_Miter_Limit
898
899      Cairo_Line_Join_Round,
900      --  use a rounded join, the center of the circle is the joint point
901
902      Cairo_Line_Join_Bevel
903      --  use a cut-off join, the join is cut off at half the line width from
904      --  the joint point
905     );
906   --  Specifies how to render the junction of two lines when stroking.
907   --
908   --  The default line join style is Cairo_Line_Join_Miter.
909
910   procedure Set_Line_Join
911     (Cr        : Cairo_Context;
912      Line_Join : Cairo_Line_Join);
913   --  Cr: a cairo context
914   --  Line_Join: a line join style
915   --
916   --  Sets the current line join style within the cairo context. See
917   --  Cairo_Line_Join for details about how the available line join styles are
918   --  drawn.
919   --
920   --  As with the other stroke parameters, the current line join style is
921   --  examined by Stroke, Stroke_Extents, and Stroke_To_Path, but does
922   --  not have any effect during path construction.
923   --
924   --  The default line join style is Cairo_Line_Join_Miter.
925
926   type Dash_Array is array (Natural range <>) of Gdouble;
927
928   No_Dashes : constant Dash_Array (1 .. 0) := (others => 0.0);
929
930   procedure Set_Dash
931     (Cr         : Cairo_Context;
932      Dashes     : Dash_Array;
933      Offset     : Gdouble);
934   --  Cr: a cairo context
935   --  Dashes: an array specifying alternate lengths of on and off stroke
936   --  portions
937   --  Offset: an Offset into the dash pattern at which the stroke should start
938   --
939   --  Sets the dash pattern to be used by Stroke. A dash pattern
940   --  is specified by dashes, an array of positive values. Each value
941   --  provides the length of alternate "on" and "off" portions of the
942   --  stroke. The offset specifies an offset into the pattern at which
943   --  the stroke begins.
944   --
945   --  Each "on" segment will have caps applied as if the segment were a
946   --  separate sub-path. In particular, it is valid to use an "on" length
947   --  of 0.0 with Cairo_Line_Cap_Round or Cairo_Line_Cap_Square in order
948   --  to distributed dots or squares along a path.
949   --
950   --  Note: The length values are in user-space units as evaluated at the
951   --  time of stroking. This is not necessarily the same as the user
952   --  space at the time of Set_Dash.
953   --
954   --  If the array is No_Dashes, dashing is disabled.
955   --
956   --  If the array contains only one element symmetric pattern is assumed with
957   --  alternating on and off portions of the size specified by the single
958   --  value in dashes.
959   --
960   --  If any value in dashes is negative, or if all values are 0, then
961   --  cr will be put into an error state with a status of
962   --  Cairo_Status_Invalid_Dash.
963
964   procedure Set_Miter_Limit (Cr : Cairo_Context; Limit : Gdouble);
965   --  Cr: a cairo context
966   --  Limit: miter Limit to set
967   --
968   --  Sets the current miter limit within the cairo context.
969   --
970   --  If the current line join style is set to Cairo_Line_Join_Miter
971   --  (see Cairo_Set_Line_Join), the miter limit is used to determine
972   --  whether the lines should be joined with a bevel instead of a miter.
973   --  Cairo divides the length of the miter by the line width.
974   --  If the result is greater than the miter limit, the style is
975   --  converted to a bevel.
976   --
977   --  As with the other stroke parameters, the current line miter limit is
978   --  examined by Stroke, Stroke_Extents, and Stroke_To_Path, but does not
979   --  have any effect during path construction.
980   --
981   --  The default miter limit value is 10.0, which will convert joins
982   --  with interior angles less than 11 degrees to bevels instead of
983   --  miters. For reference, a miter limit of 2.0 makes the miter cutoff
984   --  at 60 degrees, and a miter limit of 1.414 makes the cutoff at 90
985   --  degrees.
986   --
987   --  A miter limit for a desired angle can be computed as: miter limit =
988   --  1/sin(angle/2)
989
990   procedure Translate (Cr : Cairo_Context; Tx : Gdouble; Ty : Gdouble);
991   --  Cr: a cairo context
992   --  Tx: amount to translate in the X direction
993   --  Ty: amount to translate in the Y direction
994   --
995   --  Modifies the current transformation matrix (CTM) by translating the
996   --  user-space origin by (tx, ty). This offset is interpreted as a
997   --  user-space coordinate according to the CTM in place before the new
998   --  call to Translate. In other words, the translation of the
999   --  user-space origin takes place after any existing transformation.
1000
1001   procedure Scale (Cr : Cairo_Context; Sx : Gdouble; Sy : Gdouble);
1002   --  Cr: a cairo context
1003   --  Sx: scale factor for the X dimension
1004   --  Sy: scale factor for the Y dimension
1005   --
1006   --  Modifies the current transformation matrix (CTM) by scaling the X
1007   --  and Y user-space axes by sx and sy respectively. The scaling of
1008   --  the axes takes place after any existing transformation of user
1009   --  space.
1010
1011   procedure Rotate (Cr : Cairo_Context; Angle : Gdouble);
1012   --  Cr: a cairo context
1013   --  Angle: Angle (in radians) by which the user-space axes will be
1014   --  rotated
1015   --
1016   --  Modifies the current transformation matrix (CTM) by rotating the
1017   --  user-space axes by angle radians. The rotation of the axes takes
1018   --  places after any existing transformation of user space. The
1019   --  rotation direction for positive angles is from the positive X axis
1020   --  toward the positive Y axis.
1021
1022   procedure Transform
1023     (Cr     : Cairo_Context;
1024      Matrix : access Cairo_Matrix);
1025   --  Cr: a cairo context
1026   --  Matrix: a transformation to be applied to the user-space axes
1027   --
1028   --  Modifies the current transformation matrix (CTM) by applying
1029   --  matrix as an additional transformation. The new transformation of
1030   --  user space takes place after any existing transformation.
1031
1032   procedure Set_Matrix
1033     (Cr     : Cairo_Context;
1034      Matrix : access Cairo_Matrix);
1035   --  Cr: a cairo context
1036   --  Matrix: a transformation Matrix from user space to device space
1037   --
1038   --  Modifies the current transformation matrix (CTM) by setting it
1039   --  equal to matrix.
1040
1041   procedure Identity_Matrix (Cr : Cairo_Context);
1042   --  Cr: a cairo context
1043   --
1044   --  Resets the current transformation matrix (CTM) by setting it equal
1045   --  to the identity matrix. That is, the user-space and device-space
1046   --  axes will be aligned and one user-space unit will transform to one
1047   --  device-space unit.
1048
1049   procedure User_To_Device
1050     (Cr : Cairo_Context;
1051      X  : access Gdouble;
1052      Y  : access Gdouble);
1053   --  Cr: a cairo context
1054   --  X: X value of coordinate (in/out parameter)
1055   --  Y: Y value of coordinate (in/out parameter)
1056   --
1057   --  Transform a coordinate from user space to device space by
1058   --  multiplying the given point by the current transformation matrix
1059   --  (CTM).
1060
1061   procedure User_To_Device_Distance
1062     (Cr : Cairo_Context;
1063      Dx : access Gdouble;
1064      Dy : access Gdouble);
1065   --  Cr: a cairo context
1066   --  Dx: X component of a distance vector (in/out parameter)
1067   --  Dy: Y component of a distance vector (in/out parameter)
1068   --
1069   --  Transform a distance vector from user space to device space. This
1070   --  function is similar to User_To_Device except that the translation
1071   --  components of the CTM will be ignored when transforming (Dx,Dy).
1072
1073   procedure Device_To_User
1074     (Cr : Cairo_Context;
1075      X  : access Gdouble;
1076      Y  : access Gdouble);
1077   --  Cr: a cairo
1078   --  X: X value of coordinate (in/out parameter)
1079   --  Y: Y value of coordinate (in/out parameter)
1080   --
1081   --  Transform a coordinate from device space to user space by
1082   --  multiplying the given point by the inverse of the current
1083   --  transformation matrix (CTM).
1084
1085   procedure Device_To_User_Distance
1086     (Cr : Cairo_Context;
1087      Dx : access Gdouble;
1088      Dy : access Gdouble);
1089   --  Cr: a cairo context
1090   --  Dx: X component of a distance vector (in/out parameter)
1091   --  Dy: Y component of a distance vector (in/out parameter)
1092   --
1093   --  Transform a distance vector from device space to user space. This
1094   --  function is similar to Device_To_User except that the
1095   --  translation components of the inverse CTM will be ignored when
1096   --  transforming (Dx,dy).
1097
1098   -------------------
1099   -- Path creation --
1100   -------------------
1101
1102   procedure New_Path (Cr : Cairo_Context);
1103   --  Cr: a cairo context
1104   --
1105   --  Clears the current path. After this call there will be no path and
1106   --  no current point.
1107
1108   procedure Move_To (Cr : Cairo_Context; X : Gdouble; Y : Gdouble);
1109   --  Cr: a cairo context
1110   --  X: the X coordinate of the new position
1111   --  Y: the Y coordinate of the new position
1112   --
1113   --  Begin a new sub-path. After this call the current point will be (X, Y).
1114
1115   procedure New_Sub_Path (Cr : Cairo_Context);
1116   --  Cr: a cairo context
1117   --
1118   --  Begin a new sub-path. Note that the existing path is not
1119   --  affected. After this call there will be no current point.
1120   --
1121   --  In many cases, this call is not needed since new sub-paths are
1122   --  frequently started with Move_To.
1123   --
1124   --  A call to New_Sub_Path is particularly useful when
1125   --  beginning a new sub-path with one of the Arc calls. This
1126   --  makes things easier as it is no longer necessary to manually
1127   --  compute the arc's initial coordinates for a call to
1128   --  Move_To.
1129   --
1130   --  Since: 1.2
1131
1132   procedure Line_To (Cr : Cairo_Context; X : Gdouble; Y : Gdouble);
1133   --  Cr: a cairo context
1134   --  X: the X coordinate of the end of the new line
1135   --  Y: the Y coordinate of the end of the new line
1136   --
1137   --  Adds a line to the path from the current point to position (X, Y)
1138   --  in user-space coordinates. After this call the current point
1139   --  will be (X, Y).
1140   --
1141   --  If there is no current point before the call to Line_To
1142   --  this function will behave as Move_To (Cr, X, Y).
1143
1144   procedure Curve_To
1145     (Cr : Cairo_Context;
1146      X1 : Gdouble;
1147      Y1 : Gdouble;
1148      X2 : Gdouble;
1149      Y2 : Gdouble;
1150      X3 : Gdouble;
1151      Y3 : Gdouble);
1152   --  Cr: a cairo context
1153   --  X1: the X coordinate of the first control point
1154   --  Y1: the Y coordinate of the first control point
1155   --  X2: the X coordinate of the second control point
1156   --  Y2: the Y coordinate of the second control point
1157   --  X3: the X coordinate of the end of the curve
1158   --  Y3: the Y coordinate of the end of the curve
1159   --
1160   --  Adds a cubic Bézier spline to the path from the current point to
1161   --  position (X3, Y3) in user-space coordinates, using (X1, Y1) and
1162   --  (X2, Y2) as the control points. After this call the current point
1163   --  will be (X3, Y3).
1164   --
1165   --  If there is no current point before the call to Curve_To
1166   --  this function will behave as if preceded by a call to
1167   --  Move_To (Cr, X1, Y1).
1168
1169   procedure Arc
1170     (Cr     : Cairo_Context;
1171      Xc     : Gdouble;
1172      Yc     : Gdouble;
1173      Radius : Gdouble;
1174      Angle1 : Gdouble;
1175      Angle2 : Gdouble);
1176   --  Cr: a cairo context
1177   --  Xc: X position of the center of the arc
1178   --  Yc: Y position of the center of the arc
1179   --  Radius: the Radius of the arc
1180   --  Angle1: the start angle, in radians
1181   --  Angle2: the end angle, in radians
1182   --
1183   --  Adds a circular arc of the given radius to the current path.  The
1184   --  arc is centered at (Xc, Yc), begins at Angle1 and proceeds in
1185   --  the direction of increasing angles to end at Angle2. If Angle2 is
1186   --  less than Angle1 it will be progressively increased by 2*M_PI
1187   --  until it is greater than Angle1.
1188   --
1189   --  If there is a current point, an initial line segment will be added
1190   --  to the path to connect the current point to the beginning of the
1191   --  arc. If this initial line is undesired, it can be avoided by
1192   --  calling New_Sub_Path before calling Arc.
1193   --
1194   --  Angles are measured in radians. An angle of 0.0 is in the direction
1195   --  of the positive X axis (in user space). An angle of M_PI/2.0 radians
1196   --  (90 degrees) is in the direction of the positive Y axis (in
1197   --  user space). Angles increase in the direction from the positive X
1198   --  axis toward the positive Y axis. So with the default transformation
1199   --  matrix, angles increase in a clockwise direction.
1200   --
1201   --  (To convert from degrees to radians, use degrees * (Pi / 180.0))
1202   --
1203   --  This function gives the arc in the direction of increasing angles;
1204   --  see Cairo_Arc_Negative to get the arc in the direction of
1205   --  decreasing angles.
1206   --
1207   --  The arc is circular in user space. To achieve an elliptical arc,
1208   --  you can scale the current transformation matrix by different
1209   --  amounts in the X and Y directions. For example, to draw an ellipse
1210   --  in the box given by X, Y, Width, Height:
1211   --
1212   --  Cairo_Save (Cr);
1213   --  Cairo_Translate (Cr, X + Width / 2.0, Y + Height / 2.0);
1214   --  Cairo_Scale (Cr, Width / 2.0, Height / 2.0);
1215   --  Cairo_Arc (Cr, 0.0, 0.0, 1.0, 0.0, 2 * Pi);
1216   --  Cairo_Restore (Cr);
1217
1218   procedure Arc_Negative
1219     (Cr     : Cairo_Context;
1220      Xc     : Gdouble;
1221      Yc     : Gdouble;
1222      Radius : Gdouble;
1223      Angle1 : Gdouble;
1224      Angle2 : Gdouble);
1225   --  Cr: a cairo context
1226   --  Xc: X position of the center of the arc
1227   --  Yc: Y position of the center of the arc
1228   --  Radius: the Radius of the arc
1229   --  Angle1: the start angle, in radians
1230   --  Angle2: the end angle, in radians
1231   --
1232   --  Adds a circular arc of the given radius to the current path.  The
1233   --  arc is centered at (Xc, Yc), begins at Angle1 and proceeds in
1234   --  the direction of decreasing angles to end at Angle2. If Angle2 is
1235   --  greater than Angle1 it will be progressively decreased by 2*Pi
1236   --  until it is less than Angle1.
1237   --
1238   --  See Arc for more details. This function differs only in the
1239   --  direction of the arc between the two angles.
1240
1241   procedure Rel_Move_To (Cr : Cairo_Context; Dx : Gdouble; Dy : Gdouble);
1242   --  Cr: a cairo context
1243   --  Dx: the X offset
1244   --  Dy: the Y offset
1245   --
1246   --  Begin a new sub-path. After this call the current point will offset
1247   --  by (X, Y).
1248   --
1249   --  Given a current point of (X, Y), Rel_Move_To (Cr, Dx, Dy)
1250   --  is logically equivalent to Move_To (Cr, X + Dx, Y + Dy).
1251   --
1252   --  It is an error to call this function with no current point. Doing
1253   --  so will cause cr to shutdown with a status of
1254   --  Cairo_Status_No_Current_Point.
1255
1256   procedure Rel_Line_To (Cr : Cairo_Context; Dx : Gdouble; Dy : Gdouble);
1257   --  Cr: a cairo context
1258   --  Dx: the X offset to the end of the new line
1259   --  Dy: the Y offset to the end of the new line
1260   --
1261   --  Relative-coordinate version of Line_To. Adds a line to the
1262   --  path from the current point to a point that is offset from the
1263   --  current point by (Dx, Dy) in user space. After this call the
1264   --  current point will be offset by (Dx, Dy).
1265   --
1266   --  Given a current point of (X, Y), Rel_Line_To (Cr, Dx, Dy)
1267   --  is logically equivalent to Cairo_Line_To(Cr, X + Dx, Y + Dy).
1268   --
1269   --  It is an error to call this function with no current point. Doing
1270   --  so will cause cr to shutdown with a status of
1271   --  Cairo_Status_No_Current_Point.
1272
1273   procedure Rel_Curve_To
1274     (Cr  : Cairo_Context;
1275      Dx1 : Gdouble;
1276      Dy1 : Gdouble;
1277      Dx2 : Gdouble;
1278      Dy2 : Gdouble;
1279      Dx3 : Gdouble;
1280      Dy3 : Gdouble);
1281   --  Cr: a cairo context
1282   --  Dx1: the X offset to the first control point
1283   --  Dy1: the Y offset to the first control point
1284   --  Dx2: the X offset to the second control point
1285   --  Dy2: the Y offset to the second control point
1286   --  Dx3: the X offset to the end of the curve
1287   --  Dy3: the Y offset to the end of the curve
1288   --
1289   --  Relative-coordinate version of Cairo_Curve_To. All offsets are
1290   --  relative to the current point. Adds a cubic Bézier spline to the
1291   --  path from the current point to a point offset from the current
1292   --  point by (Dx3, Dy3), using points offset by (Dx1, Dy1) and
1293   --  (Dx2, Dy2) as the control points. After this call the current
1294   --  point will be offset by (Dx3, Dy3).
1295   --
1296   --  Given a current point of (X, Y), Cairo_Rel_Curve_To(Cr, Dx1,
1297   --  Dy1, Dx2, Dy2, Dx3, Dy3) is logically equivalent to
1298   --  Cairo_Curve_To(Cr, X+Dx1, Y+Dy1, X+Dx2, Y+Dy2, X+Dx3, Y+Dy3).
1299   --
1300   --  It is an error to call this function with no current point. Doing
1301   --  so will cause cr to shutdown with a status of
1302   --  Cairo_Status_No_Current_Point.
1303
1304   procedure Rectangle
1305     (Cr     : Cairo_Context;
1306      X      : Gdouble;
1307      Y      : Gdouble;
1308      Width  : Gdouble;
1309      Height : Gdouble);
1310   --  Cr: a cairo context
1311   --  X: the X coordinate of the top left corner of the rectangle
1312   --  Y: the Y coordinate to the top left corner of the rectangle
1313   --  Width: the Width of the rectangle
1314   --  Height: the Height of the rectangle
1315   --
1316   --  Adds a closed sub-path rectangle of the given size to the current
1317   --  path at position (X, Y) in user-space coordinates.
1318   --
1319   --  This function is logically equivalent to:
1320   --
1321   --  Move_To (Cr, x, Y);
1322   --  Rel_Line_To (Cr, Width, 0);
1323   --  Rel_Line_To (Cr, 0, Height);
1324   --  Rel_Line_To (Cr, -Width, 0);
1325   --  Close_Path (Cr);
1326
1327   procedure Close_Path (Cr : Cairo_Context);
1328   --  Cr: a cairo context
1329   --
1330   --  Adds a line segment to the path from the current point to the
1331   --  beginning of the current sub-path, (the most recent point passed to
1332   --  Move_To), and closes this sub-path. After this call the
1333   --  current point will be at the joined endpoint of the sub-path.
1334   --
1335   --  The behavior of Close_Path is distinct from simply calling
1336   --  Line_To with the equivalent coordinate in the case of
1337   --  stroking. When a closed sub-path is stroked, there are no caps on
1338   --  the ends of the sub-path. Instead, there is a line join connecting
1339   --  the final and initial segments of the sub-path.
1340   --
1341   --  If there is no current point before the call to Close_Path,
1342   --  this function will have no effect.
1343   --
1344   --  Note: As of cairo version 1.2.4 any call to Close_Path will
1345   --  place an explicit MOVE_TO element into the path immediately after
1346   --  the CLOSE_PATH element, (which can be seen in Copy_Path for
1347   --  example). This can simplify path processing in some cases as it may
1348   --  not be necessary to save the "last move_to point" during processing
1349   --  as the MOVE_TO immediately after the CLOSE_PATH will provide that
1350   --  point.
1351
1352   procedure Path_Extents
1353     (Cr : Cairo_Context;
1354      X1 : access Gdouble;
1355      Y1 : access Gdouble;
1356      X2 : access Gdouble;
1357      Y2 : access Gdouble);
1358   --  Cr: a cairo context
1359   --  X1: left of the resulting extents
1360   --  Y1: top of the resulting extents
1361   --  X2: right of the resulting extents
1362   --  Y2: bottom of the resulting extents
1363   --
1364   --  Computes a bounding box in user-space coordinates covering the
1365   --  points on the current path. If the current path is empty, returns
1366   --  an empty rectangle ((0,0), (0,0)). Stroke parameters, fill rule,
1367   --  surface dimensions and clipping are not taken into account.
1368   --
1369   --  Contrast with Fill_Extents and Stroke_Extents which
1370   --  return the extents of only the area that would be "inked" by
1371   --  the corresponding drawing operations.
1372   --
1373   --  The result of Path_Extents is defined as equivalent to the
1374   --  limit of Stroke_Extents with Cairo_Line_Cap_Round as the
1375   --  line width approaches 0.0, (but never reaching the empty-rectangle
1376   --  returned by Cairo_Stroke_Extents for a line width of 0.0).
1377   --
1378   --  Specifically, this means that zero-area sub-paths such as
1379   --  Move_To;Line_To segments, (even degenerate cases where the coordinates
1380   --  to both calls are identical), will be considered as contributing to the
1381   --  extents. However, a lone Move_To will not contribute to the results of
1382   --  Path_Extents.
1383   --
1384   --  Since: 1.6
1385
1386   --------------
1387   -- Painting --
1388   --------------
1389
1390   procedure Paint (Cr : Cairo_Context);
1391   --  Cr: a cairo context
1392   --
1393   --  A drawing operator that paints the current source everywhere within
1394   --  the current clip region.
1395
1396   procedure Paint_With_Alpha (Cr : Cairo_Context; Alpha : Gdouble);
1397   --  Cr: a cairo context
1398   --  Alpha: Alpha value, between 0 (transparent) and 1 (opaque)
1399   --
1400   --  A drawing operator that paints the current source everywhere within the
1401   --  current clip region using a mask of constant alpha value alpha. The
1402   --  effect is similar to Paint, but the drawing is faded out using the alpha
1403   --  value.
1404
1405   procedure Mask (Cr : Cairo_Context; Pattern : Cairo_Pattern);
1406   --  Cr: a cairo context
1407   --  Pattern: a Cairo_Pattern
1408   --
1409   --  A drawing operator that paints the current source using the alpha
1410   --  channel of pattern as a mask. (Opaque areas of pattern are painted with
1411   --  the source, transparent areas are not painted.)
1412
1413   procedure Mask_Surface
1414     (Cr        : Cairo_Context;
1415      Surface   : Cairo_Surface;
1416      Surface_X : Gdouble;
1417      Surface_Y : Gdouble);
1418   --  Cr: a cairo context
1419   --  Surface: a Cairo_Surface
1420   --  Surface_X: X coordinate at which to place the origin of surface
1421   --  Surface_Y: Y coordinate at which to place the origin of surface
1422   --
1423   --  A drawing operator that paints the current source
1424   --  using the alpha channel of surface as a mask. (Opaque
1425   --  areas of surface are painted with the source, transparent
1426   --  areas are not painted.)
1427
1428   procedure Stroke (Cr : Cairo_Context);
1429   --  Cr: a cairo context
1430   --
1431   --  A drawing operator that strokes the current path according to the
1432   --  current line width, line join, line cap, and dash settings. After
1433   --  Cairo_Stroke, the current path will be cleared from the cairo
1434   --  context. See Set_Line_Width, Set_Line_Join, Set_Line_Cap, Set_Dash,
1435   --  and Stroke_Preserve.
1436   --
1437   --  Note: Degenerate segments and sub-paths are treated specially and
1438   --  provide a useful result. These can result in two different
1439   --  situations:
1440   --
1441   --  1. Zero-length "on" segments set in Set_Dash. If the cap
1442   --  style is Cairo_Line_Cap_Round or Cairo_Line_Cap_Square then these
1443   --  segments will be drawn as circular dots or squares respectively. In
1444   --  the case of Cairo_Line_Cap_Square, the orientation of the squares
1445   --  is determined by the direction of the underlying path.
1446   --
1447   --  2. A sub-path created by Cairo_Move_To followed by either a
1448   --  Cairo_Close_Path or one or more calls to Cairo_Line_To to the
1449   --  same coordinate as the Cairo_Move_To. If the cap style is
1450   --  Cairo_Line_Cap_Round then these sub-paths will be drawn as circular
1451   --  dots. Note that in the case of Cairo_Line_Cap_Square a degenerate
1452   --  sub-path will not be drawn at all, (since the correct orientation
1453   --  is indeterminate).
1454   --
1455   --  In no case will a cap style of Cairo_Line_Cap_Butt cause anything
1456   --  to be drawn in the case of either degenerate segments or sub-paths.
1457
1458   procedure Stroke_Preserve (Cr : Cairo_Context);
1459   --  Cr: a cairo context
1460   --
1461   --  A drawing operator that strokes the current path according to the
1462   --  current line width, line join, line cap, and dash settings. Unlike
1463   --  Cairo_Stroke, Cairo_Stroke_Preserve preserves the path within the
1464   --  cairo context.
1465   --
1466   --  See Set_Line_Width, Set_Line_Join, Set_Line_Cap, Set_Dash, and
1467   --  Stroke_Preserve.
1468
1469   procedure Fill (Cr : Cairo_Context);
1470   --  Cr: a cairo context
1471   --
1472   --  A drawing operator that fills the current path according to the
1473   --  current fill rule, (each sub-path is implicitly closed before being
1474   --  filled). After Fill, the current path will be cleared from
1475   --  the cairo context. See Set_Fill_Rule and Fill_Preserve.
1476
1477   procedure Fill_Preserve (Cr : Cairo_Context);
1478   --  Cr: a cairo context
1479   --
1480   --  A drawing operator that fills the current path according to the
1481   --  current fill rule, (each sub-path is implicitly closed before being
1482   --  filled). Unlike Fill, Fill_Preserve preserves the path within the
1483   --  cairo context.
1484   --
1485   --  See Set_Fill_Rule and Fill.
1486
1487   procedure Copy_Page (Cr : Cairo_Context);
1488   --  Cr: a cairo context
1489   --
1490   --  Emits the current page for backends that support multiple pages, but
1491   --  doesn't clear it, so, the contents of the current page will be retained
1492   --  for the next page too.  Use Show_Page if you want to get an
1493   --  empty page after the emission.
1494   --
1495   --  This is a convenience function that simply calls
1496   --  Cairo.Surface.Copy_Page on Cr's target.
1497
1498   procedure Show_Page (Cr : Cairo_Context);
1499   --  Cr: a cairo context
1500   --
1501   --  Emits and clears the current page for backends that support multiple
1502   --  pages.  Use Copy_Page if you don't want to clear the page.
1503   --
1504   --  This is a convenience function that simply calls
1505   --  Cairo.Surface.Show_Page on cr's target.
1506
1507   ------------------------
1508   -- Insideness testing --
1509   ------------------------
1510
1511   function In_Stroke
1512     (Cr   : Cairo_Context;
1513      X    : Gdouble;
1514      Y    : Gdouble)
1515      return Boolean;
1516   --  Cr: a cairo context
1517   --  X: X coordinate of the point to test
1518   --  Y: Y coordinate of the point to test
1519   --
1520   --  Tests whether the given point is inside the area that would be
1521   --  affected by a Stroke operation given the current path and
1522   --  stroking parameters. Surface dimensions and clipping are not taken
1523   --  into account.
1524   --
1525   --  See Stroke, Set_Line_Width, Set_Line_Join,
1526   --  Set_Line_Cap, Set_Dash, and Stroke_Preserve.
1527   --
1528   --  Return value: A non-zero value if the point is inside, or zero if
1529   --  outside.
1530
1531   function In_Fill
1532     (Cr   : Cairo_Context;
1533      X    : Gdouble;
1534      Y    : Gdouble)
1535      return Boolean;
1536   --  Cr: a cairo context
1537   --  X: X coordinate of the point to test
1538   --  Y: Y coordinate of the point to test
1539   --
1540   --  Tests whether the given point is inside the area that would be
1541   --  affected by a Fill operation given the current path and
1542   --  filling parameters. Surface dimensions and clipping are not taken
1543   --  into account.
1544   --
1545   --  See Fill, Set_Fill_Rule and Fill_Preserve.
1546   --
1547   --  Return value: A non-zero value if the point is inside, or zero if
1548   --  outside.
1549
1550   -------------------------
1551   -- Rectangular extents --
1552   -------------------------
1553
1554   procedure Stroke_Extents
1555     (Cr : Cairo_Context;
1556      X1 : access Gdouble;
1557      Y1 : access Gdouble;
1558      X2 : access Gdouble;
1559      Y2 : access Gdouble);
1560   --  Cr: a cairo context
1561   --  X1: left of the resulting extents
1562   --  Y1: top of the resulting extents
1563   --  X2: right of the resulting extents
1564   --  Y2: bottom of the resulting extents
1565   --
1566   --  Computes a bounding box in user coordinates covering the area that
1567   --  would be affected, (the "inked" area), by a Stroke
1568   --  operation given the current path and stroke parameters.
1569   --  If the current path is empty, returns an empty rectangle ((0,0), (0,0)).
1570   --  Surface dimensions and clipping are not taken into account.
1571   --
1572   --  Note that if the line width is set to exactly zero, then
1573   --  Stroke_Extents will return an empty rectangle. Contrast with
1574   --  Path_Extents which can be used to compute the non-empty
1575   --  bounds as the line width approaches zero.
1576   --
1577   --  Note that Stroke_Extents must necessarily do more work to
1578   --  compute the precise inked areas in light of the stroke parameters,
1579   --  so Path_Extents may be more desirable for sake of
1580   --  performance if non-inked path extents are desired.
1581   --
1582   --  See Stroke, Set_Line_Width, Set_Line_Join, Set_Line_Cap, Set_Dash, and
1583   --  Stroke_Preserve.
1584
1585   procedure Fill_Extents
1586     (Cr : Cairo_Context;
1587      X1 : access Gdouble;
1588      Y1 : access Gdouble;
1589      X2 : access Gdouble;
1590      Y2 : access Gdouble);
1591   --  Cr: a cairo context
1592   --  X1: left of the resulting extents
1593   --  Y1: top of the resulting extents
1594   --  X2: right of the resulting extents
1595   --  Y2: bottom of the resulting extents
1596   --
1597   --  Computes a bounding box in user coordinates covering the area that
1598   --  would be affected, (the "inked" area), by a Fill operation
1599   --  given the current path and fill parameters. If the current path is
1600   --  empty, returns an empty rectangle ((0,0), (0,0)). Surface
1601   --  dimensions and clipping are not taken into account.
1602   --
1603   --  Contrast with Path_Extents, which is similar, but returns
1604   --  non-zero extents for some paths with no inked area, (such as a
1605   --  simple line segment).
1606   --
1607   --  Note that Fill_Extents must necessarily do more work to
1608   --  compute the precise inked areas in light of the fill rule, so
1609   --  Path_Extents may be more desirable for sake of performance
1610   --  if the non-inked path extents are desired.
1611   --
1612   --  See Fill, Set_Fill_Rule and Fill_Preserve.
1613
1614   --------------
1615   -- Clipping --
1616   --------------
1617
1618   procedure Reset_Clip (Cr : Cairo_Context);
1619   --  Cr: a cairo context
1620   --
1621   --  Reset the current clip region to its original, unrestricted
1622   --  state. That is, set the clip region to an infinitely large shape
1623   --  containing the target surface. Equivalently, if infinity is too
1624   --  hard to grasp, one can imagine the clip region being reset to the
1625   --  exact bounds of the target surface.
1626   --
1627   --  Note that code meant to be reusable should not call
1628   --  Reset_Clip as it will cause results unexpected by higher-level code
1629   --  which calls Clip. Consider using Save and Restore around Clip as a more
1630   --  robust means of temporarily restricting the clip region.
1631
1632   procedure Clip (Cr : Cairo_Context);
1633   --  Cr: a cairo context
1634   --
1635   --  Establishes a new clip region by intersecting the current clip
1636   --  region with the current path as it would be filled by Fill
1637   --  and according to the current fill rule (see Set_Fill_Rule).
1638   --
1639   --  After Clip, the current path will be cleared from the cairo
1640   --  context.
1641   --
1642   --  The current clip region affects all drawing operations by
1643   --  effectively masking out any changes to the surface that are outside
1644   --  the current clip region.
1645   --
1646   --  Calling Clip can only make the clip region smaller, never
1647   --  larger. But the current clip is part of the graphics state, so a
1648   --  temporary restriction of the clip region can be achieved by
1649   --  calling Clip within a Save/Restore
1650   --  pair. The only other means of increasing the size of the clip
1651   --  region is Reset_Clip.
1652
1653   procedure Clip_Preserve (Cr : Cairo_Context);
1654   --  Cr: a cairo context
1655   --
1656   --  Establishes a new clip region by intersecting the current clip
1657   --  region with the current path as it would be filled by Fill
1658   --  and according to the current fill rule (see Set_Fill_Rule).
1659   --
1660   --  Unlike Clip, Clip_Preserve preserves the path within
1661   --  the cairo context.
1662   --
1663   --  The current clip region affects all drawing operations by
1664   --  effectively masking out any changes to the surface that are outside
1665   --  the current clip region.
1666   --
1667   --  Calling Clip_Preserve can only make the clip region smaller, never
1668   --  larger. But the current clip is part of the graphics state, so a
1669   --  temporary restriction of the clip region can be achieved by
1670   --  calling Clip_Preserve within a Save/Restore
1671   --  pair. The only other means of increasing the size of the clip
1672   --  region is Reset_Clip.
1673
1674   procedure Clip_Extents
1675     (Cr : Cairo_Context;
1676      X1 : out Gdouble;
1677      Y1 : out Gdouble;
1678      X2 : out Gdouble;
1679      Y2 : out Gdouble);
1680   --  Cr: a cairo context
1681   --  X1: left of the resulting extents
1682   --  Y1: top of the resulting extents
1683   --  X2: right of the resulting extents
1684   --  Y2: bottom of the resulting extents
1685   --
1686   --  Computes a bounding box in user coordinates covering the area inside the
1687   --  current clip.
1688   --
1689   --  Since: 1.4
1690
1691   type Cairo_Rectangle is record
1692      X      : aliased Gdouble;
1693      Y      : aliased Gdouble;
1694      Width  : aliased Gdouble;
1695      Height : aliased Gdouble;
1696   end record;
1697   --  X: X coordinate of the left side of the rectangle
1698   --  Y: Y coordinate of the the top side of the rectangle
1699   --  Width: Width of the rectangle
1700   --  Height: Height of the rectangle
1701   --
1702   --  A data structure for holding a rectangle.
1703   --
1704   --  Since: 1.4
1705
1706   type Cairo_Rectangle_Array is array (Natural) of Cairo_Rectangle;
1707   type Cairo_Rectangle_Array_Access is access all Cairo_Rectangle_Array;
1708
1709   type Cairo_Rectangle_List is record
1710      Status         : aliased Cairo_Status;
1711      Rectangles     : Cairo_Rectangle_Array_Access;
1712      --  Warning: for efficiency reasons, Rectangles is a direct mapping to
1713      --  the C structure. Therefore, there is no bounds checking on this
1714      --  array, user needs to make sure only to access data between indexes 0
1715      --  and Num_Rectanges-1.
1716      Num_Rectangles : aliased Gint;
1717   end record;
1718   --  Status: Error Status of the rectangle list
1719   --  Rectangles: Array containing the Rectangles
1720   --  Num_Rectangles: Number of rectangles in this list
1721   --
1722   --  A data structure for holding a Dynamically allocated
1723   --  array of rectangles.
1724   --
1725   --  Since: 1.4
1726   pragma Convention (C_Pass_By_Copy, Cairo_Rectangle_List);
1727
1728   type Cairo_Rectangle_List_Access is access all Cairo_Rectangle_List;
1729
1730   function Copy_Clip_Rectangle_List
1731     (Cr   : Cairo_Context)
1732      return Cairo_Rectangle_List_Access;
1733   --  Cr: a cairo context
1734   --
1735   --  Gets the current clip region as a list of rectangles in user
1736   --  coordinates.
1737   --  Never returns NULL.
1738   --
1739   --  The status in the list may be Cairo_Status_Clip_Not_Representable to
1740   --  indicate that the clip region cannot be represented as a list of
1741   --  user-space rectangles. The status may have other values to indicate
1742   --  other errors.
1743   --
1744   --  Returns: the current clip region as a list of rectangles in user
1745   --  coordinates,
1746   --  which should be destroyed using Rectangle_List_Destroy.
1747   --
1748   --  Since: 1.4
1749
1750   procedure Rectangle_List_Destroy
1751     (Rectangle_List : access Cairo_Rectangle_List);
1752   --  Rectangle_List: a rectangle list, as obtained from Copy_Clip_Rectangles
1753   --
1754   --  Unconditionally frees Rectangle_List and all associated
1755   --  references. After this call, the Rectangle_List pointer must not
1756   --  be dereferenced.
1757   --
1758   --  Since: 1.4
1759
1760   -------------------------
1761   -- Font/Text functions --
1762   -------------------------
1763
1764   type Cairo_Scaled_Font is private;
1765   --  A Cairo_Scaled_Font is a font scaled to a particular size and device
1766   --  resolution. A Cairo_Scaled_Font is most useful for low-level font
1767   --  usage where a library or application wants to cache a reference
1768   --  to a scaled font to speed up the computation of metrics.
1769   --
1770   --  There are various types of scaled fonts, depending on the font backend
1771   --  they use. The type of a scaled font can be queried using
1772   --  Cairo.Scaled_Font.Get_Type.
1773   --
1774   --  Memory management of Cairo_Scaled_Font is done with
1775   --  Cairo.Scaled_Font.Reference and Cairo.Scaled_Font.Destroy.
1776
1777   type Cairo_Font_Face is private;
1778   --  A Cairo_Font_Face specifies all aspects of a font other
1779   --  than the size or font matrix (a font matrix is used to distort
1780   --  a font by sheering it or scaling it unequally in the two
1781   --  directions) . A font face can be set on a Cairo_Context by using
1782   --  Set_Font_Face; the size and font matrix are set with
1783   --  Set_Font_Size and Set_Font_Matrix.
1784   --
1785   --  There are various types of font faces, depending on the font backend
1786   --  they use. The type of a font face can be queried using
1787   --  Cairo.Font_Face.Get_Type.
1788   --
1789   --  Memory management of Cairo_Font_Face is done with
1790   --  Cairo.Font_Face.Reference and Cairo.Font_Face.Destroy.
1791   --
1792   --  The Cairo_glyph structure holds information about a single glyph when
1793   --  drawing or measuring text. A font is (in simple terms) a collection of
1794   --  shapes used to draw text. A glyph is one of these shapes. There can be
1795   --  multiple glyphs for a single character (alternates to be used in
1796   --  different contexts, for example), or a glyph can be a ligature of
1797   --  multiple characters. Cairo doesn't expose any way of converting input
1798   --  text into glyphs, so in order to use the Cairo interfaces that take
1799   --  arrays of glyphs, you must directly access the appropriate underlying
1800   --  font system.
1801   --
1802   --  Note that the offsets given by X and Y are not cumulative. When
1803   --  drawing or measuring text, each glyph is individually positioned
1804   --  with respect to the overall origin
1805   type Cairo_Glyph is record
1806      Index : aliased Gulong;
1807      --  Glyph Index in the font. The exact interpretation of the
1808      --  glyph index depends on the font technology being used.
1809
1810      X     : aliased Gdouble;
1811      --  The offset in the X direction between the origin used for
1812      --  drawing or measuring the string and the origin of this glyph.
1813
1814      Y     : aliased Gdouble;
1815      --  The offset in the Y direction between the origin used for drawing or
1816      --  measuring the string and the origin of this glyph.
1817   end record;
1818   pragma Convention (C_Pass_By_Copy, Cairo_Glyph);
1819
1820   type Cairo_Text_Cluster is record
1821      Num_Bytes  : aliased Gint;
1822      --  The number of bytes of UTF-8 text covered by cluster
1823
1824      Num_Glyphs : aliased Gint;
1825      --  The number of glyphs covered by cluster
1826   end record;
1827   --  The Cairo_text_cluster structure holds information about a single text
1828   --  cluster. A text cluster is a minimal mapping of some glyphs
1829   --  corresponding to some UTF-8 text.
1830   --
1831   --  For a cluster to be valid, both num_bytes and num_glyphs should
1832   --  be non-negative, and at least one should be non-zero.
1833   --  Note that clusters with zero glyphs are not as well supported as
1834   --  normal clusters.  For example, PDF rendering applications typically
1835   --  ignore those clusters when PDF text is being selected.
1836   --
1837   --  See Show_Text_Glyphs for how clusters are used in advanced
1838   --  text operations.
1839   --
1840   --  Since: 1.8
1841   pragma Convention (C_Pass_By_Copy, Cairo_Text_Cluster);
1842
1843   subtype Cairo_Text_Cluster_Flags is Guint;
1844   --  Specifies properties of a text cluster mapping.
1845   --
1846   --  Since: 1.8
1847
1848   Cairo_Text_Cluster_Flag_Backward : constant Cairo_Text_Cluster_Flags := 1;
1849   --  The clusters in the cluster array map to glyphs in the glyph array from
1850   --  end to start.
1851
1852   type Cairo_Text_Extents is record
1853      X_Bearing : aliased Gdouble;
1854      --  The horizontal distance from the origin to the
1855      --  leftmost part of the glyphs as drawn. Positive if the
1856      --  glyphs lie entirely to the right of the origin.
1857
1858      Y_Bearing : aliased Gdouble;
1859      --  The vertical distance from the origin to the
1860      --  topmost part of the glyphs as drawn. Positive only if the
1861      --  glyphs lie completely below the origin; will usually be
1862      --  negative.
1863
1864      Width     : aliased Gdouble;
1865      --  Width of the glyphs as drawn
1866
1867      Height    : aliased Gdouble;
1868      --  Height of the glyphs as drawn
1869
1870      X_Advance : aliased Gdouble;
1871      --  Distance to advance in the X direction after drawing these glyphs
1872
1873      Y_Advance : aliased Gdouble;
1874      --  Distance to advance in the Y direction
1875      --  after drawing these glyphs. Will typically be zero except
1876      --  for vertical text layout as found in East-Asian languages.
1877   end record;
1878   --  The Cairo_text_extents structure stores the extents of a single glyph
1879   --  or a string of glyphs in user-space coordinates. Because text extents
1880   --  are in user-space coordinates, they are mostly, but not entirely,
1881   --  independent of the current transformation matrix. If you call
1882   --  Scale (Cr, 2.0, 2.0), text will be drawn twice as big, but the reported
1883   --  text extents will not be doubled. They will change slightly due to
1884   --  hinting (so you can't assume that metrics are independent of the
1885   --  transformation matrix), but otherwise will remain unchanged.
1886   pragma Convention (C_Pass_By_Copy, Cairo_Text_Extents);
1887
1888   type Cairo_Font_Extents is record
1889      Ascent        : aliased Gdouble;
1890      --  The distance that the font extends above the baseline.
1891      --  Note that this is not always exactly equal to the maximum
1892      --  of the extents of all the glyphs in the font, but rather
1893      --  is picked to express the font designer's intent as to
1894      --  how the font should align with elements above it.
1895
1896      Descent       : aliased Gdouble;
1897      --  The distance that the font extends below the baseline.
1898      --  This value is positive for typical fonts that include
1899      --  portions below the baseline. Note that this is not always
1900      --  exactly equal to the maximum of the extents of all the
1901      --  glyphs in the font, but rather is picked to express the
1902      --  font designer's intent as to how the the font should
1903      --  align with elements below it.
1904
1905      Height        : aliased Gdouble;
1906      --  The recommended vertical distance between baselines when
1907      --  setting consecutive lines of text with the font. This
1908      --  is greater than ascent+descent by a
1909      --  quantity known as the line spacing or external leading. When space is
1910      --  at a premium, most fonts can be set with only a distance of
1911      --  ascent+descent between lines.
1912
1913      Max_X_Advance : aliased Gdouble;
1914      --  The maximum distance in the X direction that
1915      --  the the origin is advanced for any glyph in the font.
1916
1917      Max_Y_Advance : aliased Gdouble;
1918      --  The maximum distance in the Y direction that
1919      --  the the origin is advanced for any glyph in the font.
1920      --  this will be zero for normal fonts used for horizontal
1921      --  writing. (The scripts of East Asia are sometimes written
1922      --  vertically.)
1923   end record;
1924   --  The Cairo_font_extents structure stores metric information for
1925   --  a font. Values are given in the current user-space coordinate
1926   --  system.
1927   --
1928   --  Because font metrics are in user-space coordinates, they are
1929   --  mostly, but not entirely, independent of the current transformation
1930   --  matrix. If you call Scale (Cr, 2.0, 2.0), text will be drawn twice as
1931   --  big, but the reported text extents will not be doubled. They will
1932   --  change slightly due to hinting (so you can't assume that metrics are
1933   --  independent of the transformation matrix), but otherwise will remain
1934   --  unchanged.
1935   pragma Convention (C_Pass_By_Copy, Cairo_Font_Extents);
1936
1937   type Cairo_Font_Slant is (
1938                             Cairo_Font_Slant_Normal,
1939                             Cairo_Font_Slant_Italic,
1940                             Cairo_Font_Slant_Oblique);
1941   --  Specifies variants of a font face based on their slant.
1942   pragma Convention (C, Cairo_Font_Slant);
1943
1944   type Cairo_Font_Weight is (
1945                              Cairo_Font_Weight_Normal,
1946                              Cairo_Font_Weight_Bold);
1947   --  Specifies variants of a font face based on their weight.
1948   pragma Convention (C, Cairo_Font_Weight);
1949
1950   type Cairo_Subpixel_Order is
1951     (Cairo_Subpixel_Order_Default,
1952      --  Use the default subpixel order for the target device
1953
1954      Cairo_Subpixel_Order_Rgb,
1955      --  Subpixel elements are arranged horizontally with red at the left
1956
1957      Cairo_Subpixel_Order_Bgr,
1958      --  Subpixel elements are arranged horizontally with blue at the left
1959
1960      Cairo_Subpixel_Order_Vrgb,
1961      --  Subpixel elements are arranged vertically with red at the top
1962
1963      Cairo_Subpixel_Order_Vbgr
1964      --  Subpixel elements are arranged vertically with blue at the top
1965     );
1966   --  The subpixel order specifies the order of color elements within
1967   --  each pixel on the display device when rendering with an
1968   --  antialiasing mode of CAIRO_ANTIALIAS_SUBPIXEL.
1969   pragma Convention (C, Cairo_Subpixel_Order);
1970
1971   type Cairo_Hint_Style is
1972     (Cairo_Hint_Style_Default,
1973      --  Use the default hint style for font backend and target device
1974
1975      Cairo_Hint_Style_None,
1976      --  Do not hint outlines
1977
1978      Cairo_Hint_Style_Slight,
1979      --  Hint outlines slightly to improve contrast while retaining good
1980      --  fidelity to the original shapes.
1981
1982      Cairo_Hint_Style_Medium,
1983      --  Hint outlines with medium strength giving a compromise between
1984      --  fidelity to the original shapes and contrast
1985
1986      Cairo_Hint_Style_Full
1987      --  Hint outlines to maximize contrast
1988     );
1989   --  Specifies the type of hinting to do on font outlines. Hinting
1990   --  is the process of fitting outlines to the pixel grid in order
1991   --  to improve the appearance of the result. Since hinting outlines
1992   --  involves distorting them, it also reduces the faithfulness
1993   --  to the original outline shapes. Not all of the outline hinting
1994   --  styles are supported by all font backends.
1995   --
1996   --  New entries may be added in future versions.
1997   pragma Convention (C, Cairo_Hint_Style);
1998
1999   type Cairo_Hint_Metrics is
2000     (Cairo_Hint_Metrics_Default,
2001      --  Hint metrics in the default manner for the font backend and target
2002      --  device
2003
2004      Cairo_Hint_Metrics_Off,
2005      --  Do not hint font metrics
2006
2007      Cairo_Hint_Metrics_On
2008      --  Hint font metrics
2009     );
2010   --  Specifies whether to hint font metrics; hinting font metrics
2011   --  means quantizing them so that they are integer values in
2012   --  device space. Doing this improves the consistency of
2013   --  letter and line spacing, however it also means that text
2014   --  will be laid out differently at different zoom factors.
2015   pragma Convention (C, Cairo_Hint_Metrics);
2016
2017   type Cairo_Font_Options is private;
2018   --  An opaque structure holding all options that are used when
2019   --  rendering fonts.
2020   --
2021   --  Individual features of a Cairo_Font_Options can be set or
2022   --  accessed using functions named
2023   --  Cairo.Font_Options.Set_<feature_Name> and
2024   --  Cairo.Font_Options.Get_<feature_Name>, like
2025   --  Cairo.Font_Options.Set_Antialias and
2026   --  Cairo.Font_Options.Get_Antialias.
2027   --
2028   --  New features may be added to a Cairo_font_options in the
2029   --  future.  For this reason, Cairo.Font_Options.Copy,
2030   --  Cairo.Font_Options.Equal, Cairo.Font_Options.Merge, and
2031   --  Cairo.Font_Options.Hash should be used to copy, check
2032   --  for equality, merge, or compute a hash value of
2033   --  Cairo_Font_Options objects.
2034
2035   --  This interface is for dealing with text as text, not caring about the
2036   --  font object inside the the Cairo_Context.
2037
2038   procedure Select_Font_Face
2039     (Cr     : Cairo_Context;
2040      Family : String;
2041      Slant  : Cairo_Font_Slant;
2042      Weight : Cairo_Font_Weight);
2043   --  Cr: a Cairo_Context
2044   --  Family: a font Family name, encoded in UTF-8
2045   --  Slant: the Slant for the font
2046   --  Weight: the Weight for the font
2047   --
2048   --  Note: The Select_Font_Face function call is part of what
2049   --  the cairo designers call the "toy" text API. It is convenient for
2050   --  short demos and simple programs, but it is not expected to be
2051   --  adequate for serious text-using applications.
2052   --
2053   --  Selects a family and style of font from a simplified description as
2054   --  a family name, slant and weight. Cairo provides no operation to
2055   --  list available family names on the system (this is a "toy",
2056   --  remember), but the standard CSS2 generic family names, ("serif",
2057   --  "sans-serif", "cursive", "fantasy", "monospace"), are likely to
2058   --  work as expected.
2059   --
2060   --  It is expected that most applications will need to use a more
2061   --  comprehensive font handling and text layout library, (for example,
2062   --  pango), in conjunction with cairo.
2063   --
2064   --  If text is drawn without a call to Select_Font_Face, (nor
2065   --  Set_Font_Face nor Set_Scaled_Font), the default
2066   --  family is platform-specific, but is essentially "sans-serif".
2067   --  Default slant is Cairo_Font_Slant_Normal, and default weight is
2068   --  Cairo_Font_Weight_Normal.
2069   --
2070   --  This function is equivalent to a call to
2071   --  Cairo.Font_Face.Toy_Font_Face_Create followed by Set_Font_Face.
2072
2073   procedure Set_Font_Size (Cr : Cairo_Context; Size : Gdouble);
2074   --  Cr: a Cairo_Context
2075   --  Size: the new font Size, in user space units
2076   --
2077   --  Sets the current font matrix to a scale by a factor of size, replacing
2078   --  any font matrix previously set with Set_Font_Size or
2079   --  Set_Font_Matrix. This results in a font size of size user space
2080   --  units. (More precisely, this matrix will result in the font's
2081   --  em-square being a size by size square in user space.)
2082   --
2083   --  If text is drawn without a call to Set_Font_Size, (nor Set_Font_Matrix
2084   --  nor Set_Scaled_Font), the default font size is 10.0.
2085
2086   procedure Set_Font_Matrix
2087     (Cr     : Cairo_Context;
2088      Matrix : access Cairo_Matrix);
2089   --  Cr: a Cairo_Context
2090   --  Matrix: a Cairo_Matrix describing a transform to be applied to
2091   --  the current font.
2092   --
2093   --  Sets the current font matrix to matrix. The font matrix gives a
2094   --  transformation from the design space of the font (in this space,
2095   --  the em-square is 1 unit by 1 unit) to user space. Normally, a
2096   --  simple scale is used (see Set_Font_Size), but a more
2097   --  complex font matrix can be used to shear the font
2098   --  or stretch it unequally along the two axes
2099
2100   procedure Get_Font_Matrix
2101     (Cr     : Cairo_Context;
2102      Matrix : access Cairo_Matrix);
2103   --  Cr: a Cairo_Context
2104   --  Matrix: return value for the Matrix
2105   --
2106   --  Stores the current font matrix into matrix. See Set_Font_Matrix.
2107
2108   procedure Set_Font_Options
2109     (Cr      : Cairo_Context;
2110      Options : Cairo_Font_Options);
2111   --  Cr: a Cairo_Context
2112   --  Options: font Options to use
2113   --
2114   --  Sets a set of custom font rendering options for the Cairo_Context.
2115   --  Rendering options are derived by merging these options with the
2116   --  options derived from underlying surface; if the value in options
2117   --  has a default value (like Cairo_Antialias_Default), then the value
2118   --  from the surface is used.
2119
2120   procedure Get_Font_Options
2121     (Cr      : Cairo_Context;
2122      Options : Cairo_Font_Options);
2123   --  Cr: a Cairo_Context
2124   --  Options: a Cairo_Font_Options object into which to store
2125   --    the retrieved options. All existing values are overwritten
2126   --
2127   --  Retrieves font rendering options set via Set_Font_Options.
2128   --  Note that the returned options do not include any options derived
2129   --  from the underlying surface; they are literally the options
2130   --  passed to Set_Font_Options.
2131
2132   procedure Set_Font_Face
2133     (Cr        : Cairo_Context;
2134      Font_Face : Cairo_Font_Face);
2135   --  Cr: a Cairo_Context
2136   --  Font_Face: a Cairo_Font_Face, or Null_Font_Face to restore to the
2137   --  default font
2138   --
2139   --  Replaces the current Cairo_Font_Face object in the Cairo_Context with
2140   --  font_face. The replaced font face in the Cairo_Context will be
2141   --  destroyed if there are no other references to it.
2142
2143   function Get_Font_Face (Cr : Cairo_Context) return Cairo_Font_Face;
2144   --  Cr: a Cairo_Context
2145   --
2146   --  Gets the current font face for a Cairo_Context.
2147   --
2148   --  Return value: the current font face.  This object is owned by
2149   --  cairo. To keep a reference to it, you must call
2150   --  Cairo.Font_Face.Reference.
2151   --
2152   --  This function never returns Null_Font_Face. If memory cannot be
2153   --  allocated, a special "nil" Cairo_Font_Face object will be returned on
2154   --  which Cairo.Font_Face.Status returns Cairo_Status_No_Memory. Using this
2155   --  nil object will cause its error state to propagate to other objects it
2156   --  is passed to, (for example, calling Set_Font_Face with a nil font
2157   --  will trigger an error that will shutdown the Cairo_Context object).
2158
2159   procedure Set_Scaled_Font
2160     (Cr          : Cairo_Context;
2161      Scaled_Font : access Cairo_Scaled_Font);
2162   --  Cr: a Cairo_Context
2163   --  Scaled_Font: a Cairo_Scaled_Font
2164   --
2165   --  Replaces the current font face, font matrix, and font options in
2166   --  the Cairo_Context with those of the Cairo_Scaled_Font.  Except for
2167   --  some translation, the current CTM of the Cairo_Context should be the
2168   --  same as that of the Cairo_Scaled_Font, which can be accessed
2169   --  using Cairo.Scaled_Font.Get_Ctm.
2170   --
2171   --  Since: 1.2
2172
2173   function Get_Scaled_Font (Cr : Cairo_Context) return Cairo_Scaled_Font;
2174   --  Cr: a Cairo_Context
2175   --
2176   --  Gets the current scaled font for a Cairo_Context.
2177   --
2178   --  Return value: the current scaled font. This object is owned by
2179   --  cairo. To keep a reference to it, you must call
2180   --  Cairo.Scaled_Font.Reference.
2181   --
2182   --  This function never returns Null_Font_Face. If memory cannot be
2183   --  allocated, a special "nil" Cairo_Scaled_Font object will be returned on
2184   --  which Cairo.Font_Face.Status returns Cairo_Status_No_Memory. Using this
2185   --  nil object will cause its error state to propagate to other objects it
2186   --  is passed to, (for example, calling Set_Font_Face with a nil font
2187   --  will trigger an error that will shutdown the Cairo_Context object).
2188   --
2189   --  Since: 1.4
2190
2191   procedure Show_Text
2192     (Cr   : Cairo_Context;
2193      Utf8 : String);
2194   --  Cr: a cairo context
2195   --  Utf8: a NUL-terminated string of text encoded in UTF-8, or Null_Ptr
2196   --
2197   --  A drawing operator that generates the shape from a string of UTF-8
2198   --  characters, rendered according to the current Font_Face, Font_Size
2199   --  (Font_Matrix), and Font_Options.
2200   --
2201   --  This function first computes a set of glyphs for the string of
2202   --  text. The first glyph is placed so that its origin is at the
2203   --  current point. The origin of each subsequent glyph is offset from
2204   --  that of the previous glyph by the advance values of the previous
2205   --  glyph.
2206   --
2207   --  After this call the current point is moved to the origin of where
2208   --  the next glyph would be placed in this same progression. That is,
2209   --  the current point will be at the origin of the final glyph offset
2210   --  by its advance values. This allows for easy display of a single
2211   --  logical string with multiple calls to Show_Text.
2212   --
2213   --  Note: The Show_Text function call is part of what the cairo
2214   --  designers call the "toy" text API. It is convenient for short demos
2215   --  and simple programs, but it is not expected to be adequate for
2216   --  serious text-using applications. See Show_Glyphs for the
2217   --  "real" text display API in cairo.
2218
2219   procedure Show_Glyphs
2220     (Cr         : Cairo_Context;
2221      Glyphs     : access Cairo_Glyph;
2222      Num_Glyphs : Gint);
2223   --  Cr: a cairo context
2224   --  Glyphs: array of Glyphs to show
2225   --  Num_Glyphs: number of glyphs to show
2226   --
2227   --  A drawing operator that generates the shape from an array of glyphs,
2228   --  rendered according to the current font face, font size
2229   --  (font matrix), and font options.
2230
2231   procedure Text_Path
2232     (Cr   : Cairo_Context;
2233      Utf8 : String);
2234   --  Cr: a cairo context
2235   --  Utf8: a NUL-terminated string of text encoded in UTF-8, or Null_Ptr
2236   --
2237   --  Adds closed paths for text to the current path.  The generated
2238   --  path if filled, achieves an effect similar to that of
2239   --  Show_Text.
2240   --
2241   --  Text conversion and positioning is done similar to Show_Text.
2242   --
2243   --  Like Show_Text, After this call the current point is
2244   --  moved to the origin of where the next glyph would be placed in
2245   --  this same progression.  That is, the current point will be at
2246   --  the origin of the final glyph offset by its advance values.
2247   --  This allows for chaining multiple calls to to Cairo_Text_Path
2248   --  without having to set current point in between.
2249   --
2250   --  Note: The Text_Path function call is part of what the cairo
2251   --  designers call the "toy" text API. It is convenient for short demos
2252   --  and simple programs, but it is not expected to be adequate for
2253   --  serious text-using applications. See Glyph_Path for the
2254   --  "real" text path API in cairo.
2255
2256   procedure Text_Extents
2257     (Cr      : Cairo_Context;
2258      Utf8    : Interfaces.C.Strings.chars_ptr;
2259      Extents : access Cairo_Text_Extents);
2260   --  Cr: a Cairo_Context
2261   --  Utf8: a NUL-terminated string of text encoded in UTF-8, or Null_Ptr
2262   --  Extents: a Cairo_Text_Extents object into which the results
2263   --  will be stored
2264   --
2265   --  Gets the extents for a string of text. The extents describe a
2266   --  user-space rectangle that encloses the "inked" portion of the text,
2267   --  (as it would be drawn by Show_Text). Additionally, the
2268   --  x_advance and y_advance values indicate the amount by which the
2269   --  current point would be advanced by Cairo_Show_Text.
2270   --
2271   --  Note that whitespace characters do not directly contribute to the
2272   --  size of the rectangle (extents.width and extents.height). They do
2273   --  contribute indirectly by changing the position of non-whitespace
2274   --  characters. In particular, trailing whitespace characters are
2275   --  likely to not affect the size of the rectangle, though they will
2276   --  affect the x_advance and y_advance values.
2277
2278   procedure Glyph_Extents
2279     (Cr         : Cairo_Context;
2280      Glyphs     : access Cairo_Glyph;
2281      Num_Glyphs : Gint;
2282      Extents    : access Cairo_Text_Extents);
2283   --  Cr: a Cairo_Context
2284   --  Glyphs: an array of Cairo_Glyph objects
2285   --  Num_Glyphs: the number of elements in glyphs
2286   --  Extents: a Cairo_Text_Extents object into which the results
2287   --  will be stored
2288   --
2289   --  Gets the extents for an array of glyphs. The extents describe a
2290   --  user-space rectangle that encloses the "inked" portion of the
2291   --  glyphs, (as they would be drawn by Show_Glyphs).
2292   --  Additionally, the X_Advance and Y_Advance values indicate the
2293   --  amount by which the current point would be advanced by
2294   --  Show_Glyphs.
2295   --
2296   --  Note that whitespace glyphs do not contribute to the size of the
2297   --  rectangle (Extents.Width and Extents.Height).
2298
2299   procedure Font_Extents
2300     (Cr      : Cairo_Context;
2301      Extents : access Cairo_Font_Extents);
2302   --  Cr: a Cairo_Context
2303   --  Extents: a Cairo_Font_Extents object into which the results
2304   --  will be stored.
2305   --
2306   --  Gets the font extents for the currently selected font.
2307
2308   type Cairo_Font_Type is
2309     (Cairo_Font_Type_Toy,
2310      --  The font was created using cairo's toy font api (Since: 1.8)
2311
2312      Cairo_Font_Type_Ft,
2313      --  The font is of type FreeType
2314
2315      Cairo_Font_Type_Win32,
2316      --  The font is of type Win32
2317
2318      Cairo_Font_Type_Quartz,
2319      --  The font is of type Quartz (Since: 1.6)
2320
2321      Cairo_Font_Type_User
2322      --  The font was create using cairo's user font api
2323     );
2324   --  Cairo_font_type is used to describe the type of a given font
2325   --  face or scaled font. The font types are also known as "font
2326   --  backends" within Cairo.
2327   --
2328   --  The type of a font face is determined by the function used to
2329   --  create it, which will generally be of the form
2330   --  <type>_Font_Face_Create. The font face type
2331   --  can be queried
2332   --  with Cairo.Font_Face.Get_Type
2333   --
2334   --  The various Cairo_Font_Face functions can be used with a font face
2335   --  of any type.
2336   --
2337   --  The type of a scaled font is determined by the type of the font
2338   --  face passed to Cairo.Scaled_Font.Create. The scaled font type can
2339   --  be queried with Cairo.Scaled_Font.Get_Type
2340   --
2341   --  The various Cairo_scaled_font functions can be used with scaled
2342   --  fonts of any type, but some font backends also provide
2343   --  type-specific functions that must only be called with a scaled font
2344   --  of the appropriate type. These functions have names that begin with
2345   --  <type>_Scaled_Font such as Ft_Scaled_Font_Lock_Face.
2346   --
2347   --  The behavior of calling a type-specific function with a scaled font
2348   --  of the wrong type is undefined.
2349   --
2350   --  New entries may be added in future versions.
2351   --
2352   --  Since: 1.2
2353   pragma Convention (C, Cairo_Font_Type);
2354
2355   ---------------------
2356   -- Query functions --
2357   ---------------------
2358
2359   function Get_Operator (Cr : Cairo_Context) return Cairo_Operator;
2360   --  Cr: a cairo context
2361   --
2362   --  Gets the current compositing operator for a cairo context.
2363   --
2364   --  Return value: the current compositing operator.
2365
2366   function Get_Source (Cr : Cairo_Context) return Cairo_Pattern;
2367   --  Cr: a cairo context
2368   --
2369   --  Gets the current source pattern for Cr.
2370   --
2371   --  Return value: the current source pattern. This object is owned by
2372   --  cairo. To keep a reference to it, you must call
2373   --  Cairo.Pattern.Reference.
2374
2375   function Get_Tolerance (Cr : Cairo_Context) return Gdouble;
2376   --  Cr: a cairo context
2377   --
2378   --  Gets the current tolerance value, as set by Set_Tolerance.
2379   --
2380   --  Return value: the current tolerance value.
2381
2382   function Get_Antialias (Cr : Cairo_Context) return Cairo_Antialias;
2383   --  Cr: a cairo context
2384   --
2385   --  Gets the current shape antialiasing mode, as set by Set_Antialias.
2386   --
2387   --  Return value: the current shape antialiasing mode.
2388
2389   function Has_Current_Point (Cr : Cairo_Context) return Boolean;
2390   --  Cr: a cairo context
2391   --
2392   --  Returns whether a current point is defined on the current path.
2393   --  See Get_Current_Point for details on the current point.
2394   --
2395   --  Return value: whether a current point is defined.
2396   --
2397   --  Since: 1.6
2398
2399   procedure Get_Current_Point
2400     (Cr : Cairo_Context;
2401      X  : access Gdouble;
2402      Y  : access Gdouble);
2403   --  Cr: a cairo context
2404   --  X: return value for X coordinate of the current point
2405   --  Y: return value for Y coordinate of the current point
2406   --
2407   --  Gets the current point of the current path, which is
2408   --  conceptually the final point reached by the path so far.
2409   --
2410   --  The current point is returned in the user-space coordinate
2411   --  system. If there is no defined current point or if cr is in an
2412   --  error status, X and Y will both be set to 0.0. It is possible to
2413   --  check this in advance with Has_Current_Point.
2414   --
2415   --  Most path construction functions alter the current point. See the
2416   --  following for details on how they affect the current point:
2417   --  New_Path, New_Sub_Path, Append_Path, Close_Path, Move_To, Line_To,
2418   --  Curve_To, Rel_Move_To, Rel_Line_To, Rel_Curve_To, Arc, Arc_Negative,
2419   --  Rectangle, Text_Path, Glyph_Path, Stroke_To_Path.
2420   --
2421   --  Some functions use and alter the current point but do not otherwise
2422   --  change current path: Show_Text.
2423   --
2424   --  Some functions unset the current path and as a result, current point:
2425   --  Fill, Stroke.
2426
2427   function Get_Fill_Rule (Cr : Cairo_Context) return Cairo_Fill_Rule;
2428   --  Cr: a cairo context
2429   --
2430   --  Gets the current fill rule, as set by Set_Fill_Rule.
2431   --
2432   --  Return value: the current fill rule.
2433
2434   function Get_Line_Width (Cr : Cairo_Context) return Gdouble;
2435   --  Cr: a cairo context
2436   --
2437   --  This function returns the current line width value exactly as set by
2438   --  Set_Line_Width. Note that the value is unchanged even if
2439   --  the CTM has changed between the calls to Set_Line_Width and
2440   --  Get_Line_Width.
2441   --
2442   --  Return value: the current line width.
2443
2444   function Get_Line_Cap (Cr : Cairo_Context) return Cairo_Line_Cap;
2445   --  Cr: a cairo context
2446   --
2447   --  Gets the current line cap style, as set by Set_Line_Cap.
2448   --
2449   --  Return value: the current line cap style.
2450
2451   function Get_Line_Join (Cr : Cairo_Context) return Cairo_Line_Join;
2452   --  Cr: a cairo context
2453   --
2454   --  Gets the current line join style, as set by Set_Line_Join.
2455   --
2456   --  Return value: the current line join style.
2457
2458   function Get_Miter_Limit (Cr : Cairo_Context) return Gdouble;
2459   --  Cr: a cairo context
2460   --
2461   --  Gets the current miter limit, as set by Set_Miter_Limit.
2462   --
2463   --  Return value: the current miter limit.
2464
2465   function Get_Dash_Count (Cr : Cairo_Context) return Gint;
2466   --  Cr: a Cairo_Context
2467   --
2468   --  This function returns the length of the dash array in cr (0 if dashing
2469   --  is not currently in effect).
2470   --
2471   --  See also Set_Dash and Get_Dash.
2472   --
2473   --  Return value: the length of the dash array, or 0 if no dash array set.
2474   --
2475   --  Since: 1.4
2476
2477   type Dash_Array_Access is access all Dash_Array;
2478
2479   procedure Get_Dash
2480     (Cr     : Cairo_Context;
2481      Dashes : out Dash_Array_Access;
2482      Offset : out Gdouble);
2483   --  Cr: a Cairo_Context
2484   --  Dashes: return value for the dash array, or null
2485   --  Offset: return value for the current dash Offset, or null
2486   --
2487   --  Gets the current dash array.
2488   --
2489   --  Since: 1.4
2490
2491   procedure Get_Matrix (Cr : Cairo_Context; Matrix : access Cairo_Matrix);
2492   --  Cr: a cairo context
2493   --  Matrix: return value for the Matrix
2494   --
2495   --  Stores the current transformation matrix (CTM) into matrix.
2496
2497   function Get_Target (Cr : Cairo_Context) return Cairo_Surface;
2498   --  Cr: a cairo context
2499   --
2500   --  Gets the target surface for the cairo context as passed to Create.
2501   --
2502   --  This function will always return a valid pointer, but the result
2503   --  can be a "nil" surface if cr is already in an error state,
2504   --  (ie. Cairo_Status /= Cairo_Status_Success).
2505   --  A nil surface is indicated by
2506   --  Cairo.Surface.Status/= Cairo_Status_Success.
2507   --
2508   --  Return value: the target surface. This object is owned by cairo. To
2509   --  keep a reference to it, you must call Cairo.Surface.Reference.
2510
2511   function Get_Group_Target (Cr : Cairo_Context) return Cairo_Surface;
2512   --  Cr: a cairo context
2513   --
2514   --  Gets the current destination surface for the context. This is either
2515   --  the original target surface as passed to Create or the target
2516   --  surface for the current group as started by the most recent call to
2517   --  Push_Group or Push_Group_With_Content.
2518   --
2519   --  This function will always return a valid pointer, but the result
2520   --  can be a "nil" surface if cr is already in an error state,
2521   --  (ie. Cairo_Status /= Cairo_Status_Success).
2522   --  A nil surface is indicated by Cairo_Status /= Cairo_Status_Success.
2523   --
2524   --  Return value: the target surface. This object is owned by cairo. To
2525   --  keep a reference to it, you must call Cairo.Surface.Reference.
2526   --
2527   --  Since: 1.2
2528
2529   type Cairo_Path_Data_Type is
2530     (Cairo_Path_Move_To,    --  A move-to operation
2531      Cairo_Path_Line_To,    --  A line-to operation
2532      Cairo_Path_Curve_To,   --  A curve-to operation
2533      Cairo_Path_Close_Path  --  A close-path operation
2534     );
2535   --  Cairo_path_data is used to describe the type of one portion
2536   --  of a path when represented as a Cairo_Path.
2537   --  See Cairo_Path_Data for details.
2538   pragma Convention (C, Cairo_Path_Data_Type);
2539
2540   type Header_Type is record
2541      Path_Type : aliased Cairo_Path_Data_Type;
2542      Length    : aliased Gint;
2543   end record;
2544   --  A Path header. See Cairo_Path_Data for details.
2545
2546   type Point_Type is record
2547      X : aliased Gdouble;
2548      Y : aliased Gdouble;
2549   end record;
2550   --  A geometrical point. See Cairo_Path_Data for details.
2551
2552   type Cairo_Path_Data (Discr : Guint := 0) is record
2553      case Discr is
2554         when 0 =>
2555            Header : aliased Header_Type;
2556         when others =>
2557            Point : aliased Point_Type;
2558      end case;
2559   end record;
2560   --  Cairo_path_data is used to represent the path data inside a
2561   --  Cairo_path.
2562   --
2563   --  The data structure is designed to try to balance the demands of
2564   --  efficiency and ease-of-use. A path is represented as an array of
2565   --  Cairo_Path_Data, which is a union of headers and points.
2566   --
2567   --  Each portion of the path is represented by one or more elements in
2568   --  the array, (one header followed by 0 or more points). The length
2569   --  value of the header is the number of array elements for the current
2570   --  portion including the header, (ie. length == 1 +  of points), and
2571   --  where the number of points for each element type is as follows:
2572   --
2573   --      Cairo_Path_Move_To:     1 point
2574   --      Cairo_Path_Line_To:     1 point
2575   --      Cairo_Path_Curve_To:    3 points
2576   --      Cairo_Path_Close_Path:  0 points
2577   --
2578   --  The semantics and ordering of the coordinate values are consistent
2579   --  with Move_To, Line_To, Curve_To, and Close_Path.
2580   --
2581   --  Here is sample code for iterating through a Cairo_Path:
2582   --
2583   --    declare
2584   --       J    : Gint;
2585   --       Path : Cairo_Path;
2586   --       Data : Cairo_Path_Data;
2587   --     begin
2588   --       Path = Copy_Path (Cr);
2589   --
2590   --       J := 0;
2591   --       while J < Path.Num_Data loop
2592   --          Data := Path.Data(J);
2593   --
2594   --          case Data.Header.Path_Type is
2595   --
2596   --              when Cairo_Path_Move_To =>
2597   --                 Do_Move_To_Things (Data(1).Point.X, Data(1).Point.Y);
2598   --
2599   --              when Cairo_Path_Line_To =>
2600   --                 Do_Line_To_Things (Data(1).Point.X, Data(1).Point.Y);
2601   --
2602   --              when Cairo_Path_Curve_To =>
2603   --                 Do_Curve_To_Things (Data(1).Point.X, Data(1).Point.Y,
2604   --                                     Data(2).Point.X, Data(2).Point.Y,
2605   --                                     Data(3).Point.X, Data(3).Point.Y);
2606   --
2607   --              when Cairo_Path_Curve_To =>
2608   --                 Do_Close_Path_Things;
2609   --          end case;
2610   --
2611   --          J := J + Path.Data[J].Header.Length;
2612   --       end loop;
2613   --
2614   --       Path_Destroy (Path);
2615   --    end;
2616   --
2617   --  As of cairo 1.4, cairo does not mind if there are more elements in
2618   --  a portion of the path than needed.  Such elements can be used by
2619   --  users of the cairo API to hold extra values in the path data
2620   --  structure.  For this reason, it is recommended that applications
2621   --  always use Data.Header.Length to iterate over the path data, instead of
2622   --  hardcoding the number of elements for each element type.
2623
2624   type Path_Data_Array is array (Natural) of Cairo_Path_Data;
2625   type Path_Data_Array_Access is access all Path_Data_Array;
2626
2627   type Cairo_Path is record
2628      Status   : aliased Cairo_Status;
2629      Data     : Path_Data_Array_Access;
2630      --  Warning: for efficiency reasons, Data is a direct mapping to the C
2631      --  structure. Therefore, there is no bounds checking on this array,
2632      --  the user needs to make sure only to access data between indexes
2633      --  0 and Num_Data-1.
2634      Num_Data : aliased Gint;
2635   end record;
2636   type Cairo_Path_Access is access all Cairo_Path;
2637   --  Status: the current error Status
2638   --  Data: the elements in the path
2639   --  Num_Data: the number of elements in the data array
2640   --
2641   --  A data structure for holding a path. This data structure serves as the
2642   --  return value for Copy_Path and Copy_Path_Flat as well the input value
2643   --  for Append_Path.
2644   --
2645   --  See Cairo_Path_Data for hints on how to iterate over the
2646   --  actual data within the path.
2647   --
2648   --  The num_data member gives the number of elements in the data
2649   --  array. This number is larger than the number of independent path
2650   --  portions (defined in Cairo_Path_Data_Type), since the data
2651   --  includes both headers and coordinates for each portion.
2652
2653   function Copy_Path (Cr : Cairo_Context) return Cairo_Path_Access;
2654   --  Cr: a cairo context
2655   --
2656   --  Creates a copy of the current path and returns it to the user as a
2657   --  Cairo_Path. See Cairo_Path_Data for hints on how to iterate
2658   --  over the returned data structure.
2659   --
2660   --  This function will always return a valid pointer, but the result
2661   --  will have no data (Data = null and Num_Data = 0), if
2662   --  either of the following conditions hold:
2663   --
2664   --  -> If there is insufficient memory to copy the path. In this
2665   --      case Path.Status will be set to Cairo_Status_No_Memory
2666   --
2667   --  -> If Cr is already in an error state. In this case
2668   --     Path.Status will contain the same status that
2669   --     would be returned by Status.
2670   --
2671   --  Return value: the copy of the current path. The caller owns the
2672   --  returned object and should call Path_Destroy when finished with it.
2673
2674   function Copy_Path_Flat (Cr : Cairo_Context) return Cairo_Path_Access;
2675   --  Cr: a cairo context
2676   --
2677   --  Gets a flattened copy of the current path and returns it to the
2678   --  user as a Cairo_Path. See Cairo_Path_Data for hints on
2679   --  how to iterate over the returned data structure.
2680   --
2681   --  This function is like Copy_Path except that any curves
2682   --  in the path will be approximated with piecewise-linear
2683   --  approximations, (accurate to within the current tolerance
2684   --  value). That is, the result is guaranteed to not have any elements
2685   --  of type Cairo_Path_Curve_To which will instead be replaced by a
2686   --  series of Cairo_Path_Line_To elements.
2687   --
2688   --  This function will always return a valid pointer, but the result will
2689   --  have no data (Data = null and Num_Data = 0), if either of the following
2690   --  conditions hold:
2691   --
2692   --  -> If there is insufficient memory to copy the path. In this
2693   --      case Path.Status will be set to Cairo_Status_No_Memory
2694   --
2695   --  -> If Cr is already in an error state. In this case
2696   --     Path.Status will contain the same status that
2697   --     would be returned by Status.
2698   --
2699   --  Return value: the copy of the current path. The caller owns the
2700   --  returned object and should call Path_Destroy when finished
2701   --  with it.
2702
2703   procedure Append_Path
2704     (Cr   : Cairo_Context;
2705      Path : access Cairo_Path);
2706   --  Cr: a cairo context
2707   --  Path: Path to be appended
2708   --
2709   --  Append the path onto the current path. The path may be either the return
2710   --  value from one of Copy_Path or Copy_Path_Flat or it may be constructed
2711   --  manually. See Cairo_Path for details on how the path data structure
2712   --  should be initialized, and note that Path.Status must be initialized to
2713   --  Cairo_Status_Success.
2714
2715   procedure Path_Destroy (Path : access Cairo_Path);
2716   --  Path: a path previously returned by either Copy_Path or Copy_Path_Flat.
2717   --
2718   --  Immediately releases all memory associated with Path. After a call
2719   --  to Path_Destroy the Path pointer is no longer valid and should not be
2720   --  used further.
2721   --
2722   --  Note: Path_Destroy should only be called with an access to a
2723   --  Cairo_Path returned by a cairo function. Any path that is created
2724   --  manually (ie. outside of cairo) should be destroyed manually as well.
2725
2726   --------------------------
2727   -- Error status queries --
2728   --------------------------
2729
2730   function Status (Cr : Cairo_Context) return Cairo_Status;
2731   --  Cr: a cairo context
2732   --
2733   --  Checks whether an error has previously occurred for this context.
2734   --
2735   --  Returns: the current status of this context, see Cairo_Status
2736
2737   Null_Context      : constant Cairo_Context;
2738   Null_Surface      : constant Cairo_Surface;
2739   Null_Pattern      : constant Cairo_Pattern;
2740   Null_Scaled_Font  : constant Cairo_Scaled_Font;
2741   Null_Font_Face    : constant Cairo_Font_Face;
2742   Null_Font_Options : constant Cairo_Font_Options;
2743
2744private
2745   pragma Linker_Options ("-shared-libgcc");
2746
2747   pragma Convention (C, Cairo_Destroy_Func);
2748   pragma Convention (C, Cairo_Status);
2749   pragma Convention (C, Cairo_Operator);
2750   pragma Convention (C, Cairo_Antialias);
2751   pragma Convention (C, Cairo_Fill_Rule);
2752   pragma Convention (C, Cairo_Line_Cap);
2753   pragma Convention (C, Cairo_Line_Join);
2754   pragma Convention (C, Path_Data_Array_Access);
2755   pragma Convention (C_Pass_By_Copy, Cairo_Path);
2756   pragma Convention (C_Pass_By_Copy, Cairo_Rectangle);
2757   pragma Convention (C, Cairo_Rectangle_Array_Access);
2758
2759   pragma Convention (C_Pass_By_Copy, Header_Type);
2760   pragma Convention (C_Pass_By_Copy, Point_Type);
2761   pragma Convention (C_Pass_By_Copy, Cairo_Path_Data);
2762   pragma Unchecked_Union (Cairo_Path_Data);
2763
2764   type Cairo_Context is new System.Address;
2765   Null_Context : constant Cairo_Context :=
2766     Cairo_Context (System.Null_Address);
2767   type Cairo_Surface is new System.Address;
2768   Null_Surface : constant Cairo_Surface :=
2769     Cairo_Surface (System.Null_Address);
2770   type Cairo_Pattern is new System.Address;
2771   Null_Pattern : constant Cairo_Pattern :=
2772     Cairo_Pattern (System.Null_Address);
2773   type Cairo_Scaled_Font is new System.Address;
2774   Null_Scaled_Font : constant Cairo_Scaled_Font :=
2775     Cairo_Scaled_Font (System.Null_Address);
2776   type Cairo_Font_Face is new System.Address;
2777   Null_Font_Face : constant Cairo_Font_Face :=
2778     Cairo_Font_Face (System.Null_Address);
2779   type Cairo_Font_Options is new System.Address;
2780   Null_Font_Options : constant Cairo_Font_Options :=
2781     Cairo_Font_Options (System.Null_Address);
2782   pragma Import (C, Create, "cairo_create");
2783   pragma Import (C, Reference, "cairo_reference");
2784   pragma Import (C, Get_Reference_Count, "cairo_get_reference_count");
2785   pragma Import (C, Get_User_Data, "cairo_get_user_data");
2786   pragma Import (C, Set_User_Data, "cairo_set_user_data");
2787   pragma Import (C, Save, "cairo_save");
2788   pragma Import (C, Restore, "cairo_restore");
2789   pragma Import (C, Push_Group, "cairo_push_group");
2790   pragma Import
2791     (C,
2792      Push_Group_With_Content,
2793      "cairo_push_group_with_content");
2794   pragma Import (C, Pop_Group, "cairo_pop_group");
2795   pragma Import (C, Pop_Group_To_Source, "cairo_pop_group_to_source");
2796   pragma Import (C, Set_Operator, "cairo_set_operator");
2797   pragma Import (C, Set_Source, "cairo_set_source");
2798   pragma Import (C, Set_Source_Rgb, "cairo_set_source_rgb");
2799   pragma Import (C, Set_Source_Rgba, "cairo_set_source_rgba");
2800   pragma Import (C, Set_Source_Surface, "cairo_set_source_surface");
2801   pragma Import (C, Set_Tolerance, "cairo_set_tolerance");
2802   pragma Import (C, Set_Antialias, "cairo_set_antialias");
2803   pragma Import (C, Set_Fill_Rule, "cairo_set_fill_rule");
2804   pragma Import (C, Set_Line_Width, "cairo_set_line_width");
2805   pragma Import (C, Set_Line_Cap, "cairo_set_line_cap");
2806   pragma Import (C, Set_Line_Join, "cairo_set_line_join");
2807   pragma Import (C, Set_Miter_Limit, "cairo_set_miter_limit");
2808   pragma Import (C, Translate, "cairo_translate");
2809   pragma Import (C, Scale, "cairo_scale");
2810   pragma Import (C, Rotate, "cairo_rotate");
2811   pragma Import (C, Transform, "cairo_transform");
2812   pragma Import (C, Set_Matrix, "cairo_set_matrix");
2813   pragma Import (C, Identity_Matrix, "cairo_identity_matrix");
2814   pragma Import (C, User_To_Device, "cairo_user_to_device");
2815   pragma Import
2816     (C,
2817      User_To_Device_Distance,
2818      "cairo_user_to_device_distance");
2819   pragma Import (C, Device_To_User, "cairo_device_to_user");
2820   pragma Import
2821     (C,
2822      Device_To_User_Distance,
2823      "cairo_device_to_user_distance");
2824   pragma Import (C, New_Path, "cairo_new_path");
2825   pragma Import (C, Move_To, "cairo_move_to");
2826   pragma Import (C, New_Sub_Path, "cairo_new_sub_path");
2827   pragma Import (C, Line_To, "cairo_line_to");
2828   pragma Import (C, Curve_To, "cairo_curve_to");
2829   pragma Import (C, Arc, "cairo_arc");
2830   pragma Import (C, Arc_Negative, "cairo_arc_negative");
2831   pragma Import (C, Rel_Move_To, "cairo_rel_move_to");
2832   pragma Import (C, Rel_Line_To, "cairo_rel_line_to");
2833   pragma Import (C, Rel_Curve_To, "cairo_rel_curve_to");
2834   pragma Import (C, Rectangle, "cairo_rectangle");
2835   pragma Import (C, Close_Path, "cairo_close_path");
2836   pragma Import (C, Path_Extents, "cairo_path_extents");
2837   pragma Import (C, Paint, "cairo_paint");
2838   pragma Import (C, Paint_With_Alpha, "cairo_paint_with_alpha");
2839   pragma Import (C, Mask, "cairo_mask");
2840   pragma Import (C, Mask_Surface, "cairo_mask_surface");
2841   pragma Import (C, Stroke, "cairo_stroke");
2842   pragma Import (C, Stroke_Preserve, "cairo_stroke_preserve");
2843   pragma Import (C, Fill, "cairo_fill");
2844   pragma Import (C, Fill_Preserve, "cairo_fill_preserve");
2845   pragma Import (C, Copy_Page, "cairo_copy_page");
2846   pragma Import (C, Show_Page, "cairo_show_page");
2847   pragma Import (C, Stroke_Extents, "cairo_stroke_extents");
2848   pragma Import (C, Fill_Extents, "cairo_fill_extents");
2849   pragma Import (C, Reset_Clip, "cairo_reset_clip");
2850   pragma Import (C, Clip, "cairo_clip");
2851   pragma Import (C, Clip_Preserve, "cairo_clip_preserve");
2852   pragma Import (C, Clip_Extents, "cairo_clip_extents");
2853   pragma Import
2854     (C,
2855      Copy_Clip_Rectangle_List,
2856      "cairo_copy_clip_rectangle_list");
2857   pragma Import (C, Rectangle_List_Destroy, "cairo_rectangle_list_destroy");
2858   pragma Import (C, Set_Font_Size, "cairo_set_font_size");
2859   pragma Import (C, Set_Font_Matrix, "cairo_set_font_matrix");
2860   pragma Import (C, Get_Font_Matrix, "cairo_get_font_matrix");
2861   pragma Import (C, Set_Font_Options, "cairo_set_font_options");
2862   pragma Import (C, Get_Font_Options, "cairo_get_font_options");
2863   pragma Import (C, Set_Font_Face, "cairo_set_font_face");
2864   pragma Import (C, Get_Font_Face, "cairo_get_font_face");
2865   pragma Import (C, Set_Scaled_Font, "cairo_set_scaled_font");
2866   pragma Import (C, Get_Scaled_Font, "cairo_get_scaled_font");
2867   pragma Import (C, Show_Glyphs, "cairo_show_glyphs");
2868   --     pragma Import (C, Show_Text_Glyphs, "cairo_show_text_glyphs");
2869   --     pragma Import (C, Glyph_Path, "cairo_glyph_path");
2870   pragma Import (C, Text_Extents, "cairo_text_extents");
2871   pragma Import (C, Glyph_Extents, "cairo_glyph_extents");
2872   pragma Import (C, Font_Extents, "cairo_font_extents");
2873   pragma Import (C, Get_Operator, "cairo_get_operator");
2874   pragma Import (C, Get_Source, "cairo_get_source");
2875   pragma Import (C, Get_Tolerance, "cairo_get_tolerance");
2876   pragma Import (C, Get_Antialias, "cairo_get_antialias");
2877   pragma Import (C, Get_Current_Point, "cairo_get_current_point");
2878   pragma Import (C, Get_Fill_Rule, "cairo_get_fill_rule");
2879   pragma Import (C, Get_Line_Width, "cairo_get_line_width");
2880   pragma Import (C, Get_Line_Cap, "cairo_get_line_cap");
2881   pragma Import (C, Get_Line_Join, "cairo_get_line_join");
2882   pragma Import (C, Get_Miter_Limit, "cairo_get_miter_limit");
2883   pragma Import (C, Get_Dash_Count, "cairo_get_dash_count");
2884   pragma Import (C, Get_Matrix, "cairo_get_matrix");
2885   pragma Import (C, Get_Target, "cairo_get_target");
2886   pragma Import (C, Get_Group_Target, "cairo_get_group_target");
2887   pragma Import (C, Copy_Path, "cairo_copy_path");
2888   pragma Import (C, Copy_Path_Flat, "cairo_copy_path_flat");
2889   pragma Import (C, Append_Path, "cairo_append_path");
2890   pragma Import (C, Path_Destroy, "cairo_path_destroy");
2891   pragma Import (C, Status, "cairo_status");
2892
2893end Cairo;
2894