diff --git a/ChangeLog b/ChangeLog index 80b5e6c88..a1680399d 100644 --- 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 * docs/GPL.txt: Update postal address of FSF. diff --git a/include/freetype/ftbitmap.h b/include/freetype/ftbitmap.h index 909e836a0..2d9e36822 100644 --- a/include/freetype/ftbitmap.h +++ b/include/freetype/ftbitmap.h @@ -75,10 +75,12 @@ FT_BEGIN_HEADER /* Copies an bitmap into another one. */ /* */ /* */ - /* source :: A handle to the source bitmap. */ + /* library :: A handle to a library object. */ + /* */ + /* source :: A handle to the source bitmap. */ /* */ /* */ - /* target :: A handle to the target bitmap. */ + /* target :: A handle to the target bitmap. */ /* */ /* */ /* FreeType error code. 0 means success. */ diff --git a/include/freetype/internal/ftobjs.h b/include/freetype/internal/ftobjs.h index 4b92aed05..e8e3ee79a 100644 --- a/include/freetype/internal/ftobjs.h +++ b/include/freetype/internal/ftobjs.h @@ -159,7 +159,7 @@ FT_BEGIN_HEADER 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 ); diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c index 611818a40..0f74d3f7f 100644 --- a/src/base/ftobjs.c +++ b/src/base/ftobjs.c @@ -686,6 +686,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; + + 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]; + + + 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; - if ( clazz->done ) - clazz->done( cmap ); + ft_cmap_done_internal( cmap ); - FT_FREE( cmap ); + break; + } + } } } @@ -2319,7 +2366,7 @@ return error; Fail: - FT_CMap_Done( cmap ); + ft_cmap_done_internal( cmap ); cmap = NULL; goto Exit; }