[cairo] Problem with cairo_set_font_face (cr, NULL);
Peter Clifton
pcjc2 at cam.ac.uk
Mon Aug 11 02:46:04 PDT 2008
On Sun, 2008-08-10 at 23:22 -0400, Behdad Esfahbod wrote:
> -----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.
NULL was documented as a valid parameter to pass....:
cairo_set_font_face ()
void cairo_set_font_face (cairo_t *cr,
cairo_font_face_t *font_face);
Replaces the current cairo_font_face_t object in the cairo_t with
font_face. The replaced font face in the cairo_t will be destroyed if
there are no other references to it.
cr : a cairo_t
font_face : a cairo_font_face_t, or NULL to restore to the default font
I can't use the new cairo_toy_font_face_create() API, otherwise I could
just assume the userfont API existed too, and use that. The idea was
that the face generation was hidden away in a function, and the text
rendering just calls cairo_set_font_face (..) on the returned face.
This hid the fact that userfont API might not exist from my text
rendering in a quite simple way. Until your recent addition, there was
no API to get a toy font face back directly.
> However, I'm not sure why you need to rely on this in your code at all.
Its not production code, just a change in behaviour I noticed. I'll
probably get round to using Pango to lay out the text at some point.
Currently my code doesn't work with multi-line text, as I'm just
throwing cairo the whole string, newlines and all. (Most text in
electrical schematics is short one-liners, so for a proof-of-concept it
doesn't matter).
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