freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2-demos] master 2149b9c 2/2: rsvg-port.c: Simplify usage of `rs


From: suzuki toshiya
Subject: [freetype2-demos] master 2149b9c 2/2: rsvg-port.c: Simplify usage of `rsvg_handle_render_*`.
Date: Sun, 9 Jul 2023 23:30:15 -0400 (EDT)

branch: master
commit 2149b9c77cebdcb627a7edbd2ba76d7c3234db69
Author: Hin-Tak Leung <htl10@users.sourceforge.net>
Commit: Werner Lemberg <wl@gnu.org>

    rsvg-port.c: 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 <htl10@users.sourceforge.net>
---
 src/rsvg-port.c | 85 +++++++++++++++++++++------------------------------------
 1 file changed, 31 insertions(+), 54 deletions(-)

diff --git a/src/rsvg-port.c b/src/rsvg-port.c
index bdd6fac..e683e68 100644
--- a/src/rsvg-port.c
+++ b/src/rsvg-port.c
@@ -194,6 +194,9 @@
     float vertBearingX, vertBearingY;
     float tmpf;
 
+    char  *id;
+    char  str[32];
+
 
     /* If `cache` is `TRUE` we store calculations in the actual port */
     /* state variable, otherwise we just create a dummy variable and */
@@ -320,69 +323,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 )
+    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;
-      }
+      /* Render only the element with its ID equal to `glyph<ID>`. */
+      sprintf( str, "#glyph%u", slot->glyph_index );
+      id = str;
     }
-    else if ( start_glyph_id < end_glyph_id )
+    else
     {
-      char  str[32] = "#glyph";
-
-
-      /* Render only the element with its ID equal to `glyph<ID>`. */
-      sprintf( str + 6, "%u", slot->glyph_index );
+      /* NULL = Render the whole document */
+      id = NULL;
+    }
 
 #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. */



reply via email to

[Prev in Thread] Current Thread [Next in Thread]