[cairo] Can't get cairo_ft_font_create_for_ft_face() to work right

Carl Worth cworth at redhat.com
Fri Mar 18 05:52:56 PST 2005


On Thu, 17 Mar 2005 22:47:39 -0500, Owen Taylor wrote:
> On Thu, 2005-03-17 at 18:54 -0800, Ned Konz wrote:
> > I'm sure this is a stupid mistake on my part, but...

Not really. The current API is out to get you. ;-)

>     cairo_set_font(cr, font);
> 
> [...]
> 
>         cairo_scale_font(cr, fontSize);

The call sequence above looks totally reasonable to me, and did what
you want pre-0.4.0, but doesn't anymore, (as you discovered).

I should have made this more clear in the 0.4.0 release notes, but I
didn't fully understand the implications of the API changes.

Now that I do understand things better, I think that we want to make
some changes. Owen, Keith, and I have been bouncing some ideas around
in IRC, but haven't come up with any completely satisfactory yet.

As of what's in 0.4.0, the model is that a cairo_font_t is pre-scaled
for some desired device-space size. This interface fits naturally with
the way pango wants to do text layout, and the current implementation
is well-suited for pango in terms of performance.

The problem that the pre-scaled font model raises is what happens when
cairo wants to scale the text differently? One place this question
comes up is with cairo_scale_font, and one answer, (as the current
documentation hints at), is as Owen replied:

> scale_font refers only to the font selected by cairo_select_font(),
> calling it after set_font() will clear the previously set font.

If this is the model we stick with, then we clearly need to rework
something here. There's nothing obvious about the fact that scale_font
works after the user chooses a font with select_font, but fails after
the user chooses a font with set_font.

But, even if we renamed these functions somehow to make that
distinction more obvious, there are still problems with the pre-scaled
font model. Namely, beyond cairo_scale_font, the CTM can also scale
text. What happens when the CTM tries to scale a pre-scaled font?

We haven't found a satisfactory answer for that yet.

My inclination is to eliminate the notion of a pre-scaled font from
the cairo API. But I have yet to demonstrate that we can do that
without inflicting a performance penalty on the likes of pango.

> It could be argued that cairo_ft_font_create_for_ft_font() isn't a
> terribly useful in the present form - see
> 
>  http://lists.freedesktop.org/archives/cairo/2005-January/002805.html

There, Alex requests something similar to what I want:

> On Wed, 2005-01-26 at 16:17 +0100, Alexander Larsson wrote:
> > What you really want is a way to create a cairo_unscaled_font_t from the
> > face, and then scaled versions from that. I think.

But Owen says that this kind of interface won't work very well with
the win32 font backend at least (see the link above for more details).

So, I don't know what the right answer is, but I'm not completely
satisfied with what we have right now, (and with Alex's work on xpdf,
and now Ned's, we've got two applications that don't find it natural).

-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/20050318/b3db2ccb/attachment.pgp


More information about the cairo mailing list