b=404092, upgrade cairo to 1.5.2-55
authorvladimir@pobox.com
Thu, 29 Nov 2007 12:06:56 -0800
changeset 8452 c8b4609b0b91a73f7883e44c406096986272060f
parent 8451 d5d0e96d0a887fbc196fcc57e17e02ed43dac711
child 8453 0f882b9f6b6a12a25ca9afe16c72510496e2b9fd
push id1
push userbsmedberg@mozilla.com
push dateThu, 20 Mar 2008 16:49:24 +0000
treeherdermozilla-central@61007906a1f8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs404092
milestone1.9b2pre
b=404092, upgrade cairo to 1.5.2-55
gfx/cairo/README
gfx/cairo/cairo/AUTHORS
gfx/cairo/cairo/INSTALL
gfx/cairo/cairo/NEWS
gfx/cairo/cairo/README
gfx/cairo/cairo/TODO
gfx/cairo/cairo/src/Makefile.in
gfx/cairo/cairo/src/cairo-analysis-surface-private.h
gfx/cairo/cairo/src/cairo-analysis-surface.c
gfx/cairo/cairo/src/cairo-array.c
gfx/cairo/cairo/src/cairo-atomic-private.h
gfx/cairo/cairo/src/cairo-atomic.c
gfx/cairo/cairo/src/cairo-atsui-font.c
gfx/cairo/cairo/src/cairo-base85-stream.c
gfx/cairo/cairo/src/cairo-bentley-ottmann.c
gfx/cairo/cairo/src/cairo-cache-private.h
gfx/cairo/cairo/src/cairo-cache.c
gfx/cairo/cairo/src/cairo-cff-subset.c
gfx/cairo/cairo/src/cairo-clip-private.h
gfx/cairo/cairo/src/cairo-clip.c
gfx/cairo/cairo/src/cairo-compiler-private.h
gfx/cairo/cairo/src/cairo-debug.c
gfx/cairo/cairo/src/cairo-deflate-stream.c
gfx/cairo/cairo/src/cairo-directfb-surface.c
gfx/cairo/cairo/src/cairo-features.h.in
gfx/cairo/cairo/src/cairo-fixed-private.h
gfx/cairo/cairo/src/cairo-font-face.c
gfx/cairo/cairo/src/cairo-font-options.c
gfx/cairo/cairo/src/cairo-ft-font.c
gfx/cairo/cairo/src/cairo-ft-private.h
gfx/cairo/cairo/src/cairo-glitz-surface.c
gfx/cairo/cairo/src/cairo-gstate.c
gfx/cairo/cairo/src/cairo-hash-private.h
gfx/cairo/cairo/src/cairo-hash.c
gfx/cairo/cairo/src/cairo-hull.c
gfx/cairo/cairo/src/cairo-image-surface.c
gfx/cairo/cairo/src/cairo-lzw.c
gfx/cairo/cairo/src/cairo-malloc-private.h
gfx/cairo/cairo/src/cairo-matrix.c
gfx/cairo/cairo/src/cairo-meta-surface-private.h
gfx/cairo/cairo/src/cairo-meta-surface.c
gfx/cairo/cairo/src/cairo-mutex-list-private.h
gfx/cairo/cairo/src/cairo-mutex-private.h
gfx/cairo/cairo/src/cairo-os2-surface.c
gfx/cairo/cairo/src/cairo-output-stream-private.h
gfx/cairo/cairo/src/cairo-output-stream.c
gfx/cairo/cairo/src/cairo-paginated-private.h
gfx/cairo/cairo/src/cairo-paginated-surface.c
gfx/cairo/cairo/src/cairo-path-fill.c
gfx/cairo/cairo/src/cairo-path-fixed-private.h
gfx/cairo/cairo/src/cairo-path-fixed.c
gfx/cairo/cairo/src/cairo-path-private.h
gfx/cairo/cairo/src/cairo-path-stroke.c
gfx/cairo/cairo/src/cairo-path.c
gfx/cairo/cairo/src/cairo-pattern.c
gfx/cairo/cairo/src/cairo-pdf-surface-private.h
gfx/cairo/cairo/src/cairo-pdf-surface.c
gfx/cairo/cairo/src/cairo-pen.c
gfx/cairo/cairo/src/cairo-png.c
gfx/cairo/cairo/src/cairo-polygon.c
gfx/cairo/cairo/src/cairo-private.h
gfx/cairo/cairo/src/cairo-ps-surface-private.h
gfx/cairo/cairo/src/cairo-ps-surface.c
gfx/cairo/cairo/src/cairo-ps.h
gfx/cairo/cairo/src/cairo-quartz-private.h
gfx/cairo/cairo/src/cairo-quartz-surface.c
gfx/cairo/cairo/src/cairo-reference-count-private.h
gfx/cairo/cairo/src/cairo-region-private.h
gfx/cairo/cairo/src/cairo-region.c
gfx/cairo/cairo/src/cairo-scaled-font-private.h
gfx/cairo/cairo/src/cairo-scaled-font-subsets-private.h
gfx/cairo/cairo/src/cairo-scaled-font-subsets.c
gfx/cairo/cairo/src/cairo-scaled-font.c
gfx/cairo/cairo/src/cairo-skiplist.c
gfx/cairo/cairo/src/cairo-spline.c
gfx/cairo/cairo/src/cairo-stroke-style.c
gfx/cairo/cairo/src/cairo-surface-fallback.c
gfx/cairo/cairo/src/cairo-surface-private.h
gfx/cairo/cairo/src/cairo-surface.c
gfx/cairo/cairo/src/cairo-svg-surface.c
gfx/cairo/cairo/src/cairo-traps.c
gfx/cairo/cairo/src/cairo-truetype-subset.c
gfx/cairo/cairo/src/cairo-type1-fallback.c
gfx/cairo/cairo/src/cairo-type1-subset.c
gfx/cairo/cairo/src/cairo-types-private.h
gfx/cairo/cairo/src/cairo-unicode.c
gfx/cairo/cairo/src/cairo-wideint-private.h
gfx/cairo/cairo/src/cairo-win32-font.c
gfx/cairo/cairo/src/cairo-win32-printing-surface.c
gfx/cairo/cairo/src/cairo-win32-private.h
gfx/cairo/cairo/src/cairo-win32-surface.c
gfx/cairo/cairo/src/cairo-win32.h
gfx/cairo/cairo/src/cairo-xcb-surface.c
gfx/cairo/cairo/src/cairo-xlib-display.c
gfx/cairo/cairo/src/cairo-xlib-private.h
gfx/cairo/cairo/src/cairo-xlib-screen.c
gfx/cairo/cairo/src/cairo-xlib-surface.c
gfx/cairo/cairo/src/cairo.c
gfx/cairo/cairo/src/cairoint.h
gfx/cairo/cairo/src/test-fallback-surface.c
gfx/cairo/cairo/src/test-meta-surface.c
gfx/cairo/cairo/src/test-paginated-surface.c
gfx/cairo/endian.patch
gfx/cairo/glitz-endian.patch
gfx/cairo/libpixman/src/pixman-compose.c
gfx/cairo/libpixman/src/pixman-edge-imp.h
gfx/cairo/libpixman/src/pixman-edge.c
gfx/cairo/libpixman/src/pixman-image.c
gfx/cairo/libpixman/src/pixman-mmx.c
gfx/cairo/libpixman/src/pixman-pict.c
gfx/cairo/libpixman/src/pixman-private.h
gfx/cairo/libpixman/src/pixman-trap.c
gfx/cairo/libpixman/src/pixman-utils.c
gfx/cairo/libpixman/src/pixman.h
gfx/cairo/win32-glyph-metrics.patch
gfx/thebes/public/gfxASurface.h
gfx/thebes/public/gfxContext.h
gfx/thebes/public/gfxWindowsSurface.h
gfx/thebes/src/gfxContext.cpp
gfx/thebes/src/gfxWindowsSurface.cpp
--- a/gfx/cairo/README
+++ b/gfx/cairo/README
@@ -2,31 +2,27 @@ Snapshots of cairo and glitz for mozilla
 
 We only include the relevant parts of each release (generally, src/*.[ch]),
 as we have Makefile.in's that integrate into the Mozilla build system.  For
 documentation and similar, please see the official tarballs at
 http://www.cairographics.org/.
 
 VERSIONS:
 
-  cairo (1.5.x - d8b0de01d67cdf73d8266a73f54ba1ac42fee3c9)
-  pixman (0.9.x - 3be35594c99b7abd2af43b66349ca53bfa1462d6)
+  cairo (1.5.x - 1.5.2-55-g39b8ddf)
+  pixman (0.9.x - pixman-0.9.6-13-g4193b3c)
   glitz 0.5.2 (cvs - 2006-01-10)
 
 ***** NOTE FOR VISUAL C++ 6.0 *****
 
 VC6 is not supported.  Please upgrade to VC8.
 
 ==== Patches ====
 
 Some specific things:
 
 max-font-size.patch: Clamp freetype font size to 1000 to avoid overflow issues
 
 win32-logical-font-scale.patch: set CAIRO_WIN32_LOGICAL_FONT_SCALE to 1
 
 nonfatal-assertions.patch: Make assertions non-fatal
 
-win32-glyph-metrics.patch: GetGlyphOutline only works on Truetype fonts,
-so for non-Truetype fonts, assume no left or right bearing and use the
-font ascent and descent for the glyph extents.
-
 endian.patch: include cairo-platform.h for endian macros
--- a/gfx/cairo/cairo/AUTHORS
+++ b/gfx/cairo/cairo/AUTHORS
@@ -1,26 +1,99 @@
+Josh Aas <joshmoz@gmail.com> Memory leak fix for quartz backend
+Daniel Amelang <dan@amelang.net> Many (magic) floating-point optimizations
 Shawn T. Amundson <amundson@gtk.org> Build fix
 Olivier Andrieu <oliv__a@users.sourceforge.net> PNG backend
 Peter Dennis Bartok <peter@novonyx.com> Bug fix for clipping
 Dave Beckett <dajobe@debian.org> Build fixes, Debian packaging
+Christian Biesinger <cbiesinger@web.de> BeOS backend
+Billy Biggs <vektor@dumbterm.net> Pixman code merge. Optimization. Fixes for subtle rendering bugs.
+Hans Breuer <hans@breuer.org> win32 bug fixes, build fixes, and improvements
+Brian Cameron <brian.cameron@sun.com> Flag bug in Sun's X server
+Damien Carbery <damien.carbery@sun.com> Build fixes
 Andrew Chant <andrew.chant@utoronto.ca> Adding const where needed
+Steve Chaplin <stevech1097@yahoo.com.au> Bug fixes for PNG reading
+Tomasz Cholewo <cholewo@ieee-cis.org> Bug fixes
+Manu Cornet <manu@manucornet.net> SVG build fix
+Frederic Crozat <fcrozat@mandriva.com> Fix test suite for OPD platforms (IA64 or PPC64)
+Radek Doulík <rodo@novell.com> Bug report and test case
+John Ehresman <jpe@wingide.com> Build fixes for win32
 John Ellson <ellson@research.att.com> First font/glyph extents functions
+Michael Emmel <mike.emmel@gmail.com> DirectFB backend
+Miklós Erdélyi <erdelyim@gmail.com> Fix typo leading to a crash
+Behdad Esfahbod <behdad@behdad.org> Huge piles of bug fixes, improvements, and general maintenance
+Brian Ewins <Brian.Ewins@gmail.com> ATSUI maintenance (first success at making it really work)
+Bertram Felgenhauer <int-e@gmx.de> Fixes for subtle arithmetic errors
+Bdale Garbee <bdale@gag.com> Provided essential support for cairo achitecture sessions
+Jens Granseuer <jensgr@gmx.net> Fixes to generate proper compiler flags
+Laxmi Harikumar <laxmi.harikumar@digital.com> Build fix
+J. Ali Harlow <ali@avrc.city.ac.uk> win32 backend updates
+Mathias Hasselmann <mathias.hasselmann@gmx.de> Significant reduction of calls to malloc
 Richard Henderson <rth@twiddle.net> "slim" macros for better shared libraries 
 James Henstridge <james@daa.com.au> Build fixes related to freetype
 Graydon Hoare <graydon@redhat.com> Support for non-render X server, first real text support
 Thomas Hunger <info@teh-web.de> Initial version of cairo_in_stroke/fill
-Kristian Høgsberg <krh@redhat.com> PDF backend
+Kristian Høgsberg <krh@redhat.com> PDF backend, PS backend with meta-surfaces
+Amaury Jacquot <sxpert@esitcom.org> Documentation review, appplication testing
+Adrian Johnson <ajohnson@redneon.com> PDF backend improvement
+Michael Johnson <ahze@ahze.net> Bug fix for pre-C99 compilers
+Jonathon Jongsma <jonathon.jongsma@gmail.com> Fix documentation typos
+Øyvind Kolås <pippin@freedesktop.org> Bug fixes. Better default values.
+Martin Kretzschmar <martink@gnome.org> Arithmetic fix for 64-bit architectures
+Mathieu Lacage <Mathieu.Lacage@sophia.inria.fr> several bug/typo fixes
+Dominic Lachowicz <domlachowicz@gmail.com> PDF conformance fix, fix image surface to zero out contents
 Alexander Larsson <alexl@redhat.com> Profiling and performance fixes.
+Tor Lillqvist <tml@novell.com> win32 build fixes, build scripts
+Jinghua Luo <sunmoon1997@gmail.com> Add bitmap glyph transformation, many freetype and glitz fixes
+Luke-Jr <luke-jr@utopios.org> Build fix for cross-compiling
+Kjartan Maraas <kmaraas@gnome.org> Several fixes for sparse, lots of debug help for multi-thread bugs
 Jordi Mas <jordi@ximian.com> Bug fix for cairo_show_text
+Nicholas Miell <nmiell@gmail.com> Fixes for linking bugs on AMD64
+Eugeniy Meshcheryakov <eugen@debian.org> PS/PDF font subsetting improvements
+Zakharov Mikhail <zmey20000@yahoo.com> Build fix for HP-UX
+Christopher (Monty) Montgomery <xiphmont@gmail.com> Performnace fix (subimage_copy), multi-thread testing
+Tim Mooney <enchanter@users.sourceforge.net> Fix test suite to compile with Solaris compiler
+Jeff Muizelaar <jeff@infidigm.net> Patient, painful, pixman code merge. Many fixes for intricacies of dashing.
+Yevgen Muntyan <muntyan@tamu.edu> win32 build fix
+Declan Naughton <piratepenguin@gmail.com> Fix documentation typos
+Peter Nilsson <c99pnn@cs.umu.se> Glitz backend
+Henning Noren <henning.noren.402@student.lu.se> Fix memory leak
+Geoff Norton <gnorton@customerdna.com> Build fixes
+Robert O'Callahan <rocallahan@novell.com> Const-correctness fixes, several new API functions for completeness (and to help mozilla)
+Ian Osgood <iano@quirkster.com> XCB backend maintenance
+Benjamin Otte <in7y118@public.uni-hamburg.de> Refinements to cairo/perf timing
+Mike Owens <etc@filespanker.com> Bug fixes
+Emmanuel Pacaud <emmanuel.pacaud@lapp.in2p3.fr> SVG backend
 Keith Packard <keithp@keithp.com> Original concept, polygon tessellation, dashing, font metrics rewrite
+Stuart Parmenter <pavlov@pavlov.net> Original GDI+ backend, win32 fixes
+Alfred Peng <alfred.peng@sun.com> Fixes for Sun compilers and for a memory leak
 Christof Petig <christof@petig-baender.de> Build fixes related to freetype
+Joonas Pihlaja <jpihlaja@cc.helsinki.fi> Huge improvements to the tessellator performance
+Mart Raudsepp <leio@dustbite.net> Build fixes
 David Reveman <davidr@novell.com> New pattern API, glitz backend
 Calum Robinson <calumr@mac.com> Quartz backend
+Pavel Roskin <proski@gnu.org> Several cleanups to eliminate warnings
+Tim Rowley <tim.rowley@gmail.com> Quartz/ATSUI fixes, X server workarounds, win32 glyph path support, test case to expose gradient regression
+Soeren Sandmann <sandmann@daimi.au.dk> Lots of MMX love for pixman compositing
+Torsten Schönfeld <kaffeetisch@gmx.de> Build fixes
 Jamey Sharp <jamey@minilop.net> Surface/font backend virtualization, XCB backend
+Jason Dorje Short <jdorje@users.sf.net> Build fixes and bug fixes
+Jeff Smith <whydoubt@yahoo.com> Fixes for intricacies of stroking code
+Travis Spencer <tspencer@cs.pdx.edu> XCB backend fix
 Bill Spitzak <spitzak@d2.com> Build fix to find Xrender.h without xrender.pc
-Owen Taylor <otaylor@redhat.com> Font support rewrite
+Zhe Su <james.su@gmail.com> Add support for fontconfig's embeddedbitmap option
+Owen Taylor <otaylor@redhat.com> Font rewrite, documentation, win32 backend
+Alp Toker <alp@atoker.com> Fix several code/comment typos
+Malcolm Tredinnick <malcolm@commsecure.com.au> Documentation fixes
+David Turner <david@freetype.org> Optimize gradient calculations
+Kalle Vahlman <kalle.vahlman@gmail.com> Allow perf reports to be compared across different platforms
 Sasha Vasko <sasha@aftercode.net> Build fix to compile without xlib backend
-Vladimir Vukicevic <vladimir@pobox.com> Bug fix for clipping
+Vladimir Vukicevic <vladimir@pobox.com> Quartz backend rewrite, win32/quartz maintenance
+Jonathan Watt <jwatt@jwatt.org> win32 fixes
+Peter Weilbacher <pmw@avila.aip.de> OS/2 backend
+Dan Williams <dcbw@redhat.com> Implemnt MMX function to help OLPC
+Chris Wilson <chris@chris-wilson.co.uk> Large-scale robustness improvements, (warn_unsed_result and malloc failure injection)
 Carl Worth <cworth@isi.edu> Original library, support for paths, images
 Richard D. Worth <richard@theworths.org> Build fixes for cygwin
+Kent Worsnop <kworsnop@accesswave.ca> Fix PDF dashing bug
+Dave Yeo <daveryeo@telus.net> Build fix for win32
 
 (please let us know if we have missed anyone)
--- a/gfx/cairo/cairo/INSTALL
+++ b/gfx/cairo/cairo/INSTALL
@@ -1,9 +1,128 @@
-This package uses automake, in order to generate the Makefiles use:
+Quick-start build instructions
+------------------------------
+1) Configure the package:
+
+	./configure
+
+2) Compile it:
+
+	make
+
+3) Install it:
+
+	make install
+
+This final step may require temporary root access (eg. with sudo) if
+you don't have write permission to the directory in which cairo will
+be installed.
+
+NOTE: If you are working with source from git/cvs rather than from a tar
+file, then you should use ./autogen.sh in place of ./configure
+anywhere it is mentioned in these instructions.
+
+More detailed build instructions
+--------------------------------
+
+1) Configure the package
 
-	$ autogen.sh
+   The first step in building cairo is to configure the package by
+   running the configure script. The configure script attempts to
+   automatically detect as much as possible about your system. So,
+   you should primarily just accept its defaults by running:
+
+	./configure
+
+   The configure script does accept a large number of options for
+   fine-tuning its behavior. See "./configure --help" for a complete
+   list. The most commonly used options are discussed here.
+
+   --prefix=PREFIX
+
+	This option specifies the directory under which the software
+	should be installed. By default configure will choose a
+	directory such as /usr/local. If you would like to install
+	cairo to some other location, pass the director to configure
+	with the --prefix option. For example:
+
+		./configure --prefix=/opt/cairo
+
+	would install cairo into the /opt/cairo directory. You could
+	also choose a prefix directory within your home directory if
+	you don't have write access to any system-wide directory.
+
+	After installing into a custom prefix, you will need to set
+	some environment variables to allow the software to be
+	found. Assuming the /opt/cairo prefix and assuming you are
+	using the bash shell, the following environment variables
+	should be set:
+
+		PKG_CONFIG_PATH=/opt/cairo/lib/pkgconfig
+		LD_LIBRARY_PATH=/opt/cairo/lib
+		export PKG_CONFIG_PATH LD_LIBRARY_PATH
 
-After that, standard build procedures apply:
+	(NOTE: On mac OS X, at least, use DYLD_LIBRARY_PATH in place
+	       of LD_LIBRARY_PATH above.)
+
+    --enable-quartz
+    --enable-atsui
+    --enable-xcb
+    --enable-glitz
+    --enable-beos
+    --enable-os2
+    --enable-directfb
+
+	Some of cairo's backends are marked as experimental and will
+	not be built by default. If you would like to build and
+	experiment with these backends, you will need to pass one of
+	the above options to the configure script. You may need to
+	have certain libraries installed first as discussed in the
+	dependencies section of the README file.
+
+    --disable-xlib
+    --disable-win32
+    --disable-png
+    --disable-freetype
+    --disable-ps
+    --disable-pdf
+    --disable-svg
+
+	Cairo's configure script detects the libraries needed to build
+	each stable backend, and when it finds them, enables each
+	backend. If you would like to override this detection and
+	disable a backend, (even when it would be possible to build
+	it), use one of the options above to disable the backend.
 
-	$ make
-	# make install
+2) Compile the package:
+
+   This step is very simple. Just:
+
+	make
+
+   The Makefiles included with cairo are designed to work on as many
+   different systems as possible.
+
+   When cairo is compiled, you can also run some automated tests of
+   cairo with:
+
+	make check
 
+   NOTE: Some versions of X servers will cause the -xlib tests to
+   report failures in make check even when cairo is working just
+   fine. If you see failures in nothing but -xlib tests, please
+   examine the corresponding -xlib-out.png images and compare them to
+   the -ref.png reference images (the -xlib-diff.png images might also
+   be useful). If the results seem "close enough" please do not report
+   a bug against cairo as the "failures" you are seeing are just due
+   to subtle variations in X server implementations.
+
+3) Install the package:
+
+   The final step is to install the package with:
+
+	make install
+
+   If you are installing to a system-wide location you may need to
+   temporarily acquite root access in order to perform this
+   operation. A good way to do this is to use the sudo program:
+
+	sudo make install
--- a/gfx/cairo/cairo/NEWS
+++ b/gfx/cairo/cairo/NEWS
@@ -1,58 +1,2799 @@
-Release 0.9.0 (2005-08-08 Carl Worth <cworth@cworth.org>)
+Snapshot 1.5.2 (2007-10-30 Carl Worth <cworth@cworth.org>)
+==========================================================
+This is the first snapshot in cairo's unstable 1.5 series. It comes 4
+months after the 1.4.10 release. This snapshot includes significant
+improvements to PDF and PostScript output, which is one of the things
+in which we're most interested in getting feedback. There are a couple
+of minor API additions, and several optimizations, (primarily in the
+"print/vector" backends). And there are dozens of bug fixes and
+robustness improvements.
+
+New dependency on external pixman library
+-----------------------------------------
+A significant change in this snapshot compared to all previous cairo
+releases is that cairo now depends on an external "pixman" library for
+its software rendering. Previously this same code was compiled
+internally as part of cairo, but now the code is separate so that both
+cairo and the X server can now share common code, (thanks very much to
+Søren Sandmann for his work on separating pixman and maintaining it).
+
+So users will need to acquire and build pixman before being able to
+build cairo. The current release is 0.9.6 and can be obtained from
+here:
+
+	http://cairographics.org/releases/pixman-0.9.6.tar.gz
+
+ which can be verified with:
+
+	http://cairographics.org/releases/pixman-0.9.6.tar.gz.sha1
+	66f01a682c64403a3d7a855ba5aa609ed93bcb9e  pixman-0.9.6.tar.gz
+
+	http://cairographics.org/releases/pixman-0.9.6.tar.gz.sha1.asc
+	(signed by Carl Worth)
+
+Major PDF/PostScript improvements
+---------------------------------
+Adrian Johnson has done some long-awaited work to make cairo's PDF and
+PostScript output more interesting than ever before. First, many
+operations that previously triggered image fallbacks will now be
+rendered as native vectors. These operations include:
+
+	PDF: cairo_push_group, cairo_surface_create_similar,
+	cairo_mask, A8/A1 surface sources, repeating/reflecting linear
+	gradients.
+
+	PostScript: cairo_push_group, cairo_surface_create_similar,
+	gradients, bilevel alpha masks, (for example, all values either 0 or
+	255 for an A8 mask).
+
+Not only that, but when an image fallback is required, it will now be
+limited to only the necessary region. For example, a tiny translucent
+image overlaying a small portion of text would previously caused an
+entire PostScript page to be rendered as a giant image. Now, the
+majority of that page will be nice text, and there will only be a tiny
+image in the output.
+
+Additionally, the PostScript output now carefully encodes text so that
+if it is subsequently converted to PDF, the text will be
+selectable.
+
+This is very exciting progress, and we're hoping to hear from users
+during the 1.5 series about how things have improved, (for example,
+inkscape users doing cairo-based PDF export: please let us know how
+things look). And feel free to pass your thanks along to Adrian for his excellent work.
+
+NOTE: This much improved PDF output makes more sophisticated use of
+functionality in the PDF specification. This means that cairo's output
+will sometimes expose bugs in some free software PDF viewers, (evince,
+poppler, and xpdf, for example), that are not yet ready for such PDF
+files. We're working with the poppler maintainers to get these bugs
+fixed as quickly as possible. In the meantime, please double-check
+with other PDF viewers if cairo-generated PDF files are not being
+rendered correctly. It may be due to a bug in the viewer rather than
+in the PDF file that cairo has created.
+
+Robustness improvements
+-----------------------
+Chris Wilson has made the largest contribution by far to cairo 1.5.2,
+(in number of commits). His more than 150 commits include a huge
+number of fixes to increase cairo's robustness. These fixes make cairo
+more robust against invalid and degenerate input, (NaN, empty path,
+etc.), against size-0 malloc calls, against memory leaks on
+error-recovery paths, and against other failures during error
+handling. He also implemented atomic operations to cairo, and used
+them to fix cairo's previously non-thread-safe reference counting,
+again improving robustness.
+
+Chris has put a tremendous amount of time and effort into writing
+analysis tools for this work, and in running those tools and fixing
+the problems they report. We're very grateful for this work, and hope
+that all cairo users appreciate the more robust implementation that
+results from it.
+
+This work is largely thankless, so it might make sense to notice
+sometime that cairo has been running quite smoothly for you, and when
+you do, send a quick "thank you" off to Chris Wilson, since it
+is all definitely running smoother thanks to his work.
+
+New API
+-------
+There are no major additions to cairo's core API. The only new,
+generic functions are:
+
+	void
+	cairo_surface_copy_page (cairo_surface_t *surface);
+
+	void
+	cairo_surface_show_page (cairo_surface_t *surface);
+
+which can now be used much more conveniently than the existing
+cairo_copy_page and cairo_show_page functions in some
+situations. These functions act identically, but require only a
+cairo_surface_t* and not a cairo_t*.
+
+All other API additions are specific to particular backends.
+
+New cairo-win32 API (new font face function and "win32 printing" surface)
+-------------------------------------------------------------------------
+There is a new function for creating a win32 font face for both a
+logfontw and an hfont together. This complements the existing
+functions for creating a font face from one or the other:
+
+	cairo_font_face_t *
+	cairo_win32_font_face_create_for_logfontw_hfont (LOGFONTW *logfont,
+							 HFONT font);
+
+There is also a new "win32 printing" surface:
+
+	cairo_surface_t *
+	cairo_win32_printing_surface_create (HDC hdc);
+
+This interface looks identical to the original
+cairo_win32_surface_create, (both accept and HDC), but the behavior of
+this new surface is very different. It should only be called with a
+printing DC, and will result in all drawing commands being stored into
+a meta-surface and emitted after each page is complete, with analysis
+to do as minimal image-based fallbacks as necessary. The behavior and
+implementation shares much with the PDF and PostScript backends.
+
+New cairo-ps API (EPS and PostScript level control)
+---------------------------------------------------
+An often requested feature has been the ability to generate
+Encapsulated PostScript (EPS) with cairo. We have that now with the
+following very simple API. Just do cairo_ps_surface_create as usual
+then call this function with a true value:
+
+	void
+	cairo_ps_surface_set_eps (cairo_surface_t       *surface,
+				  cairo_bool_t           eps);
+
+[NOTE: As always with snapshots, it's possible---though not very
+likely---that the API could still be modified before a final
+release. For example, this is the first public cairo function that
+accepts a Boolean parameter. I'm generally opposed to Boolean
+parameters, but this is probably the one case where I'm willing to
+accept one, (namely a "set" function that accepts a single Boolean).]
+
+Also, it is now possible to control what PostScript level to target,
+(either level 2 or level 3), with the following new API:
+
+	typedef enum _cairo_ps_level {
+	    CAIRO_PS_LEVEL_2,
+	    CAIRO_PS_LEVEL_3
+	} cairo_ps_level_t;
+
+	void
+	cairo_ps_surface_restrict_to_level (cairo_surface_t    *surface,
+					    cairo_ps_level_t    level);
+
+	void
+	cairo_ps_get_levels (cairo_ps_level_t const  **levels,
+			     int                      *num_levels);
+
+	const char *
+	cairo_ps_level_to_string (cairo_ps_level_t level);
+
+Improvement for cairo-quartz
+----------------------------
+Brian Ewins had contributed several improvements to cairo-quartz. These
+include an implementation of EXTEND_NONE for linear and radial
+gradients, (so this extend mode will no longer trigger image fallbacks
+for these gradients), as well as native surface-mask clipping, (only
+on OS X 10.4+ where the CGContextClipToMask function is available).
+
+He also fixed a semantic mismatch between cairo and quartz for dashing
+with an odd number of entries in the dash array.
+
+We're grateful for Brian since not many quartz-specific improvements
+to cairo would be happening without him.
+
+Optimizations
+-------------
+Optimize SVG output for when the same path is both filled and stroked,
+and avoid unnecessary identity matrix in SVG output. (Emmanuel Pacaud).
+
+Optimize PS output to take less space (Ken Herron).
+
+Make PS output more compliant with DSC recommendations (avoid initclip
+and copy_page) (Adrian Johnson).
+
+Make PDF output more compact (Adrian Johnson).
+
+Release glyph surfaces after uploading them to the X server, (should
+save some memory for many xlib-using cairo application). (Behdad
+Esfahbod).
+
+Optimize cairo-win32 to use fewer GDI objects (Vladimir Vukicevic).
+
+win32-printing: Avoid falling back to images when alpha == 255
+everywhere. (Adrian Johnson).
+
+win32-printing: Avoid falling back for cairo_push_group and
+cairo_surface_create_similar. (Adrian Johnson)
+
+Bug fixes
+---------
+Avoid potential integer overflows when allocating large buffers
+(Vladimir Vukicevic).
+
+Preparations to allow the 16.16 fixed-point format to change to
+24.8 (Vladimir Vukicevic).
+
+Fix bugs for unsupported X server visuals (rgb565, rgb555, bgr888, and
+abgr8888). (Carl Worth and Vladimir Vukicevic)
+
+Fix bugs in PDF gradients (Adrian Johnson).
+
+Fix cairo-xlib to build without requiring Xrender header
+files (Behdad Esfahbod).
+
+Make cairo more resilient in the case of glyphs not being available in
+the current font. (Behdad Esfahbod)
+
+Prevent crashes when both atsui and ft font backends are compiled in
+(Brian Ewins).
+
+Make font subsetting code more robust against fonts that don't include
+optional tables (Adrian Johnson).
+
+Fix CFF subsetting bug, (which manifested by generating PDF files that
+Apple's Preview viewer could not read) (Adrian Johnson).
+
+Fixed error handling for quartz and ATSUI backends (Brian Ewins).
+
+Avoid rounding problems by pre-transforming to avoid integer-only
+restrictions on transformation in GDI (Adrian Johnson).
+
+Fixed an obscure bug (#7245) computing extents for some stroked
+paths (Carl Worth).
+
+Fix crashes due to extreme transformation of the pen, (seems to show
+up in many .swf files for some reason) (Carl Worth).
+
+Release 1.4.10 (2007-06-27 Carl Worth <cworth@cworth.org>)
+==========================================================
+This is the fifth update in cairo's stable 1.4 series. It comes
+roughly three weeks after the 1.4.8 release. The most significant
+change in this release is a fix to avoid an X error in certain cases,
+(that were causing OpenOffice.org to crash in Fedora). There is also a
+semantic change to include child window contents when using an xlib
+surface as a source, an optimization when drawing many rectangles, and
+several minor fixes.
+
+Eliminate X errors that were killing OO.o (Chris Wilson)
+--------------------------------------------------------
+Cairo is fixed to avoid the X errors propagated when cleaning up
+Render Pictures after the application had already destroyed the
+Drawable they reference. (It would be nice if the X server wouldn't
+complain that some cleanup work is already done, but there you have
+it.) This fixes the bug causing OpenOffice.org to crash as described
+here:
+
+        XError on right click menus in OOo.
+        https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=243811
+
+Use IncludeInferiors when using xlib surface as a source (Ryan Lortie)
+----------------------------------------------------------------------
+When an xlib surface is used as the source of a draw operation the
+contents of child windows are now included in the source data. The
+semantics of drawing to xlib surfaces are unchanged (ie: draws are
+still clipped by child windows overlapping the destination window).
+
+Optimize drawing of many rectangles (Vladimir Vukicevic)
+--------------------------------------------------------
+Avoid O(N*N) loop when filling many axis-aligned rectangles, (either
+many rectangles as separate sub-paths or due to dashing).
+
+Miscellaneous fixes
+-------------------
+Fix cairo-perf on Solaris by linking to librt. (Behdad Esfahbod)
+
+Fix make check for systems that require executable files to have a
+particular extension. (Behdad Esfahbod)
+
+Eliminate some warnings in cairo-quartz. (Brian Ewins)
+
+Fix build-breaking typo for cairo-directfb. (Chris Wilson)
+
+Release 1.4.8 (2007-06-07 Carl Worth <cworth@cworth.org>)
+=========================================================
+This is the fourth update in cairo's stable 1.4 series. It comes just
+over five weeks after the 1.4.6 release. This release includes a
+thread-safe surface-cache for solid patterns which significantly
+improves text rendering with the xlib backend. Also, dozens of error
+paths in cairo have been fixed thanks to extensive fault-injection
+testing by Chris Wilson.
+
+Surface cache for solid patterns
+--------------------------------
+Originally written by Jorn Baayen, the introduction of a small cache
+for surfaces created for solid patterns improves performance
+dramatically. For example, this reduces the volume of X requests
+during text rendering to the same level as Xft.
+
+This cache first made its appearance in a 1.3.x snapshot, but was
+removed before appearing in any previous major release due to
+complications with multi-threaded programs. For example, programs like
+evince that would carefully restrict usage of cairo-xlib to a single
+thread were unpleasantly surprised to find that using cairo-image in a
+separate thread could trigger X requests.
+
+Behdad Esfahbod designed a fix which was implemented by Chris
+Wilson. Now, the necessary X requests are queued up until the next
+time the application directly operates on an xlib surface.
+
+Improved error handling paths
+------------------------------
+Chris Wilson continued the excellent work he started in cairo 1.4.4 to
+make cairo much more robust against out-of-memory and other errors. He
+applied his memory allocation fault injection cairo's main test suite,
+(previously he had applied it to cairo's performance suite).
+
+Chris's testing found dozens of bugs which he fixed. Many of these
+bugs had perhaps never been hit by any users. But at least one was
+hit by the gnome-about program which resulted in dozens of duplicated
+bug reports against that program:
+
+	http://bugzilla.gnome.org/show_bug.cgi?id=431990
+
+We were very pleasantly surprised to see this bug get fixed as a
+side-effect of Chris's work. Well done, Chris!
+
+Other fixes
+-----------
+Cleanup of mutex declarations (Behdad Esfahbod)
+
+Remove unnecessary clip region from SVG output (Emmanuel Pacaud)
+
+Remove Xsun from the buggy_repeat blacklist (Elaine Xiong)
+
+ATSUI: Fix glyph measurement: faster and more correct (Brian Ewins)
+
+Quartz: fixed 'extend' behaviour for patterns, improved pattern performance,
+and a few smaller correctness fixes. (Brian Ewins, Vladimir Vukicevic)
+
+Release 1.4.6 (2007-05-01 Carl Worth <cworth@cworth.org>)
 =========================================================
+This is the third update in cairo's stable 1.4 series. It comes a
+little less than three weeks since the 1.4.4 release. This release
+fixes the broken mutex initialization that made cairo 1.4.4 unusable
+on win32, OS/2, and BeOS systems. This release also adds significant
+improvements to cairo's PDF backend, (native gradients!), and a couple
+of performance optimizations, (one of which is very significant for
+users of the xlib backend). See below for more details.
+
+Repaired mutex initialization
+-----------------------------
+We apologize that cairo 1.4.4 did little more than crash on many
+platforms which are less-frequently used by the most regular cairo
+maintainers, (win32, OS/2, and BeOS). The mutex initialization
+problems that caused those crashes should be fixed now. And to avoid
+similar problems in the future, we've now started posting pre-release
+snapshots to get better testing, (subscribe to cairo@cairographics.org
+if you're interested in getting notified of those and testing them).
+
+PDF Improvements
+----------------
+Thanks to Adrian Johnson, (cairo PDF hacker extraordinaire), we have
+several improvements to cairo's PDF backend to announce:
+
+Native gradients:
+
+  As of cairo 1.4.6, cairo will now generate native PDF gradients in
+  many cases, (previously, the presence of a gradient on any page
+  would force rasterized output for that page). Currently, only
+  gradients with extend types of PAD (the default) or NONE will
+  generate native PDF gradients---others will still trigger
+  rasterization, (but look for support for other extend modes in a
+  future release). Many thanks to Miklós Erdélyi as well, who did the
+  initial work for this support.
+
+Better compatibility with PDF viewers:
+
+  The PDF output from cairo should now be displayed correctly by a
+  wider range of PDF viewers. Adrian tested cairo's PDF output against
+  many PDF viewers, identified a common bug in many of those viewers
+  (ignoring the CTM matrix in some cases), and modified cairo's output
+  to avoid triggering that bugs (pre-transforming coordinates and
+  using an identity matrix).
+
+Better OpenType/CFF subsetting:
+
+  Cairo will now embed CFF and TrueType fonts as CID fonts.
+
+Performance optimizations
+-------------------------
+Faster cairo_paint_with_alpha:
+
+  The cairo_paint_with_alpha call is used to apply a uniform alpha
+  mask to a pattern. For example, it can be used to gradually fade an
+  image out or in. Jeff Muizelaar fixed some missing/broken
+  optimizations within the implementation of this function resulting
+  in cairo_paint_with_alpha being up to 4 times faster when using
+  cairo's image backend.
+
+Optimize rendering of "off-screen" geometry:
+
+  Something that applications often do is to ask cairo to render
+  things that are either partially or wholly outside the current clip
+  region. Since 1.4.0 the image backend has been fixed to not waste
+  too much time in this case. But other backends have still been
+  suffering.
+
+  In particular, the xlib backend has often performed quite badly in
+  this situation. This is due to a bug in the implementation of
+  trapezoid rasterization in many X servers.
+
+  Now, in cairo 1.4.6 there is a higher-level fix for this
+  situation. Cairo now eliminates or clips trapezoids that are wholly
+  or partially outside the clip region before handing the trapezoids
+  to the backend. This means that the X server's performance bug is
+  avoided in almost all cases.
+
+  The net result is that doing an extreme zoom-in of vector-based
+  objects drawn with cairo might have previously brought the X server
+  to its knees as it allocated buffers large enough to fit all of the
+  geometry, (whether visible or not). But now the memory usage should
+  be bounded and performance should be dramatically better.
+
+Miscellaneous
+-------------
+Behdad contributed an impressively long series of changes that
+organizes cairo's internals in several ways that will be very
+beneficial to cairo developers. Thanks, Behdad!
+
+Behdad has also provided a utility for generating malloc statistics,
+(which was used during the great malloc purges of 1.4.2 and
+1.4.4). This utility isn't specific to cairo so may be of benefit to
+others. It is found in cairo/util/malloc-stats.c and here are Behdad's
+notes on using it:
+
+    To build, do:
+
+        make malloc-stats.so
+
+    inside util/, and to use, run:
+
+        LD_PRELOAD=malloc-stats.so some-program
+
+    For binaries managed by libtool, eg, cairo-perf, do:
+
+        ../libtool --mode=execute /bin/true ./cairo-perf
+        LD_PRELOAD="../util/malloc-stats.so" .libs/lt-cairo-perf
+
+Finally, the cairo-perf-diff-files utility was enhanced to allow for
+generating performance reports from several runs of the same backend
+while some system variables were changed. For example, this is now
+being used to allow cairo-perf to measure the performance of various
+different acceleration architectures and configuration options of the
+X.org X server.
+
+Release 1.4.4 (2007-04-13 Carl Worth <cworth@cworth.org>)
+=========================================================
+This is the second update release in cairo's stable 1.4 series. It
+comes just less than a month after 1.4.2. The changes since 1.4.2
+consist primarily of bug fixes, but also include at least one
+optimization. See below for details.
+
+Of all the work that went into the 1.4.4 release
+
+There have been lots of individuals doing lots of great work on cairo,
+but two efforts during the 1.4.4 series deserve particular mention:
+
+Internal cleanup of error handling, (Chris Wilson)
+--------------------------------------------------
+Chris contributed a tremendous series of patches (74 patches!) to
+improve cairo's handling of out-of-memory and other errors. He began
+by adding gcc's warn_unused_attribute to as many functions as
+possible, and then launched into the ambitious efforts of adding
+correct code to quiet the dozens of resulting warnings.
+
+Chris also wrote a custom valgrind skin to systematically inject
+malloc failures into cairo, and did all the work necessary to verify
+that cairo's performance test suite runs to completion without
+crashing.
+
+The end result is a much more robust implementation. Previously, many
+error conditions would have gone unnoticed and would have led to
+assertion failures, segmentation faults, or other harder-to-diagnose
+problems. Now, more than ever, cairo should cleanly let the user know
+of problems through cairo_status and other similar status
+functions. Well done, Chris!
+
+More malloc reduction, (Mathias Hasselmann)
+-------------------------------------------
+After 1.4.0, Behdad launched an effort to chase down excessive calls
+to malloc within the implementation of cairo. He fixed a lot of
+malloc-happy objects for 1.4.2, but one of the worst offenders,
+(pixman regions), was left around. Mathias contributed an excellent
+series of 15 patches to finish off this effort.
+
+The end result is a cairo that calls malloc much less often than it
+did before. Compared to 1.4.2, 55% of the calls to malloc have been
+eliminate, (and 60% have been eliminated compared to 1.4.0). Well
+done, Mathias!
+
+Other improvements since 1.4.2
+------------------------------
+• Centralize mutex declarations (will reduce future build breaks),
+  (Mathias Hasselmann)
+
+• Reduce malloc by caching recently freed pattern objects (Chris
+  Wilson)
+
+• Fix some broken composite operations (David Reveman)
+	https://bugs.freedesktop.org/show_bug.cgi?id=5777
+
+Backend-specific fixes
+----------------------
+PDF:
+ • Use TJ operator for more compact representation of glyphs (Adrian
+   Johnson)
+
+ • Fix glyph positioning bug when glyphs are not horizontal
+	http://lists.freedesktop.org/archives/cairo/2007-April/010337.html
+
+win32:
+ • Fix crash when rendering with bitmap fonts (Carl Worth)
+	https://bugzilla.mozilla.org/show_bug.cgi?id=376498
+
+xlib:
+ • Turn metrics-hinting on by default (Behdad Esfahbod)
+
+ • Fix edge-effect problem with transformed images drawn to xlib
+   (Behdad Esfahbod)
+	https://bugs.freedesktop.org/show_bug.cgi?id=10508
+
+ • Avoid dereferencing a NULL screen. (Chris Wilson)
+	https://bugs.freedesktop.org/show_bug.cgi?id=10517
+
+Quartz/ATSUI:
+ • Fix scaling of glyph surfaces
+   (Brian Ewins)
+	https://bugs.freedesktop.org/show_bug.cgi?id=9568
+
+ • Fix compilation failure when both xlib and quartz enabled
+   (Brian Ewins)
+
+ • Fix rounding bug leading to incorrectly positioned glyphs
+   (Robert O'Callahan)
+	https://bugs.freedesktop.org/show_bug.cgi?id=10531
+
+Release 1.4.2 (2007-03-19 Carl Worth <cworth@cworth.org>)
+=========================================================
+This is the first update release in cairo's stable 1.4 series. It
+comes just less than 2 weeks after 1.4.0. We hadn't anticipated an
+update this early, but we've managed to collect some important fixes
+that we wanted to get out to cairo users as soon as possible, (6 fixes
+for crashes, 1 case where graphical elements would not be drawn at
+all, a handful of backend-specific bugs, and several important build
+fixes).
+
+There's almost nothing but bug fixes in this release, (see below one
+optimization that Behdad did sneak in), so we recommend that everyone
+upgrade to this release when possible.
+
+Thanks to the many people that worked to fix these bugs, and those
+that did the work to report them and to test the fixes, (wherever
+possible both names are credited below).
+
+Critical fixes
+--------------
+• Fix a crash due to a LOCK vs. UNLOCK typo (M. Drochner fixing Carl
+  Worth's embarrassing typo).
+
+  http://bugs.freedesktop.org/show_bug.cgi?id=10235
+
+• Fix potential buffer overflow, which on some systems with a checking
+  variant of snprintf would lead to a crash (Adrian Johnson, Stanislav
+  Brabec, and sangu).
+
+  https://bugs.freedesktop.org/show_bug.cgi?id=10267
+  https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=232576
+
+• Fix a crash in cairo_stroke_extents or cairo_in_stroke when line
+  width is 0.0. (Carl Worth and Sebastien Bacher)
+
+  https://bugs.freedesktop.org/show_bug.cgi?id=10231
+
+• Fix a crash on certain combinations of X server/video drivers (Carl
+  Worth and Tomas Carnecky).
+
+  https://bugs.freedesktop.org/show_bug.cgi?id=10250
+
+• Fix a crash due to mishandling of invalid user input (Carl Worth and
+  Alexander Darovsky).
+
+  https://bugs.freedesktop.org/show_bug.cgi?id=9844
+
+• xlib: Cleanup server-side glyph caches on XCloseDisplay. This
+  eliminated a crash detected by the perf suite, (and that
+  applications could have run into as well). (Chris Wilson)
+
+Other bug fixes
+---------------
+• Fix for some geometry which simply disappeared under some
+  transformations---a stroked line with an extreme skew in X, for
+  example (Carl Worth and Jonathan Watt).
+
+  https://bugzilla.mozilla.org/show_bug.cgi?id=373632
+
+• SVG: Fix radial gradients for CAIRO_EXTEND_REFLECT and when r0 > r1
+  (Emmanuel Pacaud).
+
+• PDF: Set page group color space to DeviceRGB.
+
+  This fixes incorrect (muddy) transparent colors when rendering cairo
+  PDF output in some viewers. (Adrian Johnson, Adam Goode, and
+  MenTaLguY).
+
+  http://lists.freedesktop.org/archives/cairo/2006-November/008551.html
+
+• win32: Return correct metrics when hinting is off, and fix font
+  descent computation (Behdad Esfahbod).
+
+• quartz: Fix glyph interfaces to correctly return user-space rather
+  than device-space coordinates (Brian Ewins).
+
+  https://bugs.freedesktop.org/show_bug.cgi?id=9568
+
+• xcb: Fix parameter-order confusion with xcb_create_pixmap, which now
+  makes all tests that pass with xlib now pass with xcb (Carl Worth,
+  Jamey Sharp).
+
+• Fix some memory leaks in the perf suite (Chris Wilson).
+
+• Fix perf suite to consider changes in pixman/src (Mathias
+  Hasselmann).
+
+Build fixes
+-----------
+• Don't include pre-generated cairo-features.h file. This was causing
+  build failures when building with the directfb backend enabled
+  (Behdad Esfahbod).
+
+  https://bugs.freedesktop.org/show_bug.cgi?id=10189
+
+• Eliminate use of maintainer mode from cairo's automake/configure
+  script. This means that updates to files such as Makefile.am will
+  take effect, (by rerunning automake and friends as necessary) when
+  invoking make rather than being silently ignored.  (Behdad Esfahbod)
+
+• Don't compile cairo-deflate-stream.c, which depends on zlib, unless
+  building the pdf backend which requires it. (Carl Worth, Tor
+  Lillqvist)
+
+  https://bugs.freedesktop.org/show_bug.cgi?id=10202
+
+• Don't make the ps backend link against zlib anymore, since it
+  doesn't require it (Carl Worth).
+
+• Use "find !" rather than "find -not" for better portability (Thomas
+  Klausner).
+
+  https://bugs.freedesktop.org/show_bug.cgi?id=10226
+
+• Don't use unsupported visibility attribute "hidden" on Solaris
+  (Gilles Dauphin, Thomas Klausner).
+
+  https://bugs.freedesktop.org/show_bug.cgi?id=10227
+
+Optimization
+------------
+• It was Behdad that suggested we focus strictly on bug fixes now that
+  we shipped so many performance improvements in 1.4.0, but it was
+  also Behdad that got distracted by the chance to remove a lot of
+  mallocs from cairo. Paths, gstates, trapezoids, splines, polygons,
+  and gradient color stops will now use small, stack-allocated buffers
+  in the most common cases rather than calling malloc as
+  often. (Behdad Esfahbod). And look for more from Mathias Hasselmann
+  soon.
+
+Release 1.4.0 (2007-03-06 Carl Worth <cworth@cworth.org>)
+=========================================================
+The many people[*] who have been working hard on cairo are very
+pleased to announce the long-awaited release of cairo 1.4. This
+release comes 4 months after the last stable update release (1.2.6)
+and 9 months since the initial release of 1.2.0.
+
+The release notes below are intended to capture the highlights of the
+changes that have occurred from the 1.2 series to the new 1.4.0
+release.
+
+Performance improvements
+------------------------
+Within the cairo project, the last 6 months or so has seen an intense
+effort focusing on the performance of cairo itself. That effort has
+paid off considerably, as can be seen in the following highlights of
+some of the performance differences from cairo 1.2.6 to cairo 1.4.0.
+
+(Note: The performance results reported here were measured on an x86
+laptop. Many of the improvements in 1.4---particular those involving
+text rendering---are even more dramatic on embedded platforms without
+hardware floating-point units. Such devices played an important part
+of many of the optimizations that found their way into cairo over the
+last few months.)
+
+• Dramatic improvement when drawing objects that are mostly off-screen
+  with the image backend (with the xlib backend this case is still
+  slow due to an X server bug):
+
+  image-rgba       long-lines-uncropped-100  479.64 ->  4.98: 96.24x speedup
+  ███████████████████████████████████████████████▋
+
+• Dramatic improvement when copying a small fraction of an image
+  surface to an xlib surface:
+
+   xlib-rgba              subimage_copy-512    3.93 ->  0.07: 54.52x speedup
+  ██████████████████████████▊
+
+• Dramatic improvement to tessellation speed for complex objects:
+
+  image-rgb              tessellate-256-100  874.16 -> 34.79: 25.13x speedup
+  ████████████▏
+   xlib-rgba        zrusin_another_fill-415  148.40 -> 13.85: 10.72x speedup
+  ████▉
+   xlib-rgb                  world_map-800  680.20 -> 345.54:  1.97x speedup
+  ▌
+
+• Dramatic improvement to the speed of stroking rectilinear shapes,
+  (such as the outline of a rectangle or "box"):
+
+  image-rgb          box-outline-stroke-100    0.18 ->  0.01: 24.22x speedup
+  ███████████▋
+   xlib-rgb          box-outline-stroke-100    0.46 ->  0.06:  8.05x speedup
+  ███▌
+
+
+• Dramatic improvements to text rendering speeds:
+
+   xlib-rgba       text_image_rgba_over-256   63.12 ->  9.61:  6.57x speedup
+  ██▊
+
+• 3x improvements to floating-point to fixed-point conversion speeds:
+
+  image-rgba      pattern_create_radial-16     9.29 ->  3.44:  2.70x speedup
+  ▉
+
+• 2x improvements to linear gradient computation:
+
+  image-rgb     paint_linear_rgb_source-512   26.22 -> 11.61:  2.26x speedup
+  ▋
+
+• 2x improvement to a case common in PDF rendering:
+
+  image-rgb              unaligned_clip-100    0.10 ->  0.06:  1.81x speedup
+  ▍
+
+• 1.3x improvement to rectangle filling speed (note: this improvement
+  is new since 1.3.16---previously this test case was a 1.3x slowdown
+  compared to 1.2.6):
+
+  image-rgba                 rectangles-512    6.19 ->  4.37:  1.42x speedup
+  ▎
+  xlib-rgba                  rectangles-512    7.48 ->  5.58:  1.34x speedup
+  ▏
+
+NOTE: In spite of our best efforts, there are some measurable
+performance regressions in 1.4 compared to 1.2. It appears that the
+primary problem is the increased overhead of the new tessellator when
+drawing many, very simple shapes. The following test cases capture
+some of that slowdown:
+
+  image-rgba    mosaic_tessellate_lines-800   11.03 -> 14.29:  1.30x slowdown
+  ▏
+  image-rgba           box-outline-fill-100    0.01 ->  0.01:  1.26x slowdown
+  ▏
+  image-rgba        fill_solid_rgb_over-64     0.20 ->  0.22:  1.12x slowdown
+
+  image-rgba       fill_image_rgba_over-64     0.23 ->  0.25:  1.10x slowdown
+
+   xlib-rgb     paint_image_rgba_source-256    3.24 ->  3.47:  1.07x slowdown
+
+We did put some special effort into eliminating this slowdown for the
+very common case of drawing axis-aligned rectangles with an identity
+matrix (see the box-outline-stroke and rectangles speedup numbers
+above). Eliminating the rest of this slowdown will be a worthwhile
+project going forward.
+
+Also note that the "box-outline-fill" case is a slowdown while
+"box-outline-stroke" is a (huge) speedup. These two test cases
+resulted from the fact that some GTK+ theme authors were filling
+between two rectangles to avoid slow performance from the more natural
+means of achieving the same shape by stroking a single rectangle. With
+1.4 that workaround should definitely be eliminated as it will now
+cause things to perform more slowly.
+
+Greatly improved PDF output
+---------------------------
+We are very happy to be able to announce that cairo-generated PDF
+output will now have text that can be selected, cut-and-pasted, and
+searched with most capable PDF viewer applications. This is something
+that was not ever possible with cairo 1.2.
+
+Also, the PDF output now has much more compact encoding of text than
+before. Cairo is now much more careful to not embed multiple copies of
+the same font at different sizes. It also compresses text and font
+streams within the PDF output.
+
 API additions
 -------------
-
- * Add a new function call to set the current antialiasing mode in the
-   graphics state:
+There are several new functions available in 1.4 that were not
+available in 1.2. Curiously, almost all of the new functions simply
+allow the user to query state that has been set in cairo (many new
+"get" functions) rather than providing any fundamentally new
+operations. The new functionality is:
+
+• Getting information about the current clip region
+
+  cairo_clip_extents
+  cairo_copy_clip_rectangle_list
+  cairo_rectangle_list_destroy
+
+• Getting information about the current dash setting
+
+  cairo_get_dash_count
+  cairo_get_dash
+
+• Getting information from a pattern
+
+  cairo_pattern_get_rgba
+  cairo_pattern_get_surface
+  cairo_pattern_get_color_stop_rgba
+  cairo_pattern_get_color_stop_count
+  cairo_pattern_get_linear_points
+  cairo_pattern_get_radial_circles
+
+• Getting the current scaled font
+
+  cairo_get_scaled_font
+
+• Getting reference counts
+
+  cairo_get_reference_count
+  cairo_surface_get_reference_count
+  cairo_pattern_get_reference_count
+  cairo_font_face_get_reference_count
+  cairo_scaled_font_get_reference_count
+
+• Setting/getting user data on objects
+
+  cairo_set_user_data
+  cairo_get_user_data
+  cairo_pattern_set_user_data
+  cairo_pattern_get_user_data
+  cairo_scaled_font_set_user_data
+  cairo_scaled_font_get_user_data
+
+• New cairo-win32 functions:
+
+  cairo_win32_surface_create_with_ddb
+  cairo_win32_surface_get_image
+  cairo_win32_scaled_font_get_logical_to_device
+  cairo_win32_scaled_font_get_device_to_logical
+
+API deprecation
+---------------
+The CAIRO_FORMAT_RGB16_565 enum value has been deprecated. It never
+worked as a format value for cairo_image_surface_create, and it wasn't
+necessary for supporting 16-bit 565 X server visuals.
+
+A sampling of bug fixes in cairo 1.4
+------------------------------------
+  • Fixed radial gradients
+  • Fixed dashing (degenerate and "leaky" cases)
+  • Fixed transformed images in PDF/PS output (eliminate bogus repeating)
+  • Eliminate errors from CAIRO_EXTEND_REFLECT and CAIRO_EXTEND_PAD
+  • cairo_show_page no longer needed for single-page output
+  • SVG: Fix bug preventing text from appearing in many viewers
+  • cairo-ft: Return correct metrics when hinting is off
+  • Eliminate crash in cairo_create_similar if nil surface is returned
+  • Eliminate crash after INVALID_RESTORE error
+  • Fix many bugs related to multi-threaded use and locking
+  • Fix for glyph spacing 32 times larger than desired (cairo-win32)
+  • Fixed several problems in cairo-atsui (assertion failures)
+  • Fix PDF output to avoid problems when printing from Acrobat Reader
+  • Fix segfault on Mac OS X (measuring a zero-length string)
+  • Fix text extents to not include the size of non-inked characters
+  • Fix for glyph cache race condition in glitz backend (Jinghua Luo)
+  • Fix make check to work on OPD platforms (IA64 or PPC64)
+  • Fix compilation problems of cairo "wideint" code on some platforms
+  • Many, many others...
+
+Experimental backends (quartz, XCB, OS/2, BeOS, directfb)
+---------------------------------------------------------
+None of cairo's experimental backends are graduating to "supported"
+status with 1.4.0, but two of them in particular (quartz and xcb), are
+very close.
+
+The quartz baceknd has been entirely rewritten and is now much more
+efficient. The XCB backend has been updated to track the latest XCB
+API (which recently had a 1.0 release).
+
+We hope to see these backends become supported in a future release,
+(once they are passing all the tests in cairo's test suite).
+
+The experimental OS/2 backend is new in cairo 1.4 compared to cairo
+1.2.
+
+Documentation improvements
+--------------------------
+We have added documentation for several functions and types that
+were previously undocumented, and improved documentation on other
+ones.  As of this release, there remain only two undocumented
+symbols: cairo_filter_t and cairo_operator_t.
+
+[*]Thanks to everyone
+---------------------
+I've accounted for 41 distinct people with attributed code added to
+cairo between 1.2.6 and 1.4.0, (their names are below). That's an
+impressive number, but there are certainly dozens more that
+contributed with testing, suggestions, clarifying questions, and
+encouragement. I'm grateful for the friendships that have developed as
+we have worked on cairo together. Thanks to everyone for making this
+all so much fun!
+
+Adrian Johnson, Alfred Peng, Alp Toker, Behdad Esfahbod,
+Benjamin Otte, Brian Ewins, Carl Worth, Christian Biesinger,
+Christopher (Monty) Montgomery, Daniel Amelang, Dan Williams,
+Dave Yeo, David Turner, Emmanuel Pacaud, Eugeniy Meshcheryakov,
+Frederic Crozat, Hans Breuer, Ian Osgood, Jamey Sharp, Jeff Muizelaar,
+Jeff Smith, Jinghua Luo, Jonathan Watt, Joonas Pihlaja, Jorn Baayen,
+Kalle Vahlman, Kjartan Maraas, Kristian Høgsberg, M Joonas Pihlaja,
+Mathias Hasselmann, Mathieu Lacage, Michael Emmel, Nicholas Miell,
+Pavel Roskin, Peter Weilbacher, Robert O'Callahan,
+Soren Sandmann Pedersen, Stuart Parmenter, T Rowley,
+Vladimir Vukicevic
+
+Snapshot 1.3.16 (2007-03-02 Carl Worth <cworth@cworth.org>)
+===========================================================
+New API functions
+-----------------
+A few new public functions have been added to the cairo API since the
+1.3.14 snapshot. These include a function to query the current scaled
+font:
+
+	cairo_get_scaled_font
+
+New functions to query the reference count of all cairo objects:
+
+	cairo_get_reference_count
+
+	cairo_surface_get_reference_count
+	cairo_pattern_get_reference_count
+
+	cairo_font_face_get_reference_count
+	cairo_scaled_font_get_reference_count
+
+And new functions to allow the use of user_data with any cairo object,
+(previously these were only available on cairo_surface_t and
+cairo_font_face_t objects):
+
+	cairo_set_user_data
+	cairo_get_user_data
+
+	cairo_pattern_set_user_data
+	cairo_pattern_get_user_data
+
+	cairo_scaled_font_set_user_data
+	cairo_scaled_font_get_user_data
+
+Usability improvement for PDF/PS/SVG generation
+-----------------------------------------------
+In previous versions of cairo, generating single-page output with the
+cairo-pdf, cairo-ps, or cairo-svg backends required a final call to
+cairo_show_page. This was often quite confusing as people would port
+functional code from a non-paginated backend and be totally mystified
+as to why the output was blank until they learned to add this call.
+
+Now that call to cairo_show_page is optional, (it will be generated
+implicitly if the user does not call it). So cairo_show_page is only
+needed to explicitly separate multiple pages.
+
+Greatly improved PDF output
+---------------------------
+We are very happy to be able to announce that cairo-generated PDF
+output will now have text that can be selected, cut-and-paste, and
+searched with most capable PDF viewer applications. This is something
+that was not ever possible with cairo 1.2.
+
+Also, the PDF output now has much more compact encoding of text than
+before. Cairo is now much more careful to not embed multiple copies of
+the same font at different sizes. It also compresses text and font
+streams within the PDF output.
+
+Major bug fixes
+---------------
+  • Fixed radial gradients
+
+    The rendering of radial gradients has been greatly improved. In
+    the cairo 1.2 series, there was a serious regression affecting
+    radial gradients---results would be very incorrect unless one of
+    the gradient circles had a radius of 0.0 and a center point within
+    the other circle. These bugs have now been fixed.
+
+  • Fixed dashing
+
+    Several fixes have been made to the implementation of dashed
+    stroking. Previously, some dashed, stroked rectangles would
+    mis-render and fill half of the rectangle with a large triangular
+    shape. This bug has now been fixed.
+
+  • Fixed transformed images in PDF/PS output
+
+    In previous versions of cairo, painting with an image-based source
+    surface pattern to the PDF or PS backends would cause many kinds
+    of incorrect results. One of the most common problems was that an
+    image would be repeated many times even when the user had
+    explicitly requested no repetition with CAIRO_EXTEND_NONE. These
+    bugs have now been fixed.
+
+  • Eliminate errors from CAIRO_EXTEND_REFLECT and CAIRO_EXTEND_PAD
+
+    In the 1.2 version of cairo any use of CAIRO_EXTEND_REFLECT or
+    CAIRO_EXTEND_PAD with a surface-based pattern resulted in an
+    error, (cairo would stop rendering). This bug has now been
+    fixed.
+
+    Now, CAIRO_EXTEND_REFLECT should work properly with surface
+    patterns.
+
+    CAIRO_EXTEND_PAD is still not working correctly, but it will now
+    simply behave as CAIRO_EXTEND_NONE rather than triggering the
+    error.
+
+New rewrite of quartz backend (still experimental)
+--------------------------------------------------
+Cairo's quartz backend has been entirely rewritten and is now much
+more efficient. This backend is still marked as experimental, not
+supported, but it is now much closer to becoming an officially
+supported backend. (For people that used the experimental nquartz
+backend in previous snapshots, that implementation has now been
+renamed from "nquartz" to "quartz" and has replaced the old quartz
+backend.)
+
+Documentation improvements
+--------------------------
+We have added documentation for several functions and types that
+were previously undocumented, and improved documentation on other
+ones.  As of this release, there remain only two undocumented
+symbols: cairo_filter_t and cairo_operator_t.
+
+Other bug fixes
+---------------
+  • cairo-svg: Fix bug that was preventing text from appearing in many
+    viewers
+
+  • cairo-ft: Return correct metrics when hinting is off
+
+  • Cairo 1.3.14 deadlocks in cairo_scaled_font_glyph_extents or
+    _cairo_ft_unscaled_font_lock_face
+
+    https://bugs.freedesktop.org/show_bug.cgi?id=10035
+
+  • cairo crashes in cairo_create_similar if nil surface returned by
+    other->backend->create_similar
+
+    https://bugs.freedesktop.org/show_bug.cgi?id=9844
+
+  • evolution crash in _cairo_gstate_backend_to_user()
+    https://bugs.freedesktop.org/show_bug.cgi?id=9906
+
+  • Fix memory leak in rectilinear stroking code
+
+Things not in this release
+--------------------------
+  • Solid-surface-pattern cache: This patch had been applied during
+    the 1.3.x series, but it was reverted due to some inter-thread
+    problems it caused. The patch is interesting since it made a big
+    benefit for text rendering performance---so we'll work to bring a
+    corrected version of this patch back as soon as possible.
+
+Snapshot 1.3.14 (2006-02-13 Carl Worth <cworth@cworth.org>)
+===========================================================
+This is the seventh development snapshot in the 1.3 series, (and there
+likely won't be many more before the 1.4.0 release). It comes just
+over 3 weeks after the 1.3.12 snapshot.
+
+Since we're so close to the 1.4.0 release, there are not a lot of new
+features nor even a lot of new performance improvements in this
+snapshot. Instead, there are a great number of bug fixes. Some are
+long-standing bugs that we're glad to say goodbye to, and several are
+fixes for regressions that were introduced as part of the optimization
+efforts during the 1.3.x series.
+
+PDF text selection fixed
+------------------------
+The inability to correctly select text in cairo-generated PDF has been
+a defect ever since the initial support for the PDF backend in the
+cairo 1.2.0 release. With the 1.3.14 snapshot, in most situations, and
+with most PDF viewer applications, the PDF generated by cairo will
+allow text to be correctly selected for copy-and-paste, (as well as
+searching).
+
+We're very excited about this new functionality, (and very grateful to
+Adrian Johnson, Behdad Esfahbod, and others that have put a lot of
+work into this lately). Please test this new ability and give feedback
+on the cairo@cairographics.org list.
+
+Many thread-safety issues fixed
+-------------------------------
+We've discovered that no release of cairo has ever provided safe text
+rendering from a multi-threaded application. With the 1.3.14 snapshot
+a huge number of the bugs in this area have been fixed, and multiple
+application dvelopers have now reported success at writing
+multi-threaded applications with cairo.
+
+Other fixes
+-----------
+Fixed a bug that was causing glyph spacing to be 32 times larger than
+desired when using cairo-win32.
+
+Fixed a regression in the rendering of linear gradients that had been
+present since the 1.3.8 snapshot.
+
+Fixed several problems in cairo-atsui that were leading to assertion
+failures when rendering text.
+
+Fix corrupted results when rendering a transformed source image
+surface to an xlib surface. This was a regression that had been
+present since the 1.3.2 snapshot.
+
+Fixed PDF output to prevent problems printing from some versions of
+Acrobat Reader, (a single glyph was being substituted for every
+glyph).
+
+And many other fixes as well, (see the logs for details).
+
+Snapshot 1.3.12 (2007-01-20 Carl Worth <cworth@cworth.org>)
+===========================================================
+The relentless march toward the cairo 1.4 release continues, (even if
+slightly late out of the starting blocks in 2007). This is the sixth
+development snapshot in the 1.3 series. It comes 4 weeks after the
+1.3.10 snapshot.
+
+Performance
+-----------
+As usual, this snapshot has some fun performance improvements to show
+off:
+
+image-rgba long-lines-uncropped-100  470.08 -> 4.95: 94.91x speedup
+███████████████████████████████████████████████
+image-rgb  long-lines-uncropped-100  461.60 -> 4.96: 93.02x speedup
+██████████████████████████████████████████████
+
+This 100x improvement, (and yes, that's 100x, not 100%), in the image
+backend occurs when drawing large shapes where only a fraction of the
+shape actually appears in the final result, (the rest being outside
+the bounds of the destination surface). Many applications should see
+speedups here, and the actual amount of speedup depends on the ratio
+of non-visible to visible portions of geometry.
+
+[Note: There remains a similar performance bug when drawing mostly
+non-visible objects with the xlib backend. This is due to a similar
+bug in the X server itself, but we hope a future cairo snapshot will
+workaround that bug to get a similar speedup with the xlib backend.]
+
+image-rgba       unaligned_clip-100    0.09 -> 0.06:  1.67x speedup
+▍
+image-rgb        unaligned_clip-100    0.09 -> 0.06:  1.66x speedup
+▍
+
+This speedup is due to further MMX optimization by Soeren Sandmann for
+a case commonly hit when rendering PDF files, (and thanks to Jeff
+Muizelaar for writing code to extract the test case for us).
+
+There's another MMX optimization in this snapshot (without a fancy
+speedup chart) by Dan Williams which improves compositing performance
+specifically for the OLPC machine.
+
+Thanks to Adrian Johnson, cairo's PDF output is now much more
+efficient in the way it encodes text output. By reducing redundant
+information and adding compression to text output streams, Adrian
+achieved a ~25x improvement in the efficiency of encoding text in PDF
+files, (was ~45 bytes per glyph and is now ~1.6 bytes per glyph).
+
+Bug fixes
+---------
+In addition to those performance improvements, this snapshot includes
+several bug fixes:
+
+ * A huge number of bug fixes for cairo-atsui text rendering, (for mac
+   OS X). These bugs affect font selection, glyph positioning, glyph
+   rendering, etc. One noteworthy bug fixes is that
+   cairo_select_font_face will no longer arbitrarily select bold nor
+   italic when not requested, (at least not when using a standard CSS2
+   font family name such as "serif", "sans-serif", "monospace", etc.).
+   All these fixes are thanks to Brian Ewins who continues to do a
+   great job as the new cairo-atsui maintainer.
+
+ * Fix PDF output so that images that are scaled down no longer
+   mysteriously repeat (Carl Worth).
+
+ * Fix segfault on Mac OS X dues to attempt to measure extents of a
+   zero-length string (Behdad Esfahbod).
+
+ * Fix text extents to not include the size of initial/trailing
+   non-inked characters (Behdad Esfahbod).
+
+API tweaks
+----------
+Three functions have had API changes to improve consistency. Note that
+the API functions being changed here are all functions that were
+introduced as new functions during these 1.3.x snapshots. As always,
+there will not be any API changes to functions included in a major
+release (1.2.x, 1.4.x, etc.) of cairo.
+
+The changes are as follows:
+
+ * Rename of cairo_copy_clip_rectangles to cairo_copy_clip_rectangle_list.
+
+ * Change cairo_get_dash_count to return an int rather than accepting a
+   pointer to an int for the return value.
+
+ * Change cairo_get_dash to have a void return type rather than
+   returning cairo_status_t.
+
+It's possible there will be one more round of changes to these
+functions, (and perhaps cairo_get_color_stop as well), as we seek to
+establish a unifying convention for returning lists of values.
+
+Snapshot 1.3.10 (2006-12-23 Carl Worth <cworth@cworth.org>)
+===========================================================
+Santa Claus is coming just a little bit early this year, and he's
+bringing a shiny new cairo snapshot for all the good little boys and
+girls to play with.
+
+This is the fifth development snapshot in the 1.3 series. It comes 9
+days after the 1.3.8 snapshot, and still well within our goal of
+having a new snapshot every week, (though don't expect one next
+week---we'll all be too stuffed with sugar plums).
+
+Speaking of sugar plums, there's a sweet treat waiting in this cairo
+snapshot---greatly improved performance for stroking rectilinear
+shapes, like the ever common rectangle:
+
+image-rgb          box-outline-stroke-100 0.18 -> 0.01: 25.58x speedup
+████████████████████████▋
+image-rgba         box-outline-stroke-100 0.18 -> 0.01: 25.57x speedup
+████████████████████████▋
+xlib-rgb          box-outline-stroke-100 0.49 -> 0.06:  8.67x speedup
+███████▋
+xlib-rgba         box-outline-stroke-100 0.22 -> 0.04:  5.39x speedup
+████▍
+
+In past releases of cairo, some people had noticed that using
+cairo_stroke to draw rectilinear shapes could be awfully slow. Many
+people had worked around this by using cairo_fill with a more complex
+path and gotten a 5-15x performance benefit from that.
+
+If you're one of those people, please rip that workaround out, as now
+the more natural use of cairo_stroke should be 1.2-2x faster than the
+unnatural use of cairo_fill.
+
+And if you hadn't ever implemented that workaround, then you just
+might get to see your stroked rectangles now get drawn 5-25x faster.
+
+Beyond that performance fix, there are a handful of bug fixes in this
+snapshot:
+
+ * Fix for glyph cache race condition in glitz backend (Jinghua Luo)
+
+ * Many fixes for ATSUI text rendering (Brian Ewins)
+
+ * Un-break recent optimization-triggered regression in rendering text
+   with a translation in the font matrix (Behdad Esfahbod)
+
+ * Fix make check to work on OPD platforms (IA64 or PPC64)
+   (Frederic Crozat)
+
+ * Fix a couple of character spacing issues on Windows
+    (Jonathan Watt)
+
+Have fun with that, everybody, and we'll be back for more in the new
+year, (with a plan to add the last of our performance improvements in
+this round, fix a few bad, lingering bugs, and then finish off a nice,
+stable 1.4 release before the end of January).
+
+-Carl
+
+Snapshot 1.3.8 (2006-12-14 Carl Worth <cworth@cworth.org>)
+==========================================================
+This is the fourth development snapshot in the 1.3 series. It comes
+just slightly more than one week after the 1.3.6 snapshot.
+
+After the bug fixes in 1.3.6, we're back to our original program of
+weekly snapshots, each one faster than the one from the week
+before. Cairo 1.3.8 brings a 2x improvement in the speed of rendering
+linear gradients (thanks to David Turner), and a significant reduction
+in X traffic when rendering text (thanks to Xan Lopez and Behdad
+Esfahbod), making cairo behave very much like Xft does.
+
+A few other things in the 1.3.8 snapshot worth noting include a more
+forgiving image comparator in the test suite, (using the "perceptual
+diff" metric and GPL implementation by Hector Yee[*]), a bug fix for
+broken linking on x86_64 (thanks to M Joonas Pihlaja) and an even
+better implementation of _cairo_lround, (not faster, but supporting a
+more complete input range), from Daniel Amelang.
+
+[*] http://pdiff.sourceforge.net/
+
+Snapshot 1.3.6 (2006-12-06 Carl Worth <cworth@cworth.org>)
+==========================================================
+This is the third development snapshot in the 1.3 series. It comes two
+weeks after the 1.3.4 snapshot.
+
+We don't have fancy performance charts this week as the primary
+changes in this snapshot are bug fixes. The performance work continues
+and the next snapshot (planned for one week from today) should include
+several improvements. The bug fixes in this snapshot include:
+
+ * Fix undesirable rounding in glyph positioning (Dan Amelang)
+
+   This bug was noticed by several users, most commonly by seeing
+   improper text spacing or scrambled glyphs as drawn by nautilus. For
+   example:
+
+	Update to cairo-1.3.4 worsen font rendering
+	https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=217819
+
+ * Fix reduced range of valid input coordinates to tessellator
+   (M Joonas Pihlaja)
+
+   This bug was causing lots of assertion failures in mozilla as
+   mentioned here:
+
+	CAIRO_BO_GUARD_BITS and coordinate space?
+	http://lists.freedesktop.org/archives/cairo/2006-December/008743.html
+
+ * Fix several regressions in new tessellator (M Joonas Pihlaja)
+
+   Joonas just had a good eye for detail here. I don't think any
+   external cairo users had noticed any of these bugs yet.
+
+ * Fix compilation problems of cairo "wideint" code on some platforms
+   (Mathieu Lacage)
+
+ * Fix failed configure due to broken grep (Dan Amelang)
+
+   This bug was reported here:
+
+	AX_C_FLOAT_WORDS_BIGENDIAN doesn't work because grep doesn't
+	work with binary file
+	https://bugs.freedesktop.org/show_bug.cgi?id=9124
+
+ * Remove the pkg-config minimum version requirement (Behdad Esfahbod)
+
+   Some systems ship with pkg-config 0.15 and there was really no good
+   reason for cairo to insist on having version 0.19 before it would
+   build.
+
+There is also one new (but inert) feature in this snapshot. There's a
+new option that can be passed to cairo's configure script:
+
+	--disable-some-floating-point
+
+	Disable certain code paths that rely heavily on double precision
+	floating-point calculation. This option can improve
+	performance on systems without a double precision floating-point
+	unit, but might degrade performance on those that do.
+
+As of this snapshot, this option does not make any change to cairo,
+but it is possible that future versions of cairo will respect this
+option and change the implementation of various functions as
+appropriate.
+
+Snapshot 1.3.4 (2006-11-22 Carl Worth <cworth@cworth.org>)
+==========================================================
+This is the second development snapshot in the 1.3 series. It comes
+one week after the 1.3.2 snapshot.
+
+This snapshot has a couple of significant performance improvements,
+and also adds new support for producing multi-page SVG output, (when
+targeting SVG 1.2)---thanks to Emmanuel Pacaud. The details of the
+performance improvements are as follows:
+
+1. The long-awaited "new tessellator".
+
+   The credit for this being an improvement goes to Joonas Pihlaja. He
+   took my really slow code and really put it through its paces to get
+   the dramatic performance improvement seen below (up to 38x faster
+   on realistic cases, and more than 10x faster for the zrusin_another
+   test).
+
+   His own writeup of the work he did is quite thorough, but more than
+   can be quoted here. Please see his post for the interesting details:
+
+   http://lists.freedesktop.org/archives/cairo/2006-November/008483.html
+
+   (Though note that this snapshot also includes some additional,
+   significant improvements that were only sketched out in that
+   email---see "Generating fewer trapezoids").
+
+2. More floating-point improvements
+
+   Daniel Amelang continues to work the magic he began in the 1.3.2
+   snapshot. This time he short-circuits floating-point
+   transformations by identity matrices and applies the earlier
+   floating-to-fixed-point technique to the problem of rounding.
+
+   The improvements here will primarily benefit text performance, and
+   will benefit platforms without hardware floating-point more than
+   those that have it, (some text tests show 20% improvement on an x86
+   machine and closer to 80% improvement on arm).
+
+The performance chart comparing 1.3.2 to 1.3.4 really speaks for
+itself, (this is on an x86 laptop). This is quite a lot of progress
+for one week:
+
+ xlib-rgb    stroke_similar_rgba_over-256   74.99 1.45% ->   2.03 68.38%: 36.86x speedup
+███████████████████████████████████▉
+ xlib-rgb  stroke_similar_rgba_source-256   78.23 1.43% ->   3.30 67.05%: 23.71x speedup
+██████████████████████▊
+ xlib-rgba             tessellate-256-100  820.42 0.15% ->  35.06 2.84%: 23.40x speedup
+██████████████████████▍
+image-rgba             tessellate-256-100  819.55 0.32% ->  35.04 3.56%: 23.39x speedup
+██████████████████████▍
+ xlib-rgb      stroke_image_rgba_over-256   78.10 1.43% ->   4.33 65.56%: 18.04x speedup
+█████████████████
+ xlib-rgb    stroke_image_rgba_source-256   80.11 1.63% ->   5.75 63.99%: 13.94x speedup
+█████████████
+ xlib-rgba  zrusin_another_tessellate-415   89.22 0.35% ->   8.38 5.23%: 10.65x speedup
+█████████▋
+image-rgba  zrusin_another_tessellate-415   87.38 0.89% ->   8.37 5.22%: 10.44x speedup
+█████████▍
+image-rgba        zrusin_another_fill-415  117.67 1.34% ->  12.88 2.77%:  9.14x speedup
+████████▏
+ xlib-rgba        zrusin_another_fill-415  140.52 1.57% ->  15.79 2.88%:  8.90x speedup
+███████▉
+image-rgba              tessellate-64-100    9.68 3.42% ->   1.42 0.60%:  6.82x speedup
+█████▉
+ xlib-rgba              tessellate-64-100    9.78 4.35% ->   1.45 0.83%:  6.72x speedup
+█████▊
+ xlib-rgb     stroke_linear_rgba_over-256   46.01 2.44% ->   7.74 54.51%:  5.94x speedup
+█████
+ xlib-rgb   stroke_linear_rgba_source-256   48.09 2.15% ->   9.14 53.00%:  5.26x speedup
+████▎
+ xlib-rgb     stroke_radial_rgba_over-256   50.96 2.34% ->  12.46 47.99%:  4.09x speedup
+███▏
+ xlib-rgb   stroke_radial_rgba_source-256   53.06 1.57% ->  13.96 46.57%:  3.80x speedup
+██▊
+image-rgba  paint_similar_rgba_source-256    0.12 1.57% ->   0.08 9.92%:  1.42x speedup
+▍
+image-rgba    paint_image_rgba_source-256    0.12 2.49% ->   0.08 10.70%:  1.41x speedup
+▍
+image-rgba                  world_map-800  356.28 0.46% -> 275.72 1.15%:  1.29x speedup
+▎
+ xlib-rgba                  world_map-800  456.81 0.39% -> 357.95 1.39%:  1.28x speedup
+▎
+image-rgb               tessellate-16-100    0.09 0.57% ->   0.07 3.43%:  1.23x speedup
+▎
+image-rgba              tessellate-16-100    0.09 0.06% ->   0.07 2.46%:  1.23x speedup
+▎
+image-rgba        text_solid_rgb_over-256    5.39 4.01% ->   4.47 0.70%:  1.21x speedup
+▎
+image-rgba       text_solid_rgba_over-256    5.37 0.82% ->   4.45 0.75%:  1.21x speedup
+▎
+image-rgba        text_image_rgb_over-64     0.78 0.10% ->   0.65 0.74%:  1.20x speedup
+▎
+image-rgba       text_image_rgba_over-64     0.78 0.29% ->   0.65 0.68%:  1.19x speedup
+▎
+image-rgb         text_solid_rgb_over-64     0.76 2.45% ->   0.63 0.81%:  1.19x speedup
+▎
+image-rgba       text_solid_rgba_over-64     0.76 0.33% ->   0.64 0.66%:  1.19x speedup
+▎
+image-rgba     text_similar_rgba_over-256    5.99 4.72% ->   5.04 1.09%:  1.19x speedup
+▎
+
+We should point out that there is some potential for slowdown in this
+snapshot. The following are the worst slowdowns reported by the cairo
+performance suite when comparing 1.3.2 to 1.3.4:
+
+image-rgba              subimage_copy-256    0.01 0.87% ->   0.01 3.61%:  1.45x slowdown
+▌
+ xlib-rgb        paint_solid_rgb_over-256    0.31 10.23% ->   0.38 0.33%:  1.26x slowdown
+▎
+image-rgba           box-outline-fill-100    0.01 0.30% ->   0.01 2.52%:  1.21x slowdown
+▎
+image-rgba        fill_solid_rgb_over-64     0.20 1.22% ->   0.22 1.59%:  1.12x slowdown
+▏
+image-rgb       fill_similar_rgb_over-64     0.21 1.04% ->   0.24 1.06%:  1.11x slowdown
+▏
+image-rgba        fill_image_rgb_over-64     0.21 1.19% ->   0.24 0.72%:  1.11x slowdown
+▏
+image-rgba      fill_similar_rgb_over-64     0.21 0.18% ->   0.24 0.30%:  1.11x slowdown
+▏
+image-rgb        fill_solid_rgba_over-64     0.22 1.66% ->   0.24 1.15%:  1.11x slowdown
+▏
+image-rgb         fill_image_rgb_over-64     0.21 0.14% ->   0.24 0.80%:  1.11x slowdown
+▏
+image-rgba       fill_image_rgba_over-64     0.22 1.34% ->   0.25 0.20%:  1.11x slowdown
+▏
+image-rgba       fill_solid_rgba_over-64     0.22 1.48% ->   0.24 0.95%:  1.11x slowdown
+▏
+image-rgb      fill_similar_rgba_over-64     0.22 1.13% ->   0.25 1.25%:  1.10x slowdown
+▏
+
+The 45% slowdown for subimage_copy is an extreme case. It's unlikely
+to hit many applications unless they often use cairo_rectangle;
+cairo_fill to copy a single pixel at a time. In any case, it shows a
+worst-case impact of the overhead of the new tessellator. The other
+slowdowns (~ 10%) are probably more realistic, and still very
+concerning.
+
+We will work to ensure that performance regressions like these are not
+present from one major release of cairo to the next, (for example,
+from 1.2 to 1.4).
+
+But we're putting this 1.3.4 snapshot out there now, even with this
+potential slowdown so that people can experiment with it. If you've
+got complex geometry, we hope you will see some benefit from the new
+tessellator. If you've got primarily simple geometry, we hope things
+won't slowdown too much, but please let us know what slowdown you see,
+if any, so we can calibrate our performance suite against real-world
+impacts.
+
+Thanks, and have fun with cairo!
+
+Snapshot 1.3.2 (2006-11-14 Carl Worth <cworth@cworth.org>)
+==========================================================
+This is the first development snapshot since the 1.2 stable series
+branched off shortly after the 1.2.4 release in August 2006.
+
+This snapshot includes all the bug fixes from the 1.2.6 release,
+(since they originated here on the 1.3 branch first and were
+cherry-picked over to 1.2). But more importantly, it contains some new
+API in preparation for a future 1.4 release, and most importantly, it
+contains several performance improvements.
+
+The bug fixes will not be reviewed here, as most of them are already
+described in the 1.2.6 release notes. But details for the new API and
+some performance improvements are included here.
+
+As with all snapshots, this is experimental code, and the new API
+added here is still experimental and is not guaranteed to appear
+unchanged in any future release of cairo.
+
+API additions
+-------------
+Several new API additions are available in this release. There is a
+common theme among all the additions in that they allow cairo to
+advertise information about its state that it was refusing to
+volunteer earlier. So this isn't groundbreaking new functionality, but
+it is essential for easily achieving several tasks.
+
+The new functions can be divided into three categories:
+
+	Getting information about the current clip region
+	-------------------------------------------------
+	cairo_clip_extents
+	cairo_copy_clip_rectangles
+	cairo_rectangle_list_destroy
+
+	Getting information about the current dash setting
+	--------------------------------------------------
+	cairo_get_dash_count
+	cairo_get_dash
+
+	Getting information from a pattern
+	----------------------------------
+	cairo_pattern_get_rgba
+	cairo_pattern_get_surface
+	cairo_pattern_get_color_stop_rgba
+	cairo_pattern_get_color_stop_count
+	cairo_pattern_get_linear_points
+	cairo_pattern_get_radial_circles
+
+In each of these areas, we have new API for providing a list of
+uniform values from cairo. The closest thing we had to this before was
+cairo_copy_path, (which is rather unique in providing a list of
+non-uniform data).
+
+The copy_clip_rectangles/rectangle_list_destroy functions follow a
+style similar to that of cairo_copy_path. Meanwhile, the dash and
+pattern color stop functions introduce a new style in which there is a
+single call to return the number of elements available (get_dash_count
+and get_color_stop_count) and then a function to be called once to get
+each element (get_dash and get_color_stop_rgba).
+
+I'm interested in hearing feedback from users of these new API
+functions, particularly from people writing language bindings. One
+open question is whether the clip "getter" functionality should adopt
+a style similar to that of the new dash and color_stop interfaces.
+
+API deprecation
+---------------
+The CAIRO_FORMAT_RGB16_565 enum value has been deprecated. It never
+worked as a format value for cairo_image_surface_create, and it wasn't
+necessary for supporting 16-bit 565 X server visuals.
+
+XCB backend changes
+-------------------
+The XCB backend has been updated to track the latest XCB API (which
+recently had a 1.0 release).
+
+New quartz backend
+------------------
+Vladimir Vukicevic has written a new "native quartz" backend which
+will eventually replace the current "image-surface wrapping" quartz
+backend. For now, both backends are available, (the old one is
+"quartz" and the new one is "nquartz"). But it is anticipated that the
+new backend will replace the old one and take on the "quartz" name
+before this backend is marked as supported in a release of cairo.
+
+New OS/2 backend
+----------------
+Doodle and Peter Weilbacher have contributed a new, experimental
+backend for using cairo on OS/2 systems.
+
+Performance improvements
+------------------------
+Here are some highlights from cairo's performance suite showing
+improvements from cairo 1.2.6 to cairo 1.3.2. The command used to
+generate this data is:
+
+	./cairo-perf-diff 1.2.6 HEAD
+
+available in the perf/ directory of a recent checkout of cairo's
+source, (the cairo-perf-diff script does require a git checkout and
+will not work from a tar file---though ./cairo-perf can still be used
+to generate a single report there and ./cairo-perf-diff-files can be
+used to compare two reports).
+
+Results are described below both for an x86 laptop (with an old Radeon
+video card, recent X.org build, XAA, free software drivers), as well
+as for a Nokia 770. First the x86 results with comments on each, (all
+times are reported in milliseconds).
+
+Copying subsets of an image surface to an xlib surface (much faster)
+--------------------------------------------------------------------
+ xlib-rgba              subimage_copy-512   10.50 ->   : 53.97x speedup
+█████████████████████████████████████████████████████
+
+Thanks to Christopher (Monty) Montgomery for this big performance
+improvement. Any application which has a large image surface and is
+copying small pieces of it at a time to an xlib surface, (imagine an
+application that loads a single image containing all the "sprites" for
+that application), will benefit from this fix. The larger the ratio of
+the image surface to the portion being copied, the larger the benefit.
+
+Floating-point conversion (3x faster)
+-------------------------------------
+ xlib-rgba  pattern_create_radial-16    27.75 ->   3.93 :  2.94x speedup
+██
+image-rgb   pattern_create_radial-16    26.06 ->   3.74 :  2.90x speedup
+█▉
+
+Thanks to Daniel Amelang, (and others who had contributed the idea
+earlier), for this nice improvement in the speed of converting
+floating-point values to fixed-point.
+
+Text rendering (1.3 - 2x faster)
+------------------------------
+ xlib-rgba text_image_rgba_source-256  319.73 ->  62.40 :  2.13x speedup
+█▏
+image-rgb    text_solid_rgba_over-64     2.85 ->   0.88 :  1.35x speedup
+▍
+
+I don't think we've ever set out to improve text performance
+specifically, but we did it a bit anyway. I believe the extra
+improvement in the xlib backend is due to Monty's image copying fix
+above, and the rest is due to the floating-point conversion speedup.
+
+Thin stroke improvements (1.5x faster)
+---------------------------------------------
+image-rgb               world_map-800  1641.09 -> 414.77 :  1.65x speedup
+▋
+ xlib-rgba              world_map-800  1939.66 -> 529.94 :  1.52x speedup
+▌
+
+The most modest stuff to announce in this release is the 50%
+improvement I made in the world_map case. This is in improvement that
+should help basically anything that is doing strokes with many
+straight line segments, (and the thinner the better, since that makes
+tessellation dominate rasterization). The fixes here are to use a
+custom quadrilateral tessellator rather than the generic tessellator
+for straight line segments and the miter joins.
+
+Performance results from the Nokia 770
+--------------------------------------
+ xlib-rgba          subimage_copy-512     55.88 ->     2.04 : 27.34x speedup
+██████████████████████████▍
+ xlib-rgb     text_image_rgb_over-256   1487.58 ->   294.43 :  5.05x speedup
+████
+image-rgb   pattern_create_radial-16     187.13 ->    91.86 :  2.04x speedup
+█
+ xlib-rgba              world_map-800  21261.41 -> 15628.02 :  1.36x speedup
+▍
+
+Here we see that the subimage_copy improvement was only about half as
+large as the corresponding improvement on my laptop, (27x faster
+compared to 54x) and the floating-point conversion fix also was quite
+as significant, (2x compared to 3x). Oddly the improvement to text
+rendering performance was more than twice as good (5x compared to
+2x). I don't know what the reason for that is, but I don't think it's
+anything anybody should complain about.
+
+Release 1.2.6 (2006-11-02 Behdad Esfahbod <behdad@behdad.org>)
+==============================================================
+This is the third bug fix release in the 1.2 series, coming less than
+two months after the 1.2.4 release made on August 18.
+
+The 1.2.4 release turned out to be a pretty solid one, except for a crasher
+bug when forwarding an X connection where the client and the server have
+varying byte orders, eg. from a PPC to an i686.  Other than that, various
+other small bugs have been fixed.
+
+Various improvements have been made in the testing infrastructure to prevent
+false positives, and to make sure the generated cairo shared object behaves as
+expected in terms of exported symbols and relocations.
+
+There were a total of 89 changes since 1.2.4.  The following list the most
+important ones:
+
+Common fixes
+------------
+- Avoid unsigned loop control variable to eliminate infinite,
+  memory-scribbling loop. (#7593)
+- Fix cairo_image_surface_create to report INVALID_FORMAT errors.
+  Previously the detected error was being lost and a nil surface was
+  returned that erroneously reported CAIRO_STATUS_NO_MEMORY.
+- Change _cairo_color_compute_shorts to not rely on any particular
+  floating-point epsilon value. (#7497)
+- Fix infinite-join test case (bug #8379)
+- Pass correct surface to create_similar in _cairo_clip_init_deep_copy().
+
+PS/PDF fixes
+------------
+- Fix Type 1 embedding in PDF.
+- Correct the value of /LastChar in the PDF Type 1 font dictionary.
+- Improve error checking in TrueType subsetting.
+- Compute right index when looking up left side bearing. (bug #8180)
+- Correct an unsigned to signed conversion problem in truetype subsetting
+  bbox.
+- Type1 subsetting: Don't put .notdef in Encoding when there are 256 glyphs.
+- Add cairo version to PS header / PDF document info dictionary.
+- Set CTM before path construction.
+
+Win32 fixes
+-----------
+- Get correct unhinted outlines on win32. (bug 7603)
+- Make cairo as a win32 static library possible.
+- Use CAIRO_FORMAT_RGB24 for BITSPIXEL==32 surfaces too.
+
+Build system fixes
+------------------
+- Define WINVER if it's not defined. (bug 6456)
+- Fix the AMD64 final link by removing SLIM from pixman.
+- Misc win32 compilation fixes.
+- Add Sun Pro C definition of pixman_private.
+- Use pixman_private consistently as prefix not suffix.
+- Added three tests check-plt.sh, check-def.sh, and check-header.sh that check
+  that the shared object, the .def file, and the public headers agree about
+  the exported symbols.
+- Require pkg-config 0.19. (#8686)
+
+
+Release 1.2.4 (2006-08-18 Carl Worth <cworth@cworth.org>)
+=========================================================
+This is the second bug fix release in the 1.2 series, coming less than
+two weeks after the 1.2.2 release made on August 8.
+
+The big motivation for a quick release was that there were a log of
+build system snags that people ran into with the 1.2.2 release. But,
+by the time we got those all done, we found that we had a bunch of
+fixes for cairo's rendering as well. So there's a lot of goodness in
+here for such a short time period.
+
+Rendering fixes
+---------------
+Fix image surfaces to not be clipped when used as a source (Vladimir Vukicevic)
+http://gitweb.freedesktop.org/?p=cairo;a=commit;h=72e25648c4c4bc82ddd938aa4e05887a293f0d8b
+
+Fix a couple of corner cases in dashing degenerate paths (Jeff Muizelaar)
+http://gitweb.freedesktop.org/?p=cairo;a=commit;h=fbb1758ba8384650157b2bbbc93d161b0c2a05f0
+
+Fix support for type1 fonts on win32 (Adrian Johnson)
+http://gitweb.freedesktop.org/?p=cairo;a=commit;h=da1019c9138695cb838a54f8b871bbfd0e8996d7
+
+Fix assertion failure when rotating bitmap fonts (Carl Worth)
+http://gitweb.freedesktop.org/?p=cairo;a=commit;h=0bfa6d4f33b8ddb5dc55bbe419c15df4af856ff9
+
+Fix assertion failure when calling cairo_text_path with bitmap fonts (Carl Worth)
+http://gitweb.freedesktop.org/?p=cairo;a=commit;h=9878a033531e6b96b5f27e69e10e90dee7440cd9
+
+Fix mis-handling of cairo_close_path in some situations (Tim Rowley, Carl Worth)
+http://gitweb.freedesktop.org/?p=cairo;a=commit;h=53f74e59faf1af78f2f0741ccf1f23aa5dad4efc
+
+Respect font_matrix translation in _cairo_gstate_glyph_path (Behdad Esfahbod)
+http://gitweb.freedesktop.org/?p=cairo;a=commit;h=f183b835b111d23e838889178aa8106ec84663b3
+
+Fix vertical metrics adjustment to work with non-identity shapes (Behdad Esfahbod)
+http://gitweb.freedesktop.org/?p=cairo;a=commit;h=b7bc263842a798d657a95e539e1693372448837f
+
+[PS] Set correct ImageMatrix in _cairo_ps_surface_emit_bitmap_glyph_data (Behdad Esfahbod)
+http://gitweb.freedesktop.org/?p=cairo;a=commit;h=d47388ad759b0a1a0869655a87d9b5eb6ae2445d
+
+Build system fixes
+------------------
+Fix xlib detection to prefer pkg-config to avoid false libXt dependency (Behdad Esfahbod)
+http://gitweb.freedesktop.org/?p=cairo;a=commit;h=0e78e7144353703cbd28aae6a67cd9ca261f1d68
+
+Fix typos causing win32 build problem with PS,PDF, and SVG backends (Behdad Esfahbod)
+http://gitweb.freedesktop.org/?p=cairo;a=commit;h=aea83b908d020e26732753830bb3056e6702a774
+
+Fix configure cache to not use stale results (Behdad Esfahbod)
+http://gitweb.freedesktop.org/?p=cairo;a=commit;h=6d0e3260444a2d5b6fb0cb223ac79f1c0e7b3a6e
+
+Fix to not pass unsupported warning options to the compiler (Jens Granseuer)
+http://gitweb.freedesktop.org/?p=cairo;a=commit;h=97524a8fdb899de1ae4a3e920fb7bda6d76c5571
+
+Fix to allow env. variables such as png_REQUIRES to override configure detection (Jens Granseuer)
+http://gitweb.freedesktop.org/?p=cairo;a=commit;h=abd16e47d6331bd3811c908e524b4dcb6bd23bf0
+
+Fix test suite to not use an old system cairo when converting svg2png (Behdad Esfahbod)
+http://gitweb.freedesktop.org/?p=cairo;a=commit;h=6122cc85c8f71b1ba2df3ab86907768edebe1781
+
+Fix test suite to not require signal.h to be present (Behdad Esfahbod)
+http://gitweb.freedesktop.org/?p=cairo;a=commit;h=6f8cf53b1e1ccdbe1ab6a275656b19c6e5120e40
+
+Code cleanups
+-------------
+Many useful warnings cleanups from sparse, valgrind, and careful eyes
+(Kjartan Maraas, Pavel Roskin)
+
+Release 1.2.2 (2006-08-08 Carl Worth <cworth@cworth.org>)
+=========================================================
+This is the first bug fix release in the 1.2 series since the original
+1.2.0 release made six weeks ago.
+
+There were some very serious bugs in the 1.2.0 release, (see below),
+so everybody is encouraged to upgrade from 1.2.0 to 1.2.2. The 1.2.2
+release maintains source and binary compatibility with 1.2.0 and does
+not make any API additions.
+
+Fix crashes with BGR X servers
+------------------------------
+With cairo 1.2.0 many people reported problems with all cairo-using
+programs, (including all GTK+ programs with GTK+ >= 2.8) immediately
+crashing with a complaint about an unsupported image format. This bug
+affected X servers that do not provide the Render extension and that
+provide a visual with BGR rather than RGB channel order.
+
+report:	https://bugs.freedesktop.org/show_bug.cgi?id=7294
+fix:	http://gitweb.freedesktop.org/?p=cairo;a=commit;h=9ae66174e774b57f16ad791452ed44efc2770a59
+
+Fix the "disappearing text" bug
+-------------------------------
+With cairo 1.2.0 many people reported that text would disappear from
+applications, sometimes reappearing with mouse motion or
+selection. The text would disappear after the first space in a string
+of text. This bug was caused by an underlying bug in (very common) X
+servers, and only affected text rendered without antialiasing, (either
+a bitmap font or a vector font with antialiasing disabled). The bug
+was also exacerbated by a KDE migration bug that caused antialiasing
+to be disabled more than desired.
+
+report:	https://bugs.freedesktop.org/show_bug.cgi?id=7494
+fix:	http://gitweb.freedesktop.org/?p=cairo;a=commit;h=456cdb3058f3b416109a9600167cd8842300ae14
+see also:
+Xorg:	https://bugs.freedesktop.org/show_bug.cgi?id=7681
+KDE:	http://qa.mandriva.com/show_bug.cgi?id=23990
+
+Fix broken image fallback scaling (aka. "broken printing")
+----------------------------------------------------------
+The various "print" backends, (pdf, ps, and svg), sometimes fallback
+to using image-based rendering for some operations. In cairo 1.2.0
+these image fallbacks were scaled improperly. Applications using cairo
+can influence the resolution of the image fallbacks with
+cairo_surface_set_fallback_resolution. With the bug, any value other
+than 72.0 would lead to incorrect results, (larger values would lead
+to increasingly shrunken output).
+
+report:	https://bugs.freedesktop.org/show_bug.cgi?id=7533
+fix:	http://gitweb.freedesktop.org/?p=cairo;a=commit;h=1feb4291cf7813494355459bb547eec604c54ffb
+
+Fix inadvertent semantic change of font matrix translation (Behdad Esfahbod)
+----------------------------------------------------------------------------
+The 1.2.0 release introduced an inadvertent change to how the
+translation components of a font matrix are interpreted. In the 1.0
+series, font matrix translation could be used to offset the glyph
+origin, (though glyph metrics were reported incorrectly in
+1.0). However in 1.2.0, the translation was applied to the advance
+values between each glyph. The 1.2.0 behavior is fairly useless in
+practice, and it was not intentional to introduce a semantic
+change. With 1.2.2 we return to the 1.0 semantics, with a much better
+implementation that provides correct glyph metrics.
+
+fix:	http://gitweb.freedesktop.org/?p=cairo;a=commit;h=84840e6bba6e72aa88fad7a0ee929e8955ba9051
+
+Fix create_similar to preserve fallback resolution and font options (Behdad Esfahbod)
+-------------------------------------------------------------------------------------
+There has been a long-standing issue with cairo_surface_create_similar
+such that font options and other settings from the original
+destination surface would not be preserved to the intermediate
+"similar" surface. This could result in incorrect rendering
+(particularly with respect to text hinting/antialiasing) with
+fallbacks, for example.
+
+report:	https://bugs.freedesktop.org/show_bug.cgi?id=4106
+fixes:	http://gitweb.freedesktop.org/?p=cairo;a=commit;h=9fcb3c32c1f16fe6ab913e27eb54d18b7d9a06b0
+	http://gitweb.freedesktop.org/?p=cairo;a=commit;h=bdb4e1edadb78a2118ff70b28163f8bd4317f1ec
+
+xlib: Fix text performance regression from 1.0 to 1.2.0 (Vladimir Vukicevic)
+----------------------------------------------------------------------------
+Several people noticed that upgrading from cairo 1.0 to cairo 1.2.0
+caused a significant performance regression when using the xlib
+backend. This performance regression was particularly noticeable when
+doing lots of text rendering and when using a high-latency connection
+to the X server, (such as a remote X server over an ssh
+connection). The slowdown was identified and fixed in 1.2.2.
+
+report:	https://bugs.freedesktop.org/show_bug.cgi?id=7514
+fix:	http://gitweb.freedesktop.org/?p=cairo;a=commit;h=b7191885c88068dad57d68ced69a752d1162b12c
+
+PDF: Eliminate dependency on FreeType library dependency (Adrian Johnson)
+-------------------------------------------------------------------------
+The cairo 1.2 series adds a supported pdf backend to cairo. In cairo
+1.2.0 this backend required the freetype library, which was an
+undesirable dependency on systems such as win32, (cairo is designed to
+always prefer the "native" font system). As of cairo 1.2.2 the
+freetype library is not required to use the pdf backend on the win32
+platform.
+
+report:	https://bugs.freedesktop.org/show_bug.cgi?id=7538
+fix:	http://gitweb.freedesktop.org/?p=cairo;a=commit;h=a0989f427be87c60415963dd6822b3c5c3781691
+
+PDF: Fix broken output on amd64 (Adrian Johnson)
+------------------------------------------------
+report:	http://bugzilla.gnome.org/show_bug.cgi?id=349826
+fix:	http://gitweb.freedesktop.org/?p=cairo;a=commit;h=f4b12e497b7ac282b2f6831b8fb68deebc412e60
+
+PS: Fix broken output for truetype fonts > 64k (Adrian Johnson)
+---------------------------------------------------------------
+fix:	http://gitweb.freedesktop.org/?p=cairo;a=commit;h=067d97eb1793a6b0d0dddfbd0b54117844511a94
+
+PDF: Fix so that dashing doesn't get stuck on (Kent Worsnop)
+------------------------------------------------------------
+Kent notices that with the PDF backend in cairo 1.2.0 as soon as a
+stroke was performed with dashing, all subsequent strokes would also
+be dashed. There was no way to turn dashing off again.
+
+fix:	http://gitweb.freedesktop.org/?p=cairo;a=commit;h=778c4730a86296bf0a71080cf7008d7291792256
+
+Fix memory leaks in failure paths in gradient creation (Alfred Peng)
+--------------------------------------------------------------------
+fix:	http://gitweb.freedesktop.org/?p=cairo;a=commit;h=db06681b487873788b51a6766894fc619eb8d8f2
+
+Fix memory leak in _cairo_surface_show_glyphs (Chris Wilson)
+------------------------------------------------------------
+report:	https://bugs.freedesktop.org/show_bug.cgi?id=7766
+fix:	http://gitweb.freedesktop.org/?p=cairo;a=commit;h=e2fddcccb43d06486d3680a19cfdd5a54963fcbd
+
+Solaris: Add definition of cairo_private for some Sun compilers (Alfred Peng)
+-----------------------------------------------------------------------------
+report:	https://bugzilla.mozilla.org/show_bug.cgi?id=341874
+fix:	http://gitweb.freedesktop.org/?p=cairo;a=commit;h=04757a3aa8deeff3265719ebe01b021638990ec6
+
+Solaris: Change version number of Sun's Xorg server with buggy repeat (Brian Cameron)
+-------------------------------------------------------------------------------------
+report: https://bugs.freedesktop.org/show_bug.cgi?id=7483
+fix:	http://gitweb.freedesktop.org/?p=cairo;a=commit;h=e0ad1aa995bcec4246c0b8ab0d5a5a79871ce235
+
+Various memory leak fixes
+-------------------------
+Fix memory leak in _cairo_surface_show_glyphs (bug 7766)
+Fix file handle leak in failure path (bug 7616)
+Fix some memory leaks in the test cases.
+Fix some memory leaks in font subsetting code used in print backends.
+
+Documentation improvements (Behdad Esfahbod)
+--------------------------------------------
+Added new documentation for several functions (cairo_show_page,
+cairo_copy_page, cairo_in_stroke, cairo_in_fill).
+
+Fixed some syntax errors that were preventing some existing
+documentation from being published.
+
+Fixed several minor typographical errors.
+
+Added an index for new symbols in 1.2.
+
+Release 1.2.0 (2006-06-27 Carl Worth <cworth@cworth.org>)
+=========================================================
+This is the culmination of the work that has gone on within the 1.1
+branch of cairo.
+
+There has been one API addition since the cairo 1.1.10 snapshot:
+
+	cairo_xlib_surface_get_width
+	cairo_xlib_surface_get_height
+
+There's also a new feature without any API change:
+
+	Dots can now be drawn by using CAIRO_LINE_CAP_ROUND with
+	degenerate sub-paths, (cairo_move_to() followed by either
+	cairo_close_path() or a cairo_line_to() to the same location).
+
+And at least the following bugs have been fixed:
+
+ 6759  fontconfig option AntiAlias doesn't work in cairo 1.1.2
+ 6955  Some characters aren't displayed when using xlib (cache u...
+ 7268  positive device_offset values don't work as source
+ * PDF emit_glyph function needs to support bitmapped glyphs
+ * PS emit_glyph function needs to support bitmapped glyphs
+ * SVG emit_glyph function needs to support bitmapped glyphs
+ * PDF: minefield page one is falling back unnecessarily
+ * PS/PDF: Fix broken placement for vertical glyphs
+ * PS: Fix to not draw BUTT-capped zero-length dash segments
+ * Do device offset before float->fixed conversion
+   http://bugzilla.gnome.org/show_bug.cgi?id=332266
+ * PS: Fix source surfaces with transformations
+ * PS: Fix to not draw BUTT-capped degnerate sub-paths
+ * PS: Don't walk off end of array when printing "~>"
+ * Fix some memory leaks in the test suite rig
+ * SVG: Fix memory leak when using cairo_mask
+ * Fix EXTEND_REFLECT and EXTEND_PAD to not crash (though these are
+   still not yet fully implemented for surface patterns).
+
+This has been a tremendous effort by everyone, and I'm proud to have
+been a part of it. Congratulations to all contributors to cairo!
+
+Snapshot 1.1.10 (2006-06-16 Carl Worth <cworth@cworth.org>)
+===========================================================
+This is the fifth in a series of snapshots working toward the 1.2
+release of cairo.
+
+The primary motivation for this snapshot is to fix a long-standing bug
+that had long been silent, but as of the 1.1.8 snapshot started
+causing crashes when run against 16-bit depth X servers, (often Xvnc
+or Xnest). The fix for this adds a new CAIRO_FORMAT_RGB16_565 to the
+API.
+
+This snapshot also includes a rewrite of cairo's SVG backend to
+eliminate the dependency on libxml2. With this in place, cairo 1.2
+will not depend on any libraries that cairo 1.0 did not.
+
+As usual, there are also a few fixes for minor bugs.
+
+Snapshot 1.1.8 (2006-06-14 Carl Worth <cworth@cworth.org>)
+==========================================================
+This is the fourth in a series of snapshots working toward the 1.2
+release of cairo. At this point, all major features of the 1.2 release
+are in place, leaving just a few bug fixes left.
+
+In particular, there well be no additional API changes between this
+1.1.8 snapshot and the 1.2 release.
+
+The announcement for 1.1.6 mentioned several API changes being
+considered. Only one of these changes was actually implemented
+(set_dpi -> fallback_resolution). This change does introduce one
+source-level incompatibility with respect to previous 1.1.x snapshots,
+so see below for details.
+
+Here is an abbreviated summary of changes since the 1.1.6 snapshot:
+
+** API Change **
+----------------
+According to the plan mentioned in the 1.1.6 notes, one source-level
+incompatible change has been implemented. The following three
+functions have been removed from cairo's API:
+
+	cairo_pdf_surface_set_dpi
+	cairo_ps_surface_set_dpi
+	cairo_svg_surface_set_dpi
+
+and in their place the following function has been added:
+
+	cairo_surface_set_fallback_resolution
+
+The signature and semantics of the function remains the same, so it is
+a simple matter of changing the name of the function when calling
+it. As a transition mechanism, this snapshot will (on many systems)
+build to include the old symbols so that code previously compiled will
+still run. However, all source code using the old names must be
+updated before it will compile. And the upcoming 1.2 release is not
+anticipated to include the old symbols.
+
+Finally, it should be pointed out that the old symbols never existed
+in the supported API of any stable release of cairo. (In the stable
+1.0 releases the PDF, PS, and SVG backends were advertised as
+experimental and unstable.)
+
+And, as always, cairo continues to maintain source and binary
+compatibility between major releases. So applications compiled against
+supported backends in a stable release of cairo (1.0.4 say) will
+continue to compile and run without modification against new major
+releases (1.2.0 say) without modification.
+
+API additions
+-------------
+The following new functions have been added to cairo's API:
+
+	cairo_surface_get_content
+	cairo_debug_reset_static_data
+	cairo_image_surface_get_data
+	cairo_image_surface_get_format
+	cairo_image_surface_get_stride
+	cairo_win32_font_face_create_for_hfont
+
+New, backend-specific pkg-config files
+--------------------------------------
+In addition to the original cairo.pc file, cairo will also now install
+a pkg-config files for each configured backend, (for example
+cairo-pdf.pc, cairo-svg.pc, cairo-xlib.pc, cairo-win32.pc, etc.) this
+also includes optional font backends (such as cairo-ft.pc) and the
+optional png functionality (cairo-png.pc).
+
+These new pkg-config files should be very convenient for allowing
+cairo-using code to easily check for the existing of optional
+functionality in cairo without having to write complex rules to grub
+through cairo header files or the compiled library looking for
+symbols.
+
+Printing backend (PS, PDF, and SVG)
+-----------------------------------
+Improving the quality of the "printing" backends has been a priority
+of the development between cairo 1.1.6 and cairo 1.1.8.
+
+The big improvement here is in the area of text output. Previously, at
+best, text was output as paths without taking advantage of any font
+support available in the output file format.
+
+Now, at the minimum text paths will be shared by using type3 fonts
+(for PS and PDF---and similarly, defs for SVG). Also, if possible,
+type3 and truetype fonts will be embedded in PostScript and PDF
+output. There are still some known bugs with this, (for example,
+selecting text in a cairo-generated PDF file with an embedded truetype
+font does not work). So there will be some more changes in this area
+before cairo 1.2, but do try test this feature out as it exists so
+far.
+
+Many thanks to Kristian Høgsberg for the truetype and type1 font
+embedding.
+
+win32 backend
+-------------
+Performance improvements by preferring GDI over pixman rendering when possible.
+Fixes for text rendering.
+
+xlib backend
+------------
+Fix potentially big performance bug by making xlib's create_similar
+try harder to create a pixmap of a depth matching that of the screen.
+
+Bug fixes
+---------
+Among various other fixes, the following bugs listed in bugzilla have
+been fixed:
+
+    Bug 2488: Patch to fix pixman samping location bug (#2488).
+    https://bugs.freedesktop.org/show_bug.cgi?id=2488
+
+    Bug 4196: undef MIN an MAX before defining to avoid duplicate definition
+    https://bugs.freedesktop.org/show_bug.cgi?id=4196
+
+    Bug 4723: configure.in: Fix m4 quoting when examining pkg-config version
+    https://bugs.freedesktop.org/show_bug.cgi?id=4723
+
+    Bug 4882: Flag Sun's X server has having buggy_repeat.
+    https://bugs.freedesktop.org/show_bug.cgi?id=4882
+
+    Bug 5306: test/pdf2png: Add missing include of stdio.h
+    https://bugs.freedesktop.org/show_bug.cgi?id=5306
+
+    Bug 7075: Fix make clean to remove cairo.def
+    https://bugs.freedesktop.org/show_bug.cgi?id=7075
+
+(Many thanks to Behdad Esfahbod for helping us track down and fix many
+of these.)
+
+Snapshot 1.1.6 (2006-05-04 Carl Worth <cworth@cworth.org>)
+==========================================================
+This is the third in a series of snapshots working toward the imminent
+1.2 release of cairo. For a list of items still needing work on the
+cairo 1.2 roadmap, please see:
+
+	http://cairographics.org/ROADMAP
+
+As can be seen in that list, there are no longer any API additions
+left on the roadmap. Instead, there is a feature (PDF type 3 fonts) a
+performance optimization (X server gradients) and a list of bug
+fixes. This gives us a fair amount of freedom to cut the 1.2 release
+at almost any point by deciding to defer remaining bug fixes to
+subsequent maintenance releases such as 1.2.2 and 1.2.4.
+
+Before we will do that, we must first be wiling to commit to all the
+new API additions. As a heads-up, there are a couple of potential API
+changes being considered. (Note that these are changes to new API
+introduced during 1.1 so these will not introduce API
+incompatibilities compared to the stable 1.0 series). The changes
+being considered are:
+
+  cairo_get_group_target: may acquire x and y offset return
+	parameters. May also be eliminated in favor of
+	cairo_get_target assuming its role
+
+  cairo_pdf_surface_set_dpi:
+  cairo_ps_surface_set_dpi:
+  cairo_svg_surface_set_dpi: These functions may be removed in favor
+	of a new cairo_surface_set_fallback_resolution
+
+Additionally there is the possibility of a slight change in the
+semantics of cairo_set_line_width. We believe the current behavior of the sequence:
+
+	cairo_set_line_width; ... change CTM ...; cairo_stroke;
+
+is buggy. It is currently behaving the same as:
+
+	... change CTM ...; cairo_set_line_width; cairo_stroke;
+
+We are considering fixing this bug before 1.2 with the hope that
+nobody is already relying on the buggy behavior described here. Do
+shout if you suspect you might be in that position.
+
+The items included in this snapshot (since the 1.1.4 snapshot) are
+described below.
+
+API additions
+-------------
+The long-awaited group-rendering support is now available with the
+following function calls:
+
+	cairo_push_group
+	cairo_push_group_with_content
+	cairo_pop_group
+	cairo_pop_group_to_source
+	cairo_get_group_target
+
+This API provides a much more convenient mechanism for doing rendering
+to an intermediate surface without the need to manually create a
+temporary cairo_surface_t and a temporary cairo_t and clean them up
+afterwards.
+
+Add the following missing get function to complement
+cairo_surface_set_device_offset:
+
+	cairo_surface_get_device_offset
+
+PDF backend (API addition)
+--------------------------
+The PDF backend now provides for per-page size changes, (similar to
+what the PostScript backend got in the 1.1.4 snapshot). The new API
+is:
+
+	cairo_pdf_surface_set_size
+
+Xlib backend (API additions)
+----------------------------
+The following functions have been added to allow the extraction of
+Xlib surface:
+
+	cairo_xlib_surface_get_display
+	cairo_xlib_surface_get_drawable
+	cairo_xlib_surface_get_screen
+	cairo_xlib_surface_get_visual
+	cairo_xlib_surface_get_depth
+
+XCB backend (experimental)
+--------------------------
+Update backend so that it now compiles with the recent XCB 0.9 release.
+
+Bug fixes and memory leak cleanup
+---------------------------------
+Various little things, nothing too significant though.
+
+Snapshot 1.1.4 (2006-05-03 Carl Worth <cworth@cworth.org>)
+==========================================================
+This is the second in a series of snapshots working toward the
+upcoming 1.2 release of cairo. For a list of items still needing work
+on the cairo 1.2 roadmap, please see:
+
+	http://cairographics.org/ROADMAP
+
+The items included in this snapshot (since the 1.1.2 snapshot) are
+described below.
+
+PostScript backend: new printing-oriented API
+---------------------------------------------
+We anticipate that with cairo 1.2, toolkits will begin to use cairo
+for printing on systems that use PostScript as the spool format. To
+support this use case, we have added 4 new function calls that are
+specific to the PostScript backend:
+
+	cairo_ps_surface_set_size
+        cairo_ps_surface_dsc_comment
+        cairo_ps_surface_dsc_begin_setup
+        cairo_ps_surface_dsc_begin_page_setup
+
+These functions allow variation of the page size/orientation from one
+page to the next in the PostScript output. They also allow the toolkit
+to provide per-document and per-page printer control options in a
+device-independent way, (for example, by using PPD options and
+emitting them as DSC comments into the PostScript output). This should
+allow toolkits to provide very fine-grained control of many options
+available in printers, (media size, media type, tray selection, etc.).
+
+SVG backend: builds by default, version control
+-----------------------------------------------
+The SVG backend continues to see major improvements. It is expected
+that the SVG backend will be a supported backend in the 1.2
+release. This backend will now be built by default if its dependencies
+(freetype and libxml2) are met.
+
+Additionally, the SVG backend now has flexibility with regard to what
+version of SVG it targets. It will target SVG 1.1 by default, which
+will require image fallbacks for some of the "fancier" cairo
+compositing operators. Or with the following new function calls:
+
+	cairo_svg_surface_restrict_to_version
+	cairo_svg_get_versions
+	cairo_svg_version_to_string
+
+it can be made to target SVG 1.2 in which there is native support for
+these compositing operators.
+
+Bug fixes
+---------
+At least the following bugs have been fixed since the 1.1.2 snapshot:
+
+crash at XRenderAddGlyphs
+https://bugs.freedesktop.org/show_bug.cgi?id=4705
+
+Can't build cairo-1.1.2 on opensolaris due to " void function cannot return value"
+https://bugs.freedesktop.org/show_bug.cgi?id=6792
+
+Missing out-of-memory check at gfx/cairo/cairo/src/cairo-atsui-font.c:185
+https://bugzilla.mozilla.org/show_bug.cgi?id=336129
+
+A couple of memory leaks.
+
+Snapshot 1.1.2 (2006-04-25 Carl Worth <cworth@cworth.org>)
+==========================================================
+This is the first in a series of snapshots working toward the upcoming
+1.2 release of cairo. (Subsequent snapshot will use successive even
+numbers for the third digit, 1.1.4, 1.1.6, etc.) This snapshot is
+backwards-compatible with the 1.0 series---it makes a few API
+additions but does not remove any API.
+
+PostScript and PDF backends are no longer "experimental"
+--------------------------------------------------------
+The major theme of the 1.2 release is improved PostScript and PDF
+backends for cairo. Unlike the 1.0 series, in the 1.2 series these
+backends will not be marked as experimental and will be enabled by
+default. We encourage people to test this snapshot and the PS/PDF
+backends in particular as much as possible.
+
+The PostScript and PDF output is not yet ideal.
+
+ * One major problem with the PostScript output is that image
+   fallbacks are used more often than strictly necessary, and the
+   image fallbacks are at a lower resolution than desired, (the
+   cairo_ps_surface_set_dpi call is ignored).
+
+  * The major drawback of the current PDF backend implementation is
+    its text support. Every glyph is represented by a filled path in
+    the PDF file. The causes file sizes to be much larger and
+    rendering to be much slower than desired.
+
+It is anticipated that both of these shortcomings will see some
+improvements before the final 1.2 release.
+
+In spite of those shortcomings, we hope that the PS and PDF backends
+will yield faithful results for pretty much any cairo operations you
+can throw at them. Please let us know if you are getting obviously
+"different" results from the PS/PDF backends than from the image or
+xlib backends.
+
+Other new experimental backends
+-------------------------------
+This snapshot includes three new backends that did not exist in the
+1.0 series:
+
+	* beos backend
+
+	* directfb backend
+
+	* svg backend
+
+These are all currently marked "experimental" and are disabled by
+default. But the SVG backend in particular has seen a lot of recent
+development and is very close to passing the entire cairo test
+suite. It is possible that this backend will become a fully supported
+backend by the time of the cairo 1.2 release.
+
+Public API additions
+--------------------
+There have been a few new API functions added to cairo, including:
+
+New get_type functions for querying sub-types of object:
+
+	cairo_surface_get_type
+	cairo_pattern_get_type
+	cairo_font_face_get_type
+	cairo_scaled_font_get_type
+
+More convenience in working with cairo_scaled_font_t with new getter
+functions:
+
+	cairo_scaled_font_get_font_face
+	cairo_scaled_font_get_font_matrix
+	cairo_scaled_font_get_ctm
+	cairo_scaled_font_get_font_options
+
+As well as a convenience function for setting a scaled font into a
+cairo context:
+
+	cairo_set_scaled_font
+
+and a function to allow text extents to be queried directly from a
+scaled font, (without requiring a cairo_surface_t or a cairo_t):
+
+	cairo_scaled_font_text_extents
+
+These new scaled font functions were motivated by the needs of the
+pango library.
+
+Finally, a new path-construction function was added which clears the
+current point in preparation for a new sub path. This makes cairo_arc
+easier to use in some situations:
+
+	cairo_new_sub_path
+
+Before the 1.2 release is final we do still plan a few more API
+additions specifically motivated by the needs of Mozilla/Firefox.
+
+Optimizations and bug fixes
+---------------------------
+Shortly after the 1.0 maintenance series branched off the mainline
+there was a major rework of the cairo font internals. This should
+provide some good performance benefits, but it's also another area
+people should look at closely for potential regressions.
+
+There has not yet been any widespread, systematic optimization of
+cairo, but various performance improvements have been made, (and some
+of them are fairly significant). So if some things seem faster than
+1.0 then things are good. If there are any performance regressions
+compared to 1.0 then there is a real problem and we would like to hear
+about that.
+
+There has been a huge number of bug fixes---too many to mention in
+detail. Again, things should be better, and never worse compared to
+1.0. Please let us know if your testing shows otherwise.
+
+Release 1.0.2 (2005-10-03 Carl Worth <cworth@cworth.org>)
+=========================================================
+For each bug number XXXX below, see:
+
+	https://bugs.freedesktop.org/show_bug.cgi?id=XXXX
+
+for more details.
+
+General bug fixes
+-----------------
+ * 4408 - Add support for dashing of stroked curves
+	  (Carl Worth)
+
+ * 4409 - Fix dashing so that each dash is capped on both ends
+	  (Carl Worth)
+
+ * 4414 - Prevent SIGILL failures (proper use of -mmmx and -msse flags)
+	  (Sebastien Bacher, Billy Biggs)
+
+ * 4299 - Fix crashes with text display in multi-threaded program
+	  (Alexey Shabalin, Carl Worth)
+
+ * 4401 - Do not use sincos function since it is buggy on some platforms)
+	  (Tim Mooney, Carl Worth)
+
+ * 4245 - Fix several bugs in the test suite exposed by amd64 systems
+	  (Seemant Kulleen, Carl Worth)
+
+ * 4321 - Add missing byteswapping on GetImage/PutImage
+	  (Sjoerd Simons, Owen Taylor)
+
+ * 4220 - Make the check for rectangular trapezoids simpler and more accurate
+	  (Richard Stellingwerff, Owen Taylor)
+
+ * 4260 - Add missing channel-order swapping for antialised fonts
+	  (Barbie LeVile, Owen Taylor)
+
+ * 4283 - Fix compilation failure with aggressive inlining (gcc -O3)
+	  (Marco Manfredini, Owen Taylor)
+
+ * 4208 - Fix some warnings from sparse
+	  (Kjartan Maraas, Billy Biggs)
+
+ * 4269 - Fix to not crash when compiled with -fomit-frame-pointer
+	  (Ronald Wahl, Owen Taylor)
+
+ * 4263 - Improve performance for vertical gradients
+	  (Richard Stellingwerff, Owen Taylor)
+
+ * 4231
+ * 4298 - Accomodate gentoo and Mandriva versions in X server vendor string check
+	  (Billy Biggs, Frederic Crozat, Owen Taylor)
+
+win32-specific fixes
+--------------------
+ * 4599 - Fix "missing wedges" on some stroked paths (win32)
+	  (Tim Rowley, Jonathan Watt, Bertram Felgenhauer, Carl Worth, Keith Packard)
+
+ * 4612 - Fix disappearing text if first character out of surface (win32)
+	  (Tim Rowley)
+
+ * 4602 - Fix shutdown of cairo from failing intermediate, size-0 bitmaps (win32)
+	  Aka. the "white rectangles" bug from mozilla-svg testing
+	  (Tim Rowley)
+
+ * Various portability improvements for win32
+	  (Hans Breuer, Owen Taylor, Carl Worth)
+
+ * 4593 - Fix font sizes to match user expectations (win32)
+	  (Tor Lillqvist, Owen Taylor)
+
+ * 3927 - Fix to report metrics of size 0 for glyph-not-available (win32)
+	  (Hans Breuer, Owen Taylor, Tor Lillqvist)
+
+ * Add locking primitives for win32
+	  (Hans Breuer)
+
+xlib-specific fixes
+-------------------
+ * Fix crash from size-0 pixmap due to empty clip region (xlib)
+	  (Radek Doulík, Carl Worth)
+
+Release 1.0.0 (2005-08-24 Carl Worth <cworth@cworth.org>)
+=========================================================
+Experimental backends
+---------------------
+ * The Glitz, PS, PDF, Quartz, and XCB backends have been declared
+   experimental, and are not part of the API guarantees that accompany
+   this release. They are not built by default, even when the required
+   libraries are available, and must be enabled explicitly with
+   --enable-ps, --enable-pdf, --enable-quartz or --enable-xcb.
+
+   It is very painful for us to be pushing out a major release without
+   these backends enabled. There has been a tremendous amount of work
+   put into each one and all are quite functional to some
+   extent. However, each also has some limitations. And none of these
+   backends have been tested to the level of completeness and
+   correctness that we expect from cairo backends.
+
+   We do encourage people to experiment with these backends and report
+   success, failure, or means of improving them.
+
+Operator behavior
+-----------------
+ * Prior to 0.9.0 the SOURCE, CLEAR and a number of other operators
+   behaved in an inconsistent and buggy fashion and could affect areas
+   outside the clip mask. In 0.9.0, these six "unbounded" operators
+   were fixed to consistently clear areas outside the shape but within
+   the clip mask.  This is useful behavior for an operator such as IN,
+   but not what was expected for SOURCE and CLEAR. So, in this release
+   the behavior of SOURCE and CLEAR has been changed again. They now
+   affect areas only within both the source and shape. We can write
+   the new operators as:
+
+     SOURCE: dest' = (mask IN clip) ? source : dest
+     CLEAR:  dest' = (mask IN clip) ? 0 : dest
+
+Behavior and API changes
+------------------------
+ * Setting the filter on a gradient pattern would change the
+   interpolation between color stops away from the normal linear
+   interpolation. This dubious behavior has been removed.
+
+ * The CAIRO_CONTENT_VALID() and CAIRO_FORMAT_VALID() macros --
+   implementation details that leaked into cairo.h -- have been moved
+   into an internal header.
+
+ * The cairo_show_text function now advances the current point
+   according to the total advance values of the string.
+
+API additions
+-------------
+ * cairo_set_dash can now detect error and can set
+   CAIRO_STATUS_INVALID_DASH.
+
+Features
+--------
+ * When compiled against recent versions of fontconfig and FreeType,
+   artificial bold fonts can now be turned on from fonts.conf using
+   the FC_EMBOLDEN fontconfig key.
+
+Optimization
+------------
+ * The compositing code from the 'xserver' code tree has now been
+   completely merged into libpixman. This includes MMX optimization of
+   common operations.
+
+ * The image transformation code in libpixman has been improved and
+   now performs significantly faster.
+
+Bug fixes
+---------
+ * Several crashes related to corruption in the font caches have been
+   fixed.
+
+ * All test cases now match pixel-for-pixel on x86 and PPC; this
+   required fixing bugs in the compositing, stroking, and pattern
+   rendering code.
+
+ * Negative dash offsets have been fixed to work correctly.
+
+ * The stroking of paths with mutiple subpaths has now been fixed to
+   apply caps to all subpaths rather than just the last one.
+
+ * Many build fixes for better portability on various systems.
+
+ * Lots of other bug fixes, but we're too tired to describe them in
+   more detail here.
+
+Release 0.9.2 (2005-08-13 Carl Worth <cworth@cworth.org>)
+=========================================================
+Release numbering
+-----------------
+ * You will notice that this release jumped from 0.9.0 to 0.9.2. We've
+   decided to use an odd micro version number (eg. 0.9.1) to indicate
+   in-progress development between releases. As soon as 0.9.2 is
+   tagged, the version will be incremented in CVS to 0.9.3 where it
+   will stay until just before 0.9.4 is built, uploaded, and tagged.
+
+   So, even-micro == a released version, odd-micro == something in-between.
+
+Libpixman dependency dropped
+----------------------------
+ * As of this release, the dependency on an external libpixman has
+   been dropped. Instead, the code from libpixman needed for cairo has
+   been incorporated into the cairo source tree. The motivation for
+   this change is that while cairo's API is stable and ready to be
+   maintained after the 1.0 release, libpixman's API is not, so we do
+   not want to expose it at this time.
+
+   Also, the incorporation of libpixman into cairo also renames all
+   previously-public libpixman symbols in order to avoid any conflict
+   with a future release of libpixman
+
+API additions
+-------------
+ * Macros and functions have been added so that the version of cairo
+   can be queried at either compile-time or at run-time. The version
+   is made available as both a human-readable string and as a single
+   integer:
+
+	CAIRO_VERSION_STRING		   eg. "0.9.2"
+	CAIRO_VERSION			   eg. 000902
+
+	const char*
+	cairo_version_string (void);	/* eg. "0.9.2" */
+
+	int
+	cairo_version (void);		/* eg. 000902 */
+
+   A macro is provided to convert a three-part component version into
+   the encoded single-integer form:
+
+	CAIRO_VERSION_ENCODE(X,Y,Z)
+
+   For example, the CAIRO_VERSION value of 000902 is obtained as
+   CAIRO_VERSION_ENCODE(0,9,2). The intent is to make version
+   comparisons easy, either at compile-time:
+
+	#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(0,9,2)
+	...
+	#endif
+
+   Or at run-time:
+
+	if (cairo_version() >= CAIRO_VERSION_ENCODE(0,9,2)) { /* ... */ }
+
+Thread safety
+-------------
+ * This release adds pthread-based locking (when available) to make
+   the caches used by cairo safe for threaded programs. Some may
+   remember a failed experiment with this locking between the 0.5.1
+   and 0.5.2 snapshots, (where even single-threaded programs that
+   linked with -lpthread would deadlock). We believe that that problem
+   has been fixed, so we are looking forward to testing and reports
+   from users with threaded applications.
+
+Bug fixes
+---------
+ * The XCB and Quartz backends failed to compiled in the 0.9.0 release
+   due to minor syntax errors. These have now been fixed.
+
+ * Various crashes in glitz and pixman due to size 0 glyphs have been
+   fixed.
+
+Release 0.9.0 (2005-08-08 Carl Worth <cworth@cworth.org>)
+=========================================================
+Soname change
+-------------
+ * In all prior snapshots, the libtool library versioning was set to
+   1:0:0. As this release is intended to mark the beginning of
+   backwards-compatible releases, the versioning has been incremented
+   to 2:0:0. You will notice that the numeric extension on the
+   installed library filename will change similarly.
+
+   This change will also require all cairo-using applications to be
+   recompiled. We recognize that this may cause some frustration since
+   this release is backwards-compatible with 0.6.0 and in that sense
+   "shouldn't" require re-compilation. However, since all historical
+   snapshots have used the same 1:0:0 version in spite of incompatible
+   API changes between them, it was essential that the upcoming 1.0
+   release series have distinct library versioning.
+
+   All future releases will use the library versioning to properly
+   indicate compatibility between releases. So, any application
+   re-compiled now to work with the 0.9.0 will not need to be
+   recompiled when a compatible 1.0 release of cairo is made in the
+   future.
+
+API additions
+-------------
+ * Add new function calls to set/get the current antialiasing mode in
+   the graphics state:
 
 	cairo_set_antialias
+	cairo_get_antialias
 
    This call accepts the same modes recently added for font options
    (NONE or GRAY) but affects the rendering of geometry other than
    text. The intent of this call is to enable more precise control of
    which pixels are affected by each operation, for example to allow
    for full-scene antialiasing for seam-free rendering. It is not
    expected that non-antialiased rendering will perform better than
    anti-aliased rendering.
 
  * Three new functions were added to provide support for mixed cairo-
    and non-cairo drawing to the same surface:
 
 	cairo_surface_mark_dirty
 	cairo_surface_mark_dirty_rectangle
-	cairo_flush
+	cairo_surface_flush
 
  * The return type of the several "reference" functions was change,
    (API compatibly), from void to the same type as the argument. The
    affected functions are:
 
 	cairo_font_face_reference
 	cairo_scaled_font_reference
 	cairo_pattern_reference
 	cairo_surface_reference
 	cairo_reference
 
    This allows a convenient way to assign and reference in a single
    statement.
 
+Semantic changes
+----------------
+ * The behavior of cairo_set_source with a pattern with a non-identity
+   matrix was previously not well-defined. The new behavior is as
+   follows:
+
+	The pattern's transformation matrix will be locked to the
+	user space in effect at the time of cairo_set_source(). This means
+	that further modifications of the CTM will not affect the source
+	pattern.
+
 cairo-win32
 -----------
  * Some portability improvements, (eg. workaround for missing stdint.h).
 
 cairo-ft
 --------
  * Updated to allow compilation with older versions of freetype.
 
 Bug fixes
 ---------
  * Fix the unbounded operators to actually produce a correct result,
-   (previously the results were artificially restricited to the
+   (previously the results were artificially restricted to the
    bounding box of whatever shape was being drawn rather than
    extending out infinitely). The fixed operators are:
 
 	CAIRO_OPERATOR_CLEAR
 	CAIRO_OPERATOR_SOURCE
 	CAIRO_OPERATOR_OUT
 	CAIRO_OPERATOR_IN
 	CAIRO_OPERATOR_DEST_IN
@@ -65,17 +2806,17 @@ Bug fixes
 
  * Workaround for X server Render bug involving repeating patterns
    with a general transformation matrix.
 
  * cairo_get_font_face fixed to return a "nil" font face object rather
    than NULL on error.
 
  * cairo_set_font_face fixed to not crash if given a NULL font face,
-   (which is the documented interface for restoring the defauly font
+   (which is the documented interface for restoring the default font
    face).
 
  * Fix xlib glyphset caching to not try to free a NULL glyph.
 
 Snapshot 0.6.0 (2005-07-28 Carl Worth <cworth@cworth.org>)
 ==========================================================
 API changes
 -----------
@@ -197,17 +2938,17 @@ API additions
    Significantly, it also allows surface backends to have some
    influence over the process. For example, the xlib backend now
    queries existing Xft properties to set font option defaults.
 
 * New function:
 
 	cairo_xlib_surface_set_drawable
 
-  which allos the target drawable for an xlib cairo_surface_t to be
+  which allows the target drawable for an xlib cairo_surface_t to be
   changed to another with the same format, screen, and display. This
   is necessary in certain double-buffering techniques.
 
 New features
 ------------
 * Sub-pixel text antialiasing is now supported.
 
 Bug fixes
@@ -262,17 +3003,17 @@ Bug fixes
 * Fix cairo_surface_write_to_png for RGB24 images.
 
 * Fix broken metrics and rendering for bitmap fonts. Add mostly
   useless bitmap glyph transformation.
 
 * Fix glyph caches to not eject entries that might be immediately
   needed, (fixing intermittent crashes when rendering text).
 
-* Fix all memory leaks found by running "make check-valigrind".
+* Fix all memory leaks found by running "make check-valgrind".
 
 ATSUI backend changes
 ---------------------
 * Allow building against < 10.3 SDK.
 
 * Prevent crash on empty strings.
 
 Glitz backend changes
@@ -719,17 +3460,17 @@ viewed online here:
 
 New backend: win32
 ------------------
 This is the first snapshot to include a functional win32 backend,
 (thanks to Owen Taylor). The interface is as follows:
 
 	#include <cairo-win32.h>
 
-	void 
+	void
 	cairo_set_target_win32 (cairo_t *cr,
 				HDC      hdc);
 
 	cairo_surface_t *
 	cairo_win32_surface_create (HDC hdc);
 
 	cairo_font_t *
 	cairo_win32_font_create_for_logfontw (LOGFONTW       *logfont,
@@ -1204,17 +3945,17 @@ are:
 	cairo_current_path_flat
 
 Each function accepts a number of callback functions that will be
 called for each element in the path (move_to, line_to, curve_to,
 close_path). The cairo_current_path_flat function does not accept a
 curve_to callback. Instead, all curved portions of the path will be
 converted to line segments, (within the current tolerance value). This
 can be handy for doing things like text-on-path without having to
-manually interpolate bezier splines.
+manually interpolate Bézier splines.
 
 New XCB backend
 ---------------
 Jamey Sharp has contributed a second X backend that uses the new, lean
 XCB library rather than Xlib. It cannot currently be compiled at the
 same time as the Xlib backend. See ./configure --enable-xcb.
 
 Build fixes for cygwin.
@@ -1293,8 +4034,10 @@ used for the image_surface backend. This
 as the software fallback for the render extension within the X
 server.
 
 2002-06
 =======
 Carl Worth <cworth@isi.edu> wrote the first lines of Xr, after Keith
 Packard <keithp@keithp.com> proposed the plan for a stateful drawing
 library in C providing a PostScript-like rendering model.
+
+ LocalWords:  mutex BeOS extraordinaire
--- a/gfx/cairo/cairo/README
+++ b/gfx/cairo/cairo/README
@@ -1,60 +1,161 @@
 Cairo - Multi-platform 2D graphics library
 http://cairographics.org
 
+What is cairo
+=============
+Cairo is a 2D graphics library with support for multiple output
+devices. Currently supported output targets include the X Window
+System, win32, and image buffers, as well as PDF, PostScript, and SVG
+file output. Experimental backends include OpenGL (through glitz),
+Quartz, XCB, BeOS, OS/2, and DirectFB.
+
+Cairo is designed to produce consistent output on all output media
+while taking advantage of display hardware acceleration when available
+(for example, through the X Render Extension).
+
+The cairo API provides operations similar to the drawing operators of
+PostScript and PDF. Operations in cairo include stroking and filling
+cubic Bézier splines, transforming and compositing translucent images,
+and antialiased text rendering. All drawing operations can be
+transformed by any affine transformation (scale, rotation, shear,
+etc.).
+
+Cairo has been designed to let you draw anything you want in a modern
+2D graphical user interface.  At the same time, the cairo API has been
+designed to be as fun and easy to learn as possible. If you're not
+having fun while programming with cairo, then we have failed
+somewhere---let us know and we'll try to fix it next time around.
+
+Cairo is free software and is available to be redistributed and/or
+modified under the terms of either the GNU Lesser General Public
+License (LGPL) version 2.1 or the Mozilla Public License (MPL) version
+1.1.
+
+Where to get more information about cairo
+=========================================
+The primary source of information about cairo is:
+
+	http://cairographics.org/
+
+The latest releases of cairo can be found at:
+
+	http://cairographics.org/releases
+
+Snapshots of in-development versions of cairo:
+
+	http://cairographics.org/snapshots
+
+The programming manual for using cairo:
+
+	http://cairographics.org/manual
+
+Mailing lists for contacting cairo users and developers:
+
+	http://cairographics.org/lists
+
+Answers to some frequently asked questions about cairo:
+
+	http://cairographics.org/FAQ
+
+Dependencies
+============
+The set of libraries needed to compile cairo depends on which backends
+are enabled when cairo is configured. Here are the dependencies for
+each backend:
+
+Surface backends:
+
+	image backend (required)
+	------------------------
+	pixman			http://cairographics.org/releases
+			or:	git://git.cairographics.org/git/pixman
+
+	glitz backend
+	-------------
+	glitz >= 0.4.4 		http://freedesktop.org/Software/glitz
+
+	pdf backend
+	-----------
+	freetype >= 2.1.4	http://freetype.org
+	zlib			http://www.gzip.org/zlib
+
+	postscript backend
+	------------------
+	freetype >= 2.1.4	http://freetype.org
+	zlib			http://www.gzip.org/zlib
+
+	quartz backend
+	--------------
+	[*]
+
+	win32 backend
+	-------------
+	[*]
+
+	xcb backend
+	-----------
+	XCB			http://xcb.freedesktop.org
+
+	xlib backend
+	------------
+	Xrender >= 0.6		http://freedesktop.org/Software/xlibs
+
+	beos backend
+	------------
+	No dependencies in itself other than an installed BeOS system, but cairo
+	requires a font backend. See the freetype dependency list.
+
+	os2 backend
+	-----------
+	Cairo should run on any recent version of OS/2 or eComStation, but it
+	requires a font backend. See the freetype dependency list. Ready to use
+	packages and developer dependencies are available at Netlabs:
+				ftp://ftp.netlabs.org/pub/cairo
+
+Font backends:
+
+	freetype font backend
+	---------------------
+	freetype >= 2.1.4	http://freetype.org
+	fontconfig		http://fontconfig.org
+
+	win32 font backend
+	------------------
+	[*]
+
+	atsui font backend
+	------------------
+	[*]
+
+	[*] I don't know specifically what packages might need to be
+	    installed on a Mac OS X system to use the Quartz and ATSUI
+	    backends. As far as win32, the situation is rather complex:
+
+	    The Win32 backend should work on Windows 2000 and newer
+	    (excluding Windows Me.) Most testing has been done on
+	    Windows XP. While some portions of the code have been
+	    adapted to work on older versions of Windows, considerable
+	    work still needs to be done to get cairo running in these
+	    environments.
+
+	    Cairo can be compiled on Windows either with the GCC
+	    toolchain (see http://www.mingw.org) or with Microsoft
+	    Visual C++. Makefiles or project files for compiling with
+	    MSVC are however not provided as of this release. We have
+	    received reports that MSVC 6.0 compiles parts of cairo
+	    incorrectly, (leading to incorrect color). MSVC 7.0 is
+	    known to work.
+
 Compiling
----------
+=========
 See the INSTALL document for build instructions.
 
-Description
------------
-Cairo is a vector graphics library with cross-device output
-support. Currently supported output targets include the X Window
-System and in-memory image buffers. PostScript and PDF file output is
-planned. Cairo is designed to produce identical output on all output
-media while taking advantage of display hardware acceleration when
-available (eg. through the X Render Extension).
-
-Cairo provides a stateful user-level API with capabilities similar to
-the PDF 1.4 imaging model. Cairo provides operations including
-stroking and filling Bezier cubic splines, transforming and
-compositing translucent images, and antialiased text rendering.
-
-Cairo was once named Xr, (or Xr/Xc), so if you came looking for that
-software, you've found it.
-
-Dependencies
-------------
-Cairo currently requires the following supporting libraries:
-
-	libpixman
-	Xft2
-	fontconfig
-	freetype2
-
-Documentation
--------------
-There's not much documentation yet apart from the cairo.h header
-file. We'll be correcting that shortly.
-
-In the meantime, the cairo-demo module in CVS provides a few example
-programs using cairo. These may be helpful to a programmer just
-beginning with cairo. Also, familiarity with the PostScript imaging
-model will help in understanding cairo.
-
 History
--------
+=======
 Cairo was originally developed by Carl Worth <cworth@cworth.org> and
 Keith Packard <keithp@keithp.com>. Many thanks are due to Lyle Ramshaw
 without whose patient help our ignorance would be much more apparent.
 
-Mailing List
-------------
-If you have trouble with cairo or you have some ideas for how it could be
-improved, please feel free to send a message to cairo@cairographics.org
-
-Cairo is still under active development and all discussion happens on
-that list. So if you want to lurk or, (even better), take part in the
-development, take a look. Subscription information and archives are
-available:
-
-	http://cairographics.org/cgi-bin/mailman/listinfo/cairo
+Since the original development, many more people have contributed to
+cairo. See the AUTHORS files for as complete a list as we've been able
+to compile so far.
deleted file mode 100644
--- a/gfx/cairo/cairo/TODO
+++ /dev/null
@@ -1,86 +0,0 @@
-Changes that are expected to impact the public API
-==================================================
-
- Patch submitted to mailing list?
-/ Documentation included in patch?
-|/ Review of patch completed?
-||/ Test case included?
-|||/ Committed.
-||||/
-Backwards compatible (API additions only)
------------------------------------------
-	cairo_begin_group, cairo_end_group, cairo_get_group
-PDR C	cairo_surface_mark_dirty (see below for details)
-PDRTC	Add support for non-antialiased rendering + API
-	Add CAIRO_FILL_RULE_INVERSE_WINDING and CAIRO_FILL_RULE_INVERSE_EVEN_ODD
-	Add cairo_text_glyphs (see below for details)
-	Add support for programmatic patterns, (ie. arbitrary gradients)
-P	Add cairo_arc_to.
-	Add support for custom caps (see below for details)
-	Add support for getting at image data from image surface
-	Add CAIRO_STATUS_DESTROYED
-	Add cairo_finish
-
-Backwards incompatible (API deletions or changes)
--------------------------------------------------
-PDR C	cairo_surface_finish, cairo_surface_flush
-PDR C	A hidden offset for the xlib backend
-PDR C	Consistent error handling for all objects
-PDRTC	Split cairo_format_t (see below for details)
-P---C	Remove cairo_status_string in favor of cairo_status_to_string
-
-Details on some of the above changes
-------------------------------------
-* cairo_text_glyphs:
-
-	It would function as a sort of bridge between the toy and the
-	real text APIs:
-
-	>       void
-	>       cairo_text_glyphs (cairo_t *cr, const unsigned char *utf8,
-	>                          cairo_glyph_t *glyphs, int *num_glyphs);
-	>
-	> with num_glyphs as an input-output parameter. The behavior of this
-	> function would be such that calling:
-	>
-	>       cairo_text_glyphs (cr, string, glyphs, &num_glyphs);
-	>       cairo_show_glyphs (cr, glyphs, num_glyphs);
-	>
-	> would be equivalent too:
-	>
-	>       cairo_show_text (cr, string);
-	>
-	> as long as the original size of glyphs/num_glyphs was large
-	> enough.
-
-* support for custom caps:
-
-  It would be nice if the user had a mechanism to reliably draw custom
-  caps. One approach here would be to provide the coordinates of the
-  butt cap faces so that the user can append seamless caps to the
-  current path. We may also need to provide the coordinates of the
-  faces of every dash as well.
-
-Changes that do not affect the public API
-=========================================
-* Fix clipping to work for all operators. The equation we have come up
-  with is:
-
-	((src Op dest) In clip) Add (dest Out clip)
-
-* Change stroke code to go through one giant polygon. This will fix
-  problems with stroking self-intersecting paths.
-
-* Fix the intersection problem, (see reference to Hobby's paper
-  mentioned in cairo_traps.c).
-
-* Implement dashing for cairo_curve_to.
-
-* Stroking closed, degenerate paths should still draw caps.  Round
-  caps are easy; square should probably draw an axis-aligned square.
-
-* Should add geometry pruning as appropriate.
-
-* Verification, profiling, optimization.
-
-	centi_unfinished.svg may provide a good test case.
--- a/gfx/cairo/cairo/src/Makefile.in
+++ b/gfx/cairo/cairo/src/Makefile.in
@@ -69,16 +69,17 @@ REQUIRES        = $(PNG_REQUIRES) \
                   libpixman \
                   $(NULL)
 
 CSRCS   = \
         cairo.c \
         cairo-analysis-surface.c \
         cairo-arc.c \
         cairo-array.c \
+	cairo-atomic.c \
         cairo-bentley-ottmann.c \
         cairo-cache.c \
         cairo-clip.c \
         cairo-color.c \
         cairo-debug.c \
         cairo-deflate-stream.c \
         cairo-fixed.c \
 	cairo-font-face.c \
--- a/gfx/cairo/cairo/src/cairo-analysis-surface-private.h
+++ b/gfx/cairo/cairo/src/cairo-analysis-surface-private.h
@@ -41,17 +41,21 @@ cairo_private cairo_surface_t *
 _cairo_analysis_surface_create (cairo_surface_t		*target,
 				int			 width,
 				int			 height);
 
 cairo_private cairo_region_t *
 _cairo_analysis_surface_get_supported (cairo_surface_t *surface);
 
 cairo_private cairo_region_t *
-_cairo_analysis_surface_get_unsupported (cairo_surface_t *unsupported);
+_cairo_analysis_surface_get_unsupported (cairo_surface_t *surface);
+
+cairo_private cairo_bool_t
+_cairo_analysis_surface_has_supported (cairo_surface_t *surface);
 
 cairo_private cairo_bool_t
-_cairo_analysis_surface_has_supported (cairo_surface_t *unsupported);
+_cairo_analysis_surface_has_unsupported (cairo_surface_t *surface);
 
-cairo_private cairo_bool_t
-_cairo_analysis_surface_has_unsupported (cairo_surface_t *unsupported);
+cairo_private void
+_cairo_analysis_surface_get_bounding_box (cairo_surface_t *surface,
+					  cairo_box_t     *bbox);
 
 #endif /* CAIRO_ANALYSIS_SURFACE_H */
--- a/gfx/cairo/cairo/src/cairo-analysis-surface.c
+++ b/gfx/cairo/cairo/src/cairo-analysis-surface.c
@@ -43,22 +43,24 @@
 
 typedef struct {
     cairo_surface_t base;
     int width;
     int height;
 
     cairo_surface_t	*target;
 
+    cairo_bool_t first_op;
     cairo_bool_t has_supported;
     cairo_bool_t has_unsupported;
 
     cairo_region_t supported_region;
     cairo_region_t fallback_region;
     cairo_rectangle_int_t current_clip;
+    cairo_box_t page_bbox;
 
 } cairo_analysis_surface_t;
 
 static cairo_int_status_t
 _cairo_analysis_surface_analyze_meta_surface_pattern (cairo_analysis_surface_t *surface,
 						      cairo_pattern_t	       *pattern)
 {
     cairo_surface_pattern_t *surface_pattern;
@@ -69,36 +71,56 @@ static cairo_int_status_t
     assert (pattern->type == CAIRO_PATTERN_TYPE_SURFACE);
     surface_pattern = (cairo_surface_pattern_t *) pattern;
     assert (_cairo_surface_is_meta (surface_pattern->surface));
 
     meta_surface = surface_pattern->surface;
     analysis = _cairo_analysis_surface_create (surface->target,
 					       surface->width, surface->height);
     if (analysis == NULL)
-	return CAIRO_STATUS_NO_MEMORY;
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     status = _cairo_meta_surface_replay_analyze_meta_pattern (meta_surface, analysis);
     if (status == CAIRO_STATUS_SUCCESS)
 	    status = analysis->status;
     cairo_surface_destroy (analysis);
 
     return status;
 }
 
 static cairo_int_status_t
 _cairo_analysis_surface_add_operation  (cairo_analysis_surface_t *surface,
 					cairo_rectangle_int_t    *rect,
 					cairo_int_status_t        backend_status)
 {
     cairo_int_status_t status;
+    cairo_box_t bbox;
 
     if (rect->width == 0 || rect->height == 0)
 	return CAIRO_STATUS_SUCCESS;
 
+    bbox.p1.x = _cairo_fixed_from_int (rect->x);
+    bbox.p1.y = _cairo_fixed_from_int (rect->y);
+    bbox.p2.x = _cairo_fixed_from_int (rect->x + rect->width);
+    bbox.p2.y = _cairo_fixed_from_int (rect->y + rect->height);
+
+    if (surface->first_op) {
+	surface->first_op = FALSE;
+	surface->page_bbox = bbox;
+    } else {
+	if (bbox.p1.x < surface->page_bbox.p1.x)
+	    surface->page_bbox.p1.x = bbox.p1.x;
+	if (bbox.p1.y < surface->page_bbox.p1.y)
+	    surface->page_bbox.p1.y = bbox.p1.y;
+	if (bbox.p2.x > surface->page_bbox.p2.x)
+	    surface->page_bbox.p2.x = bbox.p2.x;
+	if (bbox.p2.y > surface->page_bbox.p2.y)
+	    surface->page_bbox.p2.y = bbox.p2.y;
+    }
+
     /* If the operation is completely enclosed within the fallback
      * region there is no benefit in emitting a native operation as
      * the fallback image will be painted on top.
      */
     if (_cairo_region_contains_rectangle (&surface->fallback_region, rect) == PIXMAN_REGION_IN)
 	return CAIRO_INT_STATUS_IMAGE_FALLBACK;
 
     if (backend_status == CAIRO_INT_STATUS_FLATTEN_TRANSPARENCY) {
@@ -552,29 +574,30 @@ cairo_surface_t *
      * sure nothing will ever use this value. */
     _cairo_surface_init (&surface->base, &cairo_analysis_surface_backend,
 			 CAIRO_CONTENT_COLOR_ALPHA);
 
     surface->width = width;
     surface->height = height;
 
     surface->target = target;
+    surface->first_op  = TRUE;
     surface->has_supported = FALSE;
     surface->has_unsupported = FALSE;
     _cairo_region_init (&surface->supported_region);
     _cairo_region_init (&surface->fallback_region);
 
     surface->current_clip.x = 0;
     surface->current_clip.y = 0;
     surface->current_clip.width = width;
     surface->current_clip.height = height;
 
     return &surface->base;
 FAIL:
-    _cairo_error (CAIRO_STATUS_NO_MEMORY);
+    _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
     return NULL;
 }
 
 cairo_region_t *
 _cairo_analysis_surface_get_supported (cairo_surface_t *abstract_surface)
 {
     cairo_analysis_surface_t	*surface = (cairo_analysis_surface_t *) abstract_surface;
 
@@ -599,8 +622,17 @@ cairo_bool_t
 
 cairo_bool_t
 _cairo_analysis_surface_has_unsupported (cairo_surface_t *abstract_surface)
 {
     cairo_analysis_surface_t	*surface = (cairo_analysis_surface_t *) abstract_surface;
 
     return surface->has_unsupported;
 }
+
+void
+_cairo_analysis_surface_get_bounding_box (cairo_surface_t *abstract_surface,
+					  cairo_box_t     *bbox)
+{
+    cairo_analysis_surface_t	*surface = (cairo_analysis_surface_t *) abstract_surface;
+
+    *bbox = surface->page_bbox;
+}
--- a/gfx/cairo/cairo/src/cairo-array.c
+++ b/gfx/cairo/cairo/src/cairo-array.c
@@ -128,27 +128,28 @@ cairo_status_t
 	new_size = old_size * 2;
 
     while (new_size < required_size)
 	new_size = new_size * 2;
 
     if (array->elements == NULL) {
 	array->elements = malloc (sizeof (char *));
 	if (array->elements == NULL)
-	    return CAIRO_STATUS_NO_MEMORY;
+	    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+
 	*array->elements = NULL;
     }
 
     array->size = new_size;
-    new_elements = realloc (*array->elements,
-			    array->size * array->element_size);
+    new_elements = _cairo_realloc_ab (*array->elements,
+			              array->size, array->element_size);
 
     if (new_elements == NULL) {
 	array->size = old_size;
-	return CAIRO_STATUS_NO_MEMORY;
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
     }
 
     *array->elements = new_elements;
 
     return CAIRO_STATUS_SUCCESS;
 }
 
 /**
new file mode 100644
--- /dev/null
+++ b/gfx/cairo/cairo/src/cairo-atomic-private.h
@@ -0,0 +1,103 @@
+/* cairo - a vector graphics library with display and print output
+ *
+ * Copyright © 2007 Chris Wilson
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it either under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation
+ * (the "LGPL") or, at your option, under the terms of the Mozilla
+ * Public License Version 1.1 (the "MPL"). If you do not alter this
+ * notice, a recipient may use your version of this file under either
+ * the MPL or the LGPL.
+ *
+ * You should have received a copy of the LGPL along with this library
+ * in the file COPYING-LGPL-2.1; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the MPL along with this library
+ * in the file COPYING-MPL-1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
+ * OF ANY KIND, either express or implied. See the LGPL or the MPL for
+ * the specific language governing rights and limitations.
+ *
+ * The Original Code is the cairo graphics library.
+ *
+ * The Initial Developer of the Original Code is University of Southern
+ * California.
+ *
+ * Contributor(s):
+ *	Chris Wilson <chris@chris-wilson.co.uk>
+ */
+
+#ifndef CAIRO_ATOMIC_PRIVATE_H
+#define CAIRO_ATOMIC_PRIVATE_H
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+CAIRO_BEGIN_DECLS
+
+#define CAIRO_HAS_ATOMIC_OPS 1
+
+#if CAIRO_HAS_INTEL_ATOMIC_PRIMITIVES
+
+typedef int cairo_atomic_int_t;
+
+# define _cairo_atomic_int_inc(x) ((void) __sync_fetch_and_add(x, 1))
+# define _cairo_atomic_int_dec_and_test(x) (__sync_fetch_and_add(x, -1) == 1)
+# define _cairo_atomic_int_cmpxchg(x, oldv, newv) __sync_val_compare_and_swap (x, oldv, newv)
+
+#else
+
+# include "cairo-compiler-private.h"
+
+# undef CAIRO_HAS_ATOMIC_OPS
+
+typedef int cairo_atomic_int_t;
+
+cairo_private void
+_cairo_atomic_int_inc (int *x);
+
+cairo_private cairo_bool_t
+_cairo_atomic_int_dec_and_test (int *x);
+
+cairo_private int
+_cairo_atomic_int_cmpxchg (int *x, int oldv, int newv);
+
+#endif
+
+
+#ifdef CAIRO_ATOMIC_OP_NEEDS_MEMORY_BARRIER
+
+# include "cairo-compiler-private.h"
+
+cairo_private int
+_cairo_atomic_int_get (int *x);
+
+cairo_private void
+_cairo_atomic_int_set (int *x, int value);
+
+#else
+
+# define _cairo_atomic_int_get(x) (*x)
+# define _cairo_atomic_int_set(x, value) ((*x) = value)
+
+#endif
+
+
+#define _cairo_status_set_error(status, err) do { \
+    /* hide compiler warnings about cairo_status_t != int (gcc treats its as \
+     * an unsigned integer instead, and about ignoring the return value. */  \
+    int ret__ = _cairo_atomic_int_cmpxchg ((int *) status, CAIRO_STATUS_SUCCESS, err); \
+    (void) ret__; \
+} while (0)
+
+CAIRO_END_DECLS
+
+#endif
new file mode 100644
--- /dev/null
+++ b/gfx/cairo/cairo/src/cairo-atomic.c
@@ -0,0 +1,96 @@
+/* cairo - a vector graphics library with display and print output
+ *
+ * Copyright © 2007 Chris Wilson
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it either under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation
+ * (the "LGPL") or, at your option, under the terms of the Mozilla
+ * Public License Version 1.1 (the "MPL"). If you do not alter this
+ * notice, a recipient may use your version of this file under either
+ * the MPL or the LGPL.
+ *
+ * You should have received a copy of the LGPL along with this library
+ * in the file COPYING-LGPL-2.1; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the MPL along with this library
+ * in the file COPYING-MPL-1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
+ * OF ANY KIND, either express or implied. See the LGPL or the MPL for
+ * the specific language governing rights and limitations.
+ *
+ * The Original Code is the cairo graphics library.
+ *
+ * Contributor(s):
+ *	Chris Wilson <chris@chris-wilson.co.uk>
+ */
+
+#include "cairoint.h"
+
+#include "cairo-atomic-private.h"
+#include "cairo-mutex-private.h"
+
+#ifndef CAIRO_HAS_ATOMIC_OPS
+void
+_cairo_atomic_int_inc (int *x)
+{
+    CAIRO_MUTEX_LOCK (_cairo_atomic_mutex);
+    *x += 1;
+    CAIRO_MUTEX_UNLOCK (_cairo_atomic_mutex);
+}
+
+cairo_bool_t
+_cairo_atomic_int_dec_and_test (int *x)
+{
+    cairo_bool_t ret;
+
+    CAIRO_MUTEX_LOCK (_cairo_atomic_mutex);
+    ret = --*x == 0;
+    CAIRO_MUTEX_UNLOCK (_cairo_atomic_mutex);
+
+    return ret;
+}
+
+int
+_cairo_atomic_int_cmpxchg (int *x, int oldv, int newv)
+{
+    int ret;
+
+    CAIRO_MUTEX_LOCK (_cairo_atomic_mutex);
+    ret = *x;
+    if (ret == oldv)
+	*x = newv;
+    CAIRO_MUTEX_UNLOCK (_cairo_atomic_mutex);
+
+    return ret;
+}
+
+#endif
+
+#ifdef CAIRO_ATOMIC_OP_NEEDS_MEMORY_BARRIER
+int
+_cairo_atomic_int_get (int *x)
+{
+    int ret;
+
+    CAIRO_MUTEX_LOCK (_cairo_atomic_mutex);
+    ret = *x;
+    CAIRO_MUTEX_UNLOCK (_cairo_atomic_mutex);
+
+    return ret;
+}
+
+void
+_cairo_atomic_int_set (int *x, int value)
+{
+    CAIRO_MUTEX_LOCK (_cairo_atomic_mutex);
+    *x = value;
+    CAIRO_MUTEX_UNLOCK (_cairo_atomic_mutex);
+}
+#endif
--- a/gfx/cairo/cairo/src/cairo-atsui-font.c
+++ b/gfx/cairo/cairo/src/cairo-atsui-font.c
@@ -35,22 +35,16 @@
  */
 
 #include "cairoint.h"
 
 #include "cairo.h"
 #include "cairo-atsui.h"
 #include "cairo-quartz-private.h"
 
-/* 10.5 SDK includes a funky new definition of FloatToFixed, so reset to old-style definition */
-#ifdef FloatToFixed
-#undef FloatToFixed
-#define FloatToFixed(a)     ((Fixed)((float)(a) * fixed1))
-#endif
-
 /*
  * FixedToFloat/FloatToFixed are 10.3+ SDK items - include definitions
  * here so we can use older SDKs.
  */
 #ifndef FixedToFloat
 #define fixed1              ((Fixed) 0x00010000L)
 #define FixedToFloat(a)     ((float)(a) / fixed1)
 #define FloatToFixed(a)     ((Fixed)((float)(a) * fixed1))
@@ -64,16 +58,19 @@
 #else    /* Little endian. */
 /* x86, and will be a 10.4u SDK; ByteOrder32Host will be defined */
 #define CG_BITMAP_BYTE_ORDER_FLAG kCGBitmapByteOrder32Host
 #endif
 
 /* Public in 10.4, present in 10.3.9 */
 CG_EXTERN CGRect CGRectApplyAffineTransform (CGRect, CGAffineTransform);
 
+/* Error code for path callbacks */
+static OSStatus CAIRO_CG_PATH_ERROR = 1001;
+
 typedef struct _cairo_atsui_font_face cairo_atsui_font_face_t;
 typedef struct _cairo_atsui_font cairo_atsui_font_t;
 typedef struct _cairo_atsui_scaled_path cairo_atsui_scaled_path_t;
 
 static cairo_status_t _cairo_atsui_font_create_scaled (cairo_font_face_t *font_face,
 						       ATSUFontID font_id,
 						       ATSUStyle style,
 						       const cairo_matrix_t *font_matrix,
@@ -85,17 +82,16 @@ struct _cairo_atsui_font {
     cairo_scaled_font_t base;
 
     ATSUStyle style;
     ATSUStyle unscaled_style;
     ATSUFontID fontID;
 
     Fixed size;
     CGAffineTransform font_matrix;
-    CGFontRef cgfref;
 };
 
 struct _cairo_atsui_font_face {
   cairo_font_face_t base;
   ATSUFontID font_id;
 };
 
 struct _cairo_atsui_scaled_path {
@@ -110,29 +106,41 @@ static void
 
 static cairo_status_t
 _cairo_atsui_font_face_scaled_font_create (void	*abstract_face,
 					   const cairo_matrix_t	*font_matrix,
 					   const cairo_matrix_t	*ctm,
 					   const cairo_font_options_t *options,
 					   cairo_scaled_font_t **font)
 {
+    cairo_status_t status;
     cairo_atsui_font_face_t *font_face = abstract_face;
     OSStatus err;
     ATSUAttributeTag styleTags[] = { kATSUFontTag };
     ATSUAttributeValuePtr styleValues[] = { &font_face->font_id };
     ByteCount styleSizes[] = {  sizeof(ATSUFontID) };
     ATSUStyle style;
 
     err = ATSUCreateStyle (&style);
+    if (err != noErr)
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+
     err = ATSUSetAttributes(style, ARRAY_LENGTH (styleTags),
                             styleTags, styleSizes, styleValues);
+    if (err != noErr) {
+        ATSUDisposeStyle (style);
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+    }
 
-    return _cairo_atsui_font_create_scaled (&font_face->base, font_face->font_id, style,
+    status = _cairo_atsui_font_create_scaled (&font_face->base, font_face->font_id, style,
 					    font_matrix, ctm, options, font);
+    if (status)
+        ATSUDisposeStyle (style);
+
+    return status;
 }
 
 static const cairo_font_face_backend_t _cairo_atsui_font_face_backend = {
     CAIRO_FONT_TYPE_ATSUI,
     _cairo_atsui_font_face_destroy,
     _cairo_atsui_font_face_scaled_font_create
 };
 
@@ -162,40 +170,45 @@ cairo_atsui_font_face_create_for_atsu_fo
 
   font_face->font_id = font_id;
 
     _cairo_font_face_init (&font_face->base, &_cairo_atsui_font_face_backend);
 
     return &font_face->base;
 }
 
-static ATSUStyle
+static OSStatus
 CreateSizedCopyOfStyle(ATSUStyle inStyle, 
 		       const Fixed *theSize, 
-		       const CGAffineTransform *theTransform)
+                      const CGAffineTransform *theTransform,
+                      ATSUStyle *style)
 {
-    ATSUStyle style;
     OSStatus err;
     const ATSUAttributeTag theFontStyleTags[] = { kATSUSizeTag, 
-						  kATSUFontMatrixTag };
+                                                 kATSUFontMatrixTag };
     const ByteCount theFontStyleSizes[] = { sizeof(Fixed), 
-					    sizeof(CGAffineTransform) };
+                                           sizeof(CGAffineTransform) };
     ATSUAttributeValuePtr theFontStyleValues[] = { (Fixed *)theSize, 
-						   (CGAffineTransform *)theTransform };
+                                                  (CGAffineTransform *)theTransform };
 
-    err = ATSUCreateAndCopyStyle(inStyle, &style);
+    err = ATSUCreateAndCopyStyle (inStyle, style);
+    if (err != noErr)
+	return err;
 
-    err = ATSUSetAttributes(style,
+    err = ATSUSetAttributes(*style,
                             sizeof(theFontStyleTags) /
                             sizeof(ATSUAttributeTag), theFontStyleTags,
                             theFontStyleSizes, theFontStyleValues);
+    if (err != noErr)
+	ATSUDisposeStyle (*style);
 
-    return style;
+    return err;
 }
 
+
 static cairo_status_t
 _cairo_atsui_font_set_metrics (cairo_atsui_font_t *font)
 {
     ATSFontRef atsFont;
     ATSFontMetrics metrics;
     OSStatus err;
 
     atsFont = FMGetATSFontRefFromFont(font->fontID);
@@ -203,29 +216,29 @@ static cairo_status_t
     if (atsFont) {
         err = ATSFontGetHorizontalMetrics(atsFont, kATSOptionFlagsDefault, &metrics);
 
         if (err == noErr) {
 	    cairo_font_extents_t extents;
 
             extents.ascent = metrics.ascent;
             extents.descent = -metrics.descent;
-            extents.height = metrics.capHeight;
+            extents.height = extents.ascent + extents.descent + metrics.leading;
             extents.max_x_advance = metrics.maxAdvanceWidth;
 
             /* The FT backend doesn't handle max_y_advance either, so we'll ignore it for now. */
             extents.max_y_advance = 0.0;
 
 	    _cairo_scaled_font_set_metrics (&font->base, &extents);
 
             return CAIRO_STATUS_SUCCESS;
         }
     }
 
-    return CAIRO_STATUS_NULL_POINTER;
+    return _cairo_error (CAIRO_STATUS_NULL_POINTER);
 }
 
 static cairo_status_t
 _cairo_atsui_font_create_scaled (cairo_font_face_t *font_face,
 				 ATSUFontID font_id,
 				 ATSUStyle style,
 				 const cairo_matrix_t *font_matrix,
 				 const cairo_matrix_t *ctm,
@@ -235,84 +248,96 @@ static cairo_status_t
     cairo_atsui_font_t *font = NULL;
     OSStatus err;
     cairo_status_t status;
     double xscale = 1.0;
     double yscale = 1.0;
 
     font = malloc(sizeof(cairo_atsui_font_t));
     if (font == NULL)
-	return CAIRO_STATUS_NO_MEMORY;
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     status = _cairo_scaled_font_init (&font->base,
 				      font_face, font_matrix, ctm, options,
 				      &cairo_atsui_scaled_font_backend);
     if (status) {
 	free (font);
 	return status;
     }
 
     _cairo_matrix_compute_scale_factors (&font->base.scale, 
 					 &xscale, &yscale, 1);
     font->font_matrix = CGAffineTransformMake (1., 0.,
 					       0., yscale/xscale,
 					       0., 0.);
     font->size = FloatToFixed (xscale);
 
-    font->style = CreateSizedCopyOfStyle (style, &font->size, &font->font_matrix);
+    err = CreateSizedCopyOfStyle (style, &font->size, &font->font_matrix, &font->style);
+    if (err != noErr) {
+	_cairo_error (CAIRO_STATUS_NO_MEMORY);
+	status = CAIRO_STATUS_NO_MEMORY;
+	goto FAIL;
+    }
 
     {
 	Fixed theSize = FloatToFixed(1.0);
 	const ATSUAttributeTag theFontStyleTags[] = { kATSUSizeTag };
 	const ByteCount theFontStyleSizes[] = { sizeof(Fixed) };
 	ATSUAttributeValuePtr theFontStyleValues[] = { &theSize };
 
 	err = ATSUSetAttributes(style,
 				sizeof(theFontStyleTags) /
 				sizeof(ATSUAttributeTag), theFontStyleTags,
 				theFontStyleSizes, theFontStyleValues);
 	if (err != noErr) {
-	    status = CAIRO_STATUS_NO_MEMORY;
+	    status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	    goto FAIL;
 	}
     }
 
     font->unscaled_style = style;
     font->fontID = font_id;
 
     *font_out = &font->base;
 
     status = _cairo_atsui_font_set_metrics (font);
 
-    font->cgfref = NULL;
-
   FAIL:
     if (status) {
-	cairo_scaled_font_destroy (&font->base);
+	if (font) {
+	    if (font->style)
+		ATSUDisposeStyle(font->style);
+	    free (font);
+	}
+
 	return status;
     }
 
     return CAIRO_STATUS_SUCCESS;
 }
 
 static cairo_status_t
 _cairo_atsui_font_create_toy(cairo_toy_font_face_t *toy_face,
 			     const cairo_matrix_t *font_matrix,
 			     const cairo_matrix_t *ctm,
 			     const cairo_font_options_t *options,
 			     cairo_scaled_font_t **font_out)
 {
+    cairo_status_t status;
     ATSUStyle style;
     ATSUFontID fontID;
     OSStatus err;
     Boolean isItalic, isBold;
     const char *family = toy_face->family;
     const char *full_name;
 
     err = ATSUCreateStyle(&style);
+    if (err != noErr) {
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+    }
 
     switch (toy_face->weight) {
     case CAIRO_FONT_WEIGHT_BOLD:
         isBold = true;
         break;
     case CAIRO_FONT_WEIGHT_NORMAL:
     default:
         isBold = false;
@@ -376,49 +401,58 @@ static cairo_status_t
 	if (err != noErr) {
 	    /* Last chance - try Courier. */
 	    full_name = "Courier";
 	    err = ATSUFindFontFromName(full_name, strlen(full_name),
 				       kFontFullName,
 				       kFontNoPlatformCode,
 				       kFontRomanScript,
 				       kFontNoLanguageCode, &fontID);
+	    if (err != noErr) {
+		ATSUDisposeStyle (style);
+		return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+	    }
 	}
     }
 
     {
 	ATSUAttributeTag styleTags[] =
 	    { kATSUQDItalicTag, kATSUQDBoldfaceTag, kATSUFontTag };
 	ATSUAttributeValuePtr styleValues[] = { &isItalic, &isBold, &fontID };
 	ByteCount styleSizes[] =
 	    { sizeof(Boolean), sizeof(Boolean), sizeof(ATSUFontID) };
 
 	err = ATSUSetAttributes(style, ARRAY_LENGTH (styleTags),
 				styleTags, styleSizes, styleValues);
+	if (err != noErr) {
+	    ATSUDisposeStyle (style);
+	    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+	}
     }
 
-    return _cairo_atsui_font_create_scaled (&toy_face->base, fontID, style,
+    status = _cairo_atsui_font_create_scaled (&toy_face->base, fontID, style,
 					    font_matrix, ctm, options, font_out);
+    if (status)
+	ATSUDisposeStyle (style);
+
+    return status;
 }
 
 static void
 _cairo_atsui_font_fini(void *abstract_font)
 {
     cairo_atsui_font_t *font = abstract_font;
 
     if (font == NULL)
         return;
 
     if (font->style)
         ATSUDisposeStyle(font->style);
     if (font->unscaled_style)
         ATSUDisposeStyle(font->unscaled_style);
-    if (font->cgfref)
-	CGFontRelease(font->cgfref);
-
 }
 
 static GlyphID 
 _cairo_atsui_scaled_glyph_index (cairo_scaled_glyph_t *scaled_glyph) {
     unsigned long index = _cairo_scaled_glyph_index (scaled_glyph);
     if (index > 0xffff) 
 	return kATSDeletedGlyphcode;
     return index;
@@ -443,17 +477,17 @@ static cairo_status_t
 
     /* We calculate the advance from the screen metrics. We
      * could probably take this from the glyph path.
      */
     err = ATSUGlyphGetScreenMetrics (scaled_font->style,
 				     1, &theGlyph, 0, false,
 				     false, &metricsH);
     if (err != noErr)
-	return CAIRO_STATUS_NO_MEMORY;
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     /* Scale down to font units.*/
     _cairo_matrix_compute_scale_factors (&scaled_font->base.scale,
 					 &xscale, &yscale, 1);
     xscale = 1.0/xscale;
     yscale = 1.0/yscale;
 
     extents.x_advance = metricsH.deviceAdvance.x * xscale;
@@ -469,82 +503,97 @@ static cairo_status_t
 				     &extents);
     return CAIRO_STATUS_SUCCESS;
 }
 
 static OSStatus
 _move_to (const Float32Point *point,
 	  void *callback_data)
 {
+    cairo_status_t status;
     cairo_atsui_scaled_path_t *scaled_path = callback_data;
     double x = point->x;
     double y = point->y;
     
     cairo_matrix_transform_point (scaled_path->scale, &x, &y);
-    _cairo_path_fixed_close_path (scaled_path->path);
-    _cairo_path_fixed_move_to (scaled_path->path,
+    status = _cairo_path_fixed_close_path (scaled_path->path);
+    if (status)
+	return CAIRO_CG_PATH_ERROR;
+
+    status = _cairo_path_fixed_move_to (scaled_path->path,
 			       _cairo_fixed_from_double (x),
 			       _cairo_fixed_from_double (y));
-
+    if (status)
+	return CAIRO_CG_PATH_ERROR;
+    
     return noErr;
 }
 
 static OSStatus
 _line_to (const Float32Point *point,
 	  void *callback_data)
 {
+    cairo_status_t status;
     cairo_atsui_scaled_path_t *scaled_path = callback_data;
     double x = point->x;
     double y = point->y;
     
     cairo_matrix_transform_point (scaled_path->scale, &x, &y);
 
-    _cairo_path_fixed_line_to (scaled_path->path,
+    status = _cairo_path_fixed_line_to (scaled_path->path,
 			       _cairo_fixed_from_double (x),
 			       _cairo_fixed_from_double (y));
+    if (status)
+	return CAIRO_CG_PATH_ERROR;
 
     return noErr;
 }
 
 static OSStatus
 _curve_to (const Float32Point *point1,
 	   const Float32Point *point2,
 	   const Float32Point *point3,
 	   void *callback_data)
 {
+    cairo_status_t status;
     cairo_atsui_scaled_path_t *scaled_path = callback_data;
     double x1 = point1->x;
     double y1 = point1->y;
     double x2 = point2->x;
     double y2 = point2->y;
     double x3 = point3->x;
     double y3 = point3->y;
     
     cairo_matrix_transform_point (scaled_path->scale, &x1, &y1);
     cairo_matrix_transform_point (scaled_path->scale, &x2, &y2);
     cairo_matrix_transform_point (scaled_path->scale, &x3, &y3);
 
-    _cairo_path_fixed_curve_to (scaled_path->path,
+    status = _cairo_path_fixed_curve_to (scaled_path->path,
 				_cairo_fixed_from_double (x1),
 				_cairo_fixed_from_double (y1),
 				_cairo_fixed_from_double (x2),
 				_cairo_fixed_from_double (y2),
 				_cairo_fixed_from_double (x3),
 				_cairo_fixed_from_double (y3));
+    if (status)
+	return CAIRO_CG_PATH_ERROR;
 
     return noErr;
 }
 
 static OSStatus
 _close_path (void *callback_data)
 
 {
+    cairo_status_t status;
     cairo_atsui_scaled_path_t *scaled_path = callback_data;
 
-    _cairo_path_fixed_close_path (scaled_path->path);
+    status = _cairo_path_fixed_close_path (scaled_path->path);
+    if (status)
+	return CAIRO_CG_PATH_ERROR;
 
     return noErr;
 }
 
 static cairo_status_t
 _cairo_atsui_scaled_font_init_glyph_path (cairo_atsui_font_t *scaled_font,
 					  cairo_scaled_glyph_t *scaled_glyph)
 {
@@ -557,17 +606,17 @@ static cairo_status_t
     cairo_atsui_scaled_path_t scaled_path;
     cairo_matrix_t *font_to_device = &scaled_font->base.scale;
     cairo_matrix_t unscaled_font_to_device;
     double xscale;
     double yscale;
     
     scaled_path.path = _cairo_path_fixed_create ();
     if (!scaled_path.path)
-	return CAIRO_STATUS_NO_MEMORY;
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     if (theGlyph == kATSDeletedGlyphcode) {
 	_cairo_scaled_glyph_set_path (scaled_glyph, &scaled_font->base, 
 				      scaled_path.path);
 
 	return CAIRO_STATUS_SUCCESS;
     }
 
@@ -590,16 +639,20 @@ static cairo_status_t
     }
 
     err = ATSUGlyphGetCubicPaths(scaled_font->style,
 				 theGlyph,
 				 moveProc,
 				 lineProc,
 				 curveProc,
 				 closePathProc, (void *)&scaled_path, &err);
+    if (err != noErr) {
+	_cairo_path_fixed_destroy (scaled_path.path);
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+    }
 
     _cairo_scaled_glyph_set_path (scaled_glyph, &scaled_font->base, 
 				  scaled_path.path);
 
     return CAIRO_STATUS_SUCCESS;
 }
 
 static cairo_status_t
@@ -653,16 +706,20 @@ static cairo_status_t
     /* Horizontal sizes come from the glyph typographic metrics.
      * It is possible that this might result in clipped text
      * in fonts where the typographic bounds don't cover the ink.
      * The width is recalculated, since metricsH.width is rounded.
      */
     err = ATSUGlyphGetScreenMetrics (scaled_font->style,
 				     1, &theGlyph, 0, false,
 				     false, &metricsH);    
+    if (err != noErr) {
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+    }
+
     left = metricsH.sideBearing.x - 1.0;
     width = metricsH.deviceAdvance.x 
 	- metricsH.sideBearing.x 
 	+ metricsH.otherSideBearing.x + 2.0;
 
     /* The xy and yx components are negated because the y-axis
      * is flipped into the cairo system then flipped back, ie:
      * [1  0][xx yx][1  0]
@@ -710,17 +767,17 @@ static cairo_status_t
 						surface->stride,
 						colorSpace,
 						kCGImageAlphaNone);
 	CGColorSpaceRelease (colorSpace);
     }
 
     if (!drawingContext) {
 	cairo_surface_destroy ((cairo_surface_t *)surface);
-	return CAIRO_STATUS_NO_MEMORY;
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
     }
     
     atsFont = FMGetATSFontRefFromFont (scaled_font->fontID);
     cgFont = CGFontCreateWithPlatformFont (&atsFont);
 
     CGContextSetFont (drawingContext, cgFont);
 
     if (base.options.antialias ==  CAIRO_ANTIALIAS_NONE) {
@@ -798,62 +855,81 @@ static cairo_int_status_t
     ItemCount glyphCount;
     int i;
     CGPoint point;
     double xscale, yscale;
     CGAffineTransform device_to_user_scale;
 
     status = _cairo_utf8_to_utf16 ((unsigned char *)utf8, -1, &utf16, &n16);
     if (status)
-	return status;
+	goto BAIL3;
 
     err = ATSUCreateTextLayout(&textLayout);
+    if (err != noErr) {
+	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
+	goto BAIL3;
+    }
 
     err = ATSUSetTextPointerLocation(textLayout, utf16, 0, n16, n16);
+    if (err != noErr) {
+	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
+	goto BAIL2;
+    }
 
     /* Set the style for all of the text */
     err = ATSUSetRunStyle(textLayout,
 			  font->style, kATSUFromTextBeginning, kATSUToTextEnd);
+    if (err != noErr) {
+	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
+	goto BAIL2;
+    }
 
     err = ATSUDirectGetLayoutDataArrayPtrFromTextLayout(textLayout,
 							0,
 							kATSUDirectDataLayoutRecordATSLayoutRecordCurrent,
 							(void *)&layoutRecords,
 							&glyphCount);
+    if (err != noErr) {
+	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
+	goto BAIL2;
+    }
 
     *num_glyphs = glyphCount - 1;
     *glyphs =
 	(cairo_glyph_t *) _cairo_malloc_ab(*num_glyphs, sizeof (cairo_glyph_t));
     if (*glyphs == NULL) {
-	return CAIRO_STATUS_NO_MEMORY;
+	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
+	goto BAIL1;
     }
-
     _cairo_matrix_compute_scale_factors (&font->base.ctm, &xscale, &yscale, 1);
     device_to_user_scale = 
 	CGAffineTransformInvert (CGAffineTransformMake (xscale, 0,
 							0, yscale,
 							0, 0));
     for (i = 0; i < *num_glyphs; i++) {
 	(*glyphs)[i].index = layoutRecords[i].glyphID;
 	/* ATSLayoutRecord.realPos is in device units, convert to user units */
 	point = CGPointMake (FixedToFloat (layoutRecords[i].realPos), 0);
 	point = CGPointApplyAffineTransform (point, device_to_user_scale);
 
 	(*glyphs)[i].x = x + point.x;
 	(*glyphs)[i].y = y;
     }
 
-    free (utf16);
-
+  BAIL1:
+    /* TODO ignored return value. Is there anything we should do? */
     ATSUDirectReleaseLayoutDataArrayPtr(NULL,
 					kATSUDirectDataLayoutRecordATSLayoutRecordCurrent,
 					(void *) &layoutRecords);
+  BAIL2:
     ATSUDisposeTextLayout(textLayout);
+  BAIL3:
+    free (utf16);
 
-    return CAIRO_STATUS_SUCCESS;
+    return status;
 }
 
 ATSUStyle
 _cairo_atsui_scaled_font_get_atsu_style (cairo_scaled_font_t *sfont)
 {
     cairo_atsui_font_t *afont = (cairo_atsui_font_t *) sfont;
 
     return afont->style;
@@ -862,29 +938,16 @@ ATSUStyle
 ATSUFontID
 _cairo_atsui_scaled_font_get_atsu_font_id (cairo_scaled_font_t *sfont)
 {
     cairo_atsui_font_t *afont = (cairo_atsui_font_t *) sfont;
 
     return afont->fontID;
 }
 
-CGFontRef
-_cairo_atsui_scaled_font_get_cg_font_ref (cairo_scaled_font_t *sfont)
-{
-    cairo_atsui_font_t *afont = (cairo_atsui_font_t *) sfont;
-
-    if (!afont->cgfref) {
-	ATSFontRef atsfref = FMGetATSFontRefFromFont (afont->fontID);
-	afont->cgfref = CGFontCreateWithPlatformFont (&atsfref);
-    }
-    return afont->cgfref;
-}
-
-
 static cairo_int_status_t
 _cairo_atsui_load_truetype_table (void	           *abstract_font,
 				  unsigned long     tag,
 				  long              offset,
 				  unsigned char    *buffer,
 				  unsigned long    *length)
 {
     cairo_atsui_font_t *scaled_font = abstract_font;
--- a/gfx/cairo/cairo/src/cairo-base85-stream.c
+++ b/gfx/cairo/cairo/src/cairo-base85-stream.c
@@ -109,18 +109,20 @@ static cairo_status_t
 }
 
 cairo_output_stream_t *
 _cairo_base85_stream_create (cairo_output_stream_t *output)
 {
     cairo_base85_stream_t *stream;
 
     stream = malloc (sizeof (cairo_base85_stream_t));
-    if (stream == NULL)
+    if (stream == NULL) {
+	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return (cairo_output_stream_t *) &_cairo_output_stream_nil;
+    }
 
     _cairo_output_stream_init (&stream->base,
 			       _cairo_base85_stream_write,
 			       _cairo_base85_stream_close);
     stream->output = output;
     stream->pending = 0;
 
     return &stream->base;
--- a/gfx/cairo/cairo/src/cairo-bentley-ottmann.c
+++ b/gfx/cairo/cairo/src/cairo-bentley-ottmann.c
@@ -696,17 +696,17 @@ static void
 static cairo_status_t
 _cairo_bo_event_queue_insert (cairo_bo_event_queue_t *queue,
 			      cairo_bo_event_t	     *event)
 {
     cairo_status_t status = CAIRO_STATUS_SUCCESS;
     /* Don't insert if there's already an equivalent intersection event in the queue. */
     if (_cairo_skip_list_insert (&queue->intersection_queue, event,
 		      event->type == CAIRO_BO_EVENT_TYPE_INTERSECTION) == NULL)
-	status = CAIRO_STATUS_NO_MEMORY;
+	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
     return status;
 }
 
 static void
 _cairo_bo_event_queue_delete (cairo_bo_event_queue_t *queue,
 			      cairo_bo_event_t	     *event)
 {
     if (CAIRO_BO_EVENT_TYPE_INTERSECTION == event->type)
@@ -751,17 +751,17 @@ static cairo_status_t
 	return CAIRO_STATUS_SUCCESS;
 
     /* The skip_elt_t field of a cairo_bo_event_t isn't used for start
      * or stop events, so this allocation is safe.  XXX: make the
      * event type a union so it doesn't always contain the skip
      * elt? */
     events = _cairo_malloc_ab (num_events, sizeof (cairo_bo_event_t) + sizeof(cairo_bo_event_t*));
     if (events == NULL)
-	return CAIRO_STATUS_NO_MEMORY;
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     sorted_event_ptrs = (cairo_bo_event_t **) (events + num_events);
     event_queue->startstop_events = events;
     event_queue->sorted_startstop_event_ptrs = sorted_event_ptrs;
     event_queue->num_startstop_events = num_events;
     event_queue->next_startstop_event_index = 0;
 
     for (i = 0; i < num_edges; i++) {
@@ -854,17 +854,17 @@ static cairo_status_t
 {
     skip_elt_t *next_elt;
     sweep_line_elt_t *sweep_line_elt;
     cairo_bo_edge_t **prev_of_next, **next_of_prev;
 
     sweep_line_elt = _cairo_skip_list_insert (&sweep_line->active_edges, &edge,
 				       1 /* unique inserts*/);
     if (sweep_line_elt == NULL)
-	return CAIRO_STATUS_NO_MEMORY;
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     next_elt = sweep_line_elt->elt.next[0];
     if (next_elt)
 	prev_of_next = & (SKIP_ELT_TO_EDGE (next_elt)->prev);
     else
 	prev_of_next = &sweep_line->tail;
 
     if (*prev_of_next)
@@ -1142,17 +1142,17 @@ static cairo_status_t
 	status = _cairo_bo_edge_end_trap (edge, top, bo_traps);
 	if (status)
 	    return status;
     }
 
     if (edge->next) {
 	trap = edge->deferred_trap = _cairo_freelist_alloc (&bo_traps->freelist);
 	if (!edge->deferred_trap)
-	    return CAIRO_STATUS_NO_MEMORY;
+	    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
 	trap->right = edge->next;
 	trap->top = top;
     }
     return CAIRO_STATUS_SUCCESS;
 }
 
 static void
@@ -1433,17 +1433,17 @@ cairo_status_t
     if (0 == polygon->num_edges)
 	return CAIRO_STATUS_SUCCESS;
 
     if (polygon->num_edges < ARRAY_LENGTH (stack_edges)) {
 	edges = stack_edges;
     } else {
 	edges = _cairo_malloc_ab (polygon->num_edges, sizeof (cairo_bo_edge_t));
 	if (edges == NULL)
-	    return CAIRO_STATUS_NO_MEMORY;
+	    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
     }
 
     /* Figure out the bounding box of the input coordinates and
      * validate that we're not given invalid polygon edges. */
     for (i = 0; i < polygon->num_edges; i++) {
 	update_minmax (&xmin, &xmax, polygon->edges[i].edge.p1.x);
 	update_minmax (&ymin, &ymax, polygon->edges[i].edge.p1.y);
 	update_minmax (&xmin, &xmax, polygon->edges[i].edge.p2.x);
--- a/gfx/cairo/cairo/src/cairo-cache-private.h
+++ b/gfx/cairo/cairo/src/cairo-cache-private.h
@@ -34,16 +34,17 @@
  *      Keith Packard <keithp@keithp.com>
  *	Graydon Hoare <graydon@redhat.com>
  *	Carl Worth <cworth@cworth.org>
  */
 
 #ifndef CAIRO_CACHE_PRIVATE_H
 #define CAIRO_CACHE_PRIVATE_H
 
+#include "cairo-compiler-private.h"
 #include "cairo-types-private.h"
 
 /**
  * cairo_cache_entry_t:
  *
  * A #cairo_cache_entry_t contains both a key and a value for
  * cairo_cache_t. User-derived types for cairo_cache_entry_t must
  * have a cairo_cache_entry_t as their first field. For example:
--- a/gfx/cairo/cairo/src/cairo-cache.c
+++ b/gfx/cairo/cairo/src/cairo-cache.c
@@ -49,17 +49,17 @@ static void
 static cairo_status_t
 _cairo_cache_init (cairo_cache_t		*cache,
 		   cairo_cache_keys_equal_func_t keys_equal,
 		   cairo_destroy_func_t		 entry_destroy,
 		   unsigned long		 max_size)
 {
     cache->hash_table = _cairo_hash_table_create (keys_equal);
     if (cache->hash_table == NULL)
-	return CAIRO_STATUS_NO_MEMORY;
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     cache->entry_destroy = entry_destroy;
 
     cache->max_size = max_size;
     cache->size = 0;
 
     cache->freeze_count = 0;
 
@@ -126,18 +126,20 @@ cairo_cache_t *
 _cairo_cache_create (cairo_cache_keys_equal_func_t keys_equal,
 		     cairo_destroy_func_t	   entry_destroy,
 		     unsigned long		   max_size)
 {
     cairo_status_t status;
     cairo_cache_t *cache;
 
     cache = malloc (sizeof (cairo_cache_t));
-    if (cache == NULL)
+    if (cache == NULL) {
+	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	return NULL;
+    }
 
     status = _cairo_cache_init (cache, keys_equal, entry_destroy, max_size);
     if (status) {
 	free (cache);
 	return NULL;
     }
 
     return cache;
--- a/gfx/cairo/cairo/src/cairo-cff-subset.c
+++ b/gfx/cairo/cairo/src/cairo-cff-subset.c
@@ -380,25 +380,33 @@ cff_index_append (cairo_array_t *index, 
 }
 
 static cairo_status_t
 cff_index_append_copy (cairo_array_t *index,
                        const unsigned char *object,
                        unsigned int length)
 {
     cff_index_element_t element;
+    cairo_status_t status;
 
     element.length = length;
     element.is_copy = TRUE;
     element.data = malloc (element.length);
     if (element.data == NULL)
-        return CAIRO_STATUS_NO_MEMORY;
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+
     memcpy (element.data, object, element.length);
 
-    return _cairo_array_append (index, &element);
+    status = _cairo_array_append (index, &element);
+    if (status) {
+	free (element.data);
+	return status;
+    }
+
+    return CAIRO_STATUS_SUCCESS;
 }
 
 static void
 cff_index_fini (cairo_array_t *index)
 {
     cff_index_element_t *element;
     int i;
 
@@ -414,20 +422,24 @@ static cairo_bool_t
 _cairo_cff_dict_equal (const void *key_a, const void *key_b)
 {
     const cff_dict_operator_t *op_a = key_a;
     const cff_dict_operator_t *op_b = key_b;
 
     return op_a->operator == op_b->operator;
 }
 
-static void
+static cairo_status_t
 cff_dict_init (cairo_hash_table_t **dict)
 {
     *dict = _cairo_hash_table_create (_cairo_cff_dict_equal);
+    if (*dict == NULL)
+	return CAIRO_STATUS_NO_MEMORY;
+
+    return CAIRO_STATUS_SUCCESS;
 }
 
 static void
 _cairo_dict_init_key (cff_dict_operator_t *key, int operator)
 {
     key->base.hash = (unsigned long) operator;
     key->operator = operator;
 }
@@ -435,22 +447,26 @@ static void
 static cff_dict_operator_t *
 cff_dict_create_operator (int            operator,
                           unsigned char *operand,
                           int            operand_length)
 {
     cff_dict_operator_t *op;
 
     op = malloc (sizeof (cff_dict_operator_t));
-    if (op == NULL)
+    if (op == NULL) {
+	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
         return NULL;
+    }
+
     _cairo_dict_init_key (op, operator);
     op->operand = malloc (operand_length);
     if (op->operand == NULL) {
         free (op);
+	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
         return NULL;
     }
     memcpy (op->operand, operand, operand_length);
     op->operand_length = operand_length;
     op->operand_offset = -1;
 
     return op;
 }
@@ -475,17 +491,17 @@ cff_dict_read (cairo_hash_table_t *dict,
                 goto fail;
             p += size;
         } else {
             p = decode_operator (p, &operator);
             op = cff_dict_create_operator (operator,
                                            _cairo_array_index (&operands, 0),
                                            _cairo_array_num_elements (&operands));
             if (op == NULL) {
-                status = CAIRO_STATUS_NO_MEMORY;
+                status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
                 goto fail;
             }
             status = _cairo_hash_table_insert (dict, &op->base);
             if (status)
                 goto fail;
             _cairo_array_truncate (&operands, 0);
         }
     }
@@ -539,26 +555,28 @@ cff_dict_set_operands (cairo_hash_table_
     cairo_status_t status;
 
     _cairo_dict_init_key (&key, operator);
     if (_cairo_hash_table_lookup (dict, &key.base,
                                   (cairo_hash_entry_t **) &op))
     {
         free (op->operand);
         op->operand = malloc (size);
-        if (op->operand == NULL)
-            return CAIRO_STATUS_NO_MEMORY;
+	if (op->operand == NULL)
+	    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+
         memcpy (op->operand, operand, size);
         op->operand_length = size;
     }
     else
     {
         op = cff_dict_create_operator (operator, operand, size);
         if (op == NULL)
-	    return CAIRO_STATUS_NO_MEMORY;
+	    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+
 	status = _cairo_hash_table_insert (dict, &op->base);
 	if (status)
 	    return status;
     }
 
     return CAIRO_STATUS_SUCCESS;
 }
 
@@ -685,46 +703,54 @@ cairo_cff_font_read_name (cairo_cff_font
 
 static cairo_int_status_t
 cairo_cff_font_read_private_dict (cairo_cff_font_t   *font,
                                   cairo_hash_table_t *private_dict,
                                   cairo_array_t      *local_sub_index,
                                   unsigned char      *ptr,
                                   int                 size)
 {
+    cairo_int_status_t status;
     unsigned char buf[10];
     unsigned char *end_buf;
     int offset;
     int i;
     unsigned char *operand;
     unsigned char *p;
 
-    cff_dict_read (private_dict, ptr, size);
+    status = cff_dict_read (private_dict, ptr, size);
+    if (status)
+	return status;
+
     operand = cff_dict_get_operands (private_dict, LOCAL_SUB_OP, &i);
     if (operand) {
         decode_integer (operand, &offset);
         p = ptr + offset;
-        cff_index_read (local_sub_index, &p, font->data_end);
+        status = cff_index_read (local_sub_index, &p, font->data_end);
+	if (status)
+	    return status;
 
         /* Use maximum sized encoding to reserve space for later modification. */
         end_buf = encode_integer_max (buf, 0);
-        cff_dict_set_operands (private_dict, LOCAL_SUB_OP, buf, end_buf - buf);
+        status = cff_dict_set_operands (private_dict, LOCAL_SUB_OP, buf, end_buf - buf);
+	if (status)
+	    return status;
     }
 
     return CAIRO_STATUS_SUCCESS;
 }
 
 static cairo_int_status_t
 cairo_cff_font_read_fdselect (cairo_cff_font_t *font, unsigned char *p)
 {
     int type, num_ranges, first, last, fd, i, j;
 
     font->fdselect = calloc (font->num_glyphs, sizeof (int));
     if (font->fdselect == NULL)
-        return CAIRO_STATUS_NO_MEMORY;
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     type = *p++;
     if (type == 0)
     {
         for (i = 0; i < font->num_glyphs; i++)
             font->fdselect[i] = *p++;
     } else if (type == 3) {
         num_ranges = be16_to_cpu( *((uint16_t *)p) );
@@ -762,55 +788,53 @@ cairo_cff_font_read_cid_fontdict (cairo_
     status = cff_index_read (&index, &ptr, font->data_end);
     if (status)
         goto fail;
 
     font->num_fontdicts = _cairo_array_num_elements (&index);
 
     font->fd_dict = calloc (sizeof (cairo_hash_table_t *), font->num_fontdicts);
     if (font->fd_dict == NULL) {
-        status = CAIRO_STATUS_NO_MEMORY;
+        status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
         goto fail;
     }
 
     font->fd_private_dict = calloc (sizeof (cairo_hash_table_t *), font->num_fontdicts);
     if (font->fd_private_dict == NULL) {
-        status = CAIRO_STATUS_NO_MEMORY;
+        status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
         goto fail;
     }
 
     font->fd_local_sub_index = calloc (sizeof (cairo_array_t), font->num_fontdicts);
     if (font->fd_local_sub_index == NULL) {
-        status = CAIRO_STATUS_NO_MEMORY;
+        status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
         goto fail;
     }
 
     for (i = 0; i < font->num_fontdicts; i++) {
-        cff_dict_init (&font->fd_dict[i]);
-        if (font->fd_dict[i] == NULL) {
-            status = CAIRO_STATUS_NO_MEMORY;
+        status = cff_dict_init (&font->fd_dict[i]);
+        if (status)
             goto fail;
-        }
+
         element = _cairo_array_index (&index, i);
         status = cff_dict_read (font->fd_dict[i], element->data, element->length);
         if (status)
             goto fail;
 
         operand = cff_dict_get_operands (font->fd_dict[i], PRIVATE_OP, &size);
         if (operand == NULL) {
             status = CAIRO_INT_STATUS_UNSUPPORTED;
             goto fail;
         }
         operand = decode_integer (operand, &size);
         decode_integer (operand, &offset);
-        cff_dict_init (&font->fd_private_dict[i]);
-        if (font->fd_private_dict[i] == NULL) {
-            status = CAIRO_STATUS_NO_MEMORY;
+        status = cff_dict_init (&font->fd_private_dict[i]);
+	if (status)
             goto fail;
-        }
+
         cff_index_init (&font->fd_local_sub_index[i]);
         status = cairo_cff_font_read_private_dict (font,
                                                    font->fd_private_dict[i],
                                                    &font->fd_local_sub_index[i],
                                                    font->data + offset,
                                                    size);
         if (status)
             goto fail;
@@ -823,17 +847,17 @@ cairo_cff_font_read_cid_fontdict (cairo_
             goto fail;
     }
 
     return CAIRO_STATUS_SUCCESS;
 
 fail:
     cff_index_fini (&index);
 
-    return status;
+    return _cairo_error (status);
 }
 
 static cairo_int_status_t
 cairo_cff_font_read_top_dict (cairo_cff_font_t *font)
 {
     cairo_array_t index;
     cff_index_element_t *element;
     unsigned char buf[20];
@@ -865,38 +889,59 @@ cairo_cff_font_read_top_dict (cairo_cff_
     status = cff_index_read (&font->charstrings_index, &p, font->data_end);
     if (status)
         goto fail;
     font->num_glyphs = _cairo_array_num_elements (&font->charstrings_index);
 
     if (font->is_cid) {
         operand = cff_dict_get_operands (font->top_dict, FDSELECT_OP, &size);
         decode_integer (operand, &offset);
-        cairo_cff_font_read_fdselect (font, font->data + offset);
+        status = cairo_cff_font_read_fdselect (font, font->data + offset);
+	if (status)
+	    goto fail;
 
         operand = cff_dict_get_operands (font->top_dict, FDARRAY_OP, &size);
         decode_integer (operand, &offset);
-        cairo_cff_font_read_cid_fontdict (font, font->data + offset);
+        status = cairo_cff_font_read_cid_fontdict (font, font->data + offset);
+	if (status)
+	    goto fail;
     } else {
         operand = cff_dict_get_operands (font->top_dict, PRIVATE_OP, &size);
         operand = decode_integer (operand, &size);
         decode_integer (operand, &offset);
-        cairo_cff_font_read_private_dict (font,
-                                          font->private_dict,
-                                          &font->local_sub_index,
-                                          font->data + offset,
-                                          size);
+        status = cairo_cff_font_read_private_dict (font,
+                                                   font->private_dict,
+						   &font->local_sub_index,
+						   font->data + offset,
+						   size);
+	if (status)
+	    goto fail;
     }
 
     /* Use maximum sized encoding to reserve space for later modification. */
     end_buf = encode_integer_max (buf, 0);
-    cff_dict_set_operands (font->top_dict, CHARSTRINGS_OP, buf, end_buf - buf);
-    cff_dict_set_operands (font->top_dict, FDSELECT_OP, buf, end_buf - buf);
-    cff_dict_set_operands (font->top_dict, FDARRAY_OP, buf, end_buf - buf);
-    cff_dict_set_operands (font->top_dict, CHARSET_OP, buf, end_buf - buf);
+    status = cff_dict_set_operands (font->top_dict,
+	                            CHARSTRINGS_OP, buf, end_buf - buf);
+    if (status)
+	goto fail;
+
+    status = cff_dict_set_operands (font->top_dict,
+	                            FDSELECT_OP, buf, end_buf - buf);
+    if (status)
+	goto fail;
+
+    status = cff_dict_set_operands (font->top_dict,
+	                            FDARRAY_OP, buf, end_buf - buf);
+    if (status)
+	goto fail;
+
+    status = cff_dict_set_operands (font->top_dict,
+	                            CHARSET_OP, buf, end_buf - buf);
+    if (status)
+	goto fail;
 
     cff_dict_remove (font->top_dict, ENCODING_OP);
     cff_dict_remove (font->top_dict, PRIVATE_OP);
 
     /* Remove the unique identifier operators as the subsetted font is
      * not the same is the original font. */
     cff_dict_remove (font->top_dict, UNIQUEID_OP);
     cff_dict_remove (font->top_dict, XUID_OP);
@@ -940,42 +985,53 @@ cairo_cff_font_read_font (cairo_cff_font
         status = font_read_funcs[i] (font);
         if (status)
             return status;
     }
 
     return CAIRO_STATUS_SUCCESS;
 }
 
-static void
+static cairo_status_t
 cairo_cff_font_set_ros_strings (cairo_cff_font_t *font)
 {
+    cairo_status_t status;
     unsigned char buf[30];
     unsigned char *p;
     int sid1, sid2;
     const char *registry = "Adobe";
     const char *ordering = "Identity";
 
     sid1 = NUM_STD_STRINGS + _cairo_array_num_elements (&font->strings_subset_index);
-    cff_index_append_copy (&font->strings_subset_index,
-                           (unsigned char *)registry,
-                           strlen(registry));
+    status = cff_index_append_copy (&font->strings_subset_index,
+                                    (unsigned char *)registry,
+                                    strlen(registry));
+    if (status)
+	return status;
 
     sid2 = NUM_STD_STRINGS + _cairo_array_num_elements (&font->strings_subset_index);
-    cff_index_append_copy (&font->strings_subset_index,
-                           (unsigned char *)ordering,
-                           strlen(ordering));
+    status = cff_index_append_copy (&font->strings_subset_index,
+                                    (unsigned char *)ordering,
+				    strlen(ordering));
+    if (status)
+	return status;
 
     p = encode_integer (buf, sid1);
     p = encode_integer (p, sid2);
     p = encode_integer (p, 0);
-    cff_dict_set_operands (font->top_dict, ROS_OP, buf, p - buf);
+    status = cff_dict_set_operands (font->top_dict, ROS_OP, buf, p - buf);
+    if (status)
+	return status;
 
     p = encode_integer (buf, font->scaled_font_subset->num_glyphs);
-    cff_dict_set_operands (font->top_dict, CIDCOUNT_OP, buf, p - buf);
+    status = cff_dict_set_operands (font->top_dict, CIDCOUNT_OP, buf, p - buf);
+    if (status)
+	return status;
+
+    return CAIRO_STATUS_SUCCESS;
 }
 
 static cairo_status_t
 cairo_cff_font_subset_dict_string(cairo_cff_font_t   *font,
                                   cairo_hash_table_t *dict,
                                   int                 operator)
 {
     int size;
@@ -995,17 +1051,19 @@ cairo_cff_font_subset_dict_string(cairo_
 
     element = _cairo_array_index (&font->strings_index, sid - NUM_STD_STRINGS);
     sid = NUM_STD_STRINGS + _cairo_array_num_elements (&font->strings_subset_index);
     status = cff_index_append (&font->strings_subset_index, element->data, element->length);
     if (status)
         return status;
 
     p = encode_integer (buf, sid);
-    cff_dict_set_operands (dict, operator, buf, p - buf);
+    status = cff_dict_set_operands (dict, operator, buf, p - buf);
+    if (status)
+	return status;
 
     return CAIRO_STATUS_SUCCESS;
 }
 
 static const int dict_strings[] = {
     VERSION_OP,
     NOTICE_OP,
     COPYRIGHT_OP,
@@ -1058,29 +1116,29 @@ cairo_cff_font_subset_fontdict (cairo_cf
 {
     unsigned int i;
     int fd;
     int *reverse_map;
 
     font->fdselect_subset = calloc (font->scaled_font_subset->num_glyphs,
                                      sizeof (int));
     if (font->fdselect_subset == NULL)
-        return CAIRO_STATUS_NO_MEMORY;
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     font->fd_subset_map = calloc (font->num_fontdicts, sizeof (int));
     if (font->fd_subset_map == NULL)
-        return CAIRO_STATUS_NO_MEMORY;
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     font->private_dict_offset = calloc (font->num_fontdicts, sizeof (int));
     if (font->private_dict_offset == NULL)
-        return CAIRO_STATUS_NO_MEMORY;
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     reverse_map = calloc (font->num_fontdicts, sizeof (int));
     if (reverse_map == NULL)
-        return CAIRO_STATUS_NO_MEMORY;
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     for (i = 0; i < font->num_fontdicts; i++)
         reverse_map[i] = -1;
 
     font->num_subset_fontdicts = 0;
     for (i = 0; i < font->scaled_font_subset->num_glyphs; i++) {
         fd = font->fdselect[font->scaled_font_subset->glyphs[i]];
         if (reverse_map[fd] < 0) {
@@ -1095,53 +1153,62 @@ cairo_cff_font_subset_fontdict (cairo_cf
     return CAIRO_STATUS_SUCCESS;
 }
 
 static cairo_status_t
 cairo_cff_font_create_cid_fontdict (cairo_cff_font_t *font)
 {
     unsigned char buf[100];
     unsigned char *end_buf;
+    cairo_status_t status;
 
     font->num_fontdicts = 1;
     font->fd_dict = malloc (sizeof (cairo_hash_table_t *));
     if (font->fd_dict == NULL)
-        return CAIRO_STATUS_NO_MEMORY;
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
-    cff_dict_init (&font->fd_dict[0]);
+    if (cff_dict_init (&font->fd_dict[0])) {
+	free (font->fd_dict);
+	font->fd_dict = NULL;
+	font->num_fontdicts = 0;
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+    }
 
     font->fd_subset_map = malloc (sizeof (int));
     if (font->fd_subset_map == NULL)
-        return CAIRO_STATUS_NO_MEMORY;
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     font->private_dict_offset = malloc (sizeof (int));
     if (font->private_dict_offset == NULL)
-        return CAIRO_STATUS_NO_MEMORY;
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     font->fd_subset_map[0] = 0;
     font->num_subset_fontdicts = 1;
 
     /* Set integer operand to max value to use max size encoding to reserve
      * space for any value later */
     end_buf = encode_integer_max (buf, 0);
     end_buf = encode_integer_max (end_buf, 0);
-    cff_dict_set_operands (font->fd_dict[0], PRIVATE_OP, buf, end_buf - buf);
+    status = cff_dict_set_operands (font->fd_dict[0], PRIVATE_OP, buf, end_buf - buf);
+    if (status)
+	return status;
 
     return CAIRO_STATUS_SUCCESS;
 }
 
 static cairo_status_t
 cairo_cff_font_subset_strings (cairo_cff_font_t *font)
 {
     cairo_status_t status;
     unsigned int i;
 
     status = cairo_cff_font_subset_dict_strings (font, font->top_dict);
     if (status)
         return status;
+
     if (font->is_cid) {
         for (i = 0; i < font->num_subset_fontdicts; i++) {
             status = cairo_cff_font_subset_dict_strings (font, font->fd_dict[font->fd_subset_map[i]]);
             if (status)
                 return status;
 
             status = cairo_cff_font_subset_dict_strings (font, font->fd_private_dict[font->fd_subset_map[i]]);
             if (status)
@@ -1154,26 +1221,30 @@ cairo_cff_font_subset_strings (cairo_cff
     return status;
 }
 
 static cairo_status_t
 cairo_cff_font_subset_font (cairo_cff_font_t  *font)
 {
     cairo_status_t status;
 
-    cairo_cff_font_set_ros_strings (font);
+    status = cairo_cff_font_set_ros_strings (font);
+    if (status)
+	return status;
 
     status = cairo_cff_font_subset_charstrings (font);
     if (status)
         return status;
 
     if (font->is_cid)
-        cairo_cff_font_subset_fontdict (font);
+        status = cairo_cff_font_subset_fontdict (font);
     else
-        cairo_cff_font_create_cid_fontdict (font);
+        status = cairo_cff_font_create_cid_fontdict (font);
+    if (status)
+	return status;
 
     status = cairo_cff_font_subset_strings (font);
     if (status)
         return status;
 
     return status;
 }
 
@@ -1206,31 +1277,35 @@ cairo_cff_font_write_header (cairo_cff_f
     return _cairo_array_append_multiple (&font->output,
                                          font->header,
                                          font->header->header_size);
 }
 
 static cairo_status_t
 cairo_cff_font_write_name (cairo_cff_font_t *font)
 {
+    cairo_status_t status = CAIRO_STATUS_SUCCESS;
     cairo_array_t index;
-    cairo_status_t status;
 
     cff_index_init (&index);
+
     status = cff_index_append_copy (&index,
                                     (unsigned char *) font->subset_font_name,
                                     strlen(font->subset_font_name));
     if (status)
-        return status;
+	goto FAIL;
+
     status = cff_index_write (&index, &font->output);
     if (status)
-        return status;
+        goto FAIL;
+
+FAIL:
     cff_index_fini (&index);
 
-    return CAIRO_STATUS_SUCCESS;
+    return status;
 }
 
 static cairo_status_t
 cairo_cff_font_write_top_dict (cairo_cff_font_t *font)
 {
     uint16_t count;
     unsigned char buf[10];
     unsigned char *p;
@@ -1423,16 +1498,17 @@ cairo_cff_font_write_private_dict (cairo
     unsigned char *p;
     cairo_status_t status;
 
     /* Write private dict and update offset and size in top dict */
     font->private_dict_offset[dict_num] = _cairo_array_num_elements (&font->output);
     status = cff_dict_write (private_dict, &font->output);
     if (status)
         return status;
+
     size = _cairo_array_num_elements (&font->output) - font->private_dict_offset[dict_num];
     /* private entry has two operands - size and offset */
     buf_end = encode_integer_max (buf, size);
     buf_end = encode_integer_max (buf_end, font->private_dict_offset[dict_num]);
     offset = cff_dict_get_location (parent_dict, PRIVATE_OP, &size);
     assert (offset > 0);
     p = _cairo_array_index (&font->output, offset);
     memcpy (p, buf, buf_end - buf);
@@ -1471,17 +1547,17 @@ cairo_cff_font_write_local_sub (cairo_cf
     return CAIRO_STATUS_SUCCESS;
 }
 
 
 static cairo_status_t
 cairo_cff_font_write_cid_private_dict_and_local_sub (cairo_cff_font_t  *font)
 {
     unsigned int i;
-    cairo_int_status_t status = CAIRO_STATUS_SUCCESS;
+    cairo_int_status_t status;
 
     if (font->is_cid) {
         for (i = 0; i < font->num_subset_fontdicts; i++) {
             status = cairo_cff_font_write_private_dict (
                             font,
                             i,
                             font->fd_dict[font->fd_subset_map[i]],
                             font->fd_private_dict[font->fd_subset_map[i]]);
@@ -1498,36 +1574,41 @@ cairo_cff_font_write_cid_private_dict_an
             if (status)
                 return status;
         }
     } else {
         status = cairo_cff_font_write_private_dict (font,
                                                     0,
                                                     font->fd_dict[0],
                                                     font->private_dict);
+	if (status)
+	    return status;
+
         status = cairo_cff_font_write_local_sub (font,
                                                  0,
                                                  font->private_dict,
                                                  &font->local_sub_index);
+	if (status)
+	    return status;
     }
 
-    return status;
+    return CAIRO_STATUS_SUCCESS;
 }
 
 typedef cairo_status_t
 (*font_write_t) (cairo_cff_font_t *font);
 
 static const font_write_t font_write_funcs[] = {
     cairo_cff_font_write_header,
     cairo_cff_font_write_name,
     cairo_cff_font_write_top_dict,
     cairo_cff_font_write_strings,
     cairo_cff_font_write_global_subrs,
+    cairo_cff_font_write_charset,
     cairo_cff_font_write_fdselect,
-    cairo_cff_font_write_charset,
     cairo_cff_font_write_charstrings,
     cairo_cff_font_write_cid_fontdict,
     cairo_cff_font_write_cid_private_dict_and_local_sub,
 };
 
 static cairo_status_t
 cairo_cff_font_write_subset (cairo_cff_font_t *font)
 {
@@ -1664,41 +1745,42 @@ static cairo_int_status_t
     size = 0;
     status = backend->load_truetype_table (scaled_font_subset->scaled_font,
                                            TT_TAG_name, 0, NULL, &size);
     if (status)
         return status;
 
     name = malloc (size);
     if (name == NULL)
-        return CAIRO_STATUS_NO_MEMORY;
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+
     status = backend->load_truetype_table (scaled_font_subset->scaled_font,
                                            TT_TAG_name, 0,
                                            (unsigned char *) name, &size);
     if (status)
         goto fail1;
 
     font = malloc (sizeof (cairo_cff_font_t));
     if (font == NULL) {
-        status = CAIRO_STATUS_NO_MEMORY;
+        status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	goto fail1;
     }
 
     font->backend = backend;
     font->scaled_font_subset = scaled_font_subset;
 
     _cairo_array_init (&font->output, sizeof (char));
     status = _cairo_array_grow_by (&font->output, 4096);
     if (status)
 	goto fail2;
 
     font->subset_font_name = strdup (subset_name);
     if (font->subset_font_name == NULL) {
-        status = CAIRO_STATUS_NO_MEMORY;
-	goto fail3;
+        status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
+	goto fail2;
     }
     font->x_min = (int16_t) be16_to_cpu (head.x_min);
     font->y_min = (int16_t) be16_to_cpu (head.y_min);
     font->x_max = (int16_t) be16_to_cpu (head.x_max);
     font->y_max = (int16_t) be16_to_cpu (head.y_max);
     font->ascent = (int16_t) be16_to_cpu (hhea.ascender);
     font->descent = (int16_t) be16_to_cpu (hhea.descender);
 
@@ -1723,53 +1805,63 @@ static cairo_int_status_t
             }
             break;
         }
     }
 
     if (font->font_name == NULL) {
         font->font_name = malloc (30);
         if (font->font_name == NULL) {
-            status = CAIRO_STATUS_NO_MEMORY;
-            goto fail4;
+            status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
+            goto fail3;
         }
         snprintf(font->font_name, 30, "CairoFont-%u-%u",
                  scaled_font_subset->font_id,
                  scaled_font_subset->subset_id);
     }
 
     for (i = 0, j = 0; font->font_name[j]; j++) {
 	if (font->font_name[j] == ' ')
 	    continue;
 	font->font_name[i++] = font->font_name[j];
     }
     font->font_name[i] = '\0';
 
     font->widths = calloc (font->scaled_font_subset->num_glyphs, sizeof (int));
     if (font->widths == NULL) {
-        status = CAIRO_STATUS_NO_MEMORY;
-        goto fail5;
+        status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
+        goto fail4;
     }
-    cairo_cff_font_create_set_widths (font);
+
+    status = cairo_cff_font_create_set_widths (font);
+    if (status)
+	goto fail5;
 
     font->data_length = data_length;
     font->data = malloc (data_length);
     if (font->data == NULL) {
-        status = CAIRO_STATUS_NO_MEMORY;
-        goto fail6;
+        status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
+        goto fail5;
     }
     status = font->backend->load_truetype_table ( font->scaled_font_subset->scaled_font,
                                                   TT_TAG_CFF, 0, font->data,
                                                   &font->data_length);
     if (status)
-        goto fail7;
+        goto fail6;
+
     font->data_end = font->data + font->data_length;
 
-    cff_dict_init (&font->top_dict);
-    cff_dict_init (&font->private_dict);
+    status = cff_dict_init (&font->top_dict);
+    if (status)
+	goto fail6;
+
+    status = cff_dict_init (&font->private_dict);
+    if (status)
+	goto fail7;
+
     cff_index_init (&font->strings_index);
     cff_index_init (&font->charstrings_index);
     cff_index_init (&font->global_sub_index);
     cff_index_init (&font->local_sub_index);
     cff_index_init (&font->charstrings_subset_index);
     cff_index_init (&font->strings_subset_index);
     font->fdselect = NULL;
     font->fd_dict = NULL;
@@ -1780,30 +1872,31 @@ static cairo_int_status_t
     font->private_dict_offset = NULL;
 
     free (name);
     *font_return = font;
 
     return CAIRO_STATUS_SUCCESS;
 
 fail7:
-    free (font->data);
+    _cairo_hash_table_destroy (font->top_dict);
 fail6:
+    free (font->data);
+fail5:
     free (font->widths);
-fail5:
+fail4:
     free (font->font_name);
-fail4:
+fail3:
     free (font->subset_font_name);
-fail3:
+fail2:
     _cairo_array_fini (&font->output);
-fail2:
     free (font);
 fail1:
     free (name);
-    return status;
+    return _cairo_error (status);
 }
 
 static void
 cairo_cff_font_destroy (cairo_cff_font_t *font)
 {
     unsigned int i;
 
     free (font->widths);
@@ -1873,51 +1966,57 @@ cairo_status_t
     if (status)
 	return status;
 
     status = cairo_cff_font_generate (font, &data, &length);
     if (status)
 	goto fail1;
 
     cff_subset->base_font = strdup (font->font_name);
-    if (cff_subset->base_font == NULL)
+    if (cff_subset->base_font == NULL) {
+	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	goto fail1;
+    }
 
     cff_subset->widths = calloc (sizeof (int), font->scaled_font_subset->num_glyphs);
-    if (cff_subset->widths == NULL)
+    if (cff_subset->widths == NULL) {
+	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	goto fail2;
+    }
     for (i = 0; i < font->scaled_font_subset->num_glyphs; i++)
         cff_subset->widths[i] = font->widths[i];
 
     cff_subset->x_min = font->x_min;
     cff_subset->y_min = font->y_min;
     cff_subset->x_max = font->x_max;
     cff_subset->y_max = font->y_max;
     cff_subset->ascent = font->ascent;
     cff_subset->descent = font->descent;
 
     cff_subset->data = malloc (length);
-    if (cff_subset->data == NULL)
+    if (cff_subset->data == NULL) {
+	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	goto fail3;
+    }
 
     memcpy (cff_subset->data, data, length);
     cff_subset->data_length = length;
 
     cairo_cff_font_destroy (font);
 
     return CAIRO_STATUS_SUCCESS;
 
  fail3:
     free (cff_subset->widths);
  fail2:
     free (cff_subset->base_font);
  fail1:
     cairo_cff_font_destroy (font);
 
-    return status;
+    return _cairo_error (status);
 }
 
 void
 _cairo_cff_subset_fini (cairo_cff_subset_t *subset)
 {
     free (subset->base_font);
     free (subset->widths);
     free (subset->data);
@@ -1928,57 +2027,63 @@ static cairo_int_status_t
                                  cairo_cff_font_t           **font_return,
                                  const char                  *subset_name)
 {
     cairo_status_t status;
     cairo_cff_font_t *font;
 
     font = malloc (sizeof (cairo_cff_font_t));
     if (font == NULL)
-        return CAIRO_STATUS_NO_MEMORY;
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     font->backend = NULL;
     font->scaled_font_subset = scaled_font_subset;
 
     _cairo_array_init (&font->output, sizeof (char));
     status = _cairo_array_grow_by (&font->output, 4096);
     if (status)
 	goto fail1;
 
     font->subset_font_name = strdup (subset_name);
     if (font->subset_font_name == NULL) {
-        status = CAIRO_STATUS_NO_MEMORY;
-	goto fail2;
+        status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
+	goto fail1;
     }
 
     font->font_name = strdup (subset_name);
     if (font->subset_font_name == NULL) {
-        status = CAIRO_STATUS_NO_MEMORY;
-	goto fail3;
+        status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
+	goto fail2;
     }
 
     font->x_min = 0;
     font->y_min = 0;
     font->x_max = 0;
     font->y_max = 0;
     font->ascent = 0;
     font->descent = 0;
 
     font->widths = calloc (font->scaled_font_subset->num_glyphs, sizeof (int));
     if (font->widths == NULL) {
-        status = CAIRO_STATUS_NO_MEMORY;
-        goto fail4;
+        status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
+        goto fail3;
     }
 
     font->data_length = 0;
     font->data = NULL;
-    font->data_end = 0;
+    font->data_end = NULL;
 
-    cff_dict_init (&font->top_dict);
-    cff_dict_init (&font->private_dict);
+    status = cff_dict_init (&font->top_dict);
+    if (status)
+	goto fail4;
+
+    status = cff_dict_init (&font->private_dict);
+    if (status)
+	goto fail5;
+
     cff_index_init (&font->strings_index);
     cff_index_init (&font->charstrings_index);
     cff_index_init (&font->global_sub_index);
     cff_index_init (&font->local_sub_index);
     cff_index_init (&font->charstrings_subset_index);
     cff_index_init (&font->strings_subset_index);
     font->fdselect = NULL;
     font->fd_dict = NULL;
@@ -1987,25 +2092,28 @@ static cairo_int_status_t
     font->fdselect_subset = NULL;
     font->fd_subset_map = NULL;
     font->private_dict_offset = NULL;
 
     *font_return = font;
 
     return CAIRO_STATUS_SUCCESS;
 
+fail5:
+    _cairo_hash_table_destroy (font->top_dict);
 fail4:
+    free (font->widths);
+fail3:
     free (font->font_name);
-fail3:
-    free (font->subset_font_name);
 fail2:
-    _cairo_array_fini (&font->output);
+    free (font->subset_font_name);
 fail1:
+    _cairo_array_fini (&font->output);
     free (font);
-    return status;
+    return _cairo_error (status);
 }
 
 static cairo_int_status_t
 cairo_cff_font_fallback_generate (cairo_cff_font_t           *font,
                                   cairo_type2_charstrings_t  *type2_subset,
                                   const char                **data,
                                   unsigned long              *length)
 {
@@ -2024,26 +2132,50 @@ cairo_cff_font_fallback_generate (cairo_
     font->header = &header;
 
     /* Create Top Dict */
     font->is_cid = FALSE;
     end_buf = encode_integer (buf, type2_subset->x_min);
     end_buf = encode_integer (end_buf, type2_subset->y_min);
     end_buf = encode_integer (end_buf, type2_subset->x_max);
     end_buf = encode_integer (end_buf, type2_subset->y_max);
-    cff_dict_set_operands (font->top_dict, FONTBBOX_OP, buf, end_buf - buf);
+    status = cff_dict_set_operands (font->top_dict,
+	                            FONTBBOX_OP, buf, end_buf - buf);
+    if (status)
+	return status;
+
     end_buf = encode_integer_max (buf, 0);
-    cff_dict_set_operands (font->top_dict, CHARSTRINGS_OP, buf, end_buf - buf);
-    cff_dict_set_operands (font->top_dict, FDSELECT_OP, buf, end_buf - buf);
-    cff_dict_set_operands (font->top_dict, FDARRAY_OP, buf, end_buf - buf);
-    cff_dict_set_operands (font->top_dict, CHARSET_OP, buf, end_buf - buf);
-    cairo_cff_font_set_ros_strings (font);
+    status = cff_dict_set_operands (font->top_dict,
+	                            CHARSTRINGS_OP, buf, end_buf - buf);
+    if (status)
+	return status;
+
+    status = cff_dict_set_operands (font->top_dict,
+	                            FDSELECT_OP, buf, end_buf - buf);
+    if (status)
+	return status;
+
+    status = cff_dict_set_operands (font->top_dict,
+	                            FDARRAY_OP, buf, end_buf - buf);
+    if (status)
+	return status;
+
+    status = cff_dict_set_operands (font->top_dict,
+	                            CHARSET_OP, buf, end_buf - buf);
+    if (status)
+	return status;
+
+    status = cairo_cff_font_set_ros_strings (font);
+    if (status)
+	return status;
 
     /* Create CID FD dictionary */
-    cairo_cff_font_create_cid_fontdict (font);
+    status = cairo_cff_font_create_cid_fontdict (font);
+    if (status)
+	return status;
 
     /* Create charstrings */
     for (i = 0; i < font->scaled_font_subset->num_glyphs; i++) {
         charstring = _cairo_array_index(&type2_subset->charstrings, i);
 
         status = cff_index_append (&font->charstrings_subset_index,
                                    _cairo_array_index (charstring, 0),
                                    _cairo_array_num_elements (charstring));
@@ -2079,53 +2211,60 @@ cairo_status_t
 	return status;
 
     status = _cairo_type2_charstrings_init (&type2_subset, font_subset);
     if (status)
 	goto fail1;
 
     status = cairo_cff_font_fallback_generate (font, &type2_subset, &data, &length);
     if (status)
-	goto fail1;
+	goto fail2;
 
     cff_subset->base_font = strdup (font->font_name);
-    if (cff_subset->base_font == NULL)
-	goto fail1;
+    if (cff_subset->base_font == NULL) {
+	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
+	goto fail2;
+    }
 
     cff_subset->widths = calloc (sizeof (int), font->scaled_font_subset->num_glyphs);
-    if (cff_subset->widths == NULL)
-	goto fail2;
+    if (cff_subset->widths == NULL) {
+	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
+	goto fail3;
+    }
     for (i = 0; i < font->scaled_font_subset->num_glyphs; i++)
         cff_subset->widths[i] = type2_subset.widths[i];
 
     cff_subset->x_min = type2_subset.x_min;
     cff_subset->y_min = type2_subset.y_min;
     cff_subset->x_max = type2_subset.x_max;
     cff_subset->y_max = type2_subset.y_max;
     cff_subset->ascent = type2_subset.y_max;
     cff_subset->descent = type2_subset.y_min;
 
-    _cairo_type2_charstrings_fini (&type2_subset);
-
     cff_subset->data = malloc (length);
-    if (cff_subset->data == NULL)
-	goto fail3;
+    if (cff_subset->data == NULL) {
+	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
+	goto fail4;
+    }
 
     memcpy (cff_subset->data, data, length);
     cff_subset->data_length = length;
     cff_subset->data_length = length;
 
+    _cairo_type2_charstrings_fini (&type2_subset);
     cairo_cff_font_destroy (font);
 
     return CAIRO_STATUS_SUCCESS;
 
- fail3:
+ fail4:
     free (cff_subset->widths);
+ fail3:
+    free (cff_subset->base_font);
  fail2:
-    free (cff_subset->base_font);
+    _cairo_type2_charstrings_fini (&type2_subset);
  fail1:
     cairo_cff_font_destroy (font);
 
     return status;
 }
 
 void
 _cairo_cff_fallback_fini (cairo_cff_subset_t *subset)
--- a/gfx/cairo/cairo/src/cairo-clip-private.h
+++ b/gfx/cairo/cairo/src/cairo-clip-private.h
@@ -31,32 +31,35 @@
  *
  * Contributor(s):
  *	Kristian Høgsberg <krh@redhat.com>
  */
 
 #ifndef CAIRO_CLIP_PRIVATE_H
 #define CAIRO_CLIP_PRIVATE_H
 
+#include "cairo-compiler-private.h"
 #include "cairo-path-fixed-private.h"
 
 extern const cairo_private cairo_rectangle_list_t _cairo_rectangles_nil;
 
 struct _cairo_clip_path {
-    unsigned int	ref_count;
-    cairo_path_fixed_t	path;
-    cairo_fill_rule_t	fill_rule;
-    double		tolerance;
-    cairo_antialias_t	antialias;
-    cairo_clip_path_t	*prev;
+    cairo_reference_count_t	 ref_count;
+    cairo_path_fixed_t		 path;
+    cairo_fill_rule_t		 fill_rule;
+    double			 tolerance;
+    cairo_antialias_t		 antialias;
+    cairo_clip_path_t		*prev;
 };
 
 struct _cairo_clip {
     cairo_clip_mode_t mode;
 
+    cairo_bool_t all_clipped;
+
     /*
      * Mask-based clipping for cases where the backend
      * clipping isn't sufficiently able.
      *
      * The rectangle here represents the
      * portion of the destination surface that this
      * clip surface maps to, it does not
      * represent the extents of the clip region or
--- a/gfx/cairo/cairo/src/cairo-clip.c
+++ b/gfx/cairo/cairo/src/cairo-clip.c
@@ -49,16 +49,18 @@ static void
 void
 _cairo_clip_init (cairo_clip_t *clip, cairo_surface_t *target)
 {
     if (target)
 	clip->mode = _cairo_surface_get_clip_mode (target);
     else
 	clip->mode = CAIRO_CLIP_MODE_MASK;
 
+    clip->all_clipped = FALSE;
+
     clip->surface = NULL;
     clip->surface_rect.x = 0;
     clip->surface_rect.y = 0;
     clip->surface_rect.width = 0;
     clip->surface_rect.height = 0;
 
     clip->serial = 0;
 
@@ -68,44 +70,48 @@ void
     clip->path = NULL;
 }
 
 cairo_status_t
 _cairo_clip_init_copy (cairo_clip_t *clip, cairo_clip_t *other)
 {
     clip->mode = other->mode;
 
+    clip->all_clipped = other->all_clipped;
+
     clip->surface = cairo_surface_reference (other->surface);
     clip->surface_rect = other->surface_rect;
 
     clip->serial = other->serial;
 
     _cairo_region_init (&clip->region);
 
     if (other->has_region) {
-	if (_cairo_region_copy (&clip->region, &other->region) !=
-            CAIRO_STATUS_SUCCESS)
-        {
+	cairo_status_t status;
+	status = _cairo_region_copy (&clip->region, &other->region);
+	if (status) {
 	    _cairo_region_fini (&clip->region);
 	    cairo_surface_destroy (clip->surface);
-	    return CAIRO_STATUS_NO_MEMORY;
+	    return status;
 	}
         clip->has_region = TRUE;
     } else {
         clip->has_region = FALSE;
     }
 
     clip->path = _cairo_clip_path_reference (other->path);
-    
+
     return CAIRO_STATUS_SUCCESS;
 }
 
 void
 _cairo_clip_reset (cairo_clip_t *clip)
 {
+    clip->all_clipped = FALSE;
+
     /* destroy any existing clip-region artifacts */
     cairo_surface_destroy (clip->surface);
     clip->surface = NULL;
 
     clip->serial = 0;
 
     if (clip->has_region) {
         /* _cairo_region_fini just releases the resources used but
@@ -116,19 +122,29 @@ void
 
         clip->has_region = FALSE;
     }
 
     _cairo_clip_path_destroy (clip->path);
     clip->path = NULL;
 }
 
+static void
+_cairo_clip_set_all_clipped (cairo_clip_t *clip, cairo_surface_t *target)
+{
+    _cairo_clip_reset (clip);
+
+    clip->all_clipped = TRUE;
+    clip->serial = _cairo_surface_allocate_clip_serial (target);
+}
+
+
 static cairo_status_t
 _cairo_clip_path_intersect_to_rectangle (cairo_clip_path_t       *clip_path,
-   				         cairo_rectangle_int_t   *rectangle)
+				         cairo_rectangle_int_t   *rectangle)
 {
     while (clip_path) {
         cairo_status_t status;
         cairo_traps_t traps;
         cairo_box_t extents;
         cairo_rectangle_int_t extents_rect;
 
         _cairo_traps_init (&traps);
@@ -156,19 +172,24 @@ static cairo_status_t
 
 cairo_status_t
 _cairo_clip_intersect_to_rectangle (cairo_clip_t            *clip,
 				    cairo_rectangle_int_t *rectangle)
 {
     if (!clip)
 	return CAIRO_STATUS_SUCCESS;
 
+    if (clip->all_clipped) {
+	*rectangle = clip->surface_rect;
+	return CAIRO_STATUS_SUCCESS;
+    }
+
     if (clip->path) {
         cairo_status_t status;
-        
+
         status = _cairo_clip_path_intersect_to_rectangle (clip->path,
                                                           rectangle);
         if (status)
             return status;
     }
 
     if (clip->has_region) {
 	cairo_status_t status = CAIRO_STATUS_SUCCESS;
@@ -198,16 +219,28 @@ cairo_status_t
 _cairo_clip_intersect_to_region (cairo_clip_t      *clip,
 				 cairo_region_t *region)
 {
     cairo_status_t status;
 
     if (!clip)
 	return CAIRO_STATUS_SUCCESS;
 
+    if (clip->all_clipped) {
+	cairo_region_t clip_rect;
+
+	_cairo_region_init_rect (&clip_rect, &clip->surface_rect);
+
+	status = _cairo_region_intersect (region, &clip_rect, region);
+
+	_cairo_region_fini (&clip_rect);
+
+	return status;
+    }
+
     if (clip->path) {
 	/* Intersect clip path into region. */
     }
 
     if (clip->has_region) {
 	status = _cairo_region_intersect (region, &clip->region, region);
 	if (status)
 	    return status;
@@ -239,16 +272,19 @@ cairo_status_t
 				cairo_surface_t               *dst,
 				int                           dst_x,
 				int                           dst_y,
 				const cairo_rectangle_int_t *extents)
 {
     cairo_pattern_union_t pattern;
     cairo_status_t status;
 
+    if (clip->all_clipped)
+	return CAIRO_STATUS_SUCCESS;
+
     _cairo_pattern_init_for_surface (&pattern.surface, clip->surface);
 
     status = _cairo_surface_composite (op,
 				       &pattern.base,
 				       NULL,
 				       dst,
 				       extents->x - clip->surface_rect.x,
 				       extents->y - clip->surface_rect.y,
@@ -272,68 +308,75 @@ static cairo_status_t
     cairo_clip_path_t *clip_path;
     cairo_status_t status;
 
     if (clip->mode != CAIRO_CLIP_MODE_PATH)
 	return CAIRO_INT_STATUS_UNSUPPORTED;
 
     clip_path = malloc (sizeof (cairo_clip_path_t));
     if (clip_path == NULL)
-	return CAIRO_STATUS_NO_MEMORY;
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     status = _cairo_path_fixed_init_copy (&clip_path->path, path);
     if (status) {
 	free (clip_path);
 	return status;
     }
 
-    clip_path->ref_count = 1;
+    CAIRO_REFERENCE_COUNT_INIT (&clip_path->ref_count, 1);
     clip_path->fill_rule = fill_rule;
     clip_path->tolerance = tolerance;
     clip_path->antialias = antialias;
     clip_path->prev = clip->path;
     clip->path = clip_path;
 
     return CAIRO_STATUS_SUCCESS;
 }
 
 static cairo_clip_path_t *
 _cairo_clip_path_reference (cairo_clip_path_t *clip_path)
 {
     if (clip_path == NULL)
 	return NULL;
 
-    clip_path->ref_count++;
+    assert (CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&clip_path->ref_count));
+
+    _cairo_reference_count_inc (&clip_path->ref_count);
 
     return clip_path;
 }
 
 static void
 _cairo_clip_path_destroy (cairo_clip_path_t *clip_path)
 {
     if (clip_path == NULL)
 	return;
 
-    clip_path->ref_count--;
-    if (clip_path->ref_count)
+    assert (CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&clip_path->ref_count));
+
+    if (! _cairo_reference_count_dec_and_test (&clip_path->ref_count))
 	return;
 
     _cairo_path_fixed_fini (&clip_path->path);
     _cairo_clip_path_destroy (clip_path->prev);
     free (clip_path);
 }
 
+
 static cairo_int_status_t
 _cairo_clip_intersect_region (cairo_clip_t    *clip,
 			      cairo_traps_t   *traps,
 			      cairo_surface_t *target)
 {
     cairo_region_t region;
     cairo_int_status_t status;
 
+    if (clip->all_clipped)
+	return CAIRO_STATUS_SUCCESS;
+
     if (clip->mode != CAIRO_CLIP_MODE_REGION)
 	return CAIRO_INT_STATUS_UNSUPPORTED;
 
     status = _cairo_traps_extract_region (traps, &region);
 
     if (status)
 	return status;
 
@@ -355,31 +398,37 @@ static cairo_int_status_t
 	    status = _cairo_region_copy (&clip->region, &intersection);
 
         _cairo_region_fini (&intersection);
     }
 
     clip->serial = _cairo_surface_allocate_clip_serial (target);
     _cairo_region_fini (&region);
 
+    if (! _cairo_region_not_empty (&clip->region))
+	_cairo_clip_set_all_clipped (clip, target);
+
     return status;
 }
 
 static cairo_status_t
 _cairo_clip_intersect_mask (cairo_clip_t      *clip,
 			    cairo_traps_t     *traps,
 			    cairo_antialias_t antialias,
 			    cairo_surface_t   *target)
 {
     cairo_pattern_union_t pattern;
     cairo_box_t extents;
     cairo_rectangle_int_t surface_rect, target_rect;
     cairo_surface_t *surface;
     cairo_status_t status;
 
+    if (clip->all_clipped)
+	return CAIRO_STATUS_SUCCESS;
+
     /* Represent the clip as a mask surface.  We create a new surface
      * the size of the intersection of the old mask surface and the
      * extents of the new clip path. */
 
     _cairo_traps_extents (traps, &extents);
     _cairo_box_round_to_rectangle (&extents, &surface_rect);
 
     if (clip->surface != NULL)
@@ -387,30 +436,40 @@ static cairo_status_t
 
     /* Intersect with the target surface rectangle so we don't use
      * more memory and time than we need to. */
 
     status = _cairo_surface_get_extents (target, &target_rect);
     if (!status)
 	_cairo_rectangle_intersect (&surface_rect, &target_rect);
 
+    if (surface_rect.width == 0 || surface_rect.height == 0) {
+	surface = NULL;
+	status = CAIRO_STATUS_SUCCESS;
+	if (clip->surface != NULL)
+	    cairo_surface_destroy (clip->surface);
+	goto DONE;
+    }
+
+    _cairo_pattern_init_solid (&pattern.solid, CAIRO_COLOR_WHITE,
+			       CAIRO_CONTENT_COLOR);
     surface = _cairo_surface_create_similar_solid (target,
 						   CAIRO_CONTENT_ALPHA,
 						   surface_rect.width,
 						   surface_rect.height,
 						   CAIRO_COLOR_WHITE,
-						   NULL);
-    if (surface->status)
-	return CAIRO_STATUS_NO_MEMORY;
+						   &pattern.base);
+    if (surface->status) {
+	_cairo_pattern_fini (&pattern.base);
+	return surface->status;
+    }
 
     /* Render the new clipping path into the new mask surface. */
 
     _cairo_traps_translate (traps, -surface_rect.x, -surface_rect.y);
-    _cairo_pattern_init_solid (&pattern.solid, CAIRO_COLOR_WHITE,
-			       CAIRO_CONTENT_COLOR);
 
     status = _cairo_surface_composite_trapezoids (CAIRO_OPERATOR_IN,
 						  &pattern.base,
 						  surface,
 						  antialias,
 						  0, 0,
 						  0, 0,
 						  surface_rect.width,
@@ -448,34 +507,47 @@ static cairo_status_t
 	if (status) {
 	    cairo_surface_destroy (surface);
 	    return status;
 	}
 
 	cairo_surface_destroy (clip->surface);
     }
 
+ DONE:
     clip->surface = surface;
     clip->surface_rect = surface_rect;
     clip->serial = _cairo_surface_allocate_clip_serial (target);
 
+    if (surface_rect.width == 0 || surface_rect.height == 0)
+	_cairo_clip_set_all_clipped (clip, target);
+
     return status;
 }
 
 cairo_status_t
 _cairo_clip_clip (cairo_clip_t       *clip,
 		  cairo_path_fixed_t *path,
 		  cairo_fill_rule_t   fill_rule,
 		  double              tolerance,
 		  cairo_antialias_t   antialias,
 		  cairo_surface_t    *target)
 {
     cairo_status_t status;
     cairo_traps_t traps;
 
+    if (clip->all_clipped)
+	return CAIRO_STATUS_SUCCESS;
+
+    /* catch the empty clip path */
+    if (! path->has_current_point) {
+	_cairo_clip_set_all_clipped (clip, target);
+	return CAIRO_STATUS_SUCCESS;
+    }
+
     status = _cairo_clip_intersect_path (clip,
 					 path, fill_rule, tolerance,
 					 antialias);
     if (status == CAIRO_STATUS_SUCCESS)
         clip->serial = _cairo_surface_allocate_clip_serial (target);
 
     if (status != CAIRO_INT_STATUS_UNSUPPORTED)
 	return status;
@@ -500,16 +572,19 @@ cairo_status_t
     return status;
 }
 
 void
 _cairo_clip_translate (cairo_clip_t  *clip,
                        cairo_fixed_t  tx,
                        cairo_fixed_t  ty)
 {
+    if (clip->all_clipped)
+	return;
+
     if (clip->has_region) {
         _cairo_region_translate (&clip->region,
                                  _cairo_fixed_integer_part (tx),
                                  _cairo_fixed_integer_part (ty));
     }
 
     if (clip->surface) {
         clip->surface_rect.x += _cairo_fixed_integer_part (tx);
@@ -526,74 +601,85 @@ void
 
         while (clip_path) {
             _cairo_path_fixed_device_transform (&clip_path->path, &matrix);
             clip_path = clip_path->prev;
         }
     }
 }
 
-static void
+static cairo_status_t
 _cairo_clip_path_reapply_clip_path (cairo_clip_t      *clip,
                                     cairo_clip_path_t *clip_path)
 {
-    if (clip_path->prev)
-        _cairo_clip_path_reapply_clip_path (clip, clip_path->prev);
+    cairo_status_t status;
 
-    _cairo_clip_intersect_path (clip,
-                                &clip_path->path,
-                                clip_path->fill_rule,
-                                clip_path->tolerance,
-                                clip_path->antialias);
+    if (clip_path->prev) {
+        status = _cairo_clip_path_reapply_clip_path (clip, clip_path->prev);
+	if (status && status != CAIRO_INT_STATUS_UNSUPPORTED)
+	    return status;
+    }
+
+    return _cairo_clip_intersect_path (clip,
+                                       &clip_path->path,
+				       clip_path->fill_rule,
+				       clip_path->tolerance,
+				       clip_path->antialias);
 }
 
 cairo_status_t
 _cairo_clip_init_deep_copy (cairo_clip_t    *clip,
                             cairo_clip_t    *other,
                             cairo_surface_t *target)
 {
+    cairo_status_t status;
+
     _cairo_clip_init (clip, target);
 
     if (other->mode != clip->mode) {
         /* We should reapply the original clip path in this case, and let
          * whatever the right handling is happen */
     } else {
         if (other->has_region) {
-            if (_cairo_region_copy (&clip->region, &other->region) !=
-		CAIRO_STATUS_SUCCESS)
+            status = _cairo_region_copy (&clip->region, &other->region);
+	    if (status)
 		goto BAIL;
+
 	    clip->has_region = TRUE;
         }
 
         if (other->surface) {
-            if (_cairo_surface_clone_similar (target, other->surface,
-					  other->surface_rect.x,
-					  other->surface_rect.y,
-					  other->surface_rect.width,
-					  other->surface_rect.height,
-					  &clip->surface) !=
-		    CAIRO_STATUS_SUCCESS)
+            status = _cairo_surface_clone_similar (target, other->surface,
+					           other->surface_rect.x,
+						   other->surface_rect.y,
+						   other->surface_rect.width,
+						   other->surface_rect.height,
+						   &clip->surface);
+	    if (status)
 		goto BAIL;
+
             clip->surface_rect = other->surface_rect;
         }
 
         if (other->path) {
-            _cairo_clip_path_reapply_clip_path (clip, other->path);
+            status = _cairo_clip_path_reapply_clip_path (clip, other->path);
+	    if (status && status != CAIRO_INT_STATUS_UNSUPPORTED)
+		goto BAIL;
         }
     }
 
     return CAIRO_STATUS_SUCCESS;
 
 BAIL:
     if (clip->has_region)
 	_cairo_region_fini (&clip->region);
     if (clip->surface)
 	cairo_surface_destroy (clip->surface);
 
-    return CAIRO_STATUS_NO_MEMORY;
+    return status;
 }
 
 const cairo_rectangle_list_t _cairo_rectangles_nil =
   { CAIRO_STATUS_NO_MEMORY, NULL, 0 };
 static const cairo_rectangle_list_t _cairo_rectangles_not_representable =
   { CAIRO_STATUS_CLIP_NOT_REPRESENTABLE, NULL, 0 };
 
 static cairo_bool_t
@@ -618,70 +704,80 @@ static cairo_bool_t
     return is_tight;
 }
 
 cairo_private cairo_rectangle_list_t*
 _cairo_clip_copy_rectangle_list (cairo_clip_t *clip, cairo_gstate_t *gstate)
 {
     cairo_rectangle_list_t *list;
     cairo_rectangle_t *rectangles = NULL;
-    int n_boxes;
+    int n_boxes = 0;
+
+    if (clip->all_clipped)
+	goto DONE;
 
     if (clip->path || clip->surface)
 	return (cairo_rectangle_list_t*) &_cairo_rectangles_not_representable;
 
     if (clip->has_region) {
 	cairo_box_int_t *boxes;
         int i;
 
 	if (_cairo_region_get_boxes (&clip->region, &n_boxes, &boxes) != CAIRO_STATUS_SUCCESS)
 	    return (cairo_rectangle_list_t*) &_cairo_rectangles_nil;
 
-	rectangles = _cairo_malloc_ab (n_boxes, sizeof (cairo_rectangle_t));
-	if (rectangles == NULL) {
-	    _cairo_region_boxes_fini (&clip->region, boxes);
-	    return (cairo_rectangle_list_t*) &_cairo_rectangles_nil;
-	}
+	if (n_boxes) {
+	    rectangles = _cairo_malloc_ab (n_boxes, sizeof (cairo_rectangle_t));
+	    if (rectangles == NULL) {
+		_cairo_region_boxes_fini (&clip->region, boxes);
+		_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
+		return (cairo_rectangle_list_t*) &_cairo_rectangles_nil;
+	    }
 
-        for (i = 0; i < n_boxes; ++i) {
-	    cairo_rectangle_int_t clip_rect = { boxes[i].p1.x, boxes[i].p1.y,
-						boxes[i].p2.x - boxes[i].p1.x,
-						boxes[i].p2.y - boxes[i].p1.y };
+	    for (i = 0; i < n_boxes; ++i) {
+		cairo_rectangle_int_t clip_rect = { boxes[i].p1.x, boxes[i].p1.y,
+						    boxes[i].p2.x - boxes[i].p1.x,
+						    boxes[i].p2.y - boxes[i].p1.y };
 
-            if (!_cairo_clip_int_rect_to_user(gstate, &clip_rect, &rectangles[i])) {
-		_cairo_region_boxes_fini (&clip->region, boxes);
-		free (rectangles);
-		return (cairo_rectangle_list_t*) &_cairo_rectangles_not_representable;
+		if (!_cairo_clip_int_rect_to_user(gstate, &clip_rect, &rectangles[i])) {
+		    _cairo_region_boxes_fini (&clip->region, boxes);
+		    free (rectangles);
+		    return (cairo_rectangle_list_t*) &_cairo_rectangles_not_representable;
+		}
 	    }
-        }
+	}
 
 	_cairo_region_boxes_fini (&clip->region, boxes);
     } else {
         cairo_rectangle_int_t extents;
 
 	n_boxes = 1;
 
 	rectangles = malloc(sizeof (cairo_rectangle_t));
-	if (rectangles == NULL)
+	if (rectangles == NULL) {
+	    _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	    return (cairo_rectangle_list_t*) &_cairo_rectangles_nil;
+	}
 
 	if (_cairo_surface_get_extents (_cairo_gstate_get_target (gstate), &extents) ||
 	    !_cairo_clip_int_rect_to_user(gstate, &extents, rectangles))
 	{
 	    free (rectangles);
 	    return (cairo_rectangle_list_t*) &_cairo_rectangles_not_representable;
 	}
     }
 
+ DONE:
     list = malloc (sizeof (cairo_rectangle_list_t));
     if (list == NULL) {
         free (rectangles);
+	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
         return (cairo_rectangle_list_t*) &_cairo_rectangles_nil;
     }
-    
+
     list->status = CAIRO_STATUS_SUCCESS;
     list->rectangles = rectangles;
     list->num_rectangles = n_boxes;
     return list;
 }
 
 /**
  * cairo_rectangle_list_destroy:
new file mode 100644
--- /dev/null
+++ b/gfx/cairo/cairo/src/cairo-compiler-private.h
@@ -0,0 +1,115 @@
+/* cairo - a vector graphics library with display and print output
+ *
+ * Copyright © 2002 University of Southern California
+ * Copyright © 2005 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it either under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation
+ * (the "LGPL") or, at your option, under the terms of the Mozilla
+ * Public License Version 1.1 (the "MPL"). If you do not alter this
+ * notice, a recipient may use your version of this file under either
+ * the MPL or the LGPL.
+ *
+ * You should have received a copy of the LGPL along with this library
+ * in the file COPYING-LGPL-2.1; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the MPL along with this library
+ * in the file COPYING-MPL-1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
+ * OF ANY KIND, either express or implied. See the LGPL or the MPL for
+ * the specific language governing rights and limitations.
+ *
+ * The Original Code is the cairo graphics library.
+ *
+ * The Initial Developer of the Original Code is University of Southern
+ * California.
+ *
+ * Contributor(s):
+ *	Carl D. Worth <cworth@cworth.org>
+ */
+
+#ifndef CAIRO_COMPILER_PRIVATE_H
+#define CAIRO_COMPILER_PRIVATE_H
+
+CAIRO_BEGIN_DECLS
+
+#if __GNUC__ >= 3 && defined(__ELF__) && !defined(__sun)
+# define slim_hidden_proto(name)		slim_hidden_proto1(name, slim_hidden_int_name(name)) cairo_private
+# define slim_hidden_proto_no_warn(name)	slim_hidden_proto1(name, slim_hidden_int_name(name)) cairo_private_no_warn
+# define slim_hidden_def(name)			slim_hidden_def1(name, slim_hidden_int_name(name))
+# define slim_hidden_int_name(name) INT_##name
+# define slim_hidden_proto1(name, internal)				\
+  extern __typeof (name) name						\
+	__asm__ (slim_hidden_asmname (internal))
+# define slim_hidden_def1(name, internal)				\
+  extern __typeof (name) EXT_##name __asm__(slim_hidden_asmname(name))	\
+	__attribute__((__alias__(slim_hidden_asmname(internal))))
+# define slim_hidden_ulp		slim_hidden_ulp1(__USER_LABEL_PREFIX__)
+# define slim_hidden_ulp1(x)		slim_hidden_ulp2(x)
+# define slim_hidden_ulp2(x)		#x
+# define slim_hidden_asmname(name)	slim_hidden_asmname1(name)
+# define slim_hidden_asmname1(name)	slim_hidden_ulp #name
+#else
+# define slim_hidden_proto(name)		int _cairo_dummy_prototype(void)
+# define slim_hidden_proto_no_warn(name)	int _cairo_dummy_prototype(void)
+# define slim_hidden_def(name)			int _cairo_dummy_prototype(void)
+#endif
+
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
+#define CAIRO_PRINTF_FORMAT(fmt_index, va_index) \
+	__attribute__((__format__(__printf__, fmt_index, va_index)))
+#else
+#define CAIRO_PRINTF_FORMAT(fmt_index, va_index)
+#endif
+
+/* slim_internal.h */
+#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) && defined(__ELF__) && !defined(__sun)
+#define cairo_private_no_warn	__attribute__((__visibility__("hidden")))
+#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
+#define cairo_private_no_warn	__hidden
+#else /* not gcc >= 3.3 and not Sun Studio >= 8 */
+#define cairo_private_no_warn
+#endif
+
+#ifndef WARN_UNUSED_RESULT
+#define WARN_UNUSED_RESULT
+#endif
+/* Add attribute(warn_unused_result) if supported */
+#define cairo_warn	    WARN_UNUSED_RESULT
+#define cairo_private	    cairo_private_no_warn cairo_warn
+
+/* This macro allow us to deprecate a function by providing an alias
+   for the old function name to the new function name. With this
+   macro, binary compatibility is preserved. The macro only works on
+   some platforms --- tough.
+
+   Meanwhile, new definitions in the public header file break the
+   source code so that it will no longer link against the old
+   symbols. Instead it will give a descriptive error message
+   indicating that the old function has been deprecated by the new
+   function.
+*/
+#if __GNUC__ >= 2 && defined(__ELF__)
+# define CAIRO_FUNCTION_ALIAS(old, new)		\
+	extern __typeof (new) old		\
+	__asm__ ("" #old)			\
+	__attribute__((__alias__("" #new)))
+#else
+# define CAIRO_FUNCTION_ALIAS(old, new)
+#endif
+
+#ifndef __GNUC__
+#define __attribute__(x)
+#endif
+
+
+CAIRO_END_DECLS
+
+#endif
--- a/gfx/cairo/cairo/src/cairo-debug.c
+++ b/gfx/cairo/cairo/src/cairo-debug.c
@@ -54,16 +54,20 @@
  * active cairo objects remaining, (ie. the appropriate destroy
  * functions have been called as necessary). If there are active cairo
  * objects, this call is likely to cause a crash, (eg. an assertion
  * failure due to a hash table being destroyed when non-empty).
  **/
 void
 cairo_debug_reset_static_data (void)
 {
+    CAIRO_MUTEX_INITIALIZE ();
+
     _cairo_font_reset_static_data ();
 
 #if CAIRO_HAS_FT_FONT
     _cairo_ft_font_reset_static_data ();
 #endif
 
     _cairo_pattern_reset_static_data ();
+
+    CAIRO_MUTEX_FINALIZE ();
 }
--- a/gfx/cairo/cairo/src/cairo-deflate-stream.c
+++ b/gfx/cairo/cairo/src/cairo-deflate-stream.c
@@ -112,19 +112,27 @@ static cairo_status_t
     return _cairo_output_stream_get_status (stream->output);
 }
 
 cairo_output_stream_t *
 _cairo_deflate_stream_create (cairo_output_stream_t *output)
 {
     cairo_deflate_stream_t *stream;
 
+    if (output->status) {
+	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
+	return (cairo_output_stream_t *) &_cairo_output_stream_nil;
+    }
+
+
     stream = malloc (sizeof (cairo_deflate_stream_t));
-    if (stream == NULL)
+    if (stream == NULL) {
+	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return (cairo_output_stream_t *) &_cairo_output_stream_nil;
+    }
 
     _cairo_output_stream_init (&stream->base,
 			       _cairo_deflate_stream_write,
 			       _cairo_deflate_stream_close);
     stream->output = output;
 
     stream->zlib_stream.zalloc = Z_NULL;
     stream->zlib_stream.zfree  = Z_NULL;
--- a/gfx/cairo/cairo/src/cairo-directfb-surface.c
+++ b/gfx/cairo/cairo/src/cairo-directfb-surface.c
@@ -63,17 +63,17 @@
 #define DFB_COMPOSITE_TRAPEZOIDS 0
 
 /*
  * ShowGlyphs works fine.
  */
 #define DFB_SHOW_GLYPHS 1
 
 
-D_DEBUG_DOMAIN (Cairo_DirectFB, "Cairo/DirectFB", "Cairo DirectFB backend");
+D_DEBUG_DOMAIN (Cairo_DirectFB, "Cairo/DirectFB", "Cairo DirectFB backend")
 
 /*****************************************************************************/
 
 
 typedef struct _cairo_directfb_surface {
     cairo_surface_t      base;
     cairo_format_t       format;
     IDirectFB           *dfb;
@@ -385,17 +385,17 @@ static cairo_status_t
 
    ERROR:
     *image_extra = NULL;
     if( buffer ) {
       buffer->Unlock (buffer);
       if( buffer != surface->dfbsurface) 
         buffer->Release(buffer);
     }
-    return CAIRO_STATUS_NO_MEMORY;
+    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 }
 
 
 
 static cairo_surface_t *
 _cairo_directfb_surface_create_similar (void            *abstract_src,
                                         cairo_content_t  content,
                                         int              width,
@@ -409,18 +409,20 @@ static cairo_surface_t *
                 "%s( src=%p, content=0x%x, width=%d, height=%d).\n",
                 __FUNCTION__, source, content, width, height);
     
     width = (width <= 0) ? 1 : width;
     height = (height<= 0) ? 1 : height;
 
     format = _cairo_format_from_content (content);             
     surface = calloc (1, sizeof(cairo_directfb_surface_t));
-    if (!surface) 
+    if (!surface) {
+	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
         return NULL;
+    }
    
     surface->dfbsurface = _directfb_buffer_surface_create (source->dfb,
                                               cairo_to_directfb_format (format),
                                               width, height);
     assert(surface->dfbsurface);
 
     surface->owner = TRUE;
     if (!surface->dfbsurface) {
@@ -523,22 +525,22 @@ static void
     cairo_directfb_surface_t *surface = abstract_surface;
     IDirectFBSurface *buffer = image_extra; 
     
     D_DEBUG_AT (Cairo_DirectFB, 
                 "%s( surface=%p ).\n", __FUNCTION__, surface);
     buffer->Unlock (buffer);
 
     if (surface->dfbsurface != buffer) {
-        DFBRegion region = { x1:interest_rect->x, y1:interest_rect->y,
-                x2:interest_rect->x+interest_rect->width-1,
-                y2:interest_rect->y+interest_rect->height-1 };
+        DFBRegion region = { .x1 = interest_rect->x, .y1 = interest_rect->y,
+                .x2 = interest_rect->x+interest_rect->width-1,
+                .y2 = interest_rect->y+interest_rect->height-1 };
         surface->dfbsurface->SetClip (surface->dfbsurface, &region);
-        //surface->dfbsurface->SetBlittingFlags (surface->dfbsurface,
-         //               DSBLIT_BLEND_ALPHACHANNEL | DSBLIT_COLORIZE);
+        /* surface->dfbsurface->SetBlittingFlags (surface->dfbsurface,
+                        DSBLIT_BLEND_ALPHACHANNEL | DSBLIT_COLORIZE); */
         surface->dfbsurface->Blit (surface->dfbsurface,buffer,NULL,
                         image_rect->x,image_rect->y);
         buffer->Release (buffer);
     }
     cairo_surface_destroy (&image->base);
 }
 
 static cairo_status_t
@@ -569,24 +571,24 @@ static cairo_status_t
         int                    i, j;
         DFBResult              ret;
         
         clone = (cairo_directfb_surface_t *)
                 _cairo_directfb_surface_create_similar (surface, 
                             _cairo_content_from_format (image_src->format),
                             image_src->width, image_src->height);
         if (!clone)
-            return CAIRO_STATUS_NO_MEMORY;
+            return _cairo_error (CAIRO_STATUS_NO_MEMORY);
             
         ret = clone->dfbsurface->Lock (clone->dfbsurface, 
                                    DSLF_WRITE, (void *)&dst, &pitch);
         if (ret) {
             DirectFBError ("IDirectFBSurface::Lock()", ret);
             cairo_surface_destroy ((cairo_surface_t *)clone);
-            return CAIRO_STATUS_NO_MEMORY;
+            return _cairo_error (CAIRO_STATUS_NO_MEMORY);
         }
 
 	dst += pitch * src_y;
 	src += image_src->stride * src_y;
         
         if (image_src->format == CAIRO_FORMAT_A1) {
             /* A1 -> A8 */
             for (i = 0; i < height; i++) {
@@ -659,17 +661,17 @@ static cairo_int_status_t
             *src_x = *mask_x; *src_y = *mask_y;
             
             mask_pattern = tmp;
             *mask_x = tmp_x; *mask_y = tmp_y;
             
             if (sblend == DSBF_ONE) {
                 flags |= DSBLIT_BLEND_ALPHACHANNEL;                   
                 sblend = DSBF_SRCALPHA;
-                //dblend = DSBF_INVSRCALPHA;
+                /* dblend = DSBF_INVSRCALPHA; */
             }
         }
             
         pattern = (cairo_solid_pattern_t *)mask_pattern;
         color.a = pattern->color.alpha_short >> 8;
         color.r = pattern->color.red_short   >> 8;
         color.g = pattern->color.green_short >> 8;
         color.b = pattern->color.blue_short  >> 8;
@@ -680,17 +682,17 @@ static cairo_int_status_t
         
     if (src_pattern->type == CAIRO_PATTERN_TYPE_SOLID) {
         cairo_solid_pattern_t *pattern = (cairo_solid_pattern_t *)src_pattern;
          
         if (!dst->color) {
             dst->color = _cairo_directfb_surface_create_similar (dst,
                                                 CAIRO_CONTENT_COLOR_ALPHA, 1, 1);
             if (!dst->color)
-                return CAIRO_STATUS_NO_MEMORY;
+                return _cairo_error (CAIRO_STATUS_NO_MEMORY);
         }
         
         src = (cairo_directfb_surface_t *)dst->color;
         src->dfbsurface->SetColor (src->dfbsurface,
                                pattern->color.red_short   >> 8,
                                pattern->color.green_short >> 8,
                                pattern->color.blue_short  >> 8,
                                pattern->color.alpha_short >> 8);
@@ -751,17 +753,17 @@ static cairo_int_status_t
                                    void             *abstract_dst,
                                    int  src_x,  int  src_y,
                                    int  mask_x, int  mask_y,
                                    int  dst_x,  int  dst_y,
                                    unsigned int      width,
                                    unsigned int      height)
 {
     cairo_directfb_surface_t   *dst = abstract_dst;
-    cairo_directfb_surface_t   *src;
+    cairo_directfb_surface_t   *src = NULL; /* hide compiler warning */
     cairo_surface_attributes_t  src_attr;
     cairo_matrix_t             *m;
     cairo_status_t              ret;
     
     D_DEBUG_AT (Cairo_DirectFB,
                 "%s( op=%d, src_pattern=%p, mask_pattern=%p, dst=%p,"
                    " src_x=%d, src_y=%d, mask_x=%d, mask_y=%d, dst_x=%d,"
                    " dst_y=%d, width=%u, height=%u ).\n",
@@ -1102,29 +1104,31 @@ static cairo_int_status_t
     
     D_DEBUG_AT (Cairo_DirectFB, 
                 "%s( surface=%p, region=%p ).\n",
                 __FUNCTION__, surface, region);
     
     if (region) {
         cairo_box_int_t *boxes;
         int n_boxes, i;
+	cairo_status_t status;
 
-        if (_cairo_region_get_boxes (region, &n_boxes, &boxes) != CAIRO_STATUS_SUCCESS)
-            return CAIRO_STATUS_NO_MEMORY;
+        status = _cairo_region_get_boxes (region, &n_boxes, &boxes);
+	if (status)
+	    return status;
 
         if (surface->n_clips != n_boxes) {
             if( surface->clips )
                 free (surface->clips);
             
             surface->clips = _cairo_malloc_ab (n_boxes, sizeof(DFBRegion));
             if (!surface->clips) {
                 _cairo_region_boxes_fini (region, boxes);
                 surface->n_clips = 0;
-                return CAIRO_STATUS_NO_MEMORY;
+		return _cairo_error (CAIRO_STATUS_NO_MEMORY);
             }
         
             surface->n_clips = n_boxes;
         }
         
         for (i = 0; i < n_boxes; i++) {
             surface->clips[i].x1 = boxes[i].p1.x;
             surface->clips[i].y1 = boxes[i].p1.y;
@@ -1176,17 +1180,17 @@ static cairo_status_t
     cairo_directfb_surface_t *surface = abstract_surface;
     
     D_DEBUG_AT (Cairo_DirectFB,
                 "%s( surface=%p, x=%d, y=%d, width=%d, height=%d ).\n",
                 __FUNCTION__, surface, x, y, width, height);
     if( !surface->dirty_region ) 
             surface->dirty_region = malloc(sizeof(DFBRegion));
     if (!dirty_region)
-            return CAIRO_STATUS_NO_MEMORY;
+            return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 #endif 
     return CAIRO_STATUS_SUCCESS;
 }
 
 static cairo_status_t 
 _cairo_directfb_surface_flush (void *abstract_surface)
 {
 #if 0
@@ -1206,26 +1210,29 @@ static cairo_status_t
 
 #if DFB_SHOW_GLYPHS
 static cairo_directfb_font_cache_t*
 _directfb_allocate_font_cache (IDirectFB *dfb, int width, int height)
 {
     cairo_directfb_font_cache_t *cache;
 
     cache = calloc (1, sizeof(cairo_directfb_font_cache_t));
-    if (!cache)
-        return NULL;
+    if (!cache) {
+	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
+	return NULL;
+    }
 
     cache->dfbsurface = _directfb_buffer_surface_create( dfb, DSPF_A8, width, height);
     if (!cache->dfbsurface) {
         free (cache);
+	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
         return NULL;
     }
 
-    //dfb->AddRef (dfb);
+    /* dfb->AddRef (dfb); */
     cache->dfb = dfb;
 
     cache->width  = width;
     cache->height = height;
 
     return cache;
 }
 
@@ -1309,17 +1316,17 @@ static cairo_status_t
  
             x += img->width;
             h  = MAX (h, img->height);
             w  = MAX (w, x);
             
             /* Remember glyph location */ 
             rect = malloc (sizeof(DFBRectangle));
             if (!rect)
-                return CAIRO_STATUS_NO_MEMORY;
+		return _cairo_error (CAIRO_STATUS_NO_MEMORY);
             *rect = rects[n];
             
             scaled_glyph->surface_private = rect;
             chars[num_chars++] = scaled_glyph;
             
             /*D_DEBUG_AT (Cairo_DirectFB, 
                         "Glyph %lu will be loaded at (%d,%d).\n",
                         glyphs[i].index, rects[n].x, rects[n].y);*/
@@ -1347,44 +1354,44 @@ static cairo_status_t
             w = MAX (w, cache->width);
             h = MAX (h, cache->height);
             
             D_DEBUG_AT (Cairo_DirectFB,
                         "Reallocating font cache (%dx%d).\n", w, h);
             
             new_cache = _directfb_allocate_font_cache (surface->dfb, w, h);
             if (!new_cache)
-                return CAIRO_STATUS_NO_MEMORY;
+		return _cairo_error (CAIRO_STATUS_NO_MEMORY);
             
             new_cache->dfbsurface->Blit (new_cache->dfbsurface,
                                      cache->dfbsurface, NULL, 0, 0);
             
             _directfb_destroy_font_cache (cache);
             scaled_font->surface_private = cache = new_cache;
         }
     }
     else {
         D_DEBUG_AT (Cairo_DirectFB,
                     "Allocating font cache (%dx%d).\n", w, h);
         
         cache = _directfb_allocate_font_cache (surface->dfb, w, h);
-        if (!cache)
-            return CAIRO_STATUS_NO_MEMORY;
+	if (!cache)
+	    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
             
         scaled_font->surface_backend = &cairo_directfb_surface_backend;
         scaled_font->surface_private = cache;
     }
     
     if (num_chars) {
         unsigned char *data;
         int            pitch;
     
         if (cache->dfbsurface->Lock (cache->dfbsurface, 
                                  DSLF_WRITE, (void *)&data, &pitch))
-            return CAIRO_STATUS_NO_MEMORY;
+            return _cairo_error (CAIRO_STATUS_NO_MEMORY);
     
         for (i = 0; i < num_chars; i++) {
             cairo_image_surface_t *img  = chars[i]->surface;
             DFBRectangle          *rect = chars[i]->surface_private;
             unsigned char         *dst  = data + rect->y*pitch + rect->x;
             unsigned char         *src  = img->data;
             
             if (img->format == CAIRO_FORMAT_A1) {
@@ -1624,18 +1631,20 @@ cairo_directfb_surface_create (IDirectFB
    DFBSurfacePixelFormat format;
     cairo_directfb_surface_t *surface;
    
     assert(dfb);
     assert(dfb);
     cairo_directfb_surface_backend_init (dfb);
         
     surface = calloc (1, sizeof(cairo_directfb_surface_t));
-    if (!surface)
-        return NULL;
+    if (!surface) {
+	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
+	return NULL;
+    }
         
     dfbsurface->GetPixelFormat (dfbsurface, &format);
     _cairo_surface_init (&surface->base, &cairo_directfb_surface_backend,
                 _directfb_format_to_content(format));
     surface->owner = FALSE;
     surface->dfb = dfb;
     surface->dfbsurface = dfbsurface;
     dfbsurface->GetSize (dfbsurface,&surface->width, &surface->height);   
--- a/gfx/cairo/cairo/src/cairo-features.h.in
+++ b/gfx/cairo/cairo/src/cairo-features.h.in
@@ -48,19 +48,19 @@
 #endif
 
 #ifndef cairo_public
 # define cairo_public
 #endif
 
 #define CAIRO_VERSION_MAJOR 1
 #define CAIRO_VERSION_MINOR 5
-#define CAIRO_VERSION_MICRO 1
+#define CAIRO_VERSION_MICRO 3
 
-#define CAIRO_VERSION_STRING "1.5.1"
+#define CAIRO_VERSION_STRING "1.5.3"
 
 @PS_SURFACE_FEATURE@
 
 @PDF_SURFACE_FEATURE@
 
 @SVG_SURFACE_FEATURE@
 
 @XLIB_SURFACE_FEATURE@
--- a/gfx/cairo/cairo/src/cairo-fixed-private.h
+++ b/gfx/cairo/cairo/src/cairo-fixed-private.h
@@ -50,17 +50,20 @@ typedef cairo_int128_t	cairo_fixed_64_64
 typedef cairo_int128_t	cairo_fixed_96_32_t;
 
 /* Eventually, we should allow changing this, but I think
  * there are some assumptions in the tesselator about the
  * size of a fixed type.  For now, it must be 32.
  */
 #define CAIRO_FIXED_BITS	32
 
-/* The number of fractional bits. */
+/* The number of fractional bits.  Changing this involves
+ * making sure that you compute a double-to-fixed magic number.
+ * (see below).
+ */
 #define CAIRO_FIXED_FRAC_BITS	8
 
 /* A signed type CAIRO_FIXED_BITS in size; the main fixed point type */
 typedef int32_t cairo_fixed_t;
 
 /* An unsigned type of the same size as cairo_fixed_t */
 typedef uint32_t cairo_fixed_unsigned_t;
 
@@ -201,22 +204,23 @@ static inline int
  * 16.16 fixed point types.
  */
 static inline cairo_fixed_16_16_t
 _cairo_fixed_to_16_16 (cairo_fixed_t f)
 {
 #if (CAIRO_FIXED_FRAC_BITS == 16) && (CAIRO_FIXED_BITS == 32)
     return f;
 #elif CAIRO_FIXED_FRAC_BITS > 16
+    /* We're just dropping the low bits, so we won't ever got over/underflow here */
     return f >> (CAIRO_FIXED_FRAC_BITS - 16);
 #else
     cairo_fixed_16_16_t x;
 
-    /* Clamp to INT16 so that we don't get odd overflow or underflow by
-     * just shifting.
+    /* Handle overflow/underflow by claping to the lowest/highest
+     * value representable as 16.16
      */
     if ((f >> CAIRO_FIXED_FRAC_BITS) < INT16_MIN) {
 	x = INT32_MIN;
     } else if ((f >> CAIRO_FIXED_FRAC_BITS) > INT16_MAX) {
 	x = INT32_MAX;
     } else {
 	x = f << (16 - CAIRO_FIXED_FRAC_BITS);
     }
--- a/gfx/cairo/cairo/src/cairo-font-face.c
+++ b/gfx/cairo/cairo/src/cairo-font-face.c
@@ -45,29 +45,41 @@
  */
 static const cairo_font_face_backend_t _cairo_toy_font_face_backend;
 
 /* cairo_font_face_t */
 
 const cairo_font_face_t _cairo_font_face_nil = {
     { 0 },			/* hash_entry */
     CAIRO_STATUS_NO_MEMORY,	/* status */
-    CAIRO_REF_COUNT_INVALID,	/* ref_count */
+    CAIRO_REFERENCE_COUNT_INVALID,	/* ref_count */
     { 0, 0, 0, NULL },		/* user_data */
     &_cairo_toy_font_face_backend
 };
 
+cairo_status_t
+_cairo_font_face_set_error (cairo_font_face_t *font_face,
+	                    cairo_status_t     status)
+{
+    if (status == CAIRO_STATUS_SUCCESS)
+	return status;
+
+    _cairo_status_set_error (&font_face->status, status);
+
+    return _cairo_error (status);
+}
+
 void
 _cairo_font_face_init (cairo_font_face_t               *font_face,
 		       const cairo_font_face_backend_t *backend)
 {
     CAIRO_MUTEX_INITIALIZE ();
 
     font_face->status = CAIRO_STATUS_SUCCESS;
-    font_face->ref_count = 1;
+    CAIRO_REFERENCE_COUNT_INIT (&font_face->ref_count, 1);
     font_face->backend = backend;
 
     _cairo_user_data_array_init (&font_face->user_data);
 }
 
 /**
  * cairo_font_face_reference:
  * @font_face: a #cairo_font_face_t, (may be %NULL in which case this
@@ -80,65 +92,57 @@ void
  * The number of references to a #cairo_font_face_t can be get using
  * cairo_font_face_get_reference_count().
  *
  * Return value: the referenced #cairo_font_face_t.
  **/
 cairo_font_face_t *
 cairo_font_face_reference (cairo_font_face_t *font_face)
 {
-    if (font_face == NULL || font_face->ref_count == CAIRO_REF_COUNT_INVALID)
+    if (font_face == NULL ||
+	    CAIRO_REFERENCE_COUNT_IS_INVALID (&font_face->ref_count))
 	return font_face;
 
-    CAIRO_MUTEX_LOCK (_cairo_font_face_mutex);
-
-    /* We would normally assert (font_face->ref_count >0) here but we
+    /* We would normally assert that we have a reference here but we
      * can't get away with that due to the zombie case as documented
      * in _cairo_ft_font_face_destroy. */
 
-    font_face->ref_count++;
-
-    CAIRO_MUTEX_UNLOCK (_cairo_font_face_mutex);
+    _cairo_reference_count_inc (&font_face->ref_count);
 
     return font_face;
 }
 slim_hidden_def (cairo_font_face_reference);
 
 /**
  * cairo_font_face_destroy:
  * @font_face: a #cairo_font_face_t
  *
  * Decreases the reference count on @font_face by one. If the result
  * is zero, then @font_face and all associated resources are freed.
  * See cairo_font_face_reference().
  **/
 void
 cairo_font_face_destroy (cairo_font_face_t *font_face)
 {
-    if (font_face == NULL || font_face->ref_count == CAIRO_REF_COUNT_INVALID)
+    if (font_face == NULL ||
+	    CAIRO_REFERENCE_COUNT_IS_INVALID (&font_face->ref_count))
 	return;
 
-    CAIRO_MUTEX_LOCK (_cairo_font_face_mutex);
-
-    assert (font_face->ref_count > 0);
+    assert (CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&font_face->ref_count));
 
-    if (--(font_face->ref_count) > 0) {
-        CAIRO_MUTEX_UNLOCK (_cairo_font_face_mutex);
+    if (! _cairo_reference_count_dec_and_test (&font_face->ref_count))
 	return;
-    }
-
-    CAIRO_MUTEX_UNLOCK (_cairo_font_face_mutex);
 
     font_face->backend->destroy (font_face);
 
     /* We allow resurrection to deal with some memory management for the
      * FreeType backend where cairo_ft_font_face_t and cairo_ft_unscaled_font_t
      * need to effectively mutually reference each other
      */
-    if (font_face->ref_count > 0)
+    if (CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&font_face->ref_count))
 	return;
 
     _cairo_user_data_array_fini (&font_face->user_data);
 
     free (font_face);
 }
 slim_hidden_def (cairo_font_face_destroy);
 
@@ -168,20 +172,21 @@ cairo_font_face_get_type (cairo_font_fac
  * Return value: the current reference count of @font_face.  If the
  * object is a nil object, 0 will be returned.
  *
  * Since: 1.4
  **/
 unsigned int
 cairo_font_face_get_reference_count (cairo_font_face_t *font_face)
 {
-    if (font_face == NULL || font_face->ref_count == CAIRO_REF_COUNT_INVALID)
+    if (font_face == NULL ||
+	    CAIRO_REFERENCE_COUNT_IS_INVALID (&font_face->ref_count))
 	return 0;
 
-    return font_face->ref_count;
+    return CAIRO_REFERENCE_COUNT_GET_VALUE (&font_face->ref_count);
 }
 
 /**
  * cairo_font_face_status:
  * @font_face: a #cairo_font_face_t
  *
  * Checks whether an error has previously occurred for this
  * font face
@@ -232,18 +237,18 @@ cairo_font_face_get_user_data (cairo_fon
  * slot could not be allocated for the user data.
  **/
 cairo_status_t
 cairo_font_face_set_user_data (cairo_font_face_t	   *font_face,
 			       const cairo_user_data_key_t *key,
 			       void			   *user_data,
 			       cairo_destroy_func_t	    destroy)
 {
-    if (font_face->ref_count == CAIRO_REF_COUNT_INVALID)
-	return CAIRO_STATUS_NO_MEMORY;
+    if (CAIRO_REFERENCE_COUNT_IS_INVALID (&font_face->ref_count))
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     return _cairo_user_data_array_set_data (&font_face->user_data,
 					    key, user_data, destroy);
 }
 
 static const cairo_font_face_backend_t _cairo_toy_font_face_backend;
 
 static int
@@ -310,30 +315,31 @@ static void
     key->slant = slant;
     key->weight = weight;
 
     /* 1607 and 1451 are just a couple of arbitrary primes. */
     hash = _cairo_hash_string (family);
     hash += ((unsigned long) slant) * 1607;
     hash += ((unsigned long) weight) * 1451;
 
+    assert (hash != 0);
     key->base.hash_entry.hash = hash;
 }
 
 static cairo_status_t
 _cairo_toy_font_face_init (cairo_toy_font_face_t *font_face,
 			   const char	         *family,
 			   cairo_font_slant_t	  slant,
 			   cairo_font_weight_t	  weight)
 {
     char *family_copy;
 
     family_copy = strdup (family);
     if (family_copy == NULL)
-	return CAIRO_STATUS_NO_MEMORY;
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     _cairo_toy_font_face_init_key (font_face, family_copy,
 				      slant, weight);
     font_face->owns_family = TRUE;
 
     _cairo_font_face_init (&font_face->base, &_cairo_toy_font_face_backend);
 
     return CAIRO_STATUS_SUCCESS;
@@ -388,27 +394,35 @@ cairo_font_face_t *
 
     _cairo_toy_font_face_init_key (&key, family, slant, weight);
 
     /* Return existing font_face if it exists in the hash table. */
     if (_cairo_hash_table_lookup (hash_table,
 				  &key.base.hash_entry,
 				  (cairo_hash_entry_t **) &font_face))
     {
-	/* We increment the reference count here manually to avoid
-	   double-locking. */
-	font_face->base.ref_count++;
-	_cairo_toy_font_face_hash_table_unlock ();
-	return &font_face->base;
+	if (! font_face->base.status)  {
+	    /* We increment the reference count here manually to avoid
+	       double-locking. */
+	    _cairo_reference_count_inc (&font_face->base.ref_count);
+	    _cairo_toy_font_face_hash_table_unlock ();
+	    return &font_face->base;
+	}
+
+	/* remove the bad font from the hash table */
+	_cairo_hash_table_remove (hash_table, &key.base.hash_entry);
+	font_face->base.hash_entry.hash = 0;
     }
 
     /* Otherwise create it and insert into hash table. */
     font_face = malloc (sizeof (cairo_toy_font_face_t));
-    if (font_face == NULL)
+    if (font_face == NULL) {
+	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	goto UNWIND_HASH_TABLE_LOCK;
+    }
 
     status = _cairo_toy_font_face_init (font_face, family, slant, weight);
     if (status)
 	goto UNWIND_FONT_FACE_MALLOC;
 
     status = _cairo_hash_table_insert (hash_table, &font_face->base.hash_entry);
     if (status)
 	goto UNWIND_FONT_FACE_INIT;
@@ -427,24 +441,26 @@ cairo_font_face_t *
 }
 
 static void
 _cairo_toy_font_face_destroy (void *abstract_face)
 {
     cairo_toy_font_face_t *font_face = abstract_face;
     cairo_hash_table_t *hash_table;
 
-    if (font_face == NULL)
+    if (font_face == NULL ||
+	    CAIRO_REFERENCE_COUNT_IS_INVALID (&font_face->base.ref_count))
 	return;
 
     hash_table = _cairo_toy_font_face_hash_table_lock ();
     /* All created objects must have been mapped in the hash table. */
     assert (hash_table != NULL);
 
-    _cairo_hash_table_remove (hash_table, &font_face->base.hash_entry);
+    if (font_face->base.hash_entry.hash != 0)
+	_cairo_hash_table_remove (hash_table, &font_face->base.hash_entry);
 
     _cairo_toy_font_face_hash_table_unlock ();
 
     _cairo_toy_font_face_fini (font_face);
 }
 
 static cairo_status_t
 _cairo_toy_font_face_scaled_font_create (void                *abstract_font_face,
@@ -452,56 +468,67 @@ static cairo_status_t
 					 const cairo_matrix_t       *ctm,
 					 const cairo_font_options_t *options,
 					 cairo_scaled_font_t	   **scaled_font)
 {
     cairo_toy_font_face_t *font_face = abstract_font_face;
     const cairo_scaled_font_backend_t * backend = CAIRO_SCALED_FONT_BACKEND_DEFAULT;
     cairo_status_t status;
 
+    if (font_face->base.status)
+	return font_face->base.status;
+
     status = cairo_font_options_status ((cairo_font_options_t *) options);
     if (status)
 	return status;
 
-    return backend->create_toy (font_face,
-				font_matrix, ctm, options, scaled_font);
+    return _cairo_font_face_set_error (&font_face->base,
+	                               backend->create_toy (font_face,
+				                            font_matrix,
+							    ctm,
+							    options,
+							    scaled_font));
 }
 
 static const cairo_font_face_backend_t _cairo_toy_font_face_backend = {
     CAIRO_FONT_TYPE_TOY,
     _cairo_toy_font_face_destroy,
     _cairo_toy_font_face_scaled_font_create
 };
 
 void
 _cairo_unscaled_font_init (cairo_unscaled_font_t               *unscaled_font,
 			   const cairo_unscaled_font_backend_t *backend)
 {
-    unscaled_font->ref_count = 1;
+    CAIRO_REFERENCE_COUNT_INIT (&unscaled_font->ref_count, 1);
     unscaled_font->backend = backend;
 }
 
 cairo_unscaled_font_t *
 _cairo_unscaled_font_reference (cairo_unscaled_font_t *unscaled_font)
 {
     if (unscaled_font == NULL)
 	return NULL;
 
-    unscaled_font->ref_count++;
+    assert (CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&unscaled_font->ref_count));
+
+    _cairo_reference_count_inc (&unscaled_font->ref_count);
 
     return unscaled_font;
 }
 
 void
 _cairo_unscaled_font_destroy (cairo_unscaled_font_t *unscaled_font)
 {
     if (unscaled_font == NULL)
 	return;
 
-    if (--(unscaled_font->ref_count) > 0)
+    assert (CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&unscaled_font->ref_count));
+
+    if (! _cairo_reference_count_dec_and_test (&unscaled_font->ref_count))
 	return;
 
     unscaled_font->backend->destroy (unscaled_font);
 
     free (unscaled_font);
 }
 
 void
--- a/gfx/cairo/cairo/src/cairo-font-options.c
+++ b/gfx/cairo/cairo/src/cairo-font-options.c
@@ -81,20 +81,23 @@ void
  *   cairo_font_options_destroy(). This function always returns a
  *   valid pointer; if memory cannot be allocated, then a special
  *   error object is returned where all operations on the object do nothing.
  *   You can check for this with cairo_font_options_status().
  **/
 cairo_font_options_t *
 cairo_font_options_create (void)
 {
-    cairo_font_options_t *options = malloc (sizeof (cairo_font_options_t));
+    cairo_font_options_t *options;
 
-    if (!options)
+    options = malloc (sizeof (cairo_font_options_t));
+    if (!options) {
+	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return (cairo_font_options_t *)&_cairo_font_options_nil;
+    }
 
     _cairo_font_options_init_default (options);
 
     return options;
 }
 slim_hidden_def (cairo_font_options_create);
 
 /**
@@ -114,18 +117,20 @@ cairo_font_options_t *
 cairo_font_options_copy (const cairo_font_options_t *original)
 {
     cairo_font_options_t *options;
 
     if (original == &_cairo_font_options_nil)
 	return (cairo_font_options_t *)&_cairo_font_options_nil;
 
     options = malloc (sizeof (cairo_font_options_t));
-    if (!options)
+    if (!options) {
+	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return (cairo_font_options_t *)&_cairo_font_options_nil;
+    }
 
     _cairo_font_options_init_copy (options, original);
 
     return options;
 }
 
 /**
  * cairo_font_options_destroy:
--- a/gfx/cairo/cairo/src/cairo-ft-font.c
+++ b/gfx/cairo/cairo/src/cairo-ft-font.c
@@ -114,16 +114,20 @@ struct _cairo_ft_unscaled_font {
 
 static int
 _cairo_ft_unscaled_font_keys_equal (const void *key_a,
 				    const void *key_b);
 
 static void
 _cairo_ft_unscaled_font_fini (cairo_ft_unscaled_font_t *unscaled);
 
+static cairo_status_t
+_cairo_ft_font_options_substitute (const cairo_font_options_t *options,
+				   FcPattern                  *pattern);
+
 typedef enum _cairo_ft_extra_flags {
     CAIRO_FT_OPTIONS_HINT_METRICS = (1 << 0),
     CAIRO_FT_OPTIONS_EMBOLDEN = (1 << 1)
 } cairo_ft_extra_flags_t;
 
 typedef struct _cairo_ft_options {
     cairo_font_options_t    base;
     int			    load_flags;	 /* flags for FT_Load_Glyph */
@@ -175,18 +179,20 @@ static void
     cairo_ft_unscaled_font_map_t *font_map;
 
     /* This function is only intended to be called from
      * _cairo_ft_unscaled_font_map_lock. So we'll crash if we can
      * detect some other call path. */
     assert (cairo_ft_unscaled_font_map == NULL);
 
     font_map = malloc (sizeof (cairo_ft_unscaled_font_map_t));
-    if (font_map == NULL)
+    if (font_map == NULL) {
+	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	goto FAIL;
+    }
 
     font_map->hash_table =
 	_cairo_hash_table_create (_cairo_ft_unscaled_font_keys_equal);
 
     if (font_map->hash_table == NULL)
 	goto FAIL;
 
     if (FT_Init_FreeType (&font_map->ft_library))
@@ -254,17 +260,17 @@ static cairo_ft_unscaled_font_map_t *
     CAIRO_MUTEX_LOCK (_cairo_ft_unscaled_font_map_mutex);
 
     if (cairo_ft_unscaled_font_map == NULL)
     {
 	_cairo_ft_unscaled_font_map_create ();
 
 	if (cairo_ft_unscaled_font_map == NULL) {
 	    CAIRO_MUTEX_UNLOCK (_cairo_ft_unscaled_font_map_mutex);
-	    _cairo_error (CAIRO_STATUS_NO_MEMORY);
+	    _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	    return NULL;
 	}
     }
 
     return cairo_ft_unscaled_font_map;
 }
 
 static void
@@ -327,20 +333,18 @@ static cairo_status_t
 	unscaled->id = 0;
     } else {
 	char *filename_copy;
 
 	unscaled->from_face = FALSE;
 	unscaled->face = NULL;
 
 	filename_copy = strdup (filename);
-	if (filename_copy == NULL) {
-	    _cairo_error (CAIRO_STATUS_NO_MEMORY);
-	    return CAIRO_STATUS_NO_MEMORY;
-	}
+	if (filename_copy == NULL)
+	    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
 	_cairo_ft_unscaled_font_init_key (unscaled, filename_copy, id);
     }
 
     unscaled->have_scale = FALSE;
     CAIRO_MUTEX_INIT (unscaled->mutex);
     unscaled->lock_count = 0;
 
@@ -422,18 +426,20 @@ static cairo_ft_unscaled_font_t *
     {
 	_cairo_unscaled_font_reference (&unscaled->base);
 	_cairo_ft_unscaled_font_map_unlock ();
 	return unscaled;
     }
 
     /* Otherwise create it and insert into hash table. */
     unscaled = malloc (sizeof (cairo_ft_unscaled_font_t));
-    if (unscaled == NULL)
+    if (unscaled == NULL) {
+	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	goto UNWIND_FONT_MAP_LOCK;
+    }
 
     status = _cairo_ft_unscaled_font_init (unscaled, filename, id, NULL);
     if (status)
 	goto UNWIND_UNSCALED_MALLOC;
 
     status = _cairo_hash_table_insert (font_map->hash_table,
 				       &unscaled->base.hash_entry);
     if (status)
@@ -455,18 +461,20 @@ UNWIND:
 
 static cairo_ft_unscaled_font_t *
 _cairo_ft_unscaled_font_create_from_face (FT_Face face)
 {
     cairo_status_t status;
     cairo_ft_unscaled_font_t *unscaled;
 
     unscaled = malloc (sizeof (cairo_ft_unscaled_font_t));
-    if (unscaled == NULL)
+    if (unscaled == NULL) {
+	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return NULL;
+    }
 
     status = _cairo_ft_unscaled_font_init (unscaled, NULL, 0, face);
     if (status) {
 	free (unscaled);
 	return NULL;
     }
 
     return unscaled;
@@ -481,31 +489,33 @@ static void
 	return;
 
     if (unscaled->from_face) {
 	/* See comments in _ft_font_face_destroy about the "zombie" state
 	 * for a _ft_font_face.
 	 */
 	if (unscaled->faces && !unscaled->faces->unscaled)
 	    cairo_font_face_destroy (&unscaled->faces->base);
+
+	unscaled->face = NULL;
     } else {
 	cairo_ft_unscaled_font_map_t *font_map;
 
 	font_map = _cairo_ft_unscaled_font_map_lock ();
 	/* All created objects must have been mapped in the font map. */
 	assert (font_map != NULL);
 
 	_cairo_hash_table_remove (font_map->hash_table,
 				  &unscaled->base.hash_entry);
 
 	_font_map_release_face_lock_held (font_map, unscaled);
-	_cairo_ft_unscaled_font_fini (unscaled);
 
 	_cairo_ft_unscaled_font_map_unlock ();
     }
+    _cairo_ft_unscaled_font_fini (unscaled);
 }
 
 static cairo_bool_t
 _has_unlocked_face (void *entry)
 {
     cairo_ft_unscaled_font_t *unscaled = entry;
 
     return (unscaled->lock_count == 0 && unscaled->face);
@@ -553,17 +563,17 @@ FT_Face
 
     if (FT_New_Face (font_map->ft_library,
 		     unscaled->filename,
 		     unscaled->id,
 		     &face) != FT_Err_Ok)
     {
 	unscaled->lock_count--;
 	CAIRO_MUTEX_UNLOCK (unscaled->mutex);
-	_cairo_error (CAIRO_STATUS_NO_MEMORY);
+	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return NULL;
     }
 
     unscaled->face = face;
 
     font_map->num_open_faces++;
 
     return face;
@@ -668,20 +678,18 @@ static cairo_status_t
         if (y_scale > MAX_FONT_SIZE) {
             y_scale = MAX_FONT_SIZE;
         }
 
 	error = FT_Set_Char_Size (unscaled->face,
 				  x_scale * 64.0,
 				  y_scale * 64.0,
 				  0, 0);
-	if (error) {
-	    _cairo_error (CAIRO_STATUS_NO_MEMORY);
-	    return CAIRO_STATUS_NO_MEMORY;
-	}
+	if (error)
+	    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
     } else {
 	double min_distance = DBL_MAX;
 	int i;
 	int best_i = 0;
 
 	for (i = 0; i < unscaled->face->num_fixed_sizes; i++) {
 #if HAVE_FT_BITMAP_SIZE_Y_PPEM
 	    double size = unscaled->face->available_sizes[i].y_ppem / 64.;
@@ -700,20 +708,18 @@ static cairo_status_t
 				  unscaled->face->available_sizes[best_i].x_ppem,
 				  unscaled->face->available_sizes[best_i].y_ppem,
 				  0, 0);
 	if (error)
 #endif
 	    error = FT_Set_Pixel_Sizes (unscaled->face,
 					unscaled->face->available_sizes[best_i].width,
 					unscaled->face->available_sizes[best_i].height);
-	if (error) {
-	    _cairo_error (CAIRO_STATUS_NO_MEMORY);
-	    return CAIRO_STATUS_NO_MEMORY;
-	}
+	if (error)
+	    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
     }
 
     return CAIRO_STATUS_SUCCESS;
 }
 
 /* Empirically-derived subpixel filtering values thanks to Keith
  * Packard and libXft. */
 static const int    filters[3][3] = {
@@ -757,20 +763,18 @@ static cairo_status_t
     switch (bitmap->pixel_mode) {
     case FT_PIXEL_MODE_MONO:
 	stride = (((width + 31) & ~31) >> 3);
 	if (own_buffer) {
 	    data = bitmap->buffer;
 	    assert (stride == bitmap->pitch);
 	} else {
 	    data = _cairo_malloc_ab (height, stride);
-	    if (!data) {
-		_cairo_error (CAIRO_STATUS_NO_MEMORY);
-		return CAIRO_STATUS_NO_MEMORY;
-	    }
+	    if (!data)
+		return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
 	    if (stride == bitmap->pitch) {
 		memcpy (data, bitmap->buffer, stride * height);
 	    } else {
 		int i;
 		unsigned char *source, *dest;
 
 		source = bitmap->buffer;
@@ -807,20 +811,19 @@ static cairo_status_t
 	case CAIRO_ANTIALIAS_GRAY:
 	case CAIRO_ANTIALIAS_NONE:
 	default:
 	    stride = bitmap->pitch;
 	    if (own_buffer) {
 		data = bitmap->buffer;
 	    } else {
 		data = _cairo_malloc_ab (height, stride);
-		if (!data) {
-		    _cairo_error (CAIRO_STATUS_NO_MEMORY);
-		    return CAIRO_STATUS_NO_MEMORY;
-		}
+		if (!data)
+		    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+
 		memcpy (data, bitmap->buffer, stride * height);
 	    }
 	    format = CAIRO_FORMAT_A8;
 	    break;
 	case CAIRO_ANTIALIAS_SUBPIXEL: {
 	    int		    x, y;
 	    unsigned char   *in_line, *out_line, *in;
 	    unsigned int    *out;
@@ -848,22 +851,21 @@ static cairo_status_t
 		break;
 	    }
 	    /*
 	     * Filter the glyph to soften the color fringes
 	     */
 	    width_rgba = width;
 	    stride = bitmap->pitch;
 	    stride_rgba = (width_rgba * 4 + 3) & ~3;
-	    data_rgba = calloc (1, stride_rgba * height);
+	    data_rgba = calloc (stride_rgba, height);
 	    if (data_rgba == NULL) {
 		if (own_buffer)
 		    free (bitmap->buffer);
-		_cairo_error (CAIRO_STATUS_NO_MEMORY);
-		return CAIRO_STATUS_NO_MEMORY;
+		return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	    }
 
 	    os = 1;
 	    switch (font_options->subpixel_order) {
 	    case CAIRO_SUBPIXEL_ORDER_VRGB:
 		os = stride;
 	    case CAIRO_SUBPIXEL_ORDER_DEFAULT:
 	    case CAIRO_SUBPIXEL_ORDER_RGB:
@@ -921,27 +923,26 @@ static cairo_status_t
 	}
 	break;
     case FT_PIXEL_MODE_GRAY2:
     case FT_PIXEL_MODE_GRAY4:
 	/* These could be triggered by very rare types of TrueType fonts */
     default:
 	if (own_buffer)
 	    free (bitmap->buffer);
-	_cairo_error (CAIRO_STATUS_NO_MEMORY);
-	return CAIRO_STATUS_NO_MEMORY;
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
     }
 
     *surface = (cairo_image_surface_t *)
 	cairo_image_surface_create_for_data (data,
 					     format,
 					     width, height, stride);
     if ((*surface)->base.status) {
 	free (data);
-	return CAIRO_STATUS_NO_MEMORY;
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
     }
 
     if (subpixel)
 	pixman_image_set_component_alpha ((*surface)->pixman_image, TRUE);
 
     _cairo_image_surface_assume_ownership_of_data ((*surface));
 
     return CAIRO_STATUS_SUCCESS;
@@ -1004,17 +1005,17 @@ static cairo_status_t
 	default:
 	    format = CAIRO_FORMAT_A8;
 	    break;
 	}
 
 	(*surface) = (cairo_image_surface_t *)
 	    cairo_image_surface_create_for_data (NULL, format, 0, 0, 0);
 	if ((*surface)->base.status)
-	    return CAIRO_STATUS_NO_MEMORY;
+	    return (*surface)->base.status;
     } else  {
 
 	matrix.xx = matrix.yy = 0x10000L;
 	matrix.xy = matrix.yx = 0;
 
 	switch (font_options->antialias) {
 	case CAIRO_ANTIALIAS_NONE:
 	    bitmap.pixel_mode = FT_PIXEL_MODE_MONO;
@@ -1049,29 +1050,26 @@ static cairo_status_t
 	    bitmap.pixel_mode = FT_PIXEL_MODE_GRAY;
 	    bitmap.num_grays  = 256;
 	    stride = (width * hmul + 3) & -4;
 	}
 
 	bitmap.pitch = stride;
 	bitmap.width = width * hmul;
 	bitmap.rows = height * vmul;
-	bitmap.buffer = calloc (1, stride * bitmap.rows);
-
+	bitmap.buffer = calloc (stride, bitmap.rows);
 	if (bitmap.buffer == NULL) {
-	    _cairo_error (CAIRO_STATUS_NO_MEMORY);
-	    return CAIRO_STATUS_NO_MEMORY;
+	    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	}
 
 	FT_Outline_Translate (outline, -cbox.xMin*hmul, -cbox.yMin*vmul);
 
 	if (FT_Outline_Get_Bitmap (glyphslot->library, outline, &bitmap) != 0) {
 	    free (bitmap.buffer);
-	    _cairo_error (CAIRO_STATUS_NO_MEMORY);
-	    return CAIRO_STATUS_NO_MEMORY;
+	    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	}
 
 	status = _get_bitmap_surface (&bitmap, TRUE, font_options, surface);
 	if (status)
 	    return status;
     }
 
     /*
@@ -1102,20 +1100,18 @@ static cairo_status_t
      * FT_GLYPH_FORMAT_BITMAP. Calling FT_Render_Glyph gives FreeType
      * the opportunity to convert such to
      * bitmap. FT_GLYPH_FORMAT_COMPOSITE will not be encountered since
      * we avoid the FT_LOAD_NO_RECURSE flag.
      */
     error = FT_Render_Glyph (glyphslot, FT_RENDER_MODE_NORMAL);
     /* XXX ignoring all other errors for now.  They are not fatal, typically
      * just a glyph-not-found. */
-    if (error == FT_Err_Out_Of_Memory) {
-	_cairo_error (CAIRO_STATUS_NO_MEMORY);
-	return CAIRO_STATUS_NO_MEMORY;
-    }
+    if (error == FT_Err_Out_Of_Memory)
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     status = _get_bitmap_surface (&glyphslot->bitmap, FALSE, font_options, surface);
     if (status)
 	return status;
 
     /*
      * Note: the font's coordinate system is upside down from ours, so the
      * Y coordinate of the control box needs to be negated.  Moreover, device
@@ -1202,17 +1198,17 @@ static cairo_status_t
     status = cairo_matrix_invert (&transformed_to_original);
     if (status)
 	return status;
 
     /* We need to pad out the width to 32-bit intervals for cairo-xlib-surface.c */
     width = (width + 3) & ~3;
     image = cairo_image_surface_create (CAIRO_FORMAT_A8, width, height);
     if (image->status)
-	return CAIRO_STATUS_NO_MEMORY;
+	return image->status;
 
     /* Initialize it to empty
      */
     status = _cairo_surface_fill_rectangle (image, CAIRO_OPERATOR_CLEAR,
 				            CAIRO_COLOR_TRANSPARENT,
 					    0, 0,
 					    width, height);
     if (status) {
@@ -1468,39 +1464,39 @@ static void
 	    break;
 	}
     }
 
     options->load_flags = load_flags | load_target;
     options->extra_flags = other->extra_flags;
 }
 
-static cairo_scaled_font_t *
+static cairo_status_t
 _cairo_ft_scaled_font_create (cairo_ft_unscaled_font_t	 *unscaled,
 			      cairo_font_face_t		 *font_face,
 			      const cairo_matrix_t	 *font_matrix,
 			      const cairo_matrix_t	 *ctm,
 			      const cairo_font_options_t *options,
-			      cairo_ft_options_t	  ft_options)
+			      cairo_ft_options_t	  ft_options,
+			      cairo_scaled_font_t       **font_out)
 {
-    cairo_ft_scaled_font_t *scaled_font = NULL;
+    cairo_ft_scaled_font_t *scaled_font;
     FT_Face face;
     FT_Size_Metrics *metrics;
     cairo_font_extents_t fs_metrics;
     cairo_status_t status;
 
     face = _cairo_ft_unscaled_font_lock_face (unscaled);
     if (!face)
-	return NULL;
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     scaled_font = malloc (sizeof(cairo_ft_scaled_font_t));
     if (scaled_font == NULL) {
-	_cairo_ft_unscaled_font_unlock_face (unscaled);
-	_cairo_error (CAIRO_STATUS_NO_MEMORY);
-	return NULL;
+	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
+	goto FAIL;
     }
 
     _cairo_unscaled_font_reference (&unscaled->base);
     scaled_font->unscaled = unscaled;
 
     if (options->hint_metrics != CAIRO_HINT_METRICS_OFF)
 	ft_options.extra_flags |= CAIRO_FT_OPTIONS_HINT_METRICS;
 
@@ -1508,30 +1504,50 @@ static cairo_scaled_font_t *
     _cairo_ft_options_merge (&scaled_font->ft_options, &ft_options);
 
     status = _cairo_scaled_font_init (&scaled_font->base,
 			              font_face,
 				      font_matrix, ctm, options,
 				      &cairo_ft_scaled_font_backend);
     if (status) {
 	free (scaled_font);
-	_cairo_unscaled_font_destroy (&unscaled->base);
-	_cairo_ft_unscaled_font_unlock_face (unscaled);
-	return NULL;
+	goto FAIL;
     }
 
     status = _cairo_ft_unscaled_font_set_scale (unscaled,
 				                &scaled_font->base.scale);
     if (status) {
 	free (scaled_font);
-	_cairo_unscaled_font_destroy (&unscaled->base);
-	_cairo_ft_unscaled_font_unlock_face (unscaled);
-	return NULL;
+	goto FAIL;
     }
 
+    /*
+     * Force non-AA drawing when using a bitmap strike that
+     * won't be resampled due to non-scaling transform
+     */
+    if (!unscaled->have_shape &&
+	(scaled_font->ft_options.load_flags & FT_LOAD_NO_BITMAP) == 0 &&
+	scaled_font->ft_options.base.antialias != CAIRO_ANTIALIAS_NONE &&
+	(face->face_flags & FT_FACE_FLAG_FIXED_SIZES))
+    {
+	int		i;
+	FT_Size_Metrics	*size_metrics = &face->size->metrics;
+
+	for (i = 0; i < face->num_fixed_sizes; i++)
+	{
+	    FT_Bitmap_Size  *bitmap_size = &face->available_sizes[i];
+
+	    if (bitmap_size->x_ppem == size_metrics->x_ppem * 64 &&
+		bitmap_size->y_ppem == size_metrics->y_ppem * 64)
+	    {
+		scaled_font->ft_options.base.antialias = CAIRO_ANTIALIAS_NONE;
+		break;
+	    }
+	}
+    }
 
     metrics = &face->size->metrics;
 
     /*
      * Get to unscaled metrics so that the upper level can get back to
      * user space
      */
     if (scaled_font->base.options.hint_metrics != CAIRO_HINT_METRICS_OFF) {
@@ -1569,19 +1585,22 @@ static cairo_scaled_font_t *
 	} else {
 	    fs_metrics.max_x_advance = 0;
 	    fs_metrics.max_y_advance = face->max_advance_height / scale;
 	}
     }
 
     _cairo_scaled_font_set_metrics (&scaled_font->base, &fs_metrics);
 
+    *font_out = &scaled_font->base;
+
+ FAIL:
     _cairo_ft_unscaled_font_unlock_face (unscaled);
 
-    return &scaled_font->base;
+    return status;
 }
 
 cairo_bool_t
 _cairo_scaled_font_is_ft (cairo_scaled_font_t *scaled_font)
 {
     return scaled_font->backend == &cairo_ft_scaled_font_backend;
 }
 
@@ -1589,102 +1608,118 @@ static cairo_status_t
 _cairo_ft_scaled_font_create_toy (cairo_toy_font_face_t	      *toy_face,
 				  const cairo_matrix_t	      *font_matrix,
 				  const cairo_matrix_t	      *ctm,
 				  const cairo_font_options_t  *font_options,
 				  cairo_scaled_font_t	     **font)
 {
     FcPattern *pattern, *resolved;
     cairo_ft_unscaled_font_t *unscaled;
-    cairo_scaled_font_t *new_font = NULL;
     FcResult result;
     int fcslant;
     int fcweight;
     cairo_matrix_t scale;
+    cairo_status_t status;
     cairo_ft_font_transform_t sf;
     cairo_ft_options_t ft_options;
-    unsigned char *family = (unsigned char*) toy_face->family;
 
     pattern = FcPatternCreate ();
-    if (!pattern) {
-	_cairo_error (CAIRO_STATUS_NO_MEMORY);
-	return CAIRO_STATUS_NO_MEMORY;
-    }
-
-    switch (toy_face->weight)
+    if (!pattern)
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+
+    if (!FcPatternAddString (pattern,
+		             FC_FAMILY, (unsigned char *) toy_face->family))
     {
-    case CAIRO_FONT_WEIGHT_BOLD:
-        fcweight = FC_WEIGHT_BOLD;
-        break;
-    case CAIRO_FONT_WEIGHT_NORMAL:
-    default:
-        fcweight = FC_WEIGHT_MEDIUM;
-        break;
+	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
+	goto FREE_PATTERN;
     }
 
     switch (toy_face->slant)
     {
     case CAIRO_FONT_SLANT_ITALIC:
         fcslant = FC_SLANT_ITALIC;
         break;
     case CAIRO_FONT_SLANT_OBLIQUE:
 	fcslant = FC_SLANT_OBLIQUE;
         break;
     case CAIRO_FONT_SLANT_NORMAL:
     default:
         fcslant = FC_SLANT_ROMAN;
         break;
     }
 
-    if (!FcPatternAddString (pattern, FC_FAMILY, family))
+    if (!FcPatternAddInteger (pattern, FC_SLANT, fcslant)) {
+	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	goto FREE_PATTERN;
-    if (!FcPatternAddInteger (pattern, FC_SLANT, fcslant))
+    }
+
+    switch (toy_face->weight)
+    {
+    case CAIRO_FONT_WEIGHT_BOLD:
+        fcweight = FC_WEIGHT_BOLD;
+        break;
+    case CAIRO_FONT_WEIGHT_NORMAL:
+    default:
+        fcweight = FC_WEIGHT_MEDIUM;
+        break;
+    }
+
+    if (!FcPatternAddInteger (pattern, FC_WEIGHT, fcweight)) {
+	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	goto FREE_PATTERN;
-    if (!FcPatternAddInteger (pattern, FC_WEIGHT, fcweight))
-	goto FREE_PATTERN;
+    }
 
     cairo_matrix_multiply (&scale, font_matrix, ctm);
     _compute_transform (&sf, &scale);
 
-    FcPatternAddInteger (pattern, FC_PIXEL_SIZE, sf.y_scale);
-
-    FcConfigSubstitute (NULL, pattern, FcMatchPattern);
-    cairo_ft_font_options_substitute (font_options, pattern);
+    if (! FcPatternAddInteger (pattern, FC_PIXEL_SIZE, sf.y_scale)) {
+	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
+	goto FREE_PATTERN;
+    }
+
+    if (! FcConfigSubstitute (NULL, pattern, FcMatchPattern)) {
+	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
+	goto FREE_PATTERN;
+    }
+
+    status = _cairo_ft_font_options_substitute (font_options, pattern);
+    if (status)
+	goto FREE_PATTERN;
+
     FcDefaultSubstitute (pattern);
 
     resolved = FcFontMatch (NULL, pattern, &result);
-    if (!resolved)
+    if (!resolved) {
+	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	goto FREE_PATTERN;
+    }
 
     unscaled = _cairo_ft_unscaled_font_create_for_pattern (resolved);
-    if (!unscaled)
+    if (!unscaled) {
+	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	goto FREE_RESOLVED;
+    }
 
     _get_pattern_ft_options (resolved, &ft_options);
 
-    new_font = _cairo_ft_scaled_font_create (unscaled,
-					     &toy_face->base,
-					     font_matrix, ctm,
-					     font_options, ft_options);
+    status = _cairo_ft_scaled_font_create (unscaled,
+					   &toy_face->base,
+					   font_matrix, ctm,
+					   font_options, ft_options,
+					   font);
 
     _cairo_unscaled_font_destroy (&unscaled->base);
 
  FREE_RESOLVED:
     FcPatternDestroy (resolved);
 
  FREE_PATTERN:
     FcPatternDestroy (pattern);
 
-    if (new_font) {
-	*font = new_font;
-	return CAIRO_STATUS_SUCCESS;
-    } else {
-	_cairo_error (CAIRO_STATUS_NO_MEMORY);
-	return CAIRO_STATUS_NO_MEMORY;
-    }
+    return status;
 }
 
 static void
 _cairo_ft_scaled_font_fini (void *abstract_font)
 {
     cairo_ft_scaled_font_t *scaled_font = abstract_font;
 
     if (scaled_font == NULL)
@@ -1731,18 +1766,17 @@ static int
     cairo_path_fixed_t *path = closure;
 
     cairo_fixed_t x0, y0;
     cairo_fixed_t x1, y1;
     cairo_fixed_t x2, y2;
     cairo_fixed_t x3, y3;
     cairo_point_t conic;
 
-    if (_cairo_path_fixed_get_current_point (path, &x0, &y0) !=
-	    CAIRO_STATUS_SUCCESS)
+    if (! _cairo_path_fixed_get_current_point (path, &x0, &y0))
 	return 1;
 
     conic.x = _cairo_fixed_from_26_6 (control->x);
     conic.y = _cairo_fixed_from_26_6 (control->y);
 
     x3 = _cairo_fixed_from_26_6 (to->x);
     y3 = _cairo_fixed_from_26_6 (to->y);
 
@@ -1807,26 +1841,25 @@ static cairo_status_t
     };
 
     FT_GlyphSlot glyph;
     cairo_path_fixed_t *path;
     cairo_status_t status;
 
     path = _cairo_path_fixed_create ();
     if (!path)
-	return CAIRO_STATUS_NO_MEMORY;
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     glyph = face->glyph;
 
     /* Font glyphs have an inverted Y axis compared to cairo. */
     FT_Outline_Transform (&glyph->outline, &invert_y);
     if (FT_Outline_Decompose (&glyph->outline, &outline_funcs, path)) {
 	_cairo_path_fixed_destroy (path);
-	_cairo_error (CAIRO_STATUS_NO_MEMORY);
-	return CAIRO_STATUS_NO_MEMORY;
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
     }
 
     status = _cairo_path_fixed_close_path (path);
     if (status) {
 	_cairo_path_fixed_destroy (path);
 	return status;
     }
 
@@ -1871,17 +1904,17 @@ static cairo_int_status_t
     int load_flags = scaled_font->ft_options.load_flags;
     FT_Glyph_Metrics *metrics;
     double x_factor, y_factor;
     cairo_bool_t vertical_layout = FALSE;
     cairo_status_t status;
 
     face = _cairo_ft_unscaled_font_lock_face (unscaled);
     if (!face)
-	return CAIRO_STATUS_NO_MEMORY;
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     status = _cairo_ft_unscaled_font_set_scale (scaled_font->unscaled,
 				                &scaled_font->base.scale);
     if (status)
 	goto FAIL;
 
     /* Ignore global advance unconditionally */
     load_flags |= FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH;
@@ -1900,17 +1933,17 @@ static cairo_int_status_t
     }
 
     error = FT_Load_Glyph (scaled_font->unscaled->face,
 			   _cairo_scaled_glyph_index(scaled_glyph),
 			   load_flags);
     /* XXX ignoring all other errors for now.  They are not fatal, typically
      * just a glyph-not-found. */
     if (error == FT_Err_Out_Of_Memory) {
-	status = CAIRO_STATUS_NO_MEMORY;
+	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	goto FAIL;
     }
 
     glyph = face->glyph;
 
 #if HAVE_FT_GLYPHSLOT_EMBOLDEN
     /*
      * embolden glyphs if requested
@@ -2039,32 +2072,31 @@ static cairo_int_status_t
 	    goto FAIL;
 
 	_cairo_scaled_glyph_set_surface (scaled_glyph,
 					 &scaled_font->base,
 					 surface);
     }
 
     if (info & CAIRO_SCALED_GLYPH_INFO_PATH) {
-	cairo_path_fixed_t *path;
+	cairo_path_fixed_t *path = NULL; /* hide compiler warning */
 
 	/*
 	 * A kludge -- the above code will trash the outline,
 	 * so reload it. This will probably never occur though
 	 */
 	if ((info & CAIRO_SCALED_GLYPH_INFO_SURFACE) != 0) {
 	    error = FT_Load_Glyph (face,
 				   _cairo_scaled_glyph_index(scaled_glyph),
 				   load_flags | FT_LOAD_NO_BITMAP);
 	    /* XXX ignoring all other errors for now.  They are not fatal, typically
 	     * just a glyph-not-found. */
 	    if (error == FT_Err_Out_Of_Memory) {
-		_cairo_ft_unscaled_font_unlock_face (unscaled);
-		_cairo_error (CAIRO_STATUS_NO_MEMORY);
-		return CAIRO_STATUS_NO_MEMORY;
+		status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
+		goto FAIL;
 	    }
 #if HAVE_FT_GLYPHSLOT_EMBOLDEN
 	    /*
 	     * embolden glyphs if requested
 	     */
 	    if (scaled_font->ft_options.extra_flags & CAIRO_FT_OPTIONS_EMBOLDEN)
 		FT_GlyphSlot_Embolden (glyph);
 #endif
@@ -2121,17 +2153,17 @@ static cairo_int_status_t
     cairo_status_t status = CAIRO_INT_STATUS_UNSUPPORTED;
 
     if (_cairo_ft_scaled_font_is_vertical (&scaled_font->base))
         return CAIRO_INT_STATUS_UNSUPPORTED;
 
 #if HAVE_FT_LOAD_SFNT_TABLE
     face = _cairo_ft_unscaled_font_lock_face (unscaled);
     if (!face)
-	return CAIRO_STATUS_NO_MEMORY;
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     if (FT_IS_SFNT (face) &&
 	FT_Load_Sfnt_Table (face, tag, offset, buffer, length) == 0)
         status = CAIRO_STATUS_SUCCESS;
 
     _cairo_ft_unscaled_font_unlock_face (unscaled);
 #endif
 
@@ -2206,17 +2238,17 @@ static void
      *
      * To:
      *
      *    font_face <------- unscaled
      */
 
     if (font_face->unscaled &&
 	font_face->unscaled->from_face &&
-	font_face->unscaled->base.ref_count > 1)
+	CAIRO_REFERENCE_COUNT_GET_VALUE (&font_face->unscaled->base.ref_count) > 1)
     {
 	cairo_font_face_reference (&font_face->base);
 
 	_cairo_unscaled_font_destroy (&font_face->unscaled->base);
 	font_face->unscaled = NULL;
 
 	return;
     }
@@ -2259,26 +2291,21 @@ static cairo_status_t
      * cairo_ft_font_face_create_for_pattern(), the load flags are
      * derived from a pattern where the user has called
      * cairo_ft_font_options_substitute(), so *just* use those load
      * flags and ignore the options.
      */
 
     ft_options = font_face->ft_options;
 
-    *scaled_font = _cairo_ft_scaled_font_create (font_face->unscaled,
-						 &font_face->base,
-						 font_matrix, ctm,
-						 options, ft_options);
-    if (*scaled_font) {
-	return CAIRO_STATUS_SUCCESS;
-    } else {
-	_cairo_error (CAIRO_STATUS_NO_MEMORY);
-	return CAIRO_STATUS_NO_MEMORY;
-    }
+    return  _cairo_ft_scaled_font_create (font_face->unscaled,
+					  &font_face->base,
+					  font_matrix, ctm,
+					  options, ft_options,
+					  scaled_font);
 }
 
 static const cairo_font_face_backend_t _cairo_ft_font_face_backend = {
     CAIRO_FONT_TYPE_FT,
     _cairo_ft_font_face_destroy,
     _cairo_ft_font_face_scaled_font_create
 };
 
@@ -2304,17 +2331,17 @@ static cairo_font_face_t *
 	    *prev_font_face = font_face->next;
 	    break;
 	}
     }
 
     /* No match found, create a new one */
     font_face = malloc (sizeof (cairo_ft_font_face_t));
     if (!font_face) {
-	_cairo_error (CAIRO_STATUS_NO_MEMORY);
+	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return NULL;
     }
 
     font_face->unscaled = unscaled;
     _cairo_unscaled_font_reference (&unscaled->base);
 
     font_face->ft_options = *ft_options;
 
@@ -2323,41 +2350,35 @@ static cairo_font_face_t *
 
     _cairo_font_face_init (&font_face->base, &_cairo_ft_font_face_backend);
 
     return &font_face->base;
 }
 
 /* implement the platform-specific interface */
 
-/**
- * cairo_ft_font_options_substitute:
- * @options: a #cairo_font_options_t object
- * @pattern: an existing #FcPattern
- *
- * Add options to a #FcPattern based on a #cairo_font_options_t font
- * options object. Options that are already in the pattern, are not overridden,
- * so you should call this function after calling FcConfigSubstitute() (the
- * user's settings should override options based on the surface type), but
- * before calling FcDefaultSubstitute().
- **/
-void
-cairo_ft_font_options_substitute (const cairo_font_options_t *options,
-				  FcPattern                  *pattern)
+static cairo_status_t
+_cairo_ft_font_options_substitute (const cairo_font_options_t *options,
+				   FcPattern                  *pattern)
 {
     FcValue v;
 
     if (options->antialias != CAIRO_ANTIALIAS_DEFAULT)
     {
 	if (FcPatternGet (pattern, FC_ANTIALIAS, 0, &v) == FcResultNoMatch)
 	{
-	    FcPatternAddBool (pattern, FC_ANTIALIAS, options->antialias != CAIRO_ANTIALIAS_NONE);
+	    if (! FcPatternAddBool (pattern,
+			            FC_ANTIALIAS,
+				    options->antialias != CAIRO_ANTIALIAS_NONE))
+		return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+
 	    if (options->antialias != CAIRO_ANTIALIAS_SUBPIXEL) {
 		FcPatternDel (pattern, FC_RGBA);
-		FcPatternAddInteger (pattern, FC_RGBA, FC_RGBA_NONE);
+		if (! FcPatternAddInteger (pattern, FC_RGBA, FC_RGBA_NONE))
+		    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	    }
 	}
     }
 
     if (options->antialias != CAIRO_ANTIALIAS_DEFAULT)
     {
 	if (FcPatternGet (pattern, FC_RGBA, 0, &v) == FcResultNoMatch)
 	{
@@ -2379,25 +2400,29 @@ cairo_ft_font_options_substitute (const 
 		case CAIRO_SUBPIXEL_ORDER_VBGR:
 		    rgba = FC_RGBA_VBGR;
 		    break;
 		}
 	    } else {
 		rgba = FC_RGBA_NONE;
 	    }
 
-	    FcPatternAddInteger (pattern, FC_RGBA, rgba);
+	    if (! FcPatternAddInteger (pattern, FC_RGBA, rgba))
+		return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	}
     }
 
     if (options->hint_style != CAIRO_HINT_STYLE_DEFAULT)
     {
 	if (FcPatternGet (pattern, FC_HINTING, 0, &v) == FcResultNoMatch)
 	{
-	    FcPatternAddBool (pattern, FC_HINTING, options->hint_style != CAIRO_HINT_STYLE_NONE);
+	    if (! FcPatternAddBool (pattern,
+			            FC_HINTING,
+				    options->hint_style != CAIRO_HINT_STYLE_NONE))
+		return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	}
 
 #ifdef FC_HINT_STYLE
 	if (FcPatternGet (pattern, FC_HINT_STYLE, 0, &v) == FcResultNoMatch)
 	{
 	    int hint_style;
 
 	    switch (options->hint_style) {
@@ -2412,22 +2437,42 @@ cairo_ft_font_options_substitute (const 
 		break;
 	    case CAIRO_HINT_STYLE_FULL:
 	    case CAIRO_HINT_STYLE_DEFAULT:
 	    default:
 		hint_style = FC_HINT_FULL;
 		break;
 	    }
 
-	    FcPatternAddInteger (pattern, FC_HINT_STYLE, hint_style);
+	    if (! FcPatternAddInteger (pattern, FC_HINT_STYLE, hint_style))
+		return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	}
 #endif
     }
+
+    return CAIRO_STATUS_SUCCESS;
 }
-slim_hidden_def (cairo_ft_font_options_substitute);
+
+/**
+ * cairo_ft_font_options_substitute:
+ * @options: a #cairo_font_options_t object
+ * @pattern: an existing #FcPattern
+ *
+ * Add options to a #FcPattern based on a #cairo_font_options_t font
+ * options object. Options that are already in the pattern, are not overridden,
+ * so you should call this function after calling FcConfigSubstitute() (the
+ * user's settings should override options based on the surface type), but
+ * before calling FcDefaultSubstitute().
+ **/
+void
+cairo_ft_font_options_substitute (const cairo_font_options_t *options,
+				  FcPattern                  *pattern)
+{
+    _cairo_ft_font_options_substitute (options, pattern);
+}
 
 /**
  * cairo_ft_font_face_create_for_pattern:
  * @pattern: A fully resolved fontconfig
  *   pattern. A pattern can be resolved, by, among other things, calling
  *   FcConfigSubstitute(), FcDefaultSubstitute(), then
  *   FcFontMatch(). Cairo will call FcPatternReference() on this
  *   pattern, so you should not further modify the pattern, but you can
@@ -2454,17 +2499,17 @@ cairo_font_face_t *
 cairo_ft_font_face_create_for_pattern (FcPattern *pattern)
 {
     cairo_ft_unscaled_font_t *unscaled;
     cairo_font_face_t *font_face;
     cairo_ft_options_t ft_options;
 
     unscaled = _cairo_ft_unscaled_font_create_for_pattern (pattern);
     if (unscaled == NULL) {
-	_cairo_error (CAIRO_STATUS_NO_MEMORY);
+	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return (cairo_font_face_t *)&_cairo_font_face_nil;
     }
 
     _get_pattern_ft_options (pattern, &ft_options);
     font_face = _cairo_ft_font_face_create (unscaled, &ft_options);
     _cairo_unscaled_font_destroy (&unscaled->base);
 
     if (font_face)
@@ -2504,17 +2549,17 @@ cairo_ft_font_face_create_for_ft_face (F
 				       int             load_flags)
 {
     cairo_ft_unscaled_font_t *unscaled;
     cairo_font_face_t *font_face;
     cairo_ft_options_t ft_options;
 
     unscaled = _cairo_ft_unscaled_font_create_from_face (face);
     if (unscaled == NULL) {
-	_cairo_error (CAIRO_STATUS_NO_MEMORY);
+	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return (cairo_font_face_t *)&_cairo_font_face_nil;
     }
 
     ft_options.load_flags = load_flags;
     ft_options.extra_flags = 0;
     _cairo_font_options_init_default (&ft_options.base);
 
     font_face = _cairo_ft_font_face_create (unscaled, &ft_options);
@@ -2563,25 +2608,25 @@ cairo_ft_scaled_font_lock_face (cairo_sc
     FT_Face face;
     cairo_status_t status;
 
     if (scaled_font->base.status)
 	return NULL;
 
     face = _cairo_ft_unscaled_font_lock_face (scaled_font->unscaled);
     if (face == NULL) {
-	_cairo_scaled_font_set_error (&scaled_font->base, CAIRO_STATUS_NO_MEMORY);
+	status = _cairo_scaled_font_set_error (&scaled_font->base, CAIRO_STATUS_NO_MEMORY);
 	return NULL;
     }
 
     status = _cairo_ft_unscaled_font_set_scale (scaled_font->unscaled,
 				                &scaled_font->base.scale);
     if (status) {
 	_cairo_ft_unscaled_font_unlock_face (scaled_font->unscaled);
-	_cairo_scaled_font_set_error (&scaled_font->base, status);
+	status = _cairo_scaled_font_set_error (&scaled_font->base, status);
 	return NULL;
     }
 
     /* NOTE: We deliberately release the unscaled font's mutex here,
      * so that we are not holding a lock across two separate calls to
      * cairo function, (which would give the application some
      * opportunity for creating deadlock. This is obviously unsafe,
      * but as documented, the user must add manual locking when using
--- a/gfx/cairo/cairo/src/cairo-ft-private.h
+++ b/gfx/cairo/cairo/src/cairo-ft-private.h
@@ -62,16 +62,15 @@ cairo_private FT_Face
 _cairo_ft_unscaled_font_lock_face (cairo_ft_unscaled_font_t *unscaled);
 
 cairo_private void
 _cairo_ft_unscaled_font_unlock_face (cairo_ft_unscaled_font_t *unscaled);
 
 cairo_private cairo_bool_t
 _cairo_ft_scaled_font_is_vertical (cairo_scaled_font_t *scaled_font);
 
-slim_hidden_proto (cairo_ft_font_options_substitute);
 slim_hidden_proto (cairo_ft_scaled_font_lock_face);
 slim_hidden_proto (cairo_ft_scaled_font_unlock_face);
 
 CAIRO_END_DECLS
 
 #endif /* CAIRO_HAS_FT_FONT */
 #endif /* CAIRO_FT_PRIVATE_H */
--- a/gfx/cairo/cairo/src/cairo-glitz-surface.c
+++ b/gfx/cairo/cairo/src/cairo-glitz-surface.c
@@ -84,27 +84,27 @@ static cairo_surface_t *
     glitz_format_t	  *gformat;
 
     drawable = glitz_surface_get_drawable (src->surface);
 
     gformat =
 	glitz_find_standard_format (drawable,
 				    _glitz_format_from_content (content));
     if (!gformat) {
-	_cairo_error (CAIRO_STATUS_NO_MEMORY);
+	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return (cairo_surface_t*) &_cairo_surface_nil;
     }
 
     surface = glitz_surface_create (drawable, gformat,
 				    width <= 0 ? 1 : width,
 				    height <= 0 ? 1 : height,
 				    0, NULL);
 
     if (surface == NULL) {
-	_cairo_error (CAIRO_STATUS_NO_MEMORY);
+	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return (cairo_surface_t*) &_cairo_surface_nil;
     }
 
     crsurface = cairo_glitz_surface_create (surface);
 
     glitz_surface_destroy (surface);
 
     return crsurface;
@@ -160,18 +160,20 @@ static glitz_box_t *
     if (_cairo_region_get_boxes (region, &n, &cboxes) != CAIRO_STATUS_SUCCESS)
         return NULL;
 
     *nboxes = n;
     if (n == 0)
         return NULL;
 
     gboxes = _cairo_malloc_ab (n, sizeof(glitz_box_t));
-    if (gboxes == NULL)
+    if (gboxes == NULL) {
+	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
         goto done;
+    }
 
     for (i = 0; i < n; i++) {
         gboxes[i].x1 = cboxes[i].p1.x;
         gboxes[i].y1 = cboxes[i].p1.y;
         gboxes[i].x2 = cboxes[i].p2.x;
         gboxes[i].y2 = cboxes[i].p2.y;
     }
 
@@ -265,22 +267,22 @@ static cairo_status_t
 
     /* XXX: we should eventually return images with negative stride,
        need to verify that libpixman have no problem with this first. */
     pf.bytes_per_line = (((width * masks.bpp) / 8) + 3) & -4;
     pf.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN;
 
     pixels = _cairo_malloc_ab (height, pf.bytes_per_line);
     if (!pixels)
-	return CAIRO_STATUS_NO_MEMORY;
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     buffer = glitz_buffer_create_for_data (pixels);
     if (!buffer) {
 	free (pixels);
-	return CAIRO_STATUS_NO_MEMORY;
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
     }
 
     /* clear out the glitz clip; the clip affects glitz_get_pixels */
     if (surface->has_clip)
 	glitz_surface_set_clip_region (surface->surface,
 				       0, 0, NULL, 0);
 
     glitz_get_pixels (surface->surface,
@@ -294,17 +296,17 @@ static cairo_status_t
     /* restore the clip, if any */
     if (surface->has_clip) {
 	glitz_box_t *box;
         int n;
 
         box = _cairo_glitz_get_boxes_from_region (&surface->clip, &n);
         if (box == NULL && n != 0) {
             free (pixels);
-            return CAIRO_STATUS_NO_MEMORY;
+            return _cairo_error (CAIRO_STATUS_NO_MEMORY);
         }
 
 	glitz_surface_set_clip_region (surface->surface, 0, 0, box, n);
 
         free (box);
     }
 
     /*
@@ -340,17 +342,17 @@ static cairo_status_t
     _cairo_image_surface_assume_ownership_of_data (image);
 
     *image_out = image;
 
     return CAIRO_STATUS_SUCCESS;
 
 FAIL:
     free (pixels);
-    return CAIRO_STATUS_NO_MEMORY;
+    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 }
 
 static void
 cairo_format_get_masks (cairo_format_t  format,
 			uint32_t       *bpp,
                         uint32_t       *alpha,
 			uint32_t       *red,
 			uint32_t       *green,
@@ -423,17 +425,17 @@ static cairo_status_t
     {
 	pf.bytes_per_line = image->stride;
 	pf.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN;
 	data = (char *) image->data;
     }
 
     buffer = glitz_buffer_create_for_data (data);
     if (!buffer)
-	return CAIRO_STATUS_NO_MEMORY;
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     glitz_set_pixels (surface->surface,
 		      x_dst, y_dst,
 		      width, height,
 		      &pf,
 		      buffer);
 
     glitz_buffer_destroy (buffer);
@@ -486,35 +488,39 @@ static cairo_status_t
 static void
 _cairo_glitz_surface_release_dest_image (void                    *abstract_surface,
 					 cairo_rectangle_int_t   *interest_rect,
 					 cairo_image_surface_t   *image,
 					 cairo_rectangle_int_t   *image_rect,
 					 void                    *image_extra)
 {
     cairo_glitz_surface_t *surface = abstract_surface;
+    cairo_status_t status;
 
-    _cairo_glitz_surface_set_image (surface, image, 0, 0,
-				    image->width, image->height,
-				    image_rect->x, image_rect->y);
+    status = _cairo_glitz_surface_set_image (surface, image, 0, 0,
+				             image->width, image->height,
+				             image_rect->x, image_rect->y);
+    if (status)
+	status = _cairo_surface_set_error (&surface->base, status);
 
     cairo_surface_destroy (&image->base);
 }
 
 static cairo_status_t
 _cairo_glitz_surface_clone_similar (void	    *abstract_surface,
 				    cairo_surface_t *src,
 				    int              src_x,
 				    int              src_y,
 				    int              width,
 				    int              height,
 				    cairo_surface_t **clone_out)
 {
     cairo_glitz_surface_t *surface = abstract_surface;
     cairo_glitz_surface_t *clone;
+    cairo_status_t status;
 
     if (surface->base.status)
 	return surface->base.status;
 
     if (src->backend == surface->base.backend)
     {
 	*clone_out = cairo_surface_reference (src);
 
@@ -529,33 +535,37 @@ static cairo_status_t
 
 	content = _cairo_content_from_format (image_src->format);
 
 	clone = (cairo_glitz_surface_t *)
 	    _cairo_glitz_surface_create_similar (surface, content,
 						 image_src->width,
 						 image_src->height);
 	if (clone->base.status)
-	    return CAIRO_STATUS_NO_MEMORY;
+	    return clone->base.status;
 
 	image_extent.x = 0;
 	image_extent.y = 0;
 	image_extent.width = image_src->width;
 	image_extent.height = image_src->height;
 	extent.x = src_x;
 	extent.y = src_y;
 	extent.width = width;
 	extent.height = height;
 
 	_cairo_rectangle_intersect(&extent, &image_extent);
 
-	_cairo_glitz_surface_set_image (clone, image_src,
-					extent.x, extent.y,
-					extent.width, extent.height,
-					extent.x, extent.y);
+	status = _cairo_glitz_surface_set_image (clone, image_src,
+					         extent.x, extent.y,
+						 extent.width, extent.height,
+						 extent.x, extent.y);
+	if (status) {
+	    cairo_surface_destroy (&clone->base);
+	    return status;
+	}
 
 	*clone_out = &clone->base;
 
 	return CAIRO_STATUS_SUCCESS;
     }
 
     return CAIRO_INT_STATUS_UNSUPPORTED;
 }
@@ -759,50 +769,49 @@ static cairo_int_status_t
 
 	n_params = gradient->n_stops * 3 + n_base_params;
 
         /* check for int overflow */
         {
             int size1, size2;
             if (n_params >= INT32_MAX / sizeof (glitz_fixed16_16_t) ||
                 gradient->n_stops >= INT32_MAX / sizeof (unsigned int))
-                return CAIRO_STATUS_NO_MEMORY;
+                return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
             size1 = n_params * sizeof (glitz_fixed16_16_t);
             size2 = gradient->n_stops * sizeof (unsigned int);
 
             if (size1 >= INT32_MAX - size2)
-                return CAIRO_STATUS_NO_MEMORY;
+                return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
             data = malloc (size1 + size2);
         }
 
 	if (!data)
-	    return CAIRO_STATUS_NO_MEMORY;
+	    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
 	params = (glitz_fixed16_16_t *) data;
 	pixels = (unsigned int *)
 	    (data + sizeof (glitz_fixed16_16_t) * n_params);
 
 	buffer = glitz_buffer_create_for_data (pixels);
-	if (!buffer)
-	{
+	if (!buffer) {
 	    free (data);
-	    return CAIRO_STATUS_NO_MEMORY;
+	    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	}
 
 	src = (cairo_glitz_surface_t *)
 	    _cairo_surface_create_similar_scratch (&dst->base,
 						   CAIRO_CONTENT_COLOR_ALPHA,
 						   gradient->n_stops, 1);
 	if (src->base.status)
 	{
 	    glitz_buffer_destroy (buffer);
 	    free (data);
-	    return CAIRO_STATUS_NO_MEMORY;
+	    return src->base.status;
 	}
 
 	for (i = 0; i < gradient->n_stops; i++)
 	{
 	    pixels[i] =
 		(((int) (gradient->stops[i].color.alpha_short >> 8)) << 24) |
 		(((int) (gradient->stops[i].color.red_short   >> 8)) << 16) |
 		(((int) (gradient->stops[i].color.green_short >> 8)) << 8)  |
@@ -1153,17 +1162,17 @@ static cairo_int_status_t
 
 	src = (cairo_glitz_surface_t *)
 	    _cairo_surface_create_similar_solid (&dst->base,
 						 CAIRO_CONTENT_COLOR_ALPHA,
 						 1, 1,
 						 (cairo_color_t *) color,
 						 NULL);
 	if (src->base.status)
-	    return CAIRO_STATUS_NO_MEMORY;
+	    return src->base.status;
 
 	glitz_surface_set_fill (src->surface, GLITZ_FILL_REPEAT);
 
 	while (n_rects--)
 	{
 	    glitz_composite (_glitz_operator (op),
 			     src->surface,
 			     NULL,
@@ -1272,17 +1281,17 @@ static cairo_int_status_t
 						 CAIRO_CONTENT_ALPHA,
 						 2, 1);
 	if (mask->base.status)
 	{
 	    _cairo_glitz_pattern_release_surface (src_pattern, src, &attributes);
 	    if (src_pattern == &tmp_src_pattern.base)
 		_cairo_pattern_fini (&tmp_src_pattern.base);
 
-	    return CAIRO_STATUS_NO_MEMORY;
+	    return mask->base.status;
 	}
 
 	color.red = color.green = color.blue = color.alpha = 0xffff;
 
 	glitz_set_rectangle (mask->surface, &clear_black, 0, 0, 1, 1);
 	glitz_set_rectangle (mask->surface, &color, 1, 0, 1, 1);
 
 	glitz_surface_set_fill (mask->surface, GLITZ_FILL_NEAREST);
@@ -1299,30 +1308,30 @@ static cairo_int_status_t
 		data_size = size;
 		data = realloc (data, data_size);
 		if (!data)
 		{
 		    _cairo_glitz_pattern_release_surface (src_pattern, src,
 							  &attributes);
 		    if (src_pattern == &tmp_src_pattern.base)
 			_cairo_pattern_fini (&tmp_src_pattern.base);
-		    return CAIRO_STATUS_NO_MEMORY;
+		    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 		}
 
 		if (buffer)
 		    glitz_buffer_destroy (buffer);
 
 		buffer = glitz_buffer_create_for_data (data);
 		if (!buffer) {
 		    free (data);
 		    _cairo_glitz_pattern_release_surface (src_pattern, src,
 							  &attributes);
 		    if (src_pattern == &tmp_src_pattern.base)
 			_cairo_pattern_fini (&tmp_src_pattern.base);
-		    return CAIRO_STATUS_NO_MEMORY;
+		    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 		}
 	    }
 
 	    offset +=
 		glitz_add_trapezoids (buffer,
 				      offset, size - offset,
 				      format.vertex.type, mask->surface,
 				      (glitz_trapezoid_t *) traps, n_traps,
@@ -1342,58 +1351,62 @@ static cairo_int_status_t
     }
     else
     {
 	cairo_image_surface_t *image;
 	unsigned char	      *ptr;
 	int		      stride;
 
 	stride = (width + 3) & -4;
-	data = calloc (stride * height, 1);
+	data = calloc (stride, height);
 	if (!data)
 	{
 	    _cairo_glitz_pattern_release_surface (src_pattern, src, &attributes);
 	    if (src_pattern == &tmp_src_pattern.base)
 		_cairo_pattern_fini (&tmp_src_pattern.base);
-	    return CAIRO_STATUS_NO_MEMORY;
+	    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	}
 
 	/* using negative stride */
 	ptr = (unsigned char *) data + stride * (height - 1);
 
 	image = (cairo_image_surface_t *)
 	    cairo_image_surface_create_for_data (ptr,
 						 CAIRO_FORMAT_A8,
 						 width, height,
 						 -stride);
 	if (image->base.status)
 	{
 	    cairo_surface_destroy (&src->base);
 	    free (data);
-	    return CAIRO_STATUS_NO_MEMORY;
+	    return image->base.status;
 	}
 
 	pixman_add_trapezoids (image->pixman_image, -dst_x, -dst_y,
                                n_traps, (pixman_trapezoid_t *) traps);
 
 	mask = (cairo_glitz_surface_t *)
 	    _cairo_surface_create_similar_scratch (&dst->base,
 						   CAIRO_CONTENT_ALPHA,
 						   width, height);
 	if (mask->base.status)
 	{
 	    _cairo_glitz_pattern_release_surface (src_pattern, src, &attributes);
 	    free (data);
 	    cairo_surface_destroy (&image->base);
-	    return CAIRO_STATUS_NO_MEMORY;
+	    return mask->base.status;
 	}
 
-	_cairo_glitz_surface_set_image (mask, image, 0, 0, width, height, 0, 0);
+	status = _cairo_glitz_surface_set_image (mask, image,
+		                                 0, 0, width, height, 0, 0);
 
 	cairo_surface_destroy(&image->base);
+
+	if (status)
+	    return status;
     }
 
     _cairo_glitz_surface_set_attributes (src, &attributes);
 
     glitz_composite (_glitz_operator (op),
 		     src->surface,
 		     mask->surface,
 		     dst->surface,
@@ -1433,34 +1446,35 @@ static cairo_int_status_t
                                       cairo_region_t	*region)
 {
     cairo_glitz_surface_t *surface = abstract_surface;
 
     if (region)
     {
 	glitz_box_t *box;
 	int	    n;
+	cairo_status_t status;
 
 	if (!surface->has_clip) {
             _cairo_region_init (&surface->clip);
             surface->has_clip = TRUE;
         }
 
-	if (_cairo_region_copy (&surface->clip, region) != CAIRO_STATUS_SUCCESS)
-        {
+	status = _cairo_region_copy (&surface->clip, region);
+	if (status) {
             _cairo_region_fini (&surface->clip);
 	    surface->has_clip = FALSE;
-            return CAIRO_STATUS_NO_MEMORY;
+            return status;
         }
 
         box = _cairo_glitz_get_boxes_from_region (&surface->clip, &n);
         if (box == NULL && n != 0) {
             _cairo_region_fini (&surface->clip);
 	    surface->has_clip = FALSE;
-            return CAIRO_STATUS_NO_MEMORY;
+            return _cairo_error (CAIRO_STATUS_NO_MEMORY);
         }
 
 	glitz_surface_set_clip_region (surface->surface, 0, 0, box, n);
 
         free (box);
     }
     else
     {
@@ -1560,18 +1574,20 @@ static cairo_glitz_area_t *
 			  int			  y,
 			  int			  width,
 			  int			  height)
 {
     cairo_glitz_area_t *area;
     int		       n = 4;
 
     area = malloc (sizeof (cairo_glitz_area_t));
-    if (!area)
+    if (!area) {
+	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return NULL;
+    }
 
     area->level   = level;
     area->x	  = x;
     area->y	  = y;
     area->width   = width;
     area->height  = height;
     area->root    = root;
     area->closure = NULL;
@@ -1783,17 +1799,17 @@ static cairo_status_t
 			     int			    height,
 			     const cairo_glitz_area_funcs_t *funcs)
 {
     root->max_level = max_level;
     root->funcs     = funcs;
 
     root->area = _cairo_glitz_area_create (root, 0, 0, 0, width, height);
     if (!root->area)
-	return CAIRO_STATUS_NO_MEMORY;
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     return CAIRO_STATUS_SUCCESS;
 }
 
 static void
 _cairo_glitz_root_area_fini (cairo_glitz_root_area_t *root)
 {
     _cairo_glitz_area_destroy (root->area);
@@ -1896,17 +1912,17 @@ static cairo_status_t
 	break;
     }
 
     if (!surface_format)
 	return CAIRO_INT_STATUS_UNSUPPORTED;
 
     font_private = malloc (sizeof (cairo_glitz_surface_font_private_t));
     if (!font_private)
-	return CAIRO_STATUS_NO_MEMORY;
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     font_private->surface = glitz_surface_create (drawable, surface_format,
 						  GLYPH_CACHE_TEXTURE_SIZE,
 						  GLYPH_CACHE_TEXTURE_SIZE,
 						  0, NULL);
     if (font_private->surface == NULL)
     {
 	free (font_private);
@@ -1982,17 +1998,17 @@ static cairo_status_t
     unsigned int			bpp, am, rm, gm, bm;
     cairo_int_status_t			status;
 
     glyph_private = scaled_glyph->surface_private;
     if (glyph_private == NULL)
     {
 	glyph_private = malloc (sizeof (cairo_glitz_surface_glyph_private_t));
 	if (!glyph_private)
-	    return CAIRO_STATUS_NO_MEMORY;
+	    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
 	glyph_private->area   = NULL;
 	glyph_private->locked = FALSE;
 
 	scaled_glyph->surface_private = (void *) glyph_private;
     }
 
     if (glyph_surface->width  > GLYPH_CACHE_MAX_WIDTH ||
@@ -2026,17 +2042,17 @@ static cairo_status_t
 				    TRUE, glyph_private))
 	    return CAIRO_STATUS_SUCCESS;
     }
 
     buffer = glitz_buffer_create_for_data (glyph_surface->data);
     if (!buffer)
     {
 	_cairo_glitz_area_move_out (glyph_private->area);
-	return CAIRO_STATUS_NO_MEMORY;
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
     }
 
     cairo_format_get_masks (glyph_surface->format, &bpp, &am, &rm, &gm, &bm);
 
     pf.fourcc		= GLITZ_FOURCC_RGB;
     pf.masks.bpp        = bpp;
     pf.masks.alpha_mask = am;
     pf.masks.red_mask   = rm;
@@ -2146,18 +2162,20 @@ static cairo_int_status_t
             goto FAIL1;
 
         size1 = num_glyphs * sizeof(void *);
         size2 = num_glyphs * sizeof(glitz_float_t) * 16;
         if (size1 >= INT32_MAX - size2)
             goto FAIL1;
 
 	data = malloc (size1 + size2);
-	if (!data)
+	if (!data) {
+	    _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	    goto FAIL1;
+	}
 
 	scaled_glyphs = (cairo_scaled_glyph_t **) data;
 	vertices = (glitz_float_t *) (data + num_glyphs * sizeof (void *));
     }
     else
     {
 	scaled_glyphs = stack_scaled_glyphs;
 	vertices = stack_vertices;
@@ -2435,17 +2453,17 @@ cairo_glitz_surface_create (glitz_surfac
     cairo_glitz_surface_t *crsurface;
     glitz_format_t *format;
 
     if (surface == NULL)
 	return (cairo_surface_t*) &_cairo_surface_nil;
 
     crsurface = malloc (sizeof (cairo_glitz_surface_t));
     if (crsurface == NULL) {
-	_cairo_error (CAIRO_STATUS_NO_MEMORY);
+	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return (cairo_surface_t*) &_cairo_surface_nil;
     }
 
     format = glitz_surface_get_format (surface);
     _cairo_surface_init (&crsurface->base, &cairo_glitz_surface_backend,
 			 _glitz_format_to_content(format));
 
     glitz_surface_reference (surface);
--- a/gfx/cairo/cairo/src/cairo-gstate.c
+++ b/gfx/cairo/cairo/src/cairo-gstate.c
@@ -57,16 +57,18 @@ static void
                                            const cairo_glyph_t *glyphs,
                                            int                  num_glyphs,
                                            cairo_glyph_t       *transformed_glyphs);
 
 cairo_status_t
 _cairo_gstate_init (cairo_gstate_t  *gstate,
 		    cairo_surface_t *target)
 {
+    cairo_status_t status;
+
     gstate->next = NULL;
 
     gstate->op = CAIRO_GSTATE_OPERATOR_DEFAULT;
 
     gstate->tolerance = CAIRO_GSTATE_TOLERANCE_DEFAULT;
     gstate->antialias = CAIRO_ANTIALIAS_DEFAULT;
 
     _cairo_stroke_style_init (&gstate->stroke_style);
@@ -88,20 +90,33 @@ cairo_status_t
     gstate->parent_target = NULL;
     gstate->original_target = cairo_surface_reference (target);
 
     _cairo_gstate_identity_matrix (gstate);
     gstate->source_ctm_inverse = gstate->ctm_inverse;
 
     gstate->source = _cairo_pattern_create_solid (CAIRO_COLOR_BLACK,
 						  CAIRO_CONTENT_COLOR);
-    if (gstate->source->status)
-	return CAIRO_STATUS_NO_MEMORY;
+
+    /* Now that the gstate is fully initialized and ready for the eventual
+     * _cairo_gstate_fini(), we can check for errors (and not worry about
+     * the resource deallocation). */
+
+    if (target == NULL)
+	return _cairo_error (CAIRO_STATUS_NULL_POINTER);
 
-    return target ? target->status : CAIRO_STATUS_NULL_POINTER;
+    status = target->status;
+    if (status)
+	return status;
+
+    status = gstate->source->status;
+    if (status)
+	return status;
+
+    return CAIRO_STATUS_SUCCESS;
 }
 
 /**
  * _cairo_gstate_init_copy:
  *
  * Initialize @gstate by performing a deep copy of state fields from
  * @other. Note that gstate->next is not copied but is set to NULL by
  * this function.
@@ -126,18 +141,22 @@ static cairo_status_t
     gstate->font_face = cairo_font_face_reference (other->font_face);
     gstate->scaled_font = cairo_scaled_font_reference (other->scaled_font);
 
     gstate->font_matrix = other->font_matrix;
 
     _cairo_font_options_init_copy (&gstate->font_options , &other->font_options);
 
     status = _cairo_clip_init_copy (&gstate->clip, &other->clip);
-    if (status)
+    if (status) {
+	_cairo_stroke_style_fini (&gstate->stroke_style);
+	cairo_font_face_destroy (gstate->font_face);
+	cairo_scaled_font_destroy (gstate->scaled_font);
 	return status;
+    }
 
     gstate->target = cairo_surface_reference (other->target);
     /* parent_target is always set to NULL; it's only ever set by redirect_target */
     gstate->parent_target = NULL;
     gstate->original_target = cairo_surface_reference (other->original_target);
 
     gstate->ctm = other->ctm;
     gstate->ctm_inverse = other->ctm_inverse;
@@ -165,17 +184,17 @@ void
 
     cairo_surface_destroy (gstate->target);
     gstate->target = NULL;
 
     cairo_surface_destroy (gstate->parent_target);
     gstate->parent_target = NULL;
 
     cairo_surface_destroy (gstate->original_target);
-    gstate->target = NULL;
+    gstate->original_target = NULL;
 
     cairo_pattern_destroy (gstate->source);
     gstate->source = NULL;
 }
 
 static void
 _cairo_gstate_destroy (cairo_gstate_t *gstate)
 {
@@ -202,18 +221,20 @@ static cairo_gstate_t*
 _cairo_gstate_clone (cairo_gstate_t *other)
 {
     cairo_status_t status;
     cairo_gstate_t *gstate;
 
     assert (other != NULL);
 
     gstate = malloc (sizeof (cairo_gstate_t));
-    if (gstate == NULL)
+    if (gstate == NULL) {
+	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return NULL;
+    }
 
     status = _cairo_gstate_init_copy (gstate, other);
     if (status) {
 	free (gstate);
 	return NULL;
     }
 
     return gstate;
@@ -228,20 +249,18 @@ static cairo_gstate_t*
  * copy into @gstate.  _cairo_gstate_restore() reverses this.
  **/
 cairo_status_t
 _cairo_gstate_save (cairo_gstate_t **gstate)
 {
     cairo_gstate_t *top;
 
     top = _cairo_gstate_clone (*gstate);
-
-    if (top == NULL) {
-	return CAIRO_STATUS_NO_MEMORY;
-    }
+    if (top == NULL)
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     top->next = *gstate;
     *gstate = top;
 
     return CAIRO_STATUS_SUCCESS;
 }
 
 /**
@@ -251,20 +270,18 @@ cairo_status_t
  * Reverses the effects of one _cairo_gstate_save() call.
  **/
 cairo_status_t
 _cairo_gstate_restore (cairo_gstate_t **gstate)
 {
     cairo_gstate_t *top;
 
     top = *gstate;
-
-    if (top->next == NULL) {
-	return CAIRO_STATUS_INVALID_RESTORE;
-    }
+    if (top->next == NULL)
+	return _cairo_error (CAIRO_STATUS_INVALID_RESTORE);
 
     *gstate = top->next;
 
     _cairo_gstate_destroy (top);
 
     return CAIRO_STATUS_SUCCESS;
 }
 
@@ -528,30 +545,30 @@ cairo_status_t
 	gstate->stroke_style.dash = NULL;
 	gstate->stroke_style.dash_offset = 0.0;
 	return CAIRO_STATUS_SUCCESS;
     }
 
     gstate->stroke_style.dash = _cairo_malloc_ab (gstate->stroke_style.num_dashes, sizeof (double));
     if (gstate->stroke_style.dash == NULL) {
 	gstate->stroke_style.num_dashes = 0;
-	return CAIRO_STATUS_NO_MEMORY;
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
     }
 
     memcpy (gstate->stroke_style.dash, dash, gstate->stroke_style.num_dashes * sizeof (double));
 
     dash_total = 0.0;
     for (i = 0; i < gstate->stroke_style.num_dashes; i++) {
 	if (gstate->stroke_style.dash[i] < 0)
-	    return CAIRO_STATUS_INVALID_DASH;
+	    return _cairo_error (CAIRO_STATUS_INVALID_DASH);
 	dash_total += gstate->stroke_style.dash[i];
     }
 
     if (dash_total == 0.0)
-	return CAIRO_STATUS_INVALID_DASH;
+	return _cairo_error (CAIRO_STATUS_INVALID_DASH);
 
     /* A single dash value indicate symmetric repeating, so the total
      * is twice as long. */
     if (gstate->stroke_style.num_dashes == 1)
 	dash_total *= 2;
 
     /* The dashing code doesn't like a negative offset, so we compute
      * the equivalent positive offset. */
@@ -601,34 +618,39 @@ void
     *matrix = gstate->ctm;
 }
 
 cairo_status_t
 _cairo_gstate_translate (cairo_gstate_t *gstate, double tx, double ty)
 {
     cairo_matrix_t tmp;
 
+    if (! (tx * tx >= 0.) || ! (ty * ty >= 0.)) /* check for NaNs */
+	return _cairo_error (CAIRO_STATUS_INVALID_MATRIX);
+
     _cairo_gstate_unset_scaled_font (gstate);
 
     cairo_matrix_init_translate (&tmp, tx, ty);
     cairo_matrix_multiply (&gstate->ctm, &tmp, &gstate->ctm);
 
     cairo_matrix_init_translate (&tmp, -tx, -ty);
     cairo_matrix_multiply (&gstate->ctm_inverse, &gstate->ctm_inverse, &tmp);
 
     return CAIRO_STATUS_SUCCESS;
 }
 
 cairo_status_t
 _cairo_gstate_scale (cairo_gstate_t *gstate, double sx, double sy)
 {
     cairo_matrix_t tmp;
 
-    if (sx == 0 || sy == 0)
-	return CAIRO_STATUS_INVALID_MATRIX;
+    if (sx * sy == 0.) /* either sx or sy is 0, or det == 0 due to underflow */
+	return _cairo_error (CAIRO_STATUS_INVALID_MATRIX);
+    if (! (sx * sx > 0.) || ! (sy * sy > 0.)) /* check for NaNs */
+	return _cairo_error (CAIRO_STATUS_INVALID_MATRIX);
 
     _cairo_gstate_unset_scaled_font (gstate);
 
     cairo_matrix_init_scale (&tmp, sx, sy);
     cairo_matrix_multiply (&gstate->ctm, &tmp, &gstate->ctm);
 
     cairo_matrix_init_scale (&tmp, 1/sx, 1/sy);
     cairo_matrix_multiply (&gstate->ctm_inverse, &gstate->ctm_inverse, &tmp);
@@ -636,16 +658,22 @@ cairo_status_t
     return CAIRO_STATUS_SUCCESS;
 }
 
 cairo_status_t
 _cairo_gstate_rotate (cairo_gstate_t *gstate, double angle)
 {
     cairo_matrix_t tmp;
 
+    if (angle == 0.)
+	return CAIRO_STATUS_SUCCESS;
+
+    if (! (angle * angle >= 0.)) /* check for NaNs */
+	return _cairo_error (CAIRO_STATUS_INVALID_MATRIX);
+
     _cairo_gstate_unset_scaled_font (gstate);
 
     cairo_matrix_init_rotate (&tmp, angle);
     cairo_matrix_multiply (&gstate->ctm, &tmp, &gstate->ctm);
 
     cairo_matrix_init_rotate (&tmp, -angle);
     cairo_matrix_multiply (&gstate->ctm_inverse, &gstate->ctm_inverse, &tmp);
 
@@ -991,17 +1019,17 @@ cairo_status_t
 
 cairo_status_t
 _cairo_gstate_in_stroke (cairo_gstate_t	    *gstate,
 			 cairo_path_fixed_t *path,
 			 double		     x,
 			 double		     y,
 			 cairo_bool_t	    *inside_ret)
 {
-    cairo_status_t status = CAIRO_STATUS_SUCCESS;
+    cairo_status_t status;
     cairo_traps_t traps;
 
     if (gstate->stroke_style.line_width <= 0.0) {
 	*inside_ret = FALSE;
 	return CAIRO_STATUS_SUCCESS;
     }
 
     _cairo_gstate_user_to_backend (gstate, &x, &y);
@@ -1057,17 +1085,17 @@ cairo_status_t
 
 cairo_status_t
 _cairo_gstate_in_fill (cairo_gstate_t	  *gstate,
 		       cairo_path_fixed_t *path,
 		       double		   x,
 		       double		   y,
 		       cairo_bool_t	  *inside_ret)
 {
-    cairo_status_t status = CAIRO_STATUS_SUCCESS;
+    cairo_status_t status;
     cairo_traps_t traps;
 
     _cairo_gstate_user_to_backend (gstate, &x, &y);
 
     _cairo_traps_init (&traps);
 
     status = _cairo_path_fixed_fill_to_traps (path,
 					      gstate->fill_rule,
@@ -1264,21 +1292,19 @@ cairo_status_t
     cairo_font_face_t *font_face;
     cairo_status_t status;
 
     font_face = _cairo_toy_font_face_create (family, slant, weight);
     if (font_face->status)
 	return font_face->status;
 
     status = _cairo_gstate_set_font_face (gstate, font_face);
-    if (status)
-	return status;
     cairo_font_face_destroy (font_face);
 
-    return CAIRO_STATUS_SUCCESS;
+    return status;
 }
 
 cairo_status_t
 _cairo_gstate_set_font_size (cairo_gstate_t *gstate,
 			     double          size)
 {
     _cairo_gstate_unset_scaled_font (gstate);
 
@@ -1286,16 +1312,19 @@ cairo_status_t
 
     return CAIRO_STATUS_SUCCESS;
 }
 
 cairo_status_t
 _cairo_gstate_set_font_matrix (cairo_gstate_t	    *gstate,
 			       const cairo_matrix_t *matrix)
 {
+    if (! _cairo_matrix_is_invertible (matrix))
+	return _cairo_error (CAIRO_STATUS_INVALID_MATRIX);
+
     _cairo_gstate_unset_scaled_font (gstate);
 
     gstate->font_matrix = *matrix;
 
     return CAIRO_STATUS_SUCCESS;
 }
 
 void
@@ -1552,34 +1581,33 @@ cairo_status_t
 			   const cairo_glyph_t *glyphs,
 			   int num_glyphs)
 {
     cairo_status_t status;
     cairo_pattern_union_t source_pattern;
     cairo_glyph_t *transformed_glyphs;
     cairo_glyph_t stack_transformed_glyphs[STACK_GLYPHS_LEN];
 
-
     if (gstate->source->status)
 	return gstate->source->status;
 
     status = _cairo_surface_set_clip (gstate->target, &gstate->clip);
     if (status)
 	return status;
 
     status = _cairo_gstate_ensure_scaled_font (gstate);
     if (status)
 	return status;
 
     if (num_glyphs <= STACK_GLYPHS_LEN) {
 	transformed_glyphs = stack_transformed_glyphs;
     } else {
 	transformed_glyphs = _cairo_malloc_ab (num_glyphs, sizeof(cairo_glyph_t));
 	if (transformed_glyphs == NULL)
-	    return CAIRO_STATUS_NO_MEMORY;
+	    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
     }
 
     _cairo_gstate_transform_glyphs_to_backend (gstate, glyphs, num_glyphs,
                                                transformed_glyphs);
 
     status = _cairo_gstate_copy_transformed_source (gstate, &source_pattern.base);
     if (status)
 	goto CLEANUP_GLYPHS;
@@ -1614,24 +1642,26 @@ cairo_status_t
     if (status)
 	return status;
 
     if (num_glyphs < STACK_GLYPHS_LEN)
       transformed_glyphs = stack_transformed_glyphs;
     else
       transformed_glyphs = _cairo_malloc_ab (num_glyphs, sizeof(cairo_glyph_t));
     if (transformed_glyphs == NULL)
-	return CAIRO_STATUS_NO_MEMORY;
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     _cairo_gstate_transform_glyphs_to_backend (gstate, glyphs, num_glyphs,
                                                transformed_glyphs);
 
+    CAIRO_MUTEX_LOCK (gstate->scaled_font->mutex);
     status = _cairo_scaled_font_glyph_path (gstate->scaled_font,
 					    transformed_glyphs, num_glyphs,
 					    path);
+    CAIRO_MUTEX_UNLOCK (gstate->scaled_font->mutex);
 
     if (transformed_glyphs != stack_transformed_glyphs)
       free (transformed_glyphs);
 
     return status;
 }
 #undef STACK_GLYPHS_LEN
 
--- a/gfx/cairo/cairo/src/cairo-hash-private.h
+++ b/gfx/cairo/cairo/src/cairo-hash-private.h
@@ -34,16 +34,17 @@
  *      Keith Packard <keithp@keithp.com>
  *	Graydon Hoare <graydon@redhat.com>
  *	Carl Worth <cworth@cworth.org>
  */
 
 #ifndef CAIRO_HASH_PRIVATE_H
 #define CAIRO_HASH_PRIVATE_H
 
+#include "cairo-compiler-private.h"
 #include "cairo-types-private.h"
 
 /* XXX: I'd like this file to be self-contained in terms of
  * includeability, but that's not really possible with the current
  * monolithic cairoint.h. So, for now, just include cairoint.h instead
  * if you want to include this file. */
 
 typedef cairo_bool_t
--- a/gfx/cairo/cairo/src/cairo-hash.c
+++ b/gfx/cairo/cairo/src/cairo-hash.c
@@ -144,26 +144,29 @@ struct _cairo_hash_table {
  * Return value: the new hash table or NULL if out of memory.
  **/
 cairo_hash_table_t *
 _cairo_hash_table_create (cairo_hash_keys_equal_func_t keys_equal)
 {
     cairo_hash_table_t *hash_table;
 
     hash_table = malloc (sizeof (cairo_hash_table_t));
-    if (hash_table == NULL)
+    if (hash_table == NULL) {
+	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	return NULL;
+    }
 
     hash_table->keys_equal = keys_equal;
 
     hash_table->arrangement = &hash_table_arrangements[0];
 
     hash_table->entries = calloc (hash_table->arrangement->size,
 				  sizeof(cairo_hash_entry_t *));
     if (hash_table->entries == NULL) {
+	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	free (hash_table);
 	return NULL;
     }
 
     hash_table->live_entries = 0;
     hash_table->iterating = 0;
 
     return hash_table;
@@ -324,17 +327,17 @@ static cairo_status_t
 	if (hash_table->arrangement == &hash_table_arrangements[0])
 	    return CAIRO_STATUS_SUCCESS;
 	tmp.arrangement = hash_table->arrangement - 1;
     }
 
     new_size = tmp.arrangement->size;
     tmp.entries = calloc (new_size, sizeof (cairo_hash_entry_t*));
     if (tmp.entries == NULL)
-	return CAIRO_STATUS_NO_MEMORY;
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     for (i = 0; i < hash_table->arrangement->size; ++i) {
 	if (ENTRY_IS_LIVE (hash_table->entries[i])) {
 	    entry = _cairo_hash_table_lookup_internal (&tmp,
 						       hash_table->entries[i],
 						       TRUE);
 	    assert (ENTRY_IS_FREE(*entry));
 	    *entry = hash_table->entries[i];
--- a/gfx/cairo/cairo/src/cairo-hull.c