/usr/lib/python2.7/dist-packages/cairosvg/surface/svg.py is in python-cairosvg 1.0.9-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | # -*- coding: utf-8 -*-
# This file is part of CairoSVG
# Copyright © 2010-2012 Kozea
#
# This library is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# This library is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with CairoSVG. If not, see <http://www.gnu.org/licenses/>.
"""
Root tag drawer.
"""
from .helpers import preserve_ratio, node_format
from .units import size
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 = size(surface, node.get("width"), "x")
node.image_height = size(surface, node.get("height"), "y")
if node.parent is None:
return
if node.get("preserveAspectRatio", "none") != "none":
scale_x, scale_y, translate_x, translate_y = \
preserve_ratio(surface, node)
rect_width, rect_height = width, height
else:
scale_x, scale_y, translate_x, translate_y = (1, 1, 0, 0)
rect_width, rect_height = node.image_width, node.image_height
surface.context.translate(*surface.context.get_current_point())
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)
|