freetype-commit
[Top][All Lists]
Advanced

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

[freetype2-demos] VER-2-13-1 626b43d 3/5: Fix out-of-memory conditions w


From: Werner Lemberg
Subject: [freetype2-demos] VER-2-13-1 626b43d 3/5: Fix out-of-memory conditions with newer 'librsvg'.
Date: Sat, 24 Jun 2023 02:44:09 -0400 (EDT)

annotated tag: VER-2-13-1
commit 626b43db566f907fa7b6926705e914259c54b9cf
Author: Hin-Tak Leung <htl10@users.sourceforge.net>
Commit: Werner Lemberg <wl@gnu.org>

    Fix out-of-memory conditions with newer 'librsvg'.
    
    Excerpts from `rsvg_handle_get_intrinsic_dimensions` section in
    `librsvg/rsvg.h`:
    
    ```
    Before librsvg 2.54.0, the `out_has_width` and `out_has_height` arguments
    would be set to true or false depending on whether the SVG document actually
    had `width` and `height` attributes, respectively.
    
    However, since librsvg 2.54.0, `width` and `height` are now [geometry
    properties](https://www.w3.org/TR/SVG2/geometry.html) per the SVG2
    specification; they are not plain attributes.  SVG2 made it so that the
    initial value of those properties is `auto`, which is equivalent to
    specifying a value of `100%`.  In this sense, even SVG documents which lack
    `width` or `height` attributes semantically have to make them default to
    `100%`.  This is why since librsvg 2.54.0, `out_has_width` and
    `out_has_heigth` are always returned as `TRUE`, since with SVG2 all
    documents *have* a default width and height of `100%`.
    ```
    
    * src/rsvg-port.c (rsvg_port_preset_slot): Adjust for change of behavior of
    `rsvg_handle_get_intrinsic_dimensions` in librsvg 2.53+.  We avoid
    `LIBRSVG_CHECK_VERSION` as it is possible to build against one version but
    run against another version.
    
    Signed-off-by: Hin-Tak Leung <htl10@users.sourceforge.net>
---
 src/rsvg-port.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/src/rsvg-port.c b/src/rsvg-port.c
index 3cbce25..acac26e 100644
--- a/src/rsvg-port.c
+++ b/src/rsvg-port.c
@@ -241,12 +241,29 @@
     {
       dimension_svg.width  = (int)out_width.length; /* XXX rounding? */
       dimension_svg.height = (int)out_height.length;
+
+      /*
+       * librsvg 2.53+ behavior, on SVG doc without explicit width/height.
+       * See `rsvg_handle_get_intrinsic_dimensions` section in
+       * the `librsvg/rsvg.h` header file.
+       */
+      if ( out_width.length  == 1 &&
+           out_height.length == 1 )
+      {
+        dimension_svg.width  = units_per_EM;
+        dimension_svg.height = units_per_EM;
+      }
     }
     else
     {
-      /* If neither `ViewBox` nor `width`/`height` are present, the */
-      /* `units_per_EM` in SVG coordinates must be the same as      */
-      /* `units_per_EM` of the TTF/CFF outlines.                    */
+      /*
+       * If neither `ViewBox` nor `width`/`height` are present, the
+       * `units_per_EM` in SVG coordinates must be the same as
+       * `units_per_EM` of the TTF/CFF outlines.
+       *
+       * librsvg up to 2.52 behavior, on SVG doc without explicit
+       * width/height.
+       */
       dimension_svg.width  = units_per_EM;
       dimension_svg.height = units_per_EM;
     }



reply via email to

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