How to use the cairosvg.helpers.pop_rotation function in CairoSVG

To help you get started, we’ve selected a few CairoSVG examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Kozea / CairoSVG / cairosvg / parser.py View on Github external
child_node.text = handle_white_spaces(child.text, child_preserve)
            child_node.children, trailing_space = child_node.text_children(
                child_element, trailing_space)
            trailing_space = child_node.text.endswith(' ')
            if original_rotate and 'rotate' not in child_node:
                pop_rotation(child_node, original_rotate, rotate)
            children.append(child_node)
            if child.tail:
                anonymous_etree = Element('{http://www.w3.org/2000/svg}tspan')
                anonymous = Node(
                    cssselect2.ElementWrapper.from_xml_root(anonymous_etree),
                    self.style, self.url_fetcher, parent=self,
                    unsafe=self.unsafe)
                anonymous.text = handle_white_spaces(child.tail, preserve)
                if original_rotate:
                    pop_rotation(anonymous, original_rotate, rotate)
                if trailing_space and not preserve:
                    anonymous.text = anonymous.text.lstrip(' ')
                if anonymous.text:
                    trailing_space = anonymous.text.endswith(' ')
                children.append(anonymous)

        if text_root and not children and not preserve:
            self.text = self.text.rstrip(' ')

        return children, trailing_space
github Kozea / CairoSVG / cairosvg / parser.py View on Github external
# Retrieve the referenced node and get its flattened text
                # and remove the node children.
                child = child_tree.xml_tree
                child.text = flatten(child)
                child_element = cssselect2.ElementWrapper.from_xml_root(child)
            else:
                child_node = Node(
                    child_element, self.style, self.url_fetcher, parent=self,
                    unsafe=self.unsafe)
            child_preserve = child_node.get(space) == 'preserve'
            child_node.text = handle_white_spaces(child.text, child_preserve)
            child_node.children, trailing_space = child_node.text_children(
                child_element, trailing_space)
            trailing_space = child_node.text.endswith(' ')
            if original_rotate and 'rotate' not in child_node:
                pop_rotation(child_node, original_rotate, rotate)
            children.append(child_node)
            if child.tail:
                anonymous_etree = Element('{http://www.w3.org/2000/svg}tspan')
                anonymous = Node(
                    cssselect2.ElementWrapper.from_xml_root(anonymous_etree),
                    self.style, self.url_fetcher, parent=self,
                    unsafe=self.unsafe)
                anonymous.text = handle_white_spaces(child.tail, preserve)
                if original_rotate:
                    pop_rotation(anonymous, original_rotate, rotate)
                if trailing_space and not preserve:
                    anonymous.text = anonymous.text.lstrip(' ')
                if anonymous.text:
                    trailing_space = anonymous.text.endswith(' ')
                children.append(anonymous)
github Kozea / CairoSVG / cairosvg / parser.py View on Github external
def text_children(self, element, trailing_space, text_root=False):
        """Create children and return them."""
        children = []
        space = '{http://www.w3.org/XML/1998/namespace}space'
        preserve = self.get(space) == 'preserve'
        self.text = handle_white_spaces(element.etree_element.text, preserve)
        if trailing_space and not preserve:
            self.text = self.text.lstrip(' ')
        original_rotate = rotations(self)
        rotate = list(original_rotate)
        if original_rotate:
            pop_rotation(self, original_rotate, rotate)
        if self.text:
            trailing_space = self.text.endswith(' ')
        for child_element in element.iter_children():
            child = child_element.etree_element
            if child.tag in ('{http://www.w3.org/2000/svg}tref', 'tref'):
                href = child.get(
                    '{http://www.w3.org/1999/xlink}href', child.get('href'))
                url = parse_url(href).geturl()
                child_tree = Tree(
                    url=url, url_fetcher=self.url_fetcher, parent=self,
                    unsafe=self.unsafe)
                child_tree.clear()
                child_tree.update(self)
                child_node = Node(
                    child_element, self.style, self.url_fetcher,
                    parent=child_tree, parent_children=True,