def svg(svg, node, font_size):
    """Draw svg tags."""
    x, y = svg.point(node.get('x'), node.get('y'), font_size)
    svg.stream.transform(e=x, f=y)
    if svg.tree == node:
        width, height = svg.concrete_width, svg.concrete_height
    else:
        width, height = node.get('width'), node.get('height')
        if None in (width, height):
            node._etree_node.tag = 'g'
            box = bounding_box(svg, node, font_size, stroke=True)
            if is_valid_bounding_box(box):
                width = box[0] + box[2]
                height = box[1] + box[3]
            else:
                width = height = 0
            node._etree_node.tag = 'svg'
        else:
            width, height = svg.point(width, height, font_size)
    node.set_svg_size(svg, width, height)
    scale_x, scale_y, translate_x, translate_y = preserve_ratio(
        svg, node, font_size, width, height)
    if svg.tree != node and node.get('overflow', 'hidden') == 'hidden':
        svg.stream.rectangle(0, 0, width, height)
        svg.stream.clip()
        svg.stream.end()
    svg.stream.transform(a=scale_x, d=scale_y, e=translate_x, f=translate_y)
Draw svg tags.
weasyprint/svg/images.py