Hello community,

here is the log from the commit of package python-CairoSVG for openSUSE:Factory 
checked in at 2019-06-07 12:18:04
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-CairoSVG (Old)
 and      /work/SRC/openSUSE:Factory/.python-CairoSVG.new.4811 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-CairoSVG"

Fri Jun  7 12:18:04 2019 rev:5 rq:707611 version:2.4.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-CairoSVG/python-CairoSVG.changes  
2019-05-05 21:18:42.116833019 +0200
+++ 
/work/SRC/openSUSE:Factory/.python-CairoSVG.new.4811/python-CairoSVG.changes    
    2019-06-07 12:18:05.616795656 +0200
@@ -1,0 +2,7 @@
+Tue Jun  4 13:54:28 UTC 2019 - Tomáš Chvátal <[email protected]>
+
+- Update to 2.4.0:
+  * Fix aspect and position when resizing root SVG tag
+  * Follow aspect and position hints when using forced output size
+
+-------------------------------------------------------------------

Old:
----
  CairoSVG-2.3.1.tar.gz

New:
----
  CairoSVG-2.4.0.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-CairoSVG.spec ++++++
--- /var/tmp/diff_new_pack.KdrIoc/_old  2019-06-07 12:18:06.076795510 +0200
+++ /var/tmp/diff_new_pack.KdrIoc/_new  2019-06-07 12:18:06.080795508 +0200
@@ -19,7 +19,7 @@
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 %define skip_python2 1
 Name:           python-CairoSVG
-Version:        2.3.1
+Version:        2.4.0
 Release:        0
 Summary:        A Python SVG converter based on Cairo
 License:        LGPL-3.0-or-later

++++++ CairoSVG-2.3.1.tar.gz -> CairoSVG-2.4.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/CairoSVG-2.3.1/CairoSVG.egg-info/PKG-INFO 
new/CairoSVG-2.4.0/CairoSVG.egg-info/PKG-INFO
--- old/CairoSVG-2.3.1/CairoSVG.egg-info/PKG-INFO       2019-04-18 
14:27:07.000000000 +0200
+++ new/CairoSVG-2.4.0/CairoSVG.egg-info/PKG-INFO       2019-05-20 
13:44:43.000000000 +0200
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: CairoSVG
-Version: 2.3.1
+Version: 2.4.0
 Summary: A Simple SVG Converter based on Cairo
 Home-page: http://www.cairosvg.org/
 Author: Guillaume Ayoub
@@ -36,5 +36,5 @@
 Classifier: Topic :: Multimedia :: Graphics :: Graphics Conversion
 Requires-Python: >= 3.5
 Description-Content-Type: text/x-rst
-Provides-Extra: doc
 Provides-Extra: test
+Provides-Extra: doc
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/CairoSVG-2.3.1/PKG-INFO new/CairoSVG-2.4.0/PKG-INFO
--- old/CairoSVG-2.3.1/PKG-INFO 2019-04-18 14:27:08.000000000 +0200
+++ new/CairoSVG-2.4.0/PKG-INFO 2019-05-20 13:44:43.000000000 +0200
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: CairoSVG
-Version: 2.3.1
+Version: 2.4.0
 Summary: A Simple SVG Converter based on Cairo
 Home-page: http://www.cairosvg.org/
 Author: Guillaume Ayoub
@@ -36,5 +36,5 @@
 Classifier: Topic :: Multimedia :: Graphics :: Graphics Conversion
 Requires-Python: >= 3.5
 Description-Content-Type: text/x-rst
-Provides-Extra: doc
 Provides-Extra: test
+Provides-Extra: doc
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/CairoSVG-2.3.1/cairosvg/VERSION 
new/CairoSVG-2.4.0/cairosvg/VERSION
--- old/CairoSVG-2.3.1/cairosvg/VERSION 2019-04-18 13:55:49.000000000 +0200
+++ new/CairoSVG-2.4.0/cairosvg/VERSION 2019-05-20 13:19:01.000000000 +0200
@@ -1 +1 @@
-2.3.1
\ No newline at end of file
+2.4.0
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/CairoSVG-2.3.1/cairosvg/helpers.py 
new/CairoSVG-2.4.0/cairosvg/helpers.py
--- old/CairoSVG-2.3.1/cairosvg/helpers.py      2019-02-15 13:46:16.000000000 
+0100
+++ new/CairoSVG-2.4.0/cairosvg/helpers.py      2019-05-20 12:06:59.000000000 
+0200
@@ -113,24 +113,18 @@
     return atan2(py - cy, px - cx)
 
 
