# Path: pdfminer/utils.py
# def mult_matrix(m1, m0):
#     (a1, b1, c1, d1, e1, f1) = m1
#     (a0, b0, c0, d0, e0, f0) = m0
#     """Returns the multiplication of two matrices."""
#     return (a0*a1+c0*b1,    b0*a1+d0*b1,
#             a0*c1+c0*d1,    b0*c1+d0*d1,
#             a0*e1+c0*f1+e0, b0*e1+d0*f1+f0)
# 
# Path: pdfminer/utils.py
# def translate_matrix(m, v):
#     """Translates a matrix by (x, y)."""
#     (a, b, c, d, e, f) = m
#     (x, y) = v
#     return (a, b, c, d, x*a+y*c+e, x*b+y*d+f)
# 
# Path: pdfminer/utils.py
# def q(s):
#     """Quotes html string."""
#     return (s.replace('&','&amp;')
#             .replace('<','&lt;')
#             .replace('>','&gt;')
#             .replace('"','&quot;'))
# 
# Path: pdfminer/utils.py
# def bbox2str(bbox):
#     (x0, y0, x1, y1) = bbox
#     return '%.3f,%.3f,%.3f,%.3f' % (x0, y0, x1, y1)
# 
# Path: pdfminer/utils.py
# def isnumber(x):
#     return isinstance(x, (int, float))
# 
# Path: pdfminer/pdffont.py
# class PDFUnicodeNotDefined(PDFFontError):
#     pass


from .utils import mult_matrix
from .utils import translate_matrix
from .utils import q
from .utils import bbox2str
from .utils import isnumber
from .pdffont import PDFUnicodeNotDefined
        else:
            textstate.linematrix = self.render_string_horizontal(
                seq, matrix, textstate.linematrix, font, fontsize,
                scaling, charspace, wordspace, rise, dxscale)
        return

    def render_string_horizontal(self, seq, matrix, pos,
                                 font, fontsize, scaling, charspace, wordspace, rise, dxscale):
        (x, y) = pos
        needcharspace = False
        for obj in seq:
            if isnumber(obj):
                x -= obj*dxscale
                needcharspace = True
            else:
                for cid in font.decode(obj):
                    if needcharspace:
                        x += charspace
                    x += self.render_char(translate_matrix(matrix, (x, y)),
                                          font, fontsize, scaling, rise, cid)
                    if cid == 32 and wordspace:
                        x += wordspace
                    needcharspace = True
        return (x, y)

    def render_string_vertical(self, seq, matrix, pos,
                               font, fontsize, scaling, charspace, wordspace, rise, dxscale):
        (x, y) = pos
        needcharspace = False
        for obj in seq:

# Path: pdfminer/utils.py
# def mult_matrix(m1, m0):
#     (a1, b1, c1, d1, e1, f1) = m1
#     (a0, b0, c0, d0, e0, f0) = m0
#     """Returns the multiplication of two matrices."""
#     return (a0*a1+c0*b1,    b0*a1+d0*b1,
#             a0*c1+c0*d1,    b0*c1+d0*d1,
#             a0*e1+c0*f1+e0, b0*e1+d0*f1+f0)
# 
# Path: pdfminer/utils.py
# def translate_matrix(m, v):
#     """Translates a matrix by (x, y)."""
#     (a, b, c, d, e, f) = m
#     (x, y) = v
#     return (a, b, c, d, x*a+y*c+e, x*b+y*d+f)
# 
# Path: pdfminer/utils.py
# def q(s):
#     """Quotes html string."""
#     return (s.replace('&','&amp;')
#             .replace('<','&lt;')
#             .replace('>','&gt;')
#             .replace('"','&quot;'))
# 
# Path: pdfminer/utils.py
# def bbox2str(bbox):
#     (x0, y0, x1, y1) = bbox
#     return '%.3f,%.3f,%.3f,%.3f' % (x0, y0, x1, y1)
# 
# Path: pdfminer/utils.py
# def isnumber(x):
#     return isinstance(x, (int, float))
# 
# Path: pdfminer/pdffont.py
# class PDFUnicodeNotDefined(PDFFontError):
#     pass


# Path: pdfminer/pdfdevice.py
from .utils import mult_matrix
from .utils import translate_matrix
from .utils import q
from .utils import bbox2str
from .utils import isnumber
from .pdffont import PDFUnicodeNotDefined

        else:
            textstate.linematrix = self.render_string_horizontal(
                seq, matrix, textstate.linematrix, font, fontsize,
                scaling, charspace, wordspace, rise, dxscale)
        return

    def render_string_horizontal(self, seq, matrix, pos,
                                 font, fontsize, scaling, charspace, wordspace, rise, dxscale):
        (x, y) = pos
        needcharspace = False
        for obj in seq:
            if isnumber(obj):
                x -= obj*dxscale
                needcharspace = True
            else:
                for cid in font.decode(obj):
                    if needcharspace:
                        x += charspace
                    x += self.render_char(translate_matrix(matrix, (x, y)),
                                          font, fontsize, scaling, rise, cid)
                    if cid == 32 and wordspace:
                        x += wordspace
                    needcharspace = True
        return (x, y)

    def render_string_vertical(self, seq, matrix, pos,
                               font, fontsize, scaling, charspace, wordspace, rise, dxscale):
        (x, y) = pos
        needcharspace = False
        for obj in seq:

            if isnumber(obj):