[cairo] UserFontFace vs FtFontFace management (cairomm)

Ian Britten britten at caris.com
Tue Dec 2 09:59:55 PST 2008


Hi all,
[ NB - I'm pretty sure this is cairomm-specific ... ]

Are users supposed to be able to create+manage UserFontFace
objects the same way as FtFontFace objects?  If yes, then I'm
wondering about a crash I'm seeing...
[ If no, then the docs should maybe clarify the difference ]

I'm using libcairomm1.0_1-1.7.0-2mdv2008.1
Given two cases like this:

         if ( /* some condition */ )
         {
                 Cairo::RefPtr<Cairo::UserFontFace> uFace(
                         Cairo::UserFontFace::create());
                 uFace->set_render_glyph_func(
                         sigc::ptr_fun(drawUserGlyph));
//              this->holder.push_back(uFace);
                 this->context.set_font_face(uFace);
         }
         else
         {
                 Cairo::RefPtr<Cairo::FtFontFace> fFace(
                         Cairo::FtFontFace::create(ftFace,
                                                   load_flags));
                 this->context.set_font_face(fFace);
         }
         this->context.show_glyphs(glyphs);

In both cases, the FontFace is created, set on the context,
then released.  The context is a class member, and is only
flushed/deleted later.
- If I only go through the second (FT) case, there's no problems.
- If I go through the first (User) case, I get a crash (or errors
   from Valgrind(*)) later on, when the context/surface is being
   flushed/deleted.
- OTOH, if I go through the first case, but also maintain the
   constructed face in a std::list until later, then there is
   no problem.

(*) The problem, as reported by Valgrind, seems to be that
Cairo::UserFontFace::render_glyph_cb() (fontface.cc:287) is
accessing something that was deleted in
Cairo::UserFontFace::~UserFontFace()() (fontface.cc:330).
[ I can provide full traces, if necessary ]

It could be that I've missed something, or am doing something
wrong (If so, pointers welcome!).  I'm just gradually roughing
in some of this stuff and hit this, so I figured I'd point it
out.  Lemme know if you need more details.
Ian


More information about the cairo mailing list