Properly free memory of SVG document referenced in `slot->other'.
* include/freetype/freetype.h: Add `FT_FACE_FLAG_SVG' to indicate the presence of an SVG table in the face. * src/base/ftobjs.c (ft_glyphslot_init): Allocate memory for `FT_SVG_Document' in `slot->other' if an SVG table exists in the face. (ft_glyphslot_clear): Clear `slot->other' only if the font doesn't have an SVG table. (ft_glyphslot_done): Free the memory at `slot->other' if the face has an SVG table. * src/base/ttsvg.c (tt_face_load_svg): Set `FT_FACE_FLAG_SVG'. (tt_face_load_svg_doc): Don't allocate the memory.
This commit is contained in:
parent
1e6cfffcb2
commit
6a39dd0b16
|
@ -1206,6 +1206,9 @@ FT_BEGIN_HEADER
|
||||||
* altered with @FT_Set_MM_Design_Coordinates,
|
* altered with @FT_Set_MM_Design_Coordinates,
|
||||||
* @FT_Set_Var_Design_Coordinates, or @FT_Set_Var_Blend_Coordinates.
|
* @FT_Set_Var_Design_Coordinates, or @FT_Set_Var_Blend_Coordinates.
|
||||||
* This flag is unset by a call to @FT_Set_Named_Instance.
|
* This flag is unset by a call to @FT_Set_Named_Instance.
|
||||||
|
*
|
||||||
|
* FT_FACE_FLAG_SVG ::
|
||||||
|
* Set if the current face has an SVG table.
|
||||||
*/
|
*/
|
||||||
#define FT_FACE_FLAG_SCALABLE ( 1L << 0 )
|
#define FT_FACE_FLAG_SCALABLE ( 1L << 0 )
|
||||||
#define FT_FACE_FLAG_FIXED_SIZES ( 1L << 1 )
|
#define FT_FACE_FLAG_FIXED_SIZES ( 1L << 1 )
|
||||||
|
@ -1223,6 +1226,7 @@ FT_BEGIN_HEADER
|
||||||
#define FT_FACE_FLAG_TRICKY ( 1L << 13 )
|
#define FT_FACE_FLAG_TRICKY ( 1L << 13 )
|
||||||
#define FT_FACE_FLAG_COLOR ( 1L << 14 )
|
#define FT_FACE_FLAG_COLOR ( 1L << 14 )
|
||||||
#define FT_FACE_FLAG_VARIATION ( 1L << 15 )
|
#define FT_FACE_FLAG_VARIATION ( 1L << 15 )
|
||||||
|
#define FT_FACE_FLAG_SVG ( 1L << 16 )
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
|
|
|
@ -318,6 +318,15 @@
|
||||||
if ( !error && clazz->init_slot )
|
if ( !error && clazz->init_slot )
|
||||||
error = clazz->init_slot( slot );
|
error = clazz->init_slot( slot );
|
||||||
|
|
||||||
|
/* check if SVG table exists allocate the space in slot->other */
|
||||||
|
if ( slot->face->face_flags & FT_FACE_FLAG_SVG )
|
||||||
|
{
|
||||||
|
FT_SVG_Document document;
|
||||||
|
if ( FT_NEW( document ) )
|
||||||
|
goto Exit;
|
||||||
|
slot->other = document;
|
||||||
|
}
|
||||||
|
|
||||||
Exit:
|
Exit:
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
@ -552,7 +561,8 @@
|
||||||
slot->subglyphs = NULL;
|
slot->subglyphs = NULL;
|
||||||
slot->control_data = NULL;
|
slot->control_data = NULL;
|
||||||
slot->control_len = 0;
|
slot->control_len = 0;
|
||||||
slot->other = NULL;
|
if ( !( slot->face->face_flags & FT_FACE_FLAG_SVG ) )
|
||||||
|
slot->other = NULL;
|
||||||
slot->format = FT_GLYPH_FORMAT_NONE;
|
slot->format = FT_GLYPH_FORMAT_NONE;
|
||||||
|
|
||||||
slot->linearHoriAdvance = 0;
|
slot->linearHoriAdvance = 0;
|
||||||
|
@ -570,6 +580,11 @@
|
||||||
FT_Memory memory = driver->root.memory;
|
FT_Memory memory = driver->root.memory;
|
||||||
|
|
||||||
|
|
||||||
|
if ( slot->face->face_flags & FT_FACE_FLAG_SVG )
|
||||||
|
{
|
||||||
|
FT_FREE( slot->other );
|
||||||
|
}
|
||||||
|
|
||||||
if ( clazz->done_slot )
|
if ( clazz->done_slot )
|
||||||
clazz->done_slot( slot );
|
clazz->done_slot( slot );
|
||||||
|
|
||||||
|
@ -588,6 +603,7 @@
|
||||||
|
|
||||||
FT_FREE( slot->internal );
|
FT_FREE( slot->internal );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -91,6 +91,8 @@
|
||||||
|
|
||||||
face->svg = svg;
|
face->svg = svg;
|
||||||
|
|
||||||
|
face->root.face_flags |= FT_FACE_FLAG_SVG;
|
||||||
|
|
||||||
return FT_Err_Ok;
|
return FT_Err_Ok;
|
||||||
|
|
||||||
InvalidTable:
|
InvalidTable:
|
||||||
|
@ -182,7 +184,7 @@
|
||||||
FT_Memory memory = face->root.memory;
|
FT_Memory memory = face->root.memory;
|
||||||
Svg* svg = face->svg;
|
Svg* svg = face->svg;
|
||||||
|
|
||||||
FT_SVG_Document svg_document;
|
FT_SVG_Document svg_document = glyph->other;
|
||||||
|
|
||||||
/* handle svg being 0x0 situation here */
|
/* handle svg being 0x0 situation here */
|
||||||
doc_list = svg->svg_doc_list;
|
doc_list = svg->svg_doc_list;
|
||||||
|
@ -227,9 +229,6 @@
|
||||||
return FT_Err_Ok;
|
return FT_Err_Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( FT_NEW( svg_document ) )
|
|
||||||
return FT_THROW( Out_Of_Memory );
|
|
||||||
|
|
||||||
svg_document->svg_document = doc_list;
|
svg_document->svg_document = doc_list;
|
||||||
svg_document->svg_document_length = doc_length;
|
svg_document->svg_document_length = doc_length;
|
||||||
svg_document->metrics = glyph->face->size->metrics;
|
svg_document->metrics = glyph->face->size->metrics;
|
||||||
|
|
Loading…
Reference in New Issue