---
name: "Cairo"
section: "3pm"
platform: "linux"
package: "cairo-perl"
version: "1.109-7"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/Cairo"
---

# Cairo(3pm)

Perl interface to the cairo 2d vector graphics library

## NAME

Cairo - Perl interface to the cairo 2d vector graphics library

## SYNOPSIS

```
  use Cairo;
  my $surface = Cairo::ImageSurface->create ('argb32', 100, 100);
  my $cr = Cairo::Context->create ($surface);
  $cr->rectangle (10, 10, 40, 40);
  $cr->set_source_rgb (0, 0, 0);
  $cr->fill;
  $cr->rectangle (50, 50, 40, 40);
  $cr->set_source_rgb (1, 1, 1);
  $cr->fill;
  $cr->show_page;
  $surface->write_to_png ('output.png');
```

## ABSTRACT

Cairo provides Perl bindings for the vector graphics library cairo.  It supports multiple output targets, including PNG, PDF and SVG.  Cairo produces identical output on all those targets.

## API DOCUMENTATION

This is a listing of the API Cairo provides.  For more verbose information, refer to the cairo manual at \<http://cairographics.org/manual/\>.

### Drawing

*Cairo::Context -- The cairo drawing context*

*Cairo::Context* is the main object used when drawing with Cairo. To draw with Cairo, you create a *Cairo::Context*, set the target surface, and drawing options for the *Cairo::Context*, create shapes with methods like `"$cr->move_to"` and `"$cr->line_to"`, and then draw shapes with `"$cr->stroke"` or `"$cr->fill"`.

*Cairo::Context*'s can be pushed to a stack via `"$cr->save"`. They may then safely be changed, without loosing the current state. Use `"$cr->restore"` to restore to the saved state.

- $cr = Cairo::Context-\>create ($surface)

  - $surface: *Cairo::Surface*

    - $cr-\>save

  - $cr-\>restore

  - $status = $cr-\>status

  - $surface = $cr-\>get\_target

  - $cr-\>push\_group \[1.2\]

  - $cr-\>push\_group\_with\_content ($content) \[1.2\]

  - $content: *Cairo::Content*

    - $pattern = $cr-\>pop\_group \[1.2\]

  - $cr-\>pop\_group\_to\_source \[1.2\]

  - $surface = $cr-\>get\_group\_target \[1.2\]

  - $cr-\>set\_source\_rgb ($red, $green, $blue)

  - $red: double

    - $green: double

    - $blue: double

    - $cr-\>set\_source\_rgba ($red, $green, $blue, $alpha)

  - $red: double

    - $green: double

    - $blue: double

    - $alpha: double

    - $cr-\>set\_source ($source)

  - $source: *Cairo::Pattern*

    - $cr-\>set\_source\_surface ($surface, $x, $y)

  - $surface: *Cairo::Surface*

    - $x: double

    - $y: double

    - $source = $cr-\>get\_source

  - $cr-\>set\_antialias ($antialias)

  - $antialias: *Cairo::Antialias*

    - $antialias = $cr-\>get\_antialias

  - $cr-\>set\_dash ($offset, ...)

  - $offset: double

    - ...: list of doubles

    - $cr-\>set\_fill\_rule ($fill\_rule)

  - $fill\_rule: *Cairo::FillRule*

    - $fill\_rule = $cr-\>get\_fill\_rule

  - $cr-\>set\_line\_cap ($line\_cap)

  - $line\_cap: *Cairo::LineCap*

    - $line\_cap = $cr-\>get\_line\_cap

  - $cr-\>set\_line\_join ($line\_join)

  - $line\_join: *Cairo::LineJoin*

    - $line\_join = $cr-\>get\_line\_join

  - $cr-\>set\_line\_width ($width)

  - $width: double

    - $width = $cr-\>get\_line\_width

  - $cr-\>set\_miter\_limit ($limit)

  - $limit: double

    - ($offset, @dashes) = $cr-\>get\_dash \[1.4\]

  - $limit = $cr-\>get\_miter\_limit

  - $cr-\>set\_operator ($op)

  - $op: *Cairo::Operator*

    - $op = $cr-\>get\_operator

  - $cr-\>set\_tolerance ($tolerance)

  - $tolerance: double

    - $tolerance = $cr-\>get\_tolerance

  - $cr-\>clip

  - $cr-\>clip\_preserve

  - ($x1, $y1, $x2, $y2) = $cr-\>clip\_extents \[1.4\]

  - $bool = $cr-\>in\_clip ($x, $y) \[1.10\]

  - $x: double

    - $y: double

    - @rectangles = $cr-\>copy\_clip\_rectangle\_list \[1.4\]

  - $cr-\>reset\_clip

  - $cr-\>fill

  - $cr-\>fill\_preserve

  - ($x1, $y1, $x2, $y2) = $cr-\>fill\_extents

  - $bool = $cr-\>in\_fill ($x, $y)

  - $x: double

    - $y: double

    - $cr-\>mask ($pattern)

  - $pattern: *Cairo::Pattern*

    - $cr-\>mask\_surface ($surface, $surface\_x, $surface\_y)

  - $surface: *Cairo::Surface*

    - $surface\_x: double

    - $surface\_y: double

    - $cr-\>paint

  - $cr-\>paint\_with\_alpha ($alpha)

  - $alpha: double

    - $cr-\>stroke

  - $cr-\>stroke\_preserve

  - ($x1, $y1, $x2, $y2) = $cr-\>stroke\_extents

  - $bool = $cr-\>in\_stroke ($x, $y)

  - $x: double

    - $y: double

    - $cr-\>tag\_begin($name, $atts) \[1.16\]

  - $name: string

    - $atts: string

    - $cr-\>tag\_end($name) \[1.16\]

  - $name: string

    - Predefined names:

  - Cairo::TAG\_DEST \[1.16\]

    - Cairo::TAG\_LINK \[1.16\]

    - $cr-\>copy\_page

  - $cr-\>show\_page

  *Paths -- Creating paths and manipulating path data*

