* 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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
diff --git a/ChangeLog b/ChangeLog
index 80b5e6c..a168039 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 <wl@gnu.org>
* docs/GPL.txt: Update postal address of FSF.
diff --git a/include/freetype/ftbitmap.h b/include/freetype/ftbitmap.h
index 909e836..2d9e368 100644
--- a/include/freetype/ftbitmap.h
+++ b/include/freetype/ftbitmap.h
@@ -75,10 +75,12 @@ FT_BEGIN_HEADER
/* 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. */
diff --git a/include/freetype/internal/ftobjs.h b/include/freetype/internal/ftobjs.h
index 4b92aed..e8e3ee7 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 611818a..0f74d3f 100644
--- 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;
+
+ 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;
}