freetype
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ft] FT_Face_Copy()?


From: Ian Britten
Subject: Re: [ft] FT_Face_Copy()?
Date: Fri, 01 May 2009 08:48:06 -0300
User-agent: Thunderbird 2.0.0.21 (X11/20090330)

Werner LEMBERG wrote:
I didn't see any sort of way to copy an allocated FT_Face (analogous
to the existing FT_Glyph_Copy()).

- Could this be added to a future version?
- In the meantime, could someone suggest a safe/efficient
  work-around?  Currently, I'm having to go through FT_Open_Face()
  again, but re-opening the font file is probably not the most
  efficient approach to copying an in-memory data structure...

Please elaborate and give an example what you want to achieve.

Ya, sorry - I probably should have done that to begin with...  :P

In our code, we use FTC_Manager_New()/etc to cache the various
faces, glyphs, cmaps, etc.  This is working fine, and isn't why
I need/want this.

I've recently added Cairo (http://cairographics.org/) support to
our code, for exporting to PDF/etc.  In order to get Cairo to render
our text correctly, I use their FT-specific rendering hooks,
specifically cairo_ft_font_face_create_for_ft_face()
http://cairographics.org/manual/cairo-ft-font.html#cairo-ft-font-face-create-for-ft-face

Unfortunately, this connection exposes a memory-management mismatch,
which is what I'm trying to simplify with this request:
- The FT_Face I get from FT is from the cache, and may be de-cached
  at any point as more text is subsequently retrieved and rendered.
  Note the de-caching is done by FT, not me, and thus the suggestion
  Cairo offers isn't viable.
- Cairo accepts a FT_Face pointer, and hangs on to it for subsequent
  use, expecting it to always be valid.  Cairo doesn't render
  immediately, but instead renders in its final 'finish', which is
  when *all* the FT_Face objects I've passed it are needed.
- Cairo doesn't use any FT cache, and there's no hooks to get Cairo
  to re-request my FT_Face again (via my FT cache) when it actually
  needs to use it.

Thus, my solution is to:
- Get my (cached) FT_Face from my FT cache.
- Make a deep copy it, and maintain it in my own separate cache.
- Maintain the entire cache contents until the export/drawing to
  Cairo is done.

It's for that 'copy' step that I was looking for some sort of
FT_Face_Copy() helper.
As I mentioned, I have a solution that seems to work, but it's
sub-optimal (IMHO).  Thus, I was just wondering if this would be
a worthwhile addition to FT (Presumably the implementation would
be better than my solution)

Feedback, questions, suggestions, etc welcome.
Many thanks!
Ian




reply via email to

[Prev in Thread] Current Thread [Next in Thread]