```
  $path = [
    { type => "move-to", points => [[1, 2]] },
    { type => "line-to", points => [[3, 4]] },
    { type => "curve-to", points => [[5, 6], [7, 8], [9, 10]] },
    ...
    { type => "close-path", points => [] },
  ];
```

*Cairo::Path* is a data structure for holding a path. This data structure serves as the return value for `"$cr->copy_path"` and `"$cr->copy_path_flat"` as well the input value for `"$cr->append_path"`.

*Cairo::Path* is represented as an array reference that contains path elements, represented by hash references with two keys: *type* and *points*. The value for *type* can be either of the following:

- "move-to"

  - "line-to"

  - "curve-to"

  - "close-path"

  The value for *points* is an array reference which contains zero or more points.  Points are represented as array references that contain two doubles: *x* and *y*.  The necessary number of points depends on the *type* of the path element:

- "move-to": 1 point

  - "line\_to": 1 point

  - "curve-to": 3 points

  - "close-path": 0 points

  The semantics and ordering of the coordinate values are consistent with `"$cr->move_to"`, `"$cr->line_to"`, `"$cr->curve_to"`, and `"$cr->close_path"`.

Note that the paths returned by Cairo are implemented as tied array references which do **not** support adding, removing or shuffling of path segments.  For these operations, you need to make a shallow copy first:

```
  my @path_clone = @{$path};
  # now you can alter @path_clone which ever way you want
```

The points of a single path element can be changed directly, however, without the need for a shallow copy:

```
  $path->[$i]{points} = [[3, 4], [5, 6], [7, 8]];
```

