[Top][All Lists]

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

[Freetype] FT_Done_* problems.

From: Giardina Marina
Subject: [Freetype] FT_Done_* problems.
Date: Wed, 19 Dec 2001 20:14:51 +0100

I'm new to this mailing list. However, I'll be brief.
I've overlooked all the documentation that I've found with freetype/freetype
2 but I've STILL issues when rendering some text.

Look at my generalized code (I've omitted some variables, but should be
clear enough):

// initialize the library
FT_Library handle;
FT_Face ftFace;
FT_New_Face(handle, "a path here", 0, &ftFace);
FT_Set_Char_Size(ftFace, 0, (size * 64), 0, 0);

// load a bunch of glyphs
for (size_t i = 0; i < XX; i++)
  FT_Load_Glyph(ftFace, index[i], FT_LOAD_DEFAULT);
  FT_Get_Glyph(ftFace->glyph, &image[i]);
  FT_Glyph_Transform(image[i], &affine, NULL);

// transform everything
for (size_t i = 0; i < XX; i++)
  FT_Glyph_Copy(image[i], &trImages[i])
  FT_Glyph_Transform(trImages[i], &affine, NULL);

// render
for (size_t i = 0; i < XX; i++)
  FT_Glyph glyph = trImages[i];

  FT_Glyph_To_Bitmap(&glyph, ft_render_mode_normal, NULL, false);
  FT_BitmapGlyph bitmap = (FT_BitmapGlyph)(glyph);

  // draw here

  FT_Done_Glyph(glyph); //<-

// cleanup trImages
for (size_t i = 0; i < XX; i++)
  FT_Done_Glyph(trImages[i]); //<-

// cleanup image
for (size_t i = 0; i < XX; i++)

// close everything

As you may see, i COPY (with FT_Get_Glyph) a glyph from the slot to a
Than i store a transformed copy of it in trImages, THEN i copy it again (by
FT_Glyph_To_Bitmap with last parameter set as 0) to a bitmap.

Then, i free the temporary bitmap, trImages and image

What you may expect? Only crashes. After one day of debugging I've seen stat
the problem is the release of the memory in FT_Done_Glyph of bitmap and
trImages (see the //<- comment).

If I don't release memory in these two areas everything seems to work fine.
But, who will release this memory?
I can't forget to release memory here, I'm not on a fork() application and
the library
gets initialized/destroyed several times to free as memory as possible.

Can, please, someone clarify this strange behavior?
I'm running freetype 2.0.5, on a solaris 8 host (gcc 2.95.x and 3.x) (shared

Thanks, and sorry for the intrusive question :)


reply via email to

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