[Python-modules-commits] [cairosvg] 01/04: Import cairosvg_1.0.20.orig.tar.gz

Michael Fladischer fladi at moszumanska.debian.org
Thu Mar 31 17:48:05 UTC 2016


This is an automated email from the git hooks/post-receive script.

fladi pushed a commit to branch master
in repository cairosvg.

commit d90bafa568d75c5b622f08aa0fa24e0ee249377e
Author: Michael Fladischer <fladi at debian.org>
Date:   Thu Mar 31 15:19:36 2016 +0200

    Import cairosvg_1.0.20.orig.tar.gz
---
 NEWS.rst                     |  6 ++++++
 PKG-INFO                     |  2 +-
 cairosvg/__init__.py         | 12 ++++++++++--
 cairosvg/surface/__init__.py | 11 ++++++-----
 4 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/NEWS.rst b/NEWS.rst
index 738dc0c..d9dfb15 100644
--- a/NEWS.rst
+++ b/NEWS.rst
@@ -11,6 +11,12 @@ Version 2.0, not released yet
 * Test CairoSVG with Travis
 
 
+Version 1.0.20, released on 2016-02-23
+======================================
+
+* Allow the user to give parent size
+
+
 Version 1.0.19, released on 2015-10-30
 ======================================
 
diff --git a/PKG-INFO b/PKG-INFO
index 8c86898..42aad7e 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: CairoSVG
-Version: 1.0.19
+Version: 1.0.20
 Summary: A Simple SVG Converter for Cairo
 Home-page: http://www.cairosvg.org/
 Author: Kozea
diff --git a/cairosvg/__init__.py b/cairosvg/__init__.py
index e15e61b..ace2a02 100644
--- a/cairosvg/__init__.py
+++ b/cairosvg/__init__.py
@@ -27,7 +27,7 @@ import optparse
 from . import surface
 
 
-VERSION = '1.0.19'
+VERSION = '1.0.20'
 SURFACES = {
     'SVG': surface.SVGSurface,  # Tell us if you actually use this one!
     'PNG': surface.PNGSurface,
@@ -59,6 +59,12 @@ def main():
     option_parser.add_option(
         "-d", "--dpi", help="ratio between 1in and 1px", default=96)
     option_parser.add_option(
+        '-W', '--width', default=None, type="float",
+        help='width of the parent container in pixels')
+    option_parser.add_option(
+        '-H', '--height', default=None, type="float",
+        help='height of the parent container in pixels')
+    option_parser.add_option(
         "-o", "--output",
         default="", help="output filename")
     options, args = option_parser.parse_args()
@@ -68,7 +74,9 @@ def main():
         option_parser.print_help()
         sys.exit()
 
-    kwargs = {'dpi': float(options.dpi)}
+    kwargs = {
+        'parent_width': options.width, 'parent_height': options.height,
+        'dpi': float(options.dpi)}
 
     if not options.output or options.output == '-':
         # Python 2/3 hack
diff --git a/cairosvg/surface/__init__.py b/cairosvg/surface/__init__.py
index 93e349c..48c49e7 100644
--- a/cairosvg/surface/__init__.py
+++ b/cairosvg/surface/__init__.py
@@ -96,6 +96,8 @@ class Surface(object):
 
         """
         dpi = kwargs.pop('dpi', 96)
+        parent_width = kwargs.pop('parent_width', None)
+        parent_height = kwargs.pop('parent_height', None)
         write_to = kwargs.pop('write_to', None)
         kwargs['bytestring'] = bytestring
         tree = Tree(**kwargs)
@@ -103,11 +105,12 @@ class Surface(object):
             output = io.BytesIO()
         else:
             output = write_to
-        cls(tree, output, dpi).finish()
+        cls(tree, output, dpi, None, parent_width, parent_height).finish()
         if write_to is None:
             return output.getvalue()
 
-    def __init__(self, tree, output, dpi, parent_surface=None):
+    def __init__(self, tree, output, dpi, parent_surface=None,
+                 parent_width=None, parent_height=None):
         """Create the surface from a filename or a file-like object.
 
         The rendered content is written to ``output`` which can be a filename,
@@ -119,7 +122,7 @@ class Surface(object):
 
         """
         self.cairo = None
-        self.context_width, self.context_height = None, None
+        self.context_width, self.context_height = parent_width, parent_height
         self.cursor_position = [0, 0]
         self.cursor_d_position = [0, 0]
         self.text_path_width = 0
@@ -138,7 +141,6 @@ class Surface(object):
             self.masks = {}
             self.paths = {}
             self.filters = {}
-        self.page_sizes = []
         self._old_parent_node = self.parent_node = None
         self.output = output
         self.dpi = dpi
@@ -149,7 +151,6 @@ class Surface(object):
         self.cairo, self.width, self.height = self._create_surface(
             width * self.device_units_per_user_units,
             height * self.device_units_per_user_units)
-        self.page_sizes.append((self.width, self.height))
         self.context = cairo.Context(self.cairo)
         # We must scale the context as the surface size is using physical units
         self.context.scale(

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/cairosvg.git



More information about the Python-modules-commits mailing list