- $path = $cr-\>copy\_path

  - $path = $cr-\>copy\_path\_flat

  - $cr-\>append\_path ($path)

  - $path: *Cairo::Path*

    - $bool = $cr-\>has\_current\_point \[1.6\]

  - ($x, $y) = $cr-\>get\_current\_point

  - $cr-\>new\_path

  - $cr-\>new\_sub\_path \[1.2\]

  - $cr-\>close\_path

  - ($x1, $y1, $x2, $y2) = $cr-\>path\_extents \[1.6\]

  - $cr-\>arc ($xc, $yc, $radius, $angle1, $angle2)

  - $xc: double

    - $yc: double

    - $radius: double

    - $angle1: double

    - $angle2: double

    - $cr-\>arc\_negative ($xc, $yc, $radius, $angle1, $angle2)

  - $xc: double

    - $yc: double

    - $radius: double

    - $angle1: double

    - $angle2: double

    - $cr-\>curve\_to ($x1, $y1, $x2, $y2, $x3, $y3)

  - $x1: double

    - $y1: double

    - $x2: double

    - $y2: double

    - $x3: double

    - $y3: double

    - $cr-\>line\_to ($x, $y)

  - $x: double

    - $y: double

    - $cr-\>move\_to ($x, $y)

  - $x: double

    - $y: double

    - $cr-\>rectangle ($x, $y, $width, $height)

  - $x: double

    - $y: double

    - $width: double

    - $height: double

    - $cr-\>glyph\_path (...)

  - ...: list of *Cairo::Glyph*'s

    - $cr-\>text\_path ($utf8)

  - $utf8: string in utf8 encoding

    - $cr-\>rel\_curve\_to ($dx1, $dy1, $dx2, $dy2, $dx3, $dy3)

  - $dx1: double

    - $dy1: double

    - $dx2: double

    - $dy2: double

    - $dx3: double

    - $dy3: double

    - $cr-\>rel\_line\_to ($dx, $dy)

  - $dx: double

    - $dy: double

    - $cr-\>rel\_move\_to ($dx, $dy)

  - $dx: double

    - $dy: double

    *Patterns -- Gradients and filtered sources*

- $status = $pattern-\>status

  - $type = $pattern-\>get\_type \[1.2\]

  - $pattern-\>set\_extend ($extend)

  - $extend: *Cairo::Extend*

    - $extend = $pattern-\>get\_extend

  - $pattern-\>set\_filter ($filter)

  - $filter: *Cairo::Filter*

    - $filter = $pattern-\>get\_filter

  - $pattern-\>set\_matrix ($matrix)

  - $matrix: *Cairo::Matrix*

    - $matrix = $pattern-\>get\_matrix

  - $pattern = Cairo::SolidPattern-\>create\_rgb ($red, $green, $blue)

  - $red: double

    - $green: double

    - $blue: double

    - $pattern = Cairo::SolidPattern-\>create\_rgba ($red, $green, $blue, $alpha)

  - $red: double

    - $green: double

    - $blue: double

    - $alpha: double

    - ($r, $g, $b, $a) = $pattern-\>get\_rgba \[1.4\]

  - $pattern = Cairo::SurfacePattern-\>create ($surface)

  - $surface: *Cairo::Surface*

    - $surface = $pattern-\>get\_surface \[1.4\]

  - $pattern = Cairo::LinearGradient-\>create ($x0, $y0, $x1, $y1)

  - $x0: double

    - $y0: double

    - $x1: double

    - $y1: double

    - ($x0, $y0, $x1, $y1) = $pattern-\>get\_points \[1.4\]

  - $pattern = Cairo::RadialGradient-\>create ($cx0, $cy0, $radius0, $cx1, $cy1, $radius1)

  - $cx0: double

    - $cy0: double

    - $radius0: double

    - $cx1: double

    - $cy1: double

    - $radius1: double

    - ($x0, $y0, $r0, $x1, $y1, $r1) = $pattern-\>get\_circles \[1.4\]

  - $pattern-\>add\_color\_stop\_rgb ($offset, $red, $green, $blue)

  - $offset: double

    - $red: double

    - $green: double

    - $blue: double

    - $pattern-\>add\_color\_stop\_rgba ($offset, $red, $green, $blue, $alpha)

  - $offset: double

    - $red: double

    - $green: double

    - $blue: double

    - $alpha: double

    - @stops = $pattern-\>get\_color\_stops \[1.4\]

  A color stop is represented as an array reference with five elements: offset, red, green, blue, and alpha.

