ref: e70371c410fc571c7fad78d0f1b9867447a62145
parent: 3a36ef7e6ea40d4763a74db8fef6da0e136edc33
author: Werner Lemberg <[email protected]>
date: Fri May 27 02:01:28 EDT 2005
* src/base/ftobjs.c (ft_cmap_done_internal): New function. (FT_CMap_Done): Remove cmap from cmap list. (destroy_charmaps, FT_CMap_New): Don't call FT_CMap_Done but ft_cmap_done_internal.
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,11 @@
* src/base/ftsynth.c (FT_GlyphSlot_Embolden): Initialize `error'.
+ * src/base/ftobjs.c (ft_cmap_done_internal): New function.
+ (FT_CMap_Done): Remove cmap from cmap list.
+ (destroy_charmaps, FT_CMap_New): Don't call FT_CMap_Done but
+ ft_cmap_done_internal.
+
2005-05-26 Werner Lemberg <[email protected]>
* docs/GPL.txt: Update postal address of FSF.
--- a/include/freetype/ftbitmap.h
+++ b/include/freetype/ftbitmap.h
@@ -75,10 +75,12 @@
/* Copies an bitmap into another one. */
/* */
/* <Input> */
- /* source :: A handle to the source bitmap. */
+ /* library :: A handle to a library object. */
/* */
+ /* source :: A handle to the source bitmap. */
+ /* */
/* <Output> */
- /* target :: A handle to the target bitmap. */
+ /* target :: A handle to the target bitmap. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
--- a/include/freetype/internal/ftobjs.h
+++ b/include/freetype/internal/ftobjs.h
@@ -159,7 +159,7 @@
FT_CharMap charmap,
FT_CMap *acmap );
- /* destroy a charmap (don't remove it from face's list though) */
+ /* destroy a charmap and remove it from face's list */
FT_BASE( void )
FT_CMap_Done( FT_CMap cmap );
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -687,6 +687,10 @@
static void
+ ft_cmap_done_internal( FT_CMap cmap );
+
+
+ static void
destroy_charmaps( FT_Face face,
FT_Memory memory )
{
@@ -698,7 +702,7 @@
FT_CMap cmap = FT_CMAP( face->charmaps[n] );
- FT_CMap_Done( cmap );
+ ft_cmap_done_internal( cmap );
face->charmaps[n] = NULL;
}
@@ -2255,20 +2259,63 @@
}
+ static void
+ ft_cmap_done_internal( FT_CMap cmap )
+ {
+ FT_CMap_Class clazz = cmap->clazz;
+ FT_Face face = cmap->charmap.face;
+ FT_Memory memory = FT_FACE_MEMORY(face);
+
+
+ if ( clazz->done )
+ clazz->done( cmap );
+
+ FT_FREE( cmap );
+ }
+
+
FT_BASE_DEF( void )
FT_CMap_Done( FT_CMap cmap )
{
if ( cmap )
{
- FT_CMap_Class clazz = cmap->clazz;
- FT_Face face = cmap->charmap.face;
- FT_Memory memory = FT_FACE_MEMORY(face);
+ FT_Face face = cmap->charmap.face;
+ FT_Memory memory = FT_FACE_MEMORY( face );
+ FT_Error error;
+ FT_Int i, j;
- if ( clazz->done )
- clazz->done( cmap );
+ for ( i = 0; i < face->num_charmaps; i++ )
+ {
+ if ( (FT_CMap)face->charmaps[i] == cmap )
+ {
+ FT_CharMap last_charmap = face->charmaps[face->num_charmaps - 1];
- FT_FREE( cmap );
+
+ if ( FT_RENEW_ARRAY( face->charmaps,
+ face->num_charmaps,
+ face->num_charmaps - 1 ) )
+ return;
+
+ /* remove it from our list of charmaps */
+ for ( j = i + 1; j < face->num_charmaps; j++ )
+ {
+ if ( j == face->num_charmaps - 1 )
+ face->charmaps[j - 1] = last_charmap;
+ else
+ face->charmaps[j - 1] = face->charmaps[j];
+ }
+
+ face->num_charmaps--;
+
+ if ( (FT_CMap)face->charmap == cmap )
+ face->charmap = NULL;
+
+ ft_cmap_done_internal( cmap );
+
+ break;
+ }
+ }
}
}
@@ -2319,7 +2366,7 @@
return error;
Fail:
- FT_CMap_Done( cmap );
+ ft_cmap_done_internal( cmap );
cmap = NULL;
goto Exit;
}