[cairo] Error Loading FreeType Glyphs

Bobby Salazar bobby8934 at inbox.com
Sun Oct 19 14:53:21 PDT 2008


Ok, I've made some progress on this problem. It looks like this problem appear after I updated to a new version of Cairo, but due to the fact that it often works, I didn't notice the bug until just recently.

I've bisected the git tree from the version I know that works and found the revision(s) that broke the functionality. This took quite a few hours to accomplish, since I am using FreeType under Win32 and I have to manually strip out the fontconfig stuff, which is unneeded and doesn't work on Win32 anyways (that I'm aware of). What are the chances that we could get someone to add a new cairo feature #define to separate the fontconfig stuff from the FreeType stuff? FreeType fonts in no way depend on fontconfig, so it doesn't make sense to require it.

Anyways, back to the problem. Here are the revisions that broke this functionality:

2008-6-01 3f5051fab161da167fdedcdad0280da1f57a1828   As of this commit cairo-ft-font.c seems to work fine
2008-6-05 60cf2ef8449e1fd09fe0f2d8c8dc5fa2bb855e5a   As of this commit cairo-ft-font.c seems to render fine, but I get tons of runtime asserts
2008-6-10 c5b1674349154049646b491cac571d93328b5e0c   As of this commit cairo-ft-font.c seems to render fine, but I get tons of runtime asserts (same as above)
2008-6-10 4210bab61a1f680b0ca393e1f5fec0549ddcfcec   As of this commit cairo-ft-font.c is broken and some glyphs are randomly not rendered

I am very new to git, so I hope that I provided enough information about the broken revisions of cairo-ft-font.c so that everyone can figure out which ones I'm talking about.

I don't quite understand all the changes made in those revisions, but during my testing I noticed that if I simply changed _cairo_ft_unscaled_font_create_from_face() from it's last revision as of 2008-6-10 to this, everything works again:

static cairo_ft_unscaled_font_t *
_cairo_ft_unscaled_font_create_from_face (FT_Face face)
{
    cairo_status_t status;
    cairo_ft_unscaled_font_t *unscaled;

    unscaled = malloc (sizeof (cairo_ft_unscaled_font_t));
    if (unscaled == NULL) {
	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
	return NULL;
    }

    status = _cairo_ft_unscaled_font_init (unscaled, TRUE, NULL, 0, face);
    if (status) {
	free (unscaled);
	return NULL;
    }

    return unscaled;
    //return _cairo_ft_unscaled_font_create_internal (TRUE, NULL, 0, face);
}


Since I've been looking over this file for so long now that my eyes are starting to glaze over, would somebody else care to take a peek and see if they can find any obvious problems why the code no longer works (on Win32 at least)?

> -----Original Message-----
> From: bobby8934 at inbox.com
> Sent: Sat, 18 Oct 2008 16:06:27 -0800
> To: cairo at cairographics.org
> Subject: [cairo] Error Loading FreeType Glyphs
> 
> Hello,
> 
> I am seeing a weird error using Cairo to render some text. It is sort of
> out of the blue, as I have been using pretty much the same code to render
> text for a very long time now. But all of a sudden I am seeing a
> condition where, depending on the width and height of the surface I
> render to, some characters disappear because FreeType returns an error.
> So drag-resizing a window causes the text to lose characters and gain
> them again with no obvious clues why.
> 
> I have tracked this down to the call to _cairo_ft_scaled_glyph_init()
> where it calls FT_Load_Glyph() to load, in this case, the letter 'g'.
> FT_Load_Glyph() returns error 36 (which is FT_Err_Invalid_Size_Handle).
> 
> One other thing I have noticed is that when I maximize the window, the
> rendered text actually shrinks in size even though I pass the same height
> to create the scaled font. This also seems to be completely random, some
> window sizes give correct looking text and some give text that looks
> slightly shrunk.
> 
> After several hours of debugging I do not feel I am any closer to
> figuring out why this is happening. When I drag a window larger, I can
> have it at one size and see the letter 'g' characters appear, then drag
> it a few pixels larger and those characters fail to load, and then drag
> the window a few pixels larger and they come back again. So what gives?
> Has anyone seen a problem like this before?
> 
> Any help is appreciated!
> 
> ____________________________________________________________
> FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!
> Check it out at http://www.inbox.com/earth
> _______________________________________________
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo


More information about the cairo mailing list