*Regions -- Representing a pixel-aligned area*

- $region = Cairo::Region-\>create (...) \[1.10\]

  - ...: zero or more *Cairo::RectangleInt*

    - $status = $region-\>status \[1.10\]

  - $num = $region-\>num\_rectangles \[1.10\]

  - $rect = $region-\>get\_rectangle ($i) \[1.10\]

  - $i: integer

    - $bool = $region-\>is\_empty \[1.10\]

  - $bool = $region-\>contains\_point ($x, $y) \[1.10\]

  - $x: integer

    - $y: integer

    - $bool = $region\_one-\>equal ($region\_two) \[1.10\]

  - $region\_two: *Cairo::Region*

    - $region-\>translate ($dx, $dy) \[1.10\]

  - $dx: integer

    - $dy: integer

    - $status = $dst-\>intersect ($other) \[1.10\]

  - $status = $dst-\>intersect\_rectangle ($rect) \[1.10\]

  - $status = $dst-\>subtract ($other) \[1.10\]

  - $status = $dst-\>subtract\_rectangle ($rect) \[1.10\]

  - $status = $dst-\>union ($other) \[1.10\]

  - $status = $dst-\>union\_rectangle ($rect) \[1.10\]

  - $status = $dst-\>xor ($other) \[1.10\]

  - $status = $dst-\>xor\_rectangle ($rect) \[1.10\]

  - $other: *Cairo::Region*

    - $rect: *Cairo::RectangleInt*

    *Transformations -- Manipulating the current transformation matrix*

- $cr-\>translate ($tx, $ty)

  - $tx: double

    - $ty: double

    - $cr-\>scale ($sx, $sy)

  - $sx: double

    - $sy: double

    - $cr-\>rotate ($angle)

  - $angle: double

    - $cr-\>transform ($matrix)

  - $matrix: *Cairo::Matrix*

    - $cr-\>set\_matrix ($matrix)

  - $matrix: *Cairo::Matrix*

    - $matrix = $cr-\>get\_matrix

  - $cr-\>identity\_matrix

  - ($x, $y) = $cr-\>user\_to\_device ($x, $y)

  - $x: double

    - $y: double

    - ($dx, $dy) = $cr-\>user\_to\_device\_distance ($dx, $dy)

  - $dx: double

    - $dy: double

    - ($x, $y) = $cr-\>device\_to\_user ($x, $y)

  - $x: double

    - $y: double

    - ($dx, $dy) = $cr-\>device\_to\_user\_distance ($dx, $dy)

  - $dx: double

    - $dy: double

    *Text -- Rendering text and sets of glyphs*

Glyphs are represented as anonymous hash references with three keys: *index*, *x* and *y*.  Example:

```
  my @glyphs = ({ index => 1, x => 2, y => 3 },
                { index => 2, x => 3, y => 4 },
                { index => 3, x => 4, y => 5 });
```

