# Path: weasyprint/svg/bounding_box.py
# EMPTY_BOUNDING_BOX = inf, inf, 0, 0
# 
# def extend_bounding_box(bounding_box, points):
#     """Extend a bounding box to include given points."""
#     minx, miny, width, height = bounding_box
#     maxx, maxy = (
#         -inf if isinf(minx) else minx + width,
#         -inf if isinf(miny) else miny + height)
#     x_list, y_list = zip(*points)
#     minx, miny, maxx, maxy = (
#         min(minx, *x_list), min(miny, *y_list),
#         max(maxx, *x_list), max(maxy, *y_list))
#     return minx, miny, maxx - minx, maxy - miny
# 
# Path: weasyprint/svg/utils.py
# def normalize(string):
#     """Give a canonical version of a given value string."""
#     string = (string or '').replace('E', 'e')
#     string = re.sub('(?<!e)-', ' -', string)
#     string = re.sub('[ \n\r\t,]+', ' ', string)
#     string = re.sub(r'(\.[0-9-]+)(?=\.)', r'\1 ', string)
#     return string.strip()
# 
# def size(string, font_size=None, percentage_reference=None):
#     """Compute size from string, resolving units and percentages."""
#     from ..css.utils import LENGTHS_TO_PIXELS
# 
#     if not string:
#         return 0
# 
#     try:
#         return float(string)
#     except ValueError:
#         # Not a float, try something else
#         pass
# 
#     string = normalize(string).split(' ', 1)[0]
#     if string.endswith('%'):
#         assert percentage_reference is not None
#         return float(string[:-1]) * percentage_reference / 100
#     elif string.endswith('em'):
#         assert font_size is not None
#         return font_size * float(string[:-2])
#     elif string.endswith('ex'):
#         # Assume that 1em == 2ex
#         assert font_size is not None
#         return font_size * float(string[:-2]) / 2
# 
#     for unit, coefficient in LENGTHS_TO_PIXELS.items():
#         if string.endswith(unit):
#             return float(string[:-len(unit)]) * coefficient
# 
#     # Unknown size
#     return 0


from math import inf, radians
from .bounding_box import EMPTY_BOUNDING_BOX, extend_bounding_box
from .utils import normalize, size
    from ..css.properties import INITIAL_VALUES
    from ..draw import draw_emojis, draw_first_line
    from ..text.line_break import split_first_line
    style['font_family'] = [
        font.strip('"\'') for font in
        node.get('font-family', 'sans-serif').split(',')]
    style['font_style'] = node.get('font-style', 'normal')
    style['font_weight'] = node.get('font-weight', 400)
    style['font_size'] = font_size
    if style['font_weight'] == 'normal':
        style['font_weight'] = 400
    elif style['font_weight'] == 'bold':
        style['font_weight'] = 700
    else:
        try:
            style['font_weight'] = int(style['font_weight'])
        except ValueError:
            style['font_weight'] = 400

    layout, _, _, width, height, _ = split_first_line(
        node.text, style, svg.context, inf, 0)
    # TODO: get real values
    x_bearing, y_bearing = 0, 0

    # Get rotations and translations
    x, y, dx, dy, rotate = [], [], [], [], [0]
    if 'x' in node.attrib:
        x = [size(i, font_size, svg.inner_width)
             for i in normalize(node.attrib['x']).strip().split(' ')]
    if 'y' in node.attrib:
        y = [size(i, font_size, svg.inner_height)
             for i in normalize(node.attrib['y']).strip().split(' ')]
    if 'dx' in node.attrib:

# Path: weasyprint/svg/bounding_box.py
# EMPTY_BOUNDING_BOX = inf, inf, 0, 0
# 
# def extend_bounding_box(bounding_box, points):
#     """Extend a bounding box to include given points."""
#     minx, miny, width, height = bounding_box
#     maxx, maxy = (
#         -inf if isinf(minx) else minx + width,
#         -inf if isinf(miny) else miny + height)
#     x_list, y_list = zip(*points)
#     minx, miny, maxx, maxy = (
#         min(minx, *x_list), min(miny, *y_list),
#         max(maxx, *x_list), max(maxy, *y_list))
#     return minx, miny, maxx - minx, maxy - miny
# 
# Path: weasyprint/svg/utils.py
# def normalize(string):
#     """Give a canonical version of a given value string."""
#     string = (string or '').replace('E', 'e')
#     string = re.sub('(?<!e)-', ' -', string)
#     string = re.sub('[ \n\r\t,]+', ' ', string)
#     string = re.sub(r'(\.[0-9-]+)(?=\.)', r'\1 ', string)
#     return string.strip()
# 
# def size(string, font_size=None, percentage_reference=None):
#     """Compute size from string, resolving units and percentages."""
#     from ..css.utils import LENGTHS_TO_PIXELS
# 
#     if not string:
#         return 0
# 
#     try:
#         return float(string)
#     except ValueError:
#         # Not a float, try something else
#         pass
# 
#     string = normalize(string).split(' ', 1)[0]
#     if string.endswith('%'):
#         assert percentage_reference is not None
#         return float(string[:-1]) * percentage_reference / 100
#     elif string.endswith('em'):
#         assert font_size is not None
#         return font_size * float(string[:-2])
#     elif string.endswith('ex'):
#         # Assume that 1em == 2ex
#         assert font_size is not None
#         return font_size * float(string[:-2]) / 2
# 
#     for unit, coefficient in LENGTHS_TO_PIXELS.items():
#         if string.endswith(unit):
#             return float(string[:-len(unit)]) * coefficient
# 
#     # Unknown size
#     return 0


# Path: weasyprint/svg/text.py
from math import inf, radians
from .bounding_box import EMPTY_BOUNDING_BOX, extend_bounding_box
from .utils import normalize, size
    from ..css.properties import INITIAL_VALUES
    from ..draw import draw_emojis, draw_first_line
    from ..text.line_break import split_first_line

    style['font_family'] = [
        font.strip('"\'') for font in
        node.get('font-family', 'sans-serif').split(',')]
    style['font_style'] = node.get('font-style', 'normal')
    style['font_weight'] = node.get('font-weight', 400)
    style['font_size'] = font_size
    if style['font_weight'] == 'normal':
        style['font_weight'] = 400
    elif style['font_weight'] == 'bold':
        style['font_weight'] = 700
    else:
        try:
            style['font_weight'] = int(style['font_weight'])
        except ValueError:
            style['font_weight'] = 400

    layout, _, _, width, height, _ = split_first_line(
        node.text, style, svg.context, inf, 0)
    # TODO: get real values
    x_bearing, y_bearing = 0, 0

    # Get rotations and translations
    x, y, dx, dy, rotate = [], [], [], [], [0]
    if 'x' in node.attrib:
        x = [size(i, font_size, svg.inner_width)
             for i in normalize(node.attrib['x']).strip().split(' ')]
    if 'y' in node.attrib:
        y = [size(i, font_size, svg.inner_height)
             for i in normalize(node.attrib['y']).strip().split(' ')]
    if 'dx' in node.attrib:

        dx = [size(i, font_size, svg.inner_width)