# Path: gymnast/renderer/renderer_states.py
# class TextState(object):
#     """Renderer text state.  Has all of the various text rendering parameters
#     described on pp. 396-404 in the Reference (without the leading T).
# 
#     Attributes (all units are in text space units):
#         m:  The current text matrix
#         lm: Text matrix at the start of the current line
#         c: Charcter spacing - Amount of extra space between characters before
#            scaling by T_h.  Default 0.
#         w: Word spacing - Extra space (pre-T_h) added on encountering a space.
#            Default 0.
#         h: Horizontal scaling - Scaling factor applied to character width and
#            horizontal spacing (i.e., T_c and T_w).  Default 1.
#            N.B.: The associated Tz operator sets this to its operand divided by
#            100.
#         l: Leading - Vertical distance between the baselines of adjacent text
#            lines. Default 0.
#         f: Text font - The name of the current font in the current resource
#            dictionary.  No default value.
#         fs: Text font size - Scaling factor applied to the font in all
#             directions.  No default value.
#         mode: Text rendering mode - Determines text shading, outlining, when
#               rendering text.  Default 0 (solid fill, no stroke).
#         rise: Text rise - Vertical offset from the baseline at which to draw
#               the text.  Positive values result in superscript, negative in
#               subsctipt. Default 0.
#         k: Text knockout - Boolean used in drawing overlappign characters.
#            Set through graphics state operators.  Default True."""
#     id_matrix = PdfMatrix(1, 0, 0, 1, 0, 0)
#     def __init__(self):
#         """Create a new TextState object with values initialed to their
#         respective defaults"""
#         self.c     = 0.0    # Char space
#         self.w     = 0.0    # Word space
#         self.h     = 1.0    # Horizontal text scale
#         self.l     = 0.0    # Text leading
#         self.f     = None   # Font
#         self.fs    = None   # Font scaling
#         self.mode  = 0      # Text render mode
#         self.rise  = 0.0    # Text rise
#         self.m     = self.id_matrix # Text Matrix
#         self.lm    = self.id_matrix # Line Matrix
# 
#     def reset_m(self):
#         """Reset the text matrix to the identity"""
#         self.m  = self.id_matrix
# 
#     def reset_lm(self):
#         """Reset the line matrix to the general text matrix"""
#         self.lm = copy.copy(self.m)
# 
# class GraphicsState(RendererState):
#     """Renderer graphics state.  Has all of the various graphical state
#     parameters, including the current transformation matrix."""
#     def __init__(self):
#         self.CTM         = self.id_matrix # Current transformation matrix
#         self.line_width  = 1.0
#         self.line_cap    = 0
#         self.line_join   = 0
#         self.miter_limit = 10.0
#         self.dash_array  = []   # See p. 217
#         self.dash_phase  = 0
#         self.intent      = None # See p. 260
#         self.flatness    = 0    # See S6.5.1 - p. 508
# 
# Path: gymnast/pdf_matrix.py
# class PdfMatrix(object):
#     """Very limited matrix class representing PDF transformations"""
#     def __init__(self, a, b, c, d, e, f):
#         """Create a new PdfMatrix object.  Arguments real numbers and represent
#         a matrix as described on p. 208 of the Reference:
#                                       [ a b 0 ]
#         PdfMatrix(a, b, c, d, e, f) = [ c d 0 ]
#                                       [ e f 1 ]
#         """
#         self.a = float(a)
#         self.b = float(b)
#         self.c = float(c)
#         self.d = float(d)
#         self.e = float(e)
#         self.f = float(f)
#     def transform_coords(self, x, y):
#         return (self.a*x+self.c*y+self.e,
#                 self.b*x+self.d*y+self.f)
#     def __mul__(self, other):
#         """Matrix multiplication.
#         Given the type constraint below, this will be self*other"""
#         if not isinstance(other, PdfMatrix):
#             raise TypeError('Can only multiply PdfMatrices by PdfMatrice')
#         return PdfMatrix(self.a*other.a+self.b*other.c,
#                          self.a*other.b+self.b*other.d,
#                          self.c*other.a+self.d*other.c,
#                          self.c*other.b+self.d*other.d,
#                          self.e*other.a+self.f*other.c+other.e,
#                          self.e*other.b+self.f*other.d+other.f)
#     @property
#     def current_coords(self):
#         """Current x, y offset in whatever space this matrix represents"""
#         return self.e, self.f
#     def copy(self):
#         """Return a copy of this matrix"""
#         return PdfMatrix(self.a, self.b,
#                          self.c, self.d,
#                          self.e, self.f)


from .renderer_states import TextState, GraphicsState
from ..pdf_matrix    import PdfMatrix
import copy
import io
"""
Base page renderer class
"""




#Nonsense to make PTVS happy


class PdfBaseRenderer(object):
    """PdfRenderer object.  PdfOperations act on this to produce a
    representation of the contents of the pdf document.  This class primarily
    serves to maintain the global state as the page is drawn.

    Usage:
        redered_page = PdfRenderer(page).render()

    TODO: Vertical writing support
    TODO: Figure out graphics stuff"""

    def __init__(self, page):