- $cr-\>select\_font\_face ($family, $slant, $weight)

  - $family: string

    - $slant: *Cairo::FontSlant*

    - $weight: *Cairo::FontWeight*

    - $cr-\>set\_font\_size ($size)

  - $size: double

    - $cr-\>set\_font\_matrix ($matrix)

  - $matrix: *Cairo::Matrix*

    - $matrix = $cr-\>get\_font\_matrix

  - $cr-\>set\_font\_options ($options)

  - $options: *Cairo::FontOptions*

    - $options = $cr-\>get\_font\_options

  - $cr-\>set\_scaled\_font ($scaled\_font) \[1.2\]

  - $scaled\_font: *Cairo::ScaledFont*

    - $scaled\_font = $cr-\>get\_scaled\_font \[1.4\]

  - $cr-\>show\_text ($utf8)

  - $utf8: string

    - $cr-\>show\_glyphs (...)

  - ...: list of glyphs

    - $cr-\>show\_text\_glyphs ($utf8, $glyphs, $clusters, $cluster\_flags) \[1.8\]

  - $utf8: string

    - $glyphs: array ref of glyphs

    - $clusters: array ref of clusters

    - $cluster\_flags: *Cairo::TextClusterFlags*

    - $face = $cr-\>get\_font\_face

  - $extents = $cr-\>font\_extents

  - $cr-\>set\_font\_face ($font\_face)

  - $font\_face: *Cairo::FontFace*

    - $cr-\>set\_scaled\_font ($scaled\_font)

  - $scaled\_font: *Cairo::ScaledFont*

    - $extents = $cr-\>text\_extents ($utf8)

  - $utf8: string

    - $extents = $cr-\>glyph\_extents (...)

  - ...: list of glyphs

    - $face = Cairo::ToyFontFace-\>create ($family, $slant, $weight) \[1.8\]

  - $family: string

    - $slant: *Cairo::FontSlant*

    - $weight: *Cairo::FontWeight*

    - $family = $face-\>get\_family \[1.8\]

  - $slang = $face-\>get\_slant \[1.8\]

  - $weight = $face-\>get\_weight \[1.8\]

  ### Fonts

*Cairo::FontFace -- Base class for fonts*

- $status = $font\_face-\>status

  - $type = $font\_face-\>get\_type \[1.2\]

  *Scaled Fonts -- Caching metrics for a particular font size*

- $scaled\_font = Cairo::ScaledFont-\>create ($font\_face, $font\_matrix, $ctm, $options)

  - $font\_face: *Cairo::FontFace*

    - $font\_matrix: *Cairo::Matrix*

    - $ctm: *Cairo::Matrix*

    - $options: *Cairo::FontOptions*

    - $status = $scaled\_font-\>status

  - $extents = $scaled\_font-\>extents

  - $extents = $scaled\_font-\>text\_extents ($utf8) \[1.2\]

  - $utf8: string

    - $extents = $scaled\_font-\>glyph\_extents (...)

  - ...: list of glyphs

    - ($status, $glyphs, $clusters, $cluster\_flags) = $scaled\_font-\>text\_to\_glyphs ($x, $y, $utf8) \[1.8\]

  - $x: double

    - $y: double

    - $utf8: string

    - $font\_face = $scaled\_font-\>get\_font\_face \[1.2\]

  - $options = $scaled\_font-\>get\_font\_options \[1.2\]

  - $font\_matrix = $scaled\_font-\>get\_font\_matrix \[1.2\]

  - $ctm = $scaled\_font-\>get\_ctm \[1.2\]

  - $scale\_matrix = $scaled\_font-\>get\_scale\_matrix \[1.8\]

  - $type = $scaled\_font-\>get\_type \[1.2\]

  *Font Options -- How a font should be rendered*

- $font\_options = Cairo::FontOptions-\>create

  - $status = $font\_options-\>status

  - $font\_options-\>merge ($other)

  - $other: *Cairo::FontOptions*

    - $hash = $font\_options-\>hash

  - $bools = $font\_options-\>equal ($other)

  - $other: *Cairo::FontOptions*

    - $font\_options-\>set\_antialias ($antialias)

  - $antialias: *Cairo::AntiAlias*

    - $antialias = $font\_options-\>get\_antialias

  - $font\_options-\>set\_subpixel\_order ($subpixel\_order)

  - $subpixel\_order: *Cairo::SubpixelOrder*

    - $subpixel\_order = $font\_options-\>get\_subpixel\_order

  - $font\_options-\>set\_hint\_style ($hint\_style)

  - $hint\_style: *Cairo::HintStyle*

    - $hint\_style = $font\_options-\>get\_hint\_style

  - $font\_options-\>set\_hint\_metrics ($hint\_metrics)

  - $hint\_metrics: *Cairo::HintMetrics*

    - $hint\_metrics = $font\_options-\>get\_hint\_metrics

  *FreeType Fonts -- Font support for FreeType*

