[cairo] font lifetime
Owen Taylor
otaylor at redhat.com
Wed Jan 26 07:44:46 PST 2005
On Wed, 2005-01-26 at 16:17 +0100, Alexander Larsson wrote:
> On Wed, 2005-01-26 at 09:49 -0500, Owen Taylor wrote:
>
> > I'm not using cairo_ft_font_create_for_ft_face() in Pango at the moment,
> > so I'd be interested in knowing what you need out of it for the Xpdf
> > backend... other than the destroy notifier issue, is it doing what
> > you want?
>
> Its a bit sucky to use actually. You can create a cairo_font_t using it,
> and then set it using cairo_set_font(). However, any time you change any
> state in the cairo_t "_cairo_gstate_unset_font (gstate)" will be called,
> and the next time you render text cairo_gstate_ensure_font() will try
> create a new font using _cairo_font_create() instead of your own font.
The expectation with the new API is that you'll set a font just before
using it.... we could remove the unsetting, but then you get silent
metric screwiness rather than the wrong font. What sort of gstate
changes are you making that are unsetting the font? It should just
be transform and target surface that unset the font.
> Also, I'm not sure things are actually working right for me with several
> sizes of a font. On the xpdf side i have an object that basically refers
> to an scaled font, which owns the FT_Face. When i set the cairo font i
> create a new cairo_font from this face, which in turn creates an
> unscaled cairo font. When i do this twice for different sizes, won't i
> get two cairo_unscaled_font_t referencing the same FT_Face? Won't this
> break, since the unscaled font sets the size of the FT_Face?
Yes, you can't share the same FT_Face between multiple fonts created
with cairo_ft_font_create_for_ft_face() since Cairo will be unaware
of the sharing.
> 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.
That's certainly possible, all the bits are there internally, they'd
just have to be exported.
There's a bit of a problem in that there isn't necessarily and
"unscaled font" for every backend. The Win32 font backend, for example,
probably won't have one. So, you can't have
cairo_font_create_for_unscaled_font()
cairo_font_get_unscaled_font()
Just:
cairo_ft_font_create_for_unscaled_font()
cairo_ft_font_get_unscaled_font()
Regards,
Owen
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050126/f813c6c3/attachment.pgp
More information about the cairo
mailing list