[cairo] UserFontFace vs FtFontFace management (cairomm)

Jonathon Jongsma jonathon at quotidian.org
Tue Dec 2 12:13:40 PST 2008


Ian Britten wrote:
> 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

It's quite possible that you've hit a bug since this stuff was only implemented in cairomm 
recently (and I've held off on releasing a stable 1.8.0 of cairomm precisely because this 
stuff hasn't been well-tested yet).  In fact, you're very likely the first person to have 
tried to use it.  I will look into it.
-- 
jonner


More information about the cairo mailing list