[cairo] Problem with cairo_set_font_face (cr, NULL);

Peter Clifton pcjc2 at cam.ac.uk
Sun Aug 10 19:15:30 PDT 2008


On Mon, 2008-08-11 at 01:35 +0100, Peter Clifton wrote:
> Hi,
> 
> Apologies for the lack of in-depth debugging with this one, but I've
> just rebuild cairo from GIT, and found that my app isn't rendering text
> correctly. It is using toy text for the moment, and relies on the fact
> it can call:
> 
> cairo_set_font_face (cr, NULL);

I checked to make sure I wasn't doing something stupid before. The
documentation for cairo_set_font_face states setting font_face to NULL
is legal, so this probably is a bug.

This commit looks like it might be the problem, although I've not tested
reverting it:

commit b67d34e960fa07cfafb13e3a5b5b4a63cfb024d3
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Aug 7 15:42:58 2008 -0400

    [gstate] Check for NULL font_face in _cairo_gstate_set_font_face

diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c
index b23d0b6..3160d07 100644
--- a/src/cairo-gstate.c
+++ b/src/cairo-gstate.c
@@ -1466,7 +1466,10 @@ cairo_status_t
 _cairo_gstate_set_font_face (cairo_gstate_t    *gstate,
                             cairo_font_face_t *font_face)
 {
-    if (font_face && font_face->status)
+    if (font_face == NULL)
+       return CAIRO_STATUS_NULL_POINTER;
+
+    if (font_face->status)
        return font_face->status;
 
     if (font_face != gstate->font_face) {


Regards,

-- 
Peter Clifton

Electrical Engineering Division,
Engineering Department,
University of Cambridge,
9, JJ Thomson Avenue,
Cambridge
CB3 0FA

Tel: +44 (0)7729 980173 - (No signal in the lab!)



More information about the cairo mailing list