A library written in one programming language may be used in another language if bindings are written; Cairo has a range of bindings for various languages including C++, C# and other CLI languages, Delphi, Eiffel, Fortran, Factor, Harbour, Haskell, Julia, Lua, Perl, PHP, Python, Ruby, Rust, Scheme, Smalltalk and several others like Gambas (Visual Basic like).2
Since Cairo is only a drawing library, it can be quite useful to integrate it with a graphical user interface toolkit.
Cairo supports output (including rasterisation) to a number of different back-ends, known as "surfaces" in its code. Back-ends support includes output to the X Window System, via both Xlib and XCB, Win32 GDI, OS X Quartz Compositor, the BeOS API, OS/2, OpenGL contexts (directly4 and via glitz), local image buffers, PNG files, PDF, PostScript, DirectFB and SVG files.
There are other back-ends in development targeting the graphics APIs OpenVG,5 Qt,6 Skia,7 and Microsoft's Direct2D.8 The BeOS, OS/2, DirectFB and OpenGL backends were dropped in 2022.910
The Cairo drawing model relies on a three-layer model.
Any drawing process takes place in three steps:
This constitutes a fundamentally different approach from Scalable Vector Graphics (SVG), which specifies the color of shapes with Cascading Style Sheets (CSS) rules. Whereas Cairo would create a mask of a shape, then make a source for it, and then transfer them onto the surface, an SVG file would simply specify the shape with a style attribute. That said, the models are not incompatible; many SVG renderers use Cairo for heavy lifting.11
Quite complex "Hello world" graphics can be drawn with the help of Cairo with only a few lines of source code:
Cairo is popular in the open source community for providing cross-platform support for advanced 2D drawing.
Keith Packard and Carl Worth founded the Cairo project for use in the X Window System.20 It was originally (until at least 2003) called Xr or Xr/Xc. The name was changed to emphasize the idea of a cross-platform library to access display server, not tied to the X Window System.21 The name Cairo derives from the original name Xr, interpreted as the Greek letters chi and rho.22
Cairo handles Latin and CJK based fonts, but does not directly support complex text layout fonts, which require shaping the glyphs. The Cairo developers recommend using Pango, which provides complex text layout and can integrate with Cairo.23
"Cairo homepage". Retrieved October 30, 2010. http://cairographics.org/ ↩
"Cairo Language Bindings". Retrieved April 16, 2014. http://cairographics.org/bindings/ ↩
"SDL". Cairo. February 17, 2009. Retrieved November 3, 2014. http://cairographics.org/SDL/ ↩
Chris Wilson (July 22, 2009). "New OpenGL backend merged". Retrieved February 12, 2010. http://lists.cairographics.org/archives/cairo/2009-July/017713.html ↩
Øyvind Kolås (January 24, 2008). "Announcing OpenVG backend". Retrieved February 12, 2010. http://lists.freedesktop.org/archives/cairo/2008-January/012833.html ↩
Vladimir Vukićević (May 6, 2008). "Well Isn't That Qt". Archived from the original on April 9, 2010. Retrieved February 12, 2010. https://web.archive.org/web/20100409072817/http://blog.vlad1.com/2008/05/06/well-isnt-that-qt/ ↩
Chris Wilson (August 31, 2009). "Cool Stuff". Retrieved February 12, 2010. http://lists.cairographics.org/archives/cairo/2009-August/018052.html ↩
Bas Schouten (November 22, 2009). "Direct2D: Hardware Rendering a Browser". Retrieved February 12, 2010. http://www.basschouten.com/blog1.php/2009/11/22/direct2d-hardware-rendering-a-browser ↩
Larabel, Michael (February 27, 2022). "Cairo graphics library drops many old backends". Phoronix. Retrieved June 5, 2022. https://www.phoronix.com/scan.php?page=news_item&px=Cairo-2022-Drops-Old-Code ↩
Larabel, Michael (January 29, 2023). "Cairo Graphics Library Drops OpenGL Support After A Decade Of Inactivity". Phoronix. Retrieved February 7, 2025. https://www.phoronix.com/news/Cairo-Drops-OpenGL ↩
"GNOME/librsvg". GitHub. https://github.com/GNOME/librsvg ↩
"GTK+ to Use Cairo Vector Engine". February 5, 2005. Retrieved December 27, 2009. http://developers.slashdot.org/article.pl?sid=05/02/04/2021236 ↩
"Details of package gtk-vector-screenshot in stretch". Debian. GitHub https://packages.debian.org/stretch/gtk-vector-screenshot ↩
"Mono - Drawing". Retrieved December 27, 2009. http://www.mono-project.com/Drawing ↩
"Moonlight Notes". Retrieved December 27, 2009. http://www.mono-project.com/MoonlightNotes#Rendering ↩
"Gecko 1.9 Roadmap". Retrieved December 27, 2009. https://wiki.mozilla.org/Gecko_1.9_Roadmap#cairo_Graphics_Substrate ↩
"ReleaseNotes046". Inkscape Wiki. Retrieved March 31, 2008. http://wiki.inkscape.org/wiki/index.php/ReleaseNotes046 ↩
"ManimCE tutorial by TheoremOfBeethoven — ManimCE tutorial by TB documentation". zavden.github.io. Retrieved January 29, 2023. https://zavden.github.io/manimce-tutorial/docs/html/index.html ↩
"Gnuplot version 4.4.0 announcement". Gnuplot homepage. Archived from the original on May 14, 2011. Retrieved February 22, 2011. https://web.archive.org/web/20110514115341/http://www.gnuplot.info/announce.4.4.0 ↩
"Xr: Cross-device Rendering for Vector Graphics". Retrieved June 8, 2009. http://cworth.org/~cworth/papers/xr_ols2003/html/ ↩
"Mailing list thread about the Cairo name change". July 15, 2003. Retrieved June 8, 2009. http://lists.cairographics.org/archives/cairo/2003-July/000192.html ↩
"Mailing list thread about the Cairo name change". July 12, 2003. Retrieved December 2, 2006. http://lists.freedesktop.org/archives/cairo/2003-July/000184.html ↩
"How do I use Pango instead of Cairo's "toy" text API?". Retrieved March 20, 2024. https://www.cairographics.org/FAQ/#using_pango ↩