[cairo] using cairo in c++

Carl Worth cworth at cworth.org
Wed Oct 12 11:28:48 PDT 2005


On Wed, 12 Oct 2005 09:58:21 -0700, Bill Spitzak wrote:
>   typedef struct cairo cairo_t;
> 
> will work. However this should not be necessary. I believe the 
> definition of cairo_t has changed in cairo 1.0.0 and the x.h file needs 
> to be changed to match.

Yes. It is now:

    typedef struct _cairo cairo_t;

But it seems that games like this are inherently fragile and really
shouldn't be done anyway.

> The problem is that I need to declare the existence of the static cairo 
> context and I tried to put it into an existing header file. This is the 
> primary reason I asked a long time ago for cairo to use a thread-static 
> context like OpenGL, as the need to declare this context object and get 
> it to code that calls cairo is a serious impediment to adding cairo 
> drawing to existing code. If cairo had not required this context 
> argument then fltk/x.h would not even be necessary, instead you would 
> just include cairo.h directly.

I thought the conclusion of that discussion was that if some code
wanted an interface with an implicit thread-local-storage-based
context, then that interface could be layered on top of the
explicit-context interface in cairo. Any reason that won't work for
you here?

> PS: other question. I would like to get fltk to use the "toy" font 
> interface but am in desperate need of a font listing. Will the Xft code 
> that lists fonts produce a reasonable subset of the names the "toy" 
> interface takes? Also on Windows will using their font listing produce a 
> reasonable subset? By "reasonable subset" I mean 90% or so of the fonts 
> the user would actually care about, and NO names that don't work.

One thing we've talked about is documenting cairo_select_font_face to
be guaranteed to support a short list of font family names. I thought
we had an open bug report on this. I can't find that bug report now,
but I think it recommended using the CSS2 generic font family names,
which appear to be:

	sans, sans-serif, cursive, fantasy, monospace
	http://www.w3.org/TR/REC-CSS2/fonts.html#generic-font-families

What I would also like to do is to fix things so that no name doesn't
work, (that is, one will always get at least _some_ font, and never an
error from cairo_select_font_face). And I'd even like the
cairo_show_text interface to guarantee that _some_ glyph gets drawn
for every character, even if cairo has to get different glyphs from
different fonts, or even just create some glyph, (perhaps in the style
of pango hex boxes), for missing glyphs.

So, those are the kinds of guarantees I'd like to provide, which
should pretty much let you use any font listing approach you see
fit. And if you need better guarantees between the font lister and the
font selector, (such as, say, error reporting from selection), then
you would use the "native" selector that goes along with whatever font
lister you are using, and call cairo_set_font_face rather than
cairo_select_font_face.

Does that sound reasonable to you?

-Carl

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20051012/20173043/attachment.pgp


More information about the cairo mailing list