From 216f39cec1fe8719762aad593568015bd01622cb Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Fri, 30 Jun 2023 02:45:38 +0100 Subject: [PATCH] * src/rsvg-port.c (rsvg_port_preset_slot): simplify usage of rsvg_handle_render_* * src/rsvg-port.c (rsvg_port_preset_slot): Remove usage of `rsvg_handle_render_document' (and `rsvg_handle_render_cairo'). They are functionally the same as `rsvg_handle_render_layer' (and `rsvg_handle_render_cairo_sub') with argument id set to NULL. Signed-off-by: Hin-Tak Leung --- src/rsvg-port.c | 80 +++++++++++++++++-------------------------------- 1 file changed, 27 insertions(+), 53 deletions(-) diff --git a/src/rsvg-port.c b/src/rsvg-port.c index 16faa14..5861e19 100644 --- a/src/rsvg-port.c +++ b/src/rsvg-port.c @@ -334,69 +334,43 @@ /* If the document contains only one glyph, `start_glyph_id` and */ /* `end_glyph_id` have the same value. Otherwise `end_glyph_id` */ /* is larger. */ - if ( start_glyph_id == end_glyph_id ) - { - /* Render the whole document to the recording surface. */ -#if LIBRSVG_CHECK_VERSION( 2, 52, 0 ) - { - RsvgRectangle viewport = - { - .x = 0, - .y = 0, - .width = (double)dimension_svg.width, - .height = (double)dimension_svg.height, - }; - - - ret = rsvg_handle_render_document( handle, - rec_cr, - &viewport, - NULL ); - } -#else - ret = rsvg_handle_render_cairo( handle, rec_cr ); -#endif - - if ( ret == FALSE ) - { - error = FT_Err_Invalid_SVG_Document; - goto CleanCairo; - } - } - else if ( start_glyph_id < end_glyph_id ) - { - char str[32] = "#glyph"; + /* NULL = Render the whole document */ + char *id = NULL; + char str[32] = "#glyph"; + if ( start_glyph_id < end_glyph_id ) + { /* Render only the element with its ID equal to `glyph`. */ sprintf( str + 6, "%u", slot->glyph_index ); + id = str; + } #if LIBRSVG_CHECK_VERSION( 2, 52, 0 ) + { + RsvgRectangle viewport = { - RsvgRectangle viewport = - { - .x = 0, - .y = 0, - .width = (double)dimension_svg.width, - .height = (double)dimension_svg.height, - }; - - - ret = rsvg_handle_render_layer( handle, - rec_cr, - str, - &viewport, - NULL ); - } + .x = 0, + .y = 0, + .width = (double)dimension_svg.width, + .height = (double)dimension_svg.height, + }; + + + ret = rsvg_handle_render_layer( handle, + rec_cr, + id, + &viewport, + NULL ); + } #else - ret = rsvg_handle_render_cairo_sub( handle, rec_cr, str ); + ret = rsvg_handle_render_cairo_sub( handle, rec_cr, id ); #endif - if ( ret == FALSE ) - { - error = FT_Err_Invalid_SVG_Document; - goto CleanCairo; - } + if ( ret == FALSE ) + { + error = FT_Err_Invalid_SVG_Document; + goto CleanCairo; } /* Get the bounding box of the drawing. */ -- 2.41.0