# Path: gymnast/pdf_operation/pdf_operation.py
# class PdfOperation(object):
#     """PDF content stream operations dispatcher.  Content stream operations are
#     registered by calling PdfOperation.register(), passing the opcode, the type
#     of operation, and the function that does it."""
#     # Operation type constants (see Reference p. 196)
#     # These mostly exist to make things easier in PdfRenderer methods
#     NOP                    =     0
#     GENERAL_GRAPHICS_STATE =     1
#     SPECIAL_GRAPHICS_STATE =     2
#     PATH_CONSTRUCTION      =     4
#     PATH_PAINTING          =     8
#     CLIPPING_PATHS         =    16
#     TEXT_OBJECTS           =    32
#     TEXT_STATE             =    64
#     TEXT_POSITIONING       =   128
#     TEXT_SHOWING           =   256
#     TYPE_3_FONTS           =   512
#     COLOR                  =  1024
#     SHADING_PATTERNS       =  2048
#     INLINE_IMAGES          =  4096
#     XOBJECTS               =  8192
#     MARKED_CONTENT         = 16384
#     COMPATIBILITY          = 32768
# 
#     _opcodes = {}
#     _nops    = {} # As we spawn new NOP classes, we'll cache them here
#     @classmethod
#     def register(cls, opcode, optype, opfunc):
#         """Register a new PDF operation.  Arguments are the opcode, the type of
#         operation, and the function that actually does the operation."""
#         opcode = ensure_str(opcode)
#         if not callable(opfunc):
#             raise TypeError('opfunc must be callable')
#         args = inspect.getfullargspec(opfunc)
#         if not (args.varargs or args.args):
#             raise ValueError('opfunc must take at least one positional argument')
#         opcode = ensure_str(opcode)
#         cls._opcodes[opcode] = new_opcode(opcode, optype, opfunc)
# 
#     @classmethod
#     def __getitem__(cls, operator):
#         operator = ensure_str(operator)
#         try:
#             return cls._opcodes[operator]
#         except KeyError:
#             return cls._nop(operator)
#     @classmethod
#     def _nop(cls, operator):
#         """Get the corresponding NOP operation, creating it if necessary."""
#         warnings.warn("Opcode '{}' not implemented. NOP".format(operator),
#                       PdfOpWarning)
#         try:
#             return cls._nops[operator]
#         except KeyError:
#             tpe = new_opcode(operator, 0, lambda *x: None)
#             cls._nops[operator] = tpe
#             return tpe


from ..pdf_operation import PdfOperation

def opcode_Tc(renderer, char_spacing):
    """Set the character spacing"""
    renderer.ts.c = char_spacing

def opcode_Tw(renderer, word_spacing):
    """Set the word spacing"""
    renderer.ts.w = word_spacing

def opcode_Tz(renderer, scale):
    """Set the horizontal text scale"""
    renderer.ts.h = scale/100.0

def opcode_TL(renderer, leading):
    """Set the leading space"""
    renderer.ts.l = leading

def opcode_Tf(renderer, font, size):
    """Set the font and font size"""
    renderer.ts.f  = font
    renderer.ts.fs = size

def opcode_Tr(renderer, render):
    """Set the render mode"""
    renderer.ts.mode = render

def opcode_Ts(renderer, rise):
    """Set the rise"""
    renderer.ts.rise = rise


# Path: gymnast/pdf_operation/pdf_operation.py
# class PdfOperation(object):
#     """PDF content stream operations dispatcher.  Content stream operations are
#     registered by calling PdfOperation.register(), passing the opcode, the type
#     of operation, and the function that does it."""
#     # Operation type constants (see Reference p. 196)
#     # These mostly exist to make things easier in PdfRenderer methods
#     NOP                    =     0
#     GENERAL_GRAPHICS_STATE =     1
#     SPECIAL_GRAPHICS_STATE =     2
#     PATH_CONSTRUCTION      =     4
#     PATH_PAINTING          =     8
#     CLIPPING_PATHS         =    16
#     TEXT_OBJECTS           =    32
#     TEXT_STATE             =    64
#     TEXT_POSITIONING       =   128
#     TEXT_SHOWING           =   256
#     TYPE_3_FONTS           =   512
#     COLOR                  =  1024
#     SHADING_PATTERNS       =  2048
#     INLINE_IMAGES          =  4096
#     XOBJECTS               =  8192
#     MARKED_CONTENT         = 16384
#     COMPATIBILITY          = 32768
# 
#     _opcodes = {}
#     _nops    = {} # As we spawn new NOP classes, we'll cache them here
#     @classmethod
#     def register(cls, opcode, optype, opfunc):
#         """Register a new PDF operation.  Arguments are the opcode, the type of
#         operation, and the function that actually does the operation."""
#         opcode = ensure_str(opcode)
#         if not callable(opfunc):
#             raise TypeError('opfunc must be callable')
#         args = inspect.getfullargspec(opfunc)
#         if not (args.varargs or args.args):
#             raise ValueError('opfunc must take at least one positional argument')
#         opcode = ensure_str(opcode)
#         cls._opcodes[opcode] = new_opcode(opcode, optype, opfunc)
# 
#     @classmethod
#     def __getitem__(cls, operator):
#         operator = ensure_str(operator)
#         try:
#             return cls._opcodes[operator]
#         except KeyError:
#             return cls._nop(operator)
#     @classmethod
#     def _nop(cls, operator):
#         """Get the corresponding NOP operation, creating it if necessary."""
#         warnings.warn("Opcode '{}' not implemented. NOP".format(operator),
#                       PdfOpWarning)
#         try:
#             return cls._nops[operator]
#         except KeyError:
#             tpe = new_opcode(operator, 0, lambda *x: None)
#             cls._nops[operator] = tpe
#             return tpe


# Path: gymnast/pdf_operation/operations/text_state.py
from ..pdf_operation import PdfOperation


def opcode_Tc(renderer, char_spacing):
    """Set the character spacing"""
    renderer.ts.c = char_spacing

def opcode_Tw(renderer, word_spacing):
    """Set the word spacing"""
    renderer.ts.w = word_spacing

def opcode_Tz(renderer, scale):
    """Set the horizontal text scale"""
    renderer.ts.h = scale/100.0

def opcode_TL(renderer, leading):
    """Set the leading space"""
    renderer.ts.l = leading

def opcode_Tf(renderer, font, size):
    """Set the font and font size"""
    renderer.ts.f  = font
    renderer.ts.fs = size

def opcode_Tr(renderer, render):
    """Set the render mode"""
    renderer.ts.mode = render

def opcode_Ts(renderer, rise):
    """Set the rise"""
    renderer.ts.rise = rise


PdfOperation.register('Tc', PdfOperation.TEXT_STATE, opcode_Tc)