-def preserved_ratio(node):
-    """Return whether we must preserve the ratio."""
-    return node.get('preserveAspectRatio', 'xMidYMid').split(' ')[0] != 'none'
-
-
-def preserve_ratio(surface, node):
+def preserve_ratio(surface, node, width=None, height=None):
     """Manage the ratio preservation."""
     if node.tag == 'marker':
-        width = size(surface, node.get('markerWidth', '3'), 'x')
-        height = size(surface, node.get('markerHeight', '3'), 'y')
+        width = width or size(surface, node.get('markerWidth', '3'), 'x')
+        height = height or size(surface, node.get('markerHeight', '3'), 'y')
         _, _, viewbox = node_format(surface, node)
         viewbox_width, viewbox_height = viewbox[2:]
-    elif node.tag in ('svg', 'image'):
-        width, height, _ = node_format(surface, node)
+    elif node.tag in ('svg', 'image', 'g'):
+        node_width, node_height, _ = node_format(surface, node)
+        width = width or node_width
+        height = height or node_height
         viewbox_width, viewbox_height = node.image_width, node.image_height
-    else:
-        # Safety measure
-        return 1, 1, 0, 0
 
     translate_x = 0
     translate_y = 0
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/CairoSVG-2.3.1/cairosvg/image.py 
new/CairoSVG-2.4.0/cairosvg/image.py
--- old/CairoSVG-2.3.1/cairosvg/image.py        2019-02-15 13:46:16.000000000 
+0100
+++ new/CairoSVG-2.4.0/cairosvg/image.py        2019-05-18 19:30:56.000000000 
+0200
@@ -24,7 +24,7 @@
 
 from PIL import Image
 
-from .helpers import node_format, preserve_ratio, preserved_ratio, size
+from .helpers import node_format, preserve_ratio, size
 from .parser import Tree
 from .surface import cairo
 from .url import parse_url
@@ -64,9 +64,13 @@
             unsafe=node.unsafe)
         tree_width, tree_height, viewbox = node_format(
             surface, tree, reference=False)
-        if not viewbox:
+        if viewbox:
+            tree_scale_x = tree_width / viewbox[2]
+            tree_scale_y = tree_height / viewbox[3]
+        else:
             tree_width = tree['width'] = width
             tree_height = tree['height'] = height
+            tree_scale_x = tree_scale_y = 1
         node.image_width = tree_width or width
         node.image_height = tree_height or height
         scale_x, scale_y, translate_x, translate_y = preserve_ratio(
@@ -79,11 +83,8 @@
         # Draw image
         surface.context.save()
         surface.context.translate(x, y)
-        surface.set_context_size(
-            *node_format(surface, tree, reference=False), scale=1,
-            preserved_ratio=preserved_ratio(tree))
         surface.context.translate(*surface.context.get_current_point())
-        surface.context.scale(scale_x, scale_y)
+        surface.context.scale(scale_x * tree_scale_x, scale_y * tree_scale_y)
         surface.context.translate(translate_x, translate_y)
         surface.draw(tree)
         surface.context.restore()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/CairoSVG-2.3.1/cairosvg/surface.py 
new/CairoSVG-2.4.0/cairosvg/surface.py
--- old/CairoSVG-2.3.1/cairosvg/surface.py      2019-02-15 13:46:16.000000000 
+0100
+++ new/CairoSVG-2.4.0/cairosvg/surface.py      2019-05-20 12:10:48.000000000 
+0200
@@ -31,7 +31,7 @@
     parse_all_defs, pattern, prepare_filter, radial_gradient, use)
 from .helpers import (
     UNITS, PointError, apply_matrix_transform, clip_rect, node_format,
-    normalize, paint, preserved_ratio, size, transform)
+    normalize, paint, preserve_ratio, size, transform)
 from .image import image
 from .parser import Tree
 from .path import draw_markers, path
@@ -190,12 +190,6 @@
         self.stroke_and_fill = True
         width, height, viewbox = node_format(self, tree)
 
-        # If one of output_width or output_height is set, compute the scale
-        if output_width:
-            scale = output_width / width
-        elif output_height:
-            scale = output_height / height
-
         if output_width and output_height:
             width, height = output_width, output_height
         else:
@@ -211,12 +205,7 @@
         self.context.scale(
             self.device_units_per_user_units, self.device_units_per_user_units)
         # Initial, non-rounded dimensions
