diff --git a/modules/codec/svg.c b/modules/codec/svg.c index de2e625bc5..25631f6e53 100644 --- a/modules/codec/svg.c +++ b/modules/codec/svg.c @@ -148,8 +148,31 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block ) goto done; RsvgDimensionData dim; + #if LIBRSVG_MAJOR_VERSION > 2 || ( LIBRSVG_MAJOR_VERSION == 2 && LIBRSVG_MINOR_VERSION >= 52 ) + gboolean has_width, has_height, has_viewbox; + RsvgLength width, height; + RsvgRectangle viewbox; + + rsvg_handle_get_intrinsic_dimensions( rsvg, &has_width, &width, &has_height, &height, &has_viewbox, &viewbox ); + + if( has_width && has_height && width.unit == RSVG_UNIT_PX && height.unit == RSVG_UNIT_PX ) + { + dim.width = (int) width.length; + dim.height = (int) height.length; + } + else if( has_viewbox ) + { + dim.width = (int) viewbox.width; + dim.height = (int) viewbox.height; + } + else + { + dim.width = 0; + dim.height = 0; + } + #else rsvg_handle_get_dimensions( rsvg, &dim ); - + #endif if( p_sys->f_scale > 0.0 ) { i_width = (int32_t)(p_sys->f_scale * dim.width); diff --git a/modules/text_renderer/svg.c b/modules/text_renderer/svg.c index 9db5df4209..e542d56c61 100644 --- a/modules/text_renderer/svg.c +++ b/modules/text_renderer/svg.c @@ -243,7 +243,31 @@ static picture_t * svg_RenderPicture( filter_t *p_filter, } RsvgDimensionData dim; + #if LIBRSVG_MAJOR_VERSION > 2 || ( LIBRSVG_MAJOR_VERSION == 2 && LIBRSVG_MINOR_VERSION >= 52 ) + gboolean has_width, has_height, has_viewbox; + RsvgLength width, height; + RsvgRectangle viewbox; + + rsvg_handle_get_intrinsic_dimensions( p_handle, &has_width, &width, &has_height, &height, &has_viewbox, &viewbox ); + + if( has_width && has_height && width.unit == RSVG_UNIT_PX && height.unit == RSVG_UNIT_PX ) + { + dim.width = (int) width.length; + dim.height = (int) height.length; + } + else if( has_viewbox ) + { + dim.width = (int) viewbox.width; + dim.height = (int) viewbox.height; + } + else + { + dim.width = 0; + dim.height = 0; + } + #else rsvg_handle_get_dimensions( p_handle, &dim ); + #endif float scale; svg_RescaletoFit( p_filter, &dim.width, &dim.height, &scale );