[cairo] Cairo vs. Xft glyph rendering

Ian Osgood iano at quirkster.com
Tue Dec 12 07:43:46 PST 2006

On Dec 12, 2006, at 12:39 AM, Behdad Esfahbod wrote:

> On Mon, 2006-12-11 at 14:08 -0800, Daniel Amelang wrote:
>> It looks really good to me. The way you merged the show8/16/32
>> functions is a little scary (I wasn't aware that the various Elt*
>> structures were binary compatible, but now I do!), but without
>> something like a c++ template function, it's probably the best we can
>> get. I think you did great under the circumstances.
> I had the same feeling as well, but figured that Xft is already doing
> that.  So it should be fine.  The funny thing is that I don't think
> there's any guarantee that on other systems (say, Darwin), those  
> structs
> are binary compatible.  But I don't expect that to happen.
> One thing that Xft didn't do but I am, is to use a function pointer  
> for
> the XRenderCompositeText* call.  They simply take pointers to  
> different
> things.  So again, I think it's a safe assumption.
>> I see this quite a bit in various corners of cairo (and in your  
>> latest
>> patch):
>> glyph.index = (unsigned long) -1;
>> Would it be safer/more readable to define something like
>> CAIRO_GLYPH_INDEX_SKIP in cairoint.h?
> Done.  Except that I chose GLYPH_INDEX_SKIP and just did it there.  I
> don't think a global thing like that makes much sense.  If another
> backends needs to still two values off the index range, let them  
> do.  We
> all know that you can take finitely as many as you wish off the top of
> them range with no problem, but I don't see enough reason to declare
> that globally.
> In Pango however, we do that, because that's part of the API, not an
> implementation detail like here.
>> Also, I see a lot of stuff like this that makes me wonder if some
>> additional #defines could make the code more understandable:
>>> width = max_index < 256 ? 1 : max_index < 65536 ? 2 : 4;
> I personally prefer one-off uses to be inline.  It's easier to  
> audit at
> least.  But for anything repeating at least twice, I agree.  In this
> case, the other time I'm handling max_index, the code is a bit  
> different
> since, silly optimization maybe, because I know width can only go up,
> not down.
>> Anyway, congratulations for amazing us once again with some great
>> work!
> Thanks.  It's pushed now, after fixing the XXXs, and testing that the
> glyph skipping is actually working.
>> Dan
> -- 
> behdad
> http://behdad.org/
> "Those who would give up Essential Liberty to purchase a little
>  Temporary Safety, deserve neither Liberty nor Safety."
>         -- Benjamin Franklin, 1759

Just curious, but did you look at the XCB backend to inform your  
recent changes? The XCB renderutil wrapper for glyphs has a similar  

Are you planning to update the XCB backend to match your recent Xlib  


More information about the cairo mailing list