Add a `hooks_set' flag.

A flag is to be used to indicate whether hooks
have been set or not. In case the hooks haven't
been set, a `Missing_SVG_Hooks' error will be
thrown.
This commit is contained in:
Moazin Khatti 2019-07-21 13:43:13 +05:00
parent 246ac684e4
commit 4025f1213e
3 changed files with 15 additions and 3 deletions

View File

@ -234,6 +234,8 @@
"found FDEF or IDEF opcode in glyf bytecode" )
FT_ERRORDEF_( Missing_Bitmap, 0x9D,
"missing bitmap in strike" )
FT_ERRORDEF_( Missing_SVG_Hooks, 0x9E,
"hooks have not been set" )
/* CFF, CID, and Type 1 errors */

View File

@ -39,6 +39,9 @@
svg_module->hooks.free_svg = (SVG_Lib_Free_Func)rsvg_port_free;
svg_module->hooks.render_svg = (SVG_Lib_Render_Func)rsvg_port_render;
svg_module->hooks.get_buffer_size = (SVG_Lib_Get_Buffer_Size_Func)rsvg_port_get_buffer_size;
svg_module->hooks_set = TRUE;
#else
svg_module->hooks_set = FALSE;
#endif
return error;
}
@ -47,7 +50,8 @@
ft_svg_done( SVG_Renderer svg_module )
{
FT_Library library = svg_module->root.root.library;
if ( svg_module->loaded == TRUE )
if ( svg_module->loaded == TRUE &&
svg_module->hooks_set == TRUE )
svg_module->hooks.free_svg( library );
svg_module->loaded = FALSE;
}
@ -63,10 +67,14 @@
FT_Memory memory = library->memory;
FT_BBox outline_bbox;
FT_Error error;
FT_ULong size_image_buffer;
FT_ULong size_image_buffer;
SVG_RendererHooks hooks = svg_renderer->hooks;
if ( svg_renderer->hooks_set == FALSE )
{
return FT_THROW( Missing_SVG_Hooks );
}
if ( svg_renderer->loaded == FALSE )
{
@ -100,7 +108,8 @@
if ( !ft_strcmp( property_name, "svg_hooks" ) )
{
SVG_RendererHooks* hooks = (SVG_RendererHooks*)value;
renderer->hooks = *hooks;
renderer->hooks = *hooks;
renderer->hooks_set = TRUE;
}
else
{

View File

@ -25,6 +25,7 @@
{
FT_RendererRec root; /* This inherits FT_RendererRec */
FT_Bool loaded;
FT_Bool hooks_set;
SVG_RendererHooks hooks; /* Holds out hooks to the outside library */
} SVG_RendererRec;