If your cairo library supports it, the FreeType integration allows you to load font faces from font files.  You can query for this capability with `"Cairo::HAS_FT_FONT"`.  To actually use this, you'll need the Font::FreeType module.

- my $face = Cairo::FtFontFace-\>create ($ft\_face, $load\_flags=0)

  - $ft\_face: *Font::FreeType::Face*

    - $load\_flags: integer

    This method allows you to create a *Cairo::FontFace* from a *Font::FreeType::Face*.  To obtain the latter, you can for example load it from a file:

  ```
    my $file = '/usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf';
    my $ft_face = Font::FreeType->new->face ($file);
    my $face = Cairo::FtFontFace->create ($ft_face);
  ```

### Surfaces

*Cairo::Surface -- Base class for surfaces*

- $similar = Cairo::Surface-\>create\_similar ($other, $content, $width, $height)

  - $other: *Cairo::Surface*

    - $content: *Cairo::Content*

    - $width: integer

    - $height: integer

    For hysterical reasons, you can also use the following syntax:

  ```
    $similar = $other->create_similar ($content, $width, $height)
  ```

- $new = Cairo::Surface-\>create\_for\_rectangle ($target, $x, $y, $width, $height) \[1.10\]

  - $target: *Cairo::Surface*

    - $x: double

    - $y: double

    - $width: double

    - $height: double

    - $status = $surface-\>status

  - $surface-\>finish

  - $surface-\>flush

  - $font\_options = $surface-\>get\_font\_options

  - $content = $surface-\>get\_content \[1.2\]

  - $surface-\>mark\_dirty

  - $surface-\>mark\_dirty\_rectangle ($x, $y, $width, $height)

  - $x: integer

    - $y: integer

    - $width: integer

    - $height: integer

    - $surface-\>set\_device\_offset ($x\_offset, $y\_offset)

  - $x\_offset: integer

    - $y\_offset: integer

    - ($x\_offset, $y\_offset) = $surface-\>get\_device\_offset \[1.2\]

  - $surface-\>set\_fallback\_resolution ($x\_pixels\_per\_inch, $y\_pixels\_per\_inch) \[1.2\]

  - $x\_pixels\_per\_inch: double

    - $y\_pixels\_per\_inch: double

    - ($x\_pixels\_per\_inch, $y\_pixels\_per\_inch) = $surface-\>get\_fallback\_resolution \[1.8\]

  - $type = $surface-\>get\_type \[1.2\]

  - $surface-\>set\_mime\_data ($mime\_type, $mime\_data) \[1.10\]

  - $mime\_data = $surface-\>get\_mime\_data ($mime\_type) \[1.10\]

  - $bool = $surface-\>supports\_mime\_type ($mime\_type) \[1.12\]

  - $mime\_type: string

    - Predefined MIME types:

      - Cairo::Surface::MIME\_TYPE\_JP2 \[1.10\]

        - Cairo::Surface::MIME\_TYPE\_JPEG \[1.10\]

        - Cairo::Surface::MIME\_TYPE\_PNG \[1.10\]

        - Cairo::Surface::MIME\_TYPE\_URI \[1.10\]

        - Cairo::Surface::MIME\_TYPE\_UNIQUE\_ID \[1.12\]

        - Cairo::Surface::MIME\_TYPE\_JBIG2 \[1.14\]

        - Cairo::Surface::MIME\_TYPE\_JBIG2\_GLOBAL \[1.14\]

        - Cairo::Surface::MIME\_TYPE\_JBIG2\_GLOBAL\_PARAMS \[1.14\]

        - Cairo::Surface::MIME\_TYPE\_CCITT\_FAX \[1.16\]

        - Cairo::Surface::MIME\_TYPE\_CCITT\_FAX\_PARAMS \[1.16\]

        - Cairo::Surface::MIME\_TYPE\_EPS \[1.16\]

        - Cairo::Surface::MIME\_TYPE\_EPS\_PARAMS \[1.16\]

        - $mime\_data: binary data string

    - $status = $surface-\>copy\_page \[1.6\]

  - $status: *Cairo::Status*

    - $status = $surface-\>show\_page \[1.6\]

  - $status: *Cairo::Status*

    - $boolean = $surface-\>has\_show\_text\_glyphs \[1.8\]

  *Image Surfaces -- Rendering to memory buffers*