-        if output_width and output_height:
-            self.set_context_size(
-                width, height, viewbox, scale, tree)
-        else:
-            self.set_context_size(
-                width, height, viewbox, scale, preserved_ratio(tree))
+        self.set_context_size(width, height, viewbox, scale, tree)
         self.context.move_to(0, 0)
         self.draw(tree)
 
@@ -240,31 +229,35 @@
         cairo_surface = self.surface_class(self.output, width, height)
         return cairo_surface, width, height
 
-    def set_context_size(self, width, height, viewbox, scale, preserved_ratio):
+    def set_context_size(self, width, height, viewbox, scale, tree):
         """Set the Cairo context size, set the SVG viewport size."""
         if viewbox:
-            x, y, x_size, y_size = viewbox
-            self.context_width, self.context_height = x_size, y_size
-            x_ratio, y_ratio = width / x_size, height / y_size
+            rect_x, rect_y = viewbox[0:2]
+            tree.image_width = viewbox[2]
+            tree.image_height = viewbox[3]
+        else:
+            rect_x, rect_y = 0, 0
+            tree.image_width = width
+            tree.image_height = height
+
+        scale_x, scale_y, translate_x, translate_y = preserve_ratio(
+            self, tree, width, height)
+        rect_x, rect_y = rect_x * scale_x, rect_y * scale_y
+        rect_width, rect_height = width, height
+        self.context.translate(*self.context.get_current_point())
+        self.context.translate(-rect_x, -rect_y)
+        if tree.get('overflow', 'hidden') != 'visible':
+            self.context.rectangle(rect_x, rect_y, rect_width, rect_height)
+            self.context.clip()
+        self.context.scale(scale_x, scale_y)
+        self.context.translate(translate_x, translate_y)
+        self.context_width = rect_width / scale_x
+        self.context_height = rect_height / scale_y
+
+        if scale != 1:
             matrix = cairo.Matrix()
-            if preserved_ratio and x_ratio > y_ratio:
-                matrix.translate((width - x_size * y_ratio) / 2, 0)
-                matrix.scale(y_ratio, y_ratio)
-                matrix.translate(-x / x_ratio * y_ratio, -y)
-            elif preserved_ratio and x_ratio < y_ratio:
-                matrix.translate(0, (height - y_size * x_ratio) / 2)
-                matrix.scale(x_ratio, x_ratio)
-                matrix.translate(-x, -y / y_ratio * x_ratio)
-            else:
-                matrix.scale(x_ratio, y_ratio)
-                matrix.translate(-x, -y)
+            matrix.scale(scale, scale)
             apply_matrix_transform(self, matrix)
-        else:
-            self.context_width, self.context_height = width, height
-            if scale != 1:
-                matrix = cairo.Matrix()
-                matrix.scale(scale, scale)
-                apply_matrix_transform(self, matrix)
 
     def finish(self):
         """Read the surface content."""
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/CairoSVG-2.3.1/cairosvg/svg.py 
new/CairoSVG-2.4.0/cairosvg/svg.py
--- old/CairoSVG-2.3.1/cairosvg/svg.py  2019-02-15 13:46:16.000000000 +0100
+++ new/CairoSVG-2.4.0/cairosvg/svg.py  2019-05-18 19:30:56.000000000 +0200
@@ -19,32 +19,11 @@
 
 """
 
-from .helpers import node_format, preserve_ratio
+from .helpers import node_format
 
 
 def svg(surface, node):
     """Draw a svg ``node``."""
-    width, height, viewbox = node_format(surface, node)
-    if viewbox:
-        rect_x, rect_y = viewbox[0:2]
-        node.image_width = viewbox[2]
-        node.image_height = viewbox[3]
-    else:
-        rect_x, rect_y = 0, 0
-        node.image_width = width
-        node.image_height = height
-
-    if node.parent is None:
-        return
-
-    scale_x, scale_y, translate_x, translate_y = preserve_ratio(surface, node)
-    rect_x, rect_y = rect_x * scale_x, rect_y * scale_y
-    rect_width, rect_height = width, height
-    surface.context.translate(*surface.context.get_current_point())
-    surface.context.translate(-rect_x, -rect_y)
-    if node.get('overflow', 'hidden') != 'visible':
-        surface.context.rectangle(rect_x, rect_y, rect_width, rect_height)
-        surface.context.clip()
-    surface.context.scale(scale_x, scale_y)
-    surface.context.translate(translate_x, translate_y)
-    surface.context_width, surface.context_height = rect_width, rect_height
+    if node.parent is not None:
+        width, height, viewbox = node_format(surface, node)
+        surface.set_context_size(width, height, viewbox, 1, node)


Reply via email to