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

Behdad Esfahbod behdad at behdad.org
Sun Aug 10 20:22:40 PDT 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Peter Clifton wrote:
> 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.

Interesting.  I admit I didn't check the docs before making this change.
 However, I did document the newly added cairo_toy_font_face_create() to
create the default face if family is "".  If we've allowed NULL before,
which is what you imply, I'll go fix that to use NULL for default face.
It just comes as a surprise to me.

However, I'm not sure why you need to rely on this in your code at all.

Cheers,

behdad


> 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,
> 

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iEYEARECAAYFAkifsIAACgkQn+4E5dNTERXZiACgvyfqHQdnzeIDtcXpaH7GGwqp
JV8AnjRzu5LUaGeEtjzuRlBEQu9QNPpm
=ERvo
-----END PGP SIGNATURE-----


More information about the cairo mailing list