- $surface = Cairo::ImageSurface-\>create ($format, $width, $height)

  - $format: *Cairo::Format*

    - $width: integer

    - $height: integer

    - $surface = Cairo::ImageSurface-\>create\_for\_data ($data, $format, $width, $height, $stride)

  - $data: image data

    - $format: *Cairo::Format*

    - $width: integer

    - $height: integer

    - $stride: integer

    - $data = $surface-\>get\_data \[1.2\]

  - $format = $surface-\>get\_format \[1.2\]

  - $width = $surface-\>get\_width

  - $height = $surface-\>get\_height

  - $stride = $surface-\>get\_stride \[1.2\]

  - $stride = Cairo::Format::stride\_for\_width ($format, $width) \[1.6\]

  - $format: *Cairo::Format*

    - $width: integer

    *PDF Surfaces -- Rendering PDF documents*

- $surface = Cairo::PdfSurface-\>create ($filename, $width\_in\_points, $height\_in\_points) \[1.2\]

  - $filename: string

    - $width\_in\_points: double

    - $height\_in\_points: double

    - $surface = Cairo::PdfSurface-\>create\_for\_stream ($callback, $callback\_data, $width\_in\_points, $height\_in\_points) \[1.2\]

  - $callback: *Cairo::WriteFunc*

    - $callback\_data: scalar

    - $width\_in\_points: double

    - $height\_in\_points: double

    - $surface-\>set\_size ($width\_in\_points, $height\_in\_points) \[1.2\]

  - $width\_in\_points: double

    - $height\_in\_points: double

    - $surface-\>restrict\_to\_version ($version) \[1.10\]

  - $version: *Cairo::PdfVersion*

    - @versions = Cairo::PdfSurface::get\_versions \[1.10\]

  - $string = Cairo::PdfSurface::version\_to\_string ($version) \[1.10\]

  - $version: *Cairo::PdfVersion*

    - $item\_id = $surface-\>add\_outline($parent\_id, $name, $attributes, $flags) \[1.16\]

  - $item\_id: int, item ID

    - $parent\_id: parent item id or Cairo::PdfSurface::OUTLINE\_ROOT

    - $name: string, item display

    - $attributes: string, item attributes

    - $flags: list reference, item flags

    - $surface-\>set\_metadata($name, $value) \[1.16\]

  - $name: string

    - $value: string

    - $surface-\>set\_page\_label($label) \[1.16\]

  - $label: string, page label

    - $surface-\>set\_thumbnail\_size($width, $height) \[1.16\]

  - $width: int, thumbnail width

    - $height: int, thumbnail height

    *PNG Support -- Reading and writing PNG images*

- $surface = Cairo::ImageSurface-\>create\_from\_png ($filename)

  - $filename: string

    - Cairo::ReadFunc: $data = sub { my ($callback\_data, $length) = @\_; }

  - $data: binary image data, of length $length

    - $callback\_data: scalar, user data

    - $length: integer, bytes to read

    - $surface = Cairo::ImageSurface-\>create\_from\_png\_stream ($callback, $callback\_data)

  - $callback: *Cairo::ReadFunc*

    - $callback\_data: scalar

    - $status = $surface-\>write\_to\_png ($filename)

  - $filename: string

    - Cairo::WriteFunc: sub { my ($callback\_data, $data) = @\_; }

  - $callback\_data: scalar, user data

    - $data: binary image data, to be written

    - $status = $surface-\>write\_to\_png\_stream ($callback, $callback\_data)

  - $callback: *Cairo::WriteFunc*

    - $callback\_data: scalar

    *PostScript Surfaces -- Rendering PostScript documents*