# Path: gymnast/renderer/renderer_states.py
# class TextState(object):
#     """Renderer text state.  Has all of the various text rendering parameters
#     described on pp. 396-404 in the Reference (without the leading T).
# 
#     Attributes (all units are in text space units):
#         m:  The current text matrix
#         lm: Text matrix at the start of the current line
#         c: Charcter spacing - Amount of extra space between characters before
#            scaling by T_h.  Default 0.
#         w: Word spacing - Extra space (pre-T_h) added on encountering a space.
#            Default 0.
#         h: Horizontal scaling - Scaling factor applied to character width and
#            horizontal spacing (i.e., T_c and T_w).  Default 1.
#            N.B.: The associated Tz operator sets this to its operand divided by
#            100.
#         l: Leading - Vertical distance between the baselines of adjacent text
#            lines. Default 0.
#         f: Text font - The name of the current font in the current resource
#            dictionary.  No default value.
#         fs: Text font size - Scaling factor applied to the font in all
#             directions.  No default value.
#         mode: Text rendering mode - Determines text shading, outlining, when
#               rendering text.  Default 0 (solid fill, no stroke).
#         rise: Text rise - Vertical offset from the baseline at which to draw
#               the text.  Positive values result in superscript, negative in
#               subsctipt. Default 0.
#         k: Text knockout - Boolean used in drawing overlappign characters.
#            Set through graphics state operators.  Default True."""
#     id_matrix = PdfMatrix(1, 0, 0, 1, 0, 0)
#     def __init__(self):
#         """Create a new TextState object with values initialed to their
#         respective defaults"""
#         self.c     = 0.0    # Char space
#         self.w     = 0.0    # Word space
#         self.h     = 1.0    # Horizontal text scale
#         self.l     = 0.0    # Text leading
#         self.f     = None   # Font
#         self.fs    = None   # Font scaling
#         self.mode  = 0      # Text render mode
#         self.rise  = 0.0    # Text rise
#         self.m     = self.id_matrix # Text Matrix
#         self.lm    = self.id_matrix # Line Matrix
# 
#     def reset_m(self):
#         """Reset the text matrix to the identity"""
#         self.m  = self.id_matrix
# 
#     def reset_lm(self):
#         """Reset the line matrix to the general text matrix"""
#         self.lm = copy.copy(self.m)
# 
# class GraphicsState(RendererState):
#     """Renderer graphics state.  Has all of the various graphical state
#     parameters, including the current transformation matrix."""
#     def __init__(self):
#         self.CTM         = self.id_matrix # Current transformation matrix
#         self.line_width  = 1.0
#         self.line_cap    = 0
#         self.line_join   = 0
#         self.miter_limit = 10.0
#         self.dash_array  = []   # See p. 217
#         self.dash_phase  = 0
#         self.intent      = None # See p. 260
#         self.flatness    = 0    # See S6.5.1 - p. 508
# 
# Path: gymnast/pdf_matrix.py
# class PdfMatrix(object):
#     """Very limited matrix class representing PDF transformations"""
#     def __init__(self, a, b, c, d, e, f):
#         """Create a new PdfMatrix object.  Arguments real numbers and represent
#         a matrix as described on p. 208 of the Reference:
#                                       [ a b 0 ]
#         PdfMatrix(a, b, c, d, e, f) = [ c d 0 ]
#                                       [ e f 1 ]
#         """
#         self.a = float(a)
#         self.b = float(b)
#         self.c = float(c)
#         self.d = float(d)
#         self.e = float(e)
#         self.f = float(f)
#     def transform_coords(self, x, y):
#         return (self.a*x+self.c*y+self.e,
#                 self.b*x+self.d*y+self.f)
#     def __mul__(self, other):
#         """Matrix multiplication.
#         Given the type constraint below, this will be self*other"""
#         if not isinstance(other, PdfMatrix):
#             raise TypeError('Can only multiply PdfMatrices by PdfMatrice')
#         return PdfMatrix(self.a*other.a+self.b*other.c,
#                          self.a*other.b+self.b*other.d,
#                          self.c*other.a+self.d*other.c,
#                          self.c*other.b+self.d*other.d,
#                          self.e*other.a+self.f*other.c+other.e,
#                          self.e*other.b+self.f*other.d+other.f)
#     @property
#     def current_coords(self):
#         """Current x, y offset in whatever space this matrix represents"""
#         return self.e, self.f
#     def copy(self):
#         """Return a copy of this matrix"""
#         return PdfMatrix(self.a, self.b,
#                          self.c, self.d,
#                          self.e, self.f)


# Path: gymnast/renderer/base_renderer.py
from .renderer_states import TextState, GraphicsState
from ..pdf_matrix    import PdfMatrix
import copy
import io

"""
Base page renderer class
"""




#Nonsense to make PTVS happy


class PdfBaseRenderer(object):
    """PdfRenderer object.  PdfOperations act on this to produce a
    representation of the contents of the pdf document.  This class primarily
    serves to maintain the global state as the page is drawn.

    Usage:
        redered_page = PdfRenderer(page).render()

    TODO: Vertical writing support
    TODO: Figure out graphics stuff"""

    def __init__(self, page):

        self.ts      = TextState()     # Text state