- $surface = Cairo::PsSurface-\>create ($filename, $width\_in\_points, $height\_in\_points) \[1.2\]

  - $filename: string

    - $width\_in\_points: double

    - $height\_in\_points: double

    - $surface = Cairo::PsSurface-\>create\_for\_stream ($callback, $callback\_data, $width\_in\_points, $height\_in\_points) \[1.2\]

  - $callback: *Cairo::WriteFunc*

    - $callback\_data: scalar

    - $width\_in\_points: double

    - $height\_in\_points: double

    - $surface-\>set\_size ($width\_in\_points, $height\_in\_points) \[1.2\]

  - $width\_in\_points: double

    - $height\_in\_points: double

    - $surface-\>dsc\_begin\_setup \[1.2\]

  - $surface-\>dsc\_begin\_page\_setup \[1.2\]

  - $surface-\>dsc\_comment ($comment) \[1.2\]

  - $comment: string

    - $surface-\>restrict\_to\_level ($level) \[1.6\]

  - $level: *Cairo::PsLevel*

    - @levels = Cairo::PsSurface::get\_levels \[1.6\]

  - $string = Cairo::PsSurface::level\_to\_string ($level) \[1.6\]

  - $level: *Cairo::PsLevel*

    - $surface-\>set\_eps ($eps) \[1.6\]

  - $eps: boolean

    - $eps = $surface-\>get\_eps \[1.6\]

  *Recording Surfaces -- Records all drawing operations*

- $surface = Cairo::RecordingSurface-\>create ($content, $extents) \[1.10\]

  - $content: *Cairo::Content*

    - $extents: *Cairo::Rectangle*

    - ($x0, $y0, $width, $height) = $surface-\>ink\_extents \[1.10\]

  - $extents\_ref = $surface-\>get\_extents \[1.12\]

  - $extents\_ref: *Cairo::Rectangle* reference

    *SVG Surfaces -- Rendering SVG documents*

- $surface = Cairo::SvgSurface-\>create ($filename, $width\_in\_points, $height\_in\_points) \[1.2\]

  - $filename: string

    - $width\_in\_points: double

    - $height\_in\_points: double

    - $surface = Cairo::SvgSurface-\>create\_for\_stream ($callback, $callback\_data, $width\_in\_points, $height\_in\_points) \[1.2\]

  - $callback: *Cairo::WriteFunc*

    - $callback\_data: scalar

    - $width\_in\_points: double

    - $height\_in\_points: double

    - $surface-\>restrict\_to\_version ($version) \[1.2\]

  - $version: *Cairo::SvgVersion*

    - @versions = Cairo::SvgSurface::get\_versions \[1.2\]

  - $string = Cairo::SvgSurface::version\_to\_string ($version) \[1.2\]

  - $version: *Cairo::SvgVersion*

    ### Utilities

*Version Information -- Run-time and compile-time version checks.*

- $version\_code = Cairo-\>lib\_version

  - $version\_string = Cairo-\>lib\_version\_string

  These two functions return the version of libcairo that the program is currently running against.

- $version\_code = Cairo-\>LIB\_VERSION

  Returns the version of libcairo that Cairo was compiled against.

- $version\_code = Cairo-\>LIB\_VERSION\_ENCODE ($major, $minor, $micro)

  - $major: integer

    - $minor: integer

    - $micro: integer

    Encodes the version `"$major.$minor.$micro"` as an integer suitable for comparison against `"Cairo->lib_version"` and `"Cairo->LIB_VERSION"`.

## SEE ALSO

- \<http://cairographics.org/documentation\>

  Lists many available resources including tutorials and examples

- \<http://cairographics.org/manual/\>

  Contains the reference manual

## AUTHORS

- Ross McFarland \<rwmcfa1 at neces dot com\>

  - Torsten Schoenfeld \<kaffeetisch at gmx dot de\>

  ## COPYRIGHT

Copyright (C) 2004-2013 by the cairo perl team
