%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/reportlab/graphics/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/reportlab/graphics/__pycache__/renderPS.cpython-312.pyc

�

��d1���f�dZdZddlZddlmZmZddlmZmZm	Z	ddl
mZmZm
Z
mZmZddlmZddlmZmZmZdd	lmZdd
lmZddlmZiZed�D]HZed
ksedk\r	dezee<�eed�ed�ed�fvrde e�zee<�>e e�ee<�J[d�Z!dZ"Gd�d�Z#	ddl�ddejHfd�Z%d�Z&Gd�de�Z'ejHfd�Z(ejHfd�Z)d$d�Z*e+d k(r6ddl,Z,e-e,j\�d!kDre,j\d!Z/ndZ/e*e/d"�#�yy)%z3.3.0z$Render drawing objects in Postscript�N)�BytesIO�StringIO)�getFont�stringWidth�
unicode2T1)�asBytes�char2int�rawBytes�asNative�	isUnicode)�fp_str)�Renderer�
getStateDelta�renderScaledDrawing)�STATE_DEFAULTS)�	rl_config)�
FILL_EVEN_ODD�� �z\%03o�\�(�)c���t|�}g}|j}d}|D]:}tt|�}||�|t	|�z
}|dk\s�1d}|d��<dj|�S)Nr��z\
�)r�append�_ESCAPEDICTr	�len�join)�s�R�aR�n�cs     �=/usr/lib/python3/dist-packages/reportlab/graphics/renderPS.py�_escape_and_limitr'sr����
�A�
�A�	
���B�	�A�
�������$��
�1��	�S��V����c�6��A��v�J�
��7�7�1�:��a?
/RE { %def
  findfont begin
  currentdict dup length dict begin
 { %forall
   1 index /FID ne { def } { pop pop } ifelse
 } forall
 /FontName exch def dup length 0 ne { %if
   /Encoding Encoding 256 array copy def
   0 exch { %forall
     dup type /nametype eq { %ifelse
       Encoding 2 index 2 index put
       pop 1 add
     }{ %else
       exch pop
     } ifelse
   } forall
 } if pop
  currentdict dup end end
  /FontName get exch definefont pop
} bind def

/WinAnsiEncoding [
  39/quotesingle 96/grave 128/euro 130/quotesinglbase/florin/quotedblbase
  /ellipsis/dagger/daggerdbl/circumflex/perthousand
  /Scaron/guilsinglleft/OE 145/quoteleft/quoteright
  /quotedblleft/quotedblright/bullet/endash/emdash
  /tilde/trademark/scaron/guilsinglright/oe/dotlessi
  159/Ydieresis 164/currency 166/brokenbar 168/dieresis/copyright
  /ordfeminine 172/logicalnot 174/registered/macron/ring
  177/plusminus/twosuperior/threesuperior/acute/mu
  183/periodcentered/cedilla/onesuperior/ordmasculine
  188/onequarter/onehalf/threequarters 192/Agrave/Aacute
  /Acircumflex/Atilde/Adieresis/Aring/AE/Ccedilla
  /Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute
  /Icircumflex/Idieresis/Eth/Ntilde/Ograve/Oacute
  /Ocircumflex/Otilde/Odieresis/multiply/Oslash
  /Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn
  /germandbls/agrave/aacute/acircumflex/atilde/adieresis
  /aring/ae/ccedilla/egrave/eacute/ecircumflex
  /edieresis/igrave/iacute/icircumflex/idieresis
  /eth/ntilde/ograve/oacute/ocircumflex/otilde
  /odieresis/divide/oslash/ugrave/uacute/ucircumflex
  /udieresis/yacute/thorn/ydieresis
] def
c�Z�eZdZd3d�Zd�Zd4d�Zd�Zd�Zd5d�Zd�Z	d	�Z
d4d
�Zd�Zd�Z
gd
fd�Zd�Zd�Zd�Zd�Zd�Zd5d�Zd�Zd�Zd6d�Zd6d�Zd7d�Zd8d�Zd9d�Zd6d�Zd:d�Zd;d�Zd�Zd �Z d<d!�Z!d"�Z"d=d#�Z#d4d$�Z$d%�Z%d&�Z&d'�Z'd(�Z(d)�Z)d6d*�Z*d>d+�Z+d,�Z,d-�Z-d.�Z.d/�Z/d4d0�Z0d1�Z1d4d2�Z2y)?�PSCanvasc�B�|\|_|_g}|j|_|j|_d|_g|_|jj|_d|_	dx|_
x|_x|_x|_
x|_x|_x|_|_g|_|j't(dt(d�|j+t(d�|j-d�|j/d�|j1d�||_t4|_y)Nr�
�fontName�fontSize�strokeColor��)�width�heightr�_xtraState_push�pop�_xtraState_pop�comments�code�code_append�_sep�_strokeColor�
_fillColor�
_lineWidth�_font�	_fontSize�_lineCap�	_lineJoin�_color�
_fontsUsed�setFontr�setStrokeColor�
setLineCap�setLineJoin�setLineWidth�PostScriptLevelr�	_fillMode)�self�sizerI�	xtraStates    r&�__init__zPSCanvas.__init__[s��"&���
�D�K��	�(�/�/���'�m�m�����
���	��9�9�+�+�����	�,0�	0���	0�D�O�	0�d�o�	0��J�	0���	0�*.�-�	0��N�T�[�������^�J�/��z�0J�K����N�=�9�:��������������!��,���&��r(c�F�|jr|jd|z�yy)N�%)r7r9)rK�msgs  r&�commentzPSCanvas.commentqs���=�=�$�*�*�3�s�7�3�=r(Nc���|jdk(r|j|||||�y|jdk(r|j|||||�ytd|jz��)Nr1r0zUnsupported Postscript Level %s)rI�_drawImageLevel1�_drawImageLevel2�
ValueError)rK�image�x1�y1r2r3s      r&�	drawImagezPSCanvas.drawImagetsa������"��!�!�%��B��v�>�
�
!�
!�1�
$��!�!�%��R���?��>��AU�AU�U�V�Vr(c�&�|jd�y)N�showpage�r9�rKs r&�clearzPSCanvas.clear}s������$r(c�`�|jsyg}|jD]B}t|�}|jr�|jdk(s�+|j	d|�d|�d���D|rL|jdt�|jjd|jj|��yy)N�WinAnsiEncodingzWinAnsiEncoding /z /z RErr1)
rCr�_dynamicFont�encNamer�insert�PS_WinAnsiEncodingr8r:r )rK�Cr-�fontObjs    r&�
_t1_re_encodezPSCanvas._t1_re_encode�s������������	N�H��h�'�G��'�'�G�O�O�=N�,N�����8�L�M�	N�
�
�H�H�Q�)�*��I�I���Q��	�	���q� 1�2�
r(c���t|d�s
t|d�}n|}|jddk7r|j�|jj	dd|j
|jfz�|j�|jt|jj|j���||ur"|j�ddl
m}||dd	�
�yy)N�write�wb���r\rz�%%!PS-Adobe-3.0 EPSF-3.0
%%%%BoundingBox: 0 0 %d %d
%%%% Initialization:
/m {moveto} bind def
/l {lineto} bind def
/c {curveto} bind def
)�markfilename�XPR3�EPSF)�creatorcode�filetype)�hasattr�openr8r_rdr2r3rhrjr
r:r �close�reportlab.lib.utilsrm)rK�f�_frms    r&�savez
PSCanvas.save�s����q��!��a���B��B��9�9�R�=�*�$�d�j�j�l��	�	������z�z�$�+�+���	 �	
����
����$�)�)�.�.����3�4�5�
�Q�;��H�H�J�8���v�v�>�r(c�^�|j|jf�|jd�y)N�gsave)r4�_fontCodeLocr9r^s r&�	saveStatezPSCanvas.saveState�s'�����d�/�/�1�2�����!r(c�T�|jd�|j�\|_y)N�grestore)r9r6r{r^s r&�restoreStatezPSCanvas.restoreState�s$������$�!�0�0�2���r(c�\�|xs|j}|xs|j}t|||�S)zlReturn the logical width of the string if it were drawn
        in the current font (defaults to self.font).)r>r?r)rKr!�fontr.s    r&rzPSCanvas.stringWidth�s/���!�t�z�z���-�t�~�~���1�d�H�-�-r(c�Z�|j|k7r||_|jd|z�yy)Nz
%d setlinecap)r@r9�rK�vs  r&rFzPSCanvas.setLineCap�s-���=�=�!���D�M����_�Q�.�/�r(c�Z�|j|k7r||_|jd|z�yy)Nz%d setlinejoin)rAr9r�s  r&rGzPSCanvas.setLineJoin�s.���>�>�1���D�N����-�a�/�0�r(rc�"�d}t|ttf�r|jd|�d|�d|���yt|tt
f�rF|dk\sJd��dj
tt|��}|jd|�d|�d|���yy)	z7Two notations.  pass two numbers, or an array and phase�setdash�[� z] 0 rzphase is a length in user spacez] N)	�
isinstance�float�intr9�tuple�listr �map�str)rK�array�phase�psoperation�	textarrays     r&�setDashzPSCanvas.setDash�sz�� ���e�U�3�K�(����u�e�[�I�J�
��u�T�l�
+��A�:�@�@�@�:�����S�%��1�I����Y��{�K�L�,r(c�4�||_|j|�y�N)r;�setColor�rK�colors  r&rEzPSCanvas.setStrokeColor�s��!����
�
�e�r(c	�\�|j|k7r�||_|r�t|d�rI|jdt|j|j
|j|j�z�y|jdt|j|j|j�z�yyy)N�cyanz%s setcmykcolorz%s setrgbcolor)rBrrr9r
r��magenta�yellow�black�red�green�bluer�s  r&r�zPSCanvas.setColor�s����;�;����D�K���5�&�)��$�$�%6���
�
�E�M�M�[`�[g�[g�in�it�it�9u�%u�v��$�$�%5��u�y�y�%�+�+�W\�Wa�Wa�8b�%b�c�	�r(c�4�||_|j|�yr�)r<r�r�s  r&�setFillColorzPSCanvas.setFillColor�s������
�
�e�r(c��||_yr�)rJr�s  r&�setFillModezPSCanvas.setFillMode�s	����r(c�Z�||jk7r||_|jd|z�yy)Nz%s setlinewidth)r=r9)rKr2s  r&rHzPSCanvas.setLineWidth�s.���D�O�O�#�#�D�O����.��6�7�$r(c��|j|k7s|j|k7r:t|j�|_||_||_|jd�yy)Nr)r>r?rr8r{r9)rKr�r.�leadings    r&rDzPSCanvas.setFont�sJ���:�:�t��t�~�~�x�7� #�D�I�I��D���D�J�%�D�N����R� �	 8r(c��|jdk7rG|j|j�|jt||��dt||��d��yy)Nz m z	 l stroke)r;r�r9r
�rKrXrY�x2�y2s     r&�linez
PSCanvas.line�sF������$��M�M�$�+�+�,����6�"�b�>�6�"�b�>�R�S�%r(c�R�	t|�S#tdt|�z��xYw)z{
        return a copy of string s with special characters in postscript strings
        escaped with backslashes.
        zcannot escape %s)r'rV�ascii)rKr!s  r&�_escapezPSCanvas._escape�s.��
	<�$�Q�'�'��	<��/�%��(�:�;�;�s�

�&c��|dk(ryt||�}|j|�}|dk(r3|j|j�|j	|�d|�d��y|dk(xs|dk(xs|dk(xs|dk(}|dk(xs|dk(xs|d	k(xs|dk(}|dk\}|r�|r�|j�d
}	nd}	|j|j�|j	|�d|�d|	���|j	d
�|j
�-|j|j
�|j	d�yy|j|j
�|j	|�d|�d��y)N�rz m (z) show r0��r1�rzfill z) true charpath gsave z	grestore zstroke z) true charpath stroke )r
r�r�r<r9r;)
rK�x�yr!�textRenderMode�xy�fill�stroke�	addToClip�ops
          r&�_textOutzPSCanvas._textOut�sS���1��f�
�A�a�[���L�L��O���1���M�M�$�/�/�*����"�Q�7�8���q� �_�N�A�$5�_���9J�_�n�^_�N_����"�a�n�a�&7�a�>�1�;L�a�P^�`a�Pa��"�A�%�	��F����&������
�
�d�o�o�.����2�a��K�L����[�)�� � �,��
�
�d�/�/�0�� � ��+�-�
�M�M�$�+�+�,����"�Q�G�Hr(c�<�|}|j}|j}|j}	|j}
t	|�s	|jd�}t||g|jz�D]�\}}||k7rNt|jj�}|d|�d	t|��d
��||	vr|	j|�|}|j||||�||j!|j|j"�|�z
}��||k7r.d|_|j'|jj|�yy#t$rW}|jdd\}}
t
|jdd|jd�d||dz
|�d|||
�d||
|
dz��fz��d}~wwxYw)N�utf8r0r�r,�
z-->z<--r�) findfont � scalefont setfont)r9r?rCr�r�decode�UnicodeDecodeError�argsr�substitutionFontsr�face�namer
rr�rrcr>rD)rKrgr�r�r!r��fcr9r.�	fontsUsed�escape�e�i�jrv�t�psNames                 r&�_issueT1StringzPSCanvas._issueT1Strings���
���&�&���>�>���O�O�	�������|�
w��H�H�V�$��
�q�'��7�+D�+D�!D�E�	=�D�A�q��"�u�!�!�&�&�+�+�.���F�6�RZ�K[�\�]���*��$�$�V�,����M�M�!�A�a��/�
����q�x�x��	�	�2�8�<�<�A�	=��B�;��D�J��L�L����*�*�8�4���&�
w��f�f�Q�q�k���!�(�1�6�6�"�1�:�Q�V�V�TU�Y�WX�YZ�[]�Y]�^_�W`�ab�cd�ef�ag�hi�jk�lm�np�lp�hq�7r�6t�+t�v�v��
w�s�D;�;	F�AF�Fc��|dv}|dv}|s|�r�|dk7ret||j|j�}	|dk(r||	z}n9|dk(r	||	dzz}n+|dk(r&|t|||	|j|j�z}t	|j�}
|j
|js{t|
jj�}d|�d	t|j��d
�|j
|j<||jvr|jj|�|dk7r/|jdt||��d
t|��d��dx}}|j}|
jr|j!||||��n|j#|
||||��|j%|�|dk7r|jd�yyy)N)rr0r�r�)r1r0r�r��left�end�middle�@�numericrr�r�rzgsave z translate z rotate�r�r~)rr>r?�
numericXShiftrr8r{rr�r�r
rCrr9rBrbr�r�r�)
rKr�r�r!�angle�text_anchorr��needFill�
needStroke�textLenrgr��oldColors
             r&�
drawStringzPSCanvas.drawString+s���!�Y�.��#�y�0�
��z��F�"�%�a����D�N�N�C����%���L�A� �(�*�����O�A� �)�+���{�1�W�T�Z�Z����W�W�A��d�j�j�)�G��9�9�T�.�.�/�!�'�,�,�"3�"3�4��U[�\b�cg�cq�cq�\r�-s��	�	�$�+�+�,�����0��O�O�*�*�6�2��a�x�� � �6�!�A�;�v�V[�}�!]�^��	��A��{�{�H��#�#��
�
�a��A�n�
�E��#�#�G�A�a��.�#�Q��M�M�(�#��a�x�� � ��,��1"r(c�0�|j|||||��y�N)r�r��r�)rKr�r��textr�r�s      r&�drawCentredStringzPSCanvas.drawCentredStringIs���O�O�A�a��+�n�O�]r(c�0�|j|||||��yr�r�)rKr�r�r�r�r�s      r&�drawRightStringzPSCanvas.drawRightStringLs������Q�q�[���Xr(c
	�\�d}
t||�t||||||�f}|jdk7r2|j|j�|j|
|zdz�|jdk7r>|j|j�|j|
|z|	xrdxsdzdz�yy)Nz%s m %s curvetoz eofillz
 closepathrz stroke)r
r<r�r9r;)rKrXrYr�r��x3�y3�x4�y4�closed�codeline�datas            r&�	drawCurvezPSCanvas.drawCurveOs���$���r�2���r�2�r�2�r�2� >�?���?�?�d�"��M�M�$�/�/�*����h��o��:�;�����$��M�M�$�+�+�,����h��o� &� 7�<�>�B�@�'�(�
)�%r(c��t||�t||�}}t||�t||�}}|j||f||f||f||ffd||��y)z)Draw a rectangle between x1,y1, and x2,y2r1)r�r�r�N)�min�max�polygon)rKrXrYr�r�r�r�s       r&�rectz
PSCanvas.rect]s\���R���S��R�[�B���R���S��R�[�B�����r�"�g�r�"�g�r�"�g�r�"�g�6�q��X\��]r(c	�x�t||�t||�}}t||�t||�}}d}dg}|j}	|	|||z||z||ddfz�|	|||z||z
||ddfz�|	|||z
||z
||ddfz�|	|||z
||z||ddfz�|	d�|j|�y	)
z�Draw a rounded rectangle between x1,y1, and x2,y2,
        with corners inset as ellipses with x radius rx and y radius ry.
        These should have x1<x2, y1<y2, rx>0, and ry>0.zJmatrix currentmatrix %s %s translate %s %s scale 0 0 1 %s %s arc setmatrix�newpath�Z�i�hr�	closepathN)r�r�r�_fillAndStroke)
rKrXrYr�r��rx�ry�ellipsePath�rr�as
          r&�	roundRectzPSCanvas.roundRectes����R���S��R�[�B���R���S��R�[�B��c���[���I�I��	�+��B���2��r�B�3��C�8�
8�9�	�+��B���2��r�B�3��S�9�
9�:�	�+��B���2��r�B�3��S�9�
9�:�	�+��B���2��r�B�3��B�7�
7�9�	�+�����B�r(c�,�|j||||�y)zqDraw an orthogonal ellipse inscribed within the rectangle x1,y1,x2,y2.
        These should have x1<x2 and y1<y2.N)�drawArcr�s     r&�ellipsezPSCanvas.ellipse�s��	
���R��B�r�"r(c�D�|j||z
||z
||z||z�yr�)r)rK�xc�yc�rs    r&�circlezPSCanvas.circle�s$�����R��T�"�Q�$��1��R��T�*r(c��||zdz||zdz}	}||z
dz||z
dz}}
|j||||||�}tj|zdz}
tj|zdz}|
|z}d}|jdk7r�|j	|j�|j|�d}|jdk7r|jd�|j||	�|jd�|jdk7r|jd�|jdk7r�|j	|j�||
tj|
�zz|	|tj|
�zz}}|s|j|�|r5|j||	�|j||�|jd	�|jd
�yy)z�Draw a partial ellipse inscribed within the rectangle x1,y1,x2,y2,
        starting at startAng degrees and covering extent degrees.   Angles
        start with 0 to the right (+x) and increase counter-clockwise.
        These should have x1<x2 and y1<y2.r�g�f@rNr1rz�eofillr~r�r�)
�_genArcCode�math�pir<r�r9r;�lineTo�cos�sin)rKrXrYr�r��startAng�extent�
fromcenter�cx�cyr�rr��startAngleRadians�
extentRadians�endAngleRadians�codelineAppended�startx�startys                   r&rzPSCanvas.drawArc�s����R�%���r�"�u�c�k�B���R�%���r�"�u�c�k�B���#�#�B��B��H�f�E�� �G�G�H�,�U�2�������u�,�
�+�m�;�����?�?�d�"��M�M�$�/�/�*����X�&� ��� � �$�&��(8�(8��(A��K�K��2�����X�&�� � �$�&��(8�(8��(D�����$��M�M�$�+�+�,� "�2�d�h�h�/@�&A�#A� A�2�b����Rc�Id�Fd�Cd�V�V�#�� � ��*�����B�r�"����F�F�+�� � ��-����X�&�%r(c��t||z
dz�}t||z
dz�}||zdz||zdz}
}	d}|dk\rd}nd}|	|
|||||z|f}
||
zS)zOCalculate the path for an arc inscribed in rectangle defined by (x1,y1),(x2,y2)r�zImatrix currentmatrix %s %s translate %s %s scale 0 0 1 %s %s %s setmatrixr�arc�arcn)�abs)rKrXrYr�r�rr�xScale�yScaler�r�r�r!r�s              r&rzPSCanvas._genArcCode�sy���b��e�S�[�!���b��e�S�[�!���2��s�{�R��U�C�K�1��^���Q�;��C��C��!�V�V�X�x����D���$��r(c��t|�dk\sJd��|d}|dd}g}|j}|dt|�z�|D]}|dt|�z��|r|d�|j|||��y)	Nr0z"Polygon must have 2 or more pointsrr1�%s m�%s lr�)r�r�)rrr
r�)	rK�pr�r�r��start�polyr�points	         r&r�zPSCanvas.polygon�s����1�v��{�@�@�@�{��!���
�a�b�E�����K�K��	�&�6�%�=�
 �!��	&�E�
�f�v�e�}�$�%�	&��
�k�N����D��D��9r(c	���|jdk7rS|j|j�d}|D]0}|j|t|d�t|d�fz��2yy)Nz%s m %s l strokerr1)r;�	_setColorr9r
)rK�lineListr�r2r�r�s      r&�lineszPSCanvas.lines�se������$��N�N�4�,�,�-�)�H� �
O��� � ��V�D��G�_�V�D��G�_�,M�!M�N�
O�%r(c�@�|jdt||�z�y)Nr'�r9r
�rKr�r�s   r&�moveTozPSCanvas.moveTo��������&��A�,�.�/r(c�@�|jdt||�z�y)Nr(r2r3s   r&rzPSCanvas.lineTo�r5r(c�H�|jdt||||||�z�y)Nz%s cr2)rKrXrYr�r�r�r�s       r&�curveTozPSCanvas.curveTo�s$������&��B�r�"�R��";�;�<r(c�&�|jd�y)Nr�r]r^s r&�	closePathzPSCanvas.closePath�s������%r(c�&�t|�dk\sJd��|jdk7rm|j|j�|j|dd|dd�|ddD]}|j	|d|d��|jd�yy)Nr1z#Polyline must have 1 or more pointsrr�)rr;r�r4rr9)rKr)r�s   r&�polyLinezPSCanvas.polyLine�s����1�v��{�A�A�A�{�����$��M�M�$�+�+�,��K�K��!��Q���1��a��)��q�r�U�
(�����A�a�D�!�A�$�'�
(����X�&�%r(c�`�g}|j}d}|D]�}|d}t|dd�}|tk(rK|rd}|dt|dd�z�n|dt|dd�z�|dt|dd�z��j|tk(r+d}|dd\}	}
}}}
}||j|	|
|||
|����|tk(rK|rd}|dt|dd�z�n|dt|dd�z�|dt|dd�z���td|z��|r|d	�|j|�y)
Nr1rr'r0r(r�z
%s curvetozunknown figure operator: r�)	rr��
figureLiner
�	figureArcr�figureCurve�	TypeErrorr�)rK�partListr��
figureCoder�first�partr�r�rXrYr�r��
startAnglers               r&�
drawFigurezPSCanvas.drawFigure�s\���
��������	@�D��a��B���Q�R��>�D��Z����E��f�v�d�2�A�h�/�/�0��f�v�d�2�A�h�/�/�0��&�6�$�q�r�(�+�+�,��y����04�R�a��-��2�b��J�v��$�"�"�2�b��B�z�&�A�B��{�"���E��f�v�d�2�A�h�/�/�0��f�v�d�2�A�h�/�/�0��,���Q�R��!1�1�2�� ;�B� >�?�?�3	@�6�
�k�N����J�'r(c�^�|jxr|}|jxr|}|s|s|�r|jj|�|ro|�|j}|s|r|jd�|j
|j�|j|tk(rdnd�|s|r|jd�|rR|r|jd�|j
|j�|jd�|r|jd�|r#|jd�|jd�yyy)Nrzrr�r~r��clipr�)r<r;r8�extendrJr9r�r)rKr8rIr�r��fillModes      r&r�zPSCanvas._fillAndStrokes�����'�4���"�"�-�v���6�T��I�I���T�"���#�#�~�~�H��T�4�#3�#3�G�#<��
�
�d�o�o�.�� � �X�}�-D��&�Q��T�4�#3�#3�J�#?����)�)�'�2��
�
�d�/�/�0�� � ��*���)�)�*�5��� � ��(�� � ��+��"r(c�@�|jdt||�z�y)Nz%s translater2r3s   r&�	translatezPSCanvas.translate,s������&��1�+�5�6r(c�@�|jdt||�z�y)Nz%s scaler2r3s   r&�scalezPSCanvas.scale/s������f�Q�q�k�1�2r(c�H�|jdt||||||�z�y)Nz[%s] concatr2)rKr�br%�dr�rvs       r&�	transformzPSCanvas.transform2s$��������!�A�a��!�)<�<�=r(c�"�||c|_|_y)z1if this is used we're probably in the wrong worldN)r2r3)rK�w�hs   r&�_drawTimeResizezPSCanvas._drawTimeResize5s��"#�Q���
�D�Kr(c�t�d}|jd�}|j\}}	|s|}|s|	}|jjd|�d|�d�|�d|�d�d|zg�|jj|�d|	�d|��d|�dd	�dd	�d|	�dd	�d|	�d
�
ddg�t	|d
�r|j
n|j�}
|j|
�}t|�}|jd�}
|
dk7r(|j|
�|jd�}
|
dk7r�(|jd�|jd�y)N��RGBrzr��
 translate� scalez/scanline %d 3 mul string defr�r�]z2{ currentfile scanline readhexstring pop } false 3zcolorimage �tobytes�Nrz% end of image datar~)�convertrLr8rJrrr^�tostring�_AsciiHexEncoder�readr9)rKrWrXrYr2r3�component_depth�myimage�imgwidth�	imgheight�rawimage�hex_encoded�	outstream�datalines              r&rTzPSCanvas._drawImageLevel19s;�����-�-��&��%�l�l���)���E���F�&	
�	�	����!#�B�'�"�6�*�+�h�6�	�	�	
�	�	���"�I��?�%-�q�!�i�Z��I�N�@��	�	�X�w�w�y�'A�G�O�O�w�GW�GW�Z���*�*�8�4���[�)�	��>�>�"�%���"�n����X�&��n�n�R�(�H��"�n�	
���.�/�����$r(c��t�}t|�D]}|jdt|�z��!|j	�S)zHelper function used by imagesz%02x)rrrjr	�getvalue)rK�input�output�chars    r&rbzPSCanvas._AsciiHexEncodews>������E�N�	2�D��L�L��(�4�.�0�1�	2���� � r(c	��|jdk(rd}d}|}n:|jdk(r|jd�}d}|}n|jd�}d}d}|j\}	}
|s|	}|s|
}|jj	d|�d|�d	�|�d|�d
�g�|dk(r|jd�n|dk(r|jd�|jd
|	|
fz�|dk(r|jd�|dk(r|jd�|jj	d|	�d|
�d|
�d�dddg�t
|d�r|jn|j�}|j|�}t|�}
|
jd�}|dk7r(|j|�|
jd�}|dk7r�(|jd�|jd�y)z"At present we're handling only PIL�LrYr1�1rZr�rzr�r[r\z/DeviceRGB setcolorspacez/DeviceGray setcolorspacezY
<<
/ImageType 1
/Width %d /Height %d  %% dimensions of source image
/BitsPerComponent %dz
/Decode [0 1]z6/Decode [0 1 0 1 0 1]  %% decode color values normallyz/ImageMatrix [z 0 0 z 0 r]z./DataSource currentfile /ASCIIHexDecode filterz>> % End image dictionaryrWr^r_rz> % end of image datar~N)�moder`rLr8rJr9rrr^rarbrrc)rKrWrXrYr2r3�imBitsPerComponent�imNumComponentsre�imwidth�imheightrhrirjrks               r&rUzPSCanvas._drawImageLevel2~s����:�:�s�?�!"���O��G�
�Z�Z�3�
��m�m�C�(�G��O��G��m�m�E�*�G��O�!"��#�L�L������E���F��	�	����!#�B�'�"�6�*�,�	-�
�a�����7�8�
��
!����8�9�����#�H�.@�A�	B�	D��a�����_�-��a�����U�V��	�	���w��	�S[�\�L�7�#�%�	&�
X�w�w�y�'A�G�O�O�w�GW�GW�Z���*�*�8�4���[�)�	��>�>�"�%���"�n����X�&��n�n�R�(�H��"�n�	
���0�1�����$r())�,ryr0)NNr�)r)rr�r)r�r)r�r)r1r1)rYrY)rr�r)rr1r1)rr1r1N)3�__name__�
__module__�__qualname__rNrRrZr_rhrxr|rrrFrGr�rEr�r�r�rHrDr�r�r�r�r�r�r�r�r�rrrrrr�r0r4rr8r:r<rGr�rMrOrSrWrTrbrU�r(r&r*r*Zs��'�,4�W�%�
3�?�,"�3�.�0�
1�
�a�	M��d���8�
!�T�
<�I�85�4-�<^�Y�
)�^� �8#�+�)'�V�$:� O�0�0�=�&�'�"(�H,�*7�3�>�'�;%�|!�:%r(r*)�*c�V�t�}|jt|�||||��y)z
As it says��showBoundaryN)�_PSRenderer�drawr)�drawing�canvasr�r�r�r"s      r&r�r��s%���
�A��F�F��w�'���A�L�F�Qr(c�~�g}|j}tdt|�d�D]}|||||dzf��|S)zo
    given a list of coordinates [x0, y0, x1, y1....]
    produce a list of points [(x0,y0), (y1,y0),....]
    rr0r1)r�ranger)rr�Prr�s    r&�_pointsFromListr��sK��
	�A�	���A�
�1�S��V�A�
���	�1�Q�4��!�A�#��-����Hr(c�n�eZdZdZd�Zddddddd	d
�Zd�Zd�Zd
�Zd�Z	d�Z
d�Zd�Zd�Z
dd�Zd�Zd�Zy)r�z�This draws onto a EPS document.  It needs to be a class
    rather than a function, as some EPS-specific state tracking is
    needed outside of the state info in the SVG model.c��|jjd|z�|jj}t|t�r|j
s|jj
�t|�}|jj|�|j|i�|j|�|jj�}t|t�r|j
s|jj�|jjd|z�||j_|j�D]8\}}||jvs�t!|j|j||��:y)zEThis is the recursive method called for each node
        in the treez
begin node %rzend node %rN)�_canvasrRrBr��Path�
isClipPathr|r�_tracker�push�applyStateChanges�drawNodeDispatcherr5r�items�	_restores�setattr)rK�noder��deltas�rDeltas�kr�s       r&�drawNodez_PSRenderer.drawNode�s��	
�����_�T�1�2����#�#���4��&�4�?�?��L�L�"�"�$��t�$���
�
���6�"����v�r�*�	
����%��-�-�#�#�%���4��&�4�?�?��L�L�%�%�'������]�4�/�0�#������M�M�O�	:�D�A�q��D�N�N�"�����T�^�^�A�%6�q�9�	:r(r;r=r@rAr<r>r?)r/�strokeWidth�
strokeLineCap�strokeLineJoin�	fillColorr-r.c��|j|jcxk(rdk(rdnna|jj|j|j
|j|jz|j
|jz�y|jj|j|j
|j|jz|j
|jz|j|j�y)Nr)	r�rr�r�r�r�r2r3r)rKr�s  r&�drawRectz_PSRenderer.drawRect�s����7�7�d�g�g�"��"��L�L����F�F�D�F�F��F�F�4�:�:�%�t�v�v�d�k�k�'9�
;�
�L�L�"�"��F�F�D�F�F��F�F�4�:�:�%�t�v�v�d�k�k�'9�4�7�7�D�G�G�
r(c��|jjrG|jj|j|j|j
|j�yyr�)r�r;r�rXrYr�r�)rKr�s  r&�drawLinez_PSRenderer.drawLine
s<���<�<�$�$��L�L���d�g�g�t�w�w�������A�%r(c�z�|jj|j|j|j�yr�)r�rrrr)rKrs  r&�
drawCirclez_PSRenderer.drawCircles$�������V�Y�Y��	�	�6�8�8�<r(c	���|j�\}}}|dk(s|��|dk(s|�||jsp|j}|j}|j}|j
}|j}	||z
}
|jj||	z
||z
||	z||z||
d��y|j�}t|t�r|j|�y|j|�y)Nrr1)r)�
_xtraRadii�annular�startangledegrees�endangledegrees�centerx�centery�radiusr�r�	asPolygonr�r��drawPath�drawPolygon)rK�wedge�yradius�radius1�yradius1r�r�r�r�r�rr�s            r&�	drawWedgez_PSRenderer.drawWedges���%*�%5�%5�%7�"���(��Q�J�'�/��!��x�?O�Y^�Yf�Yf� %� 7� 7��#�3�3�O��]�]�G��m�m�G��\�\�F�$�'8�8�F��L�L� � �������'�&�.�RY�Za�Ra�!�6�a�
!�
9����!�A��!�D�!��
�
�a� �� � ��#r(c��|jjr/|jjt|j��yyr�)r�r;r<r��points�rKr)s  r&�drawPolyLinez_PSRenderer.drawPolyLine#s/���<�<�$�$��L�L�!�!�/�!�(�(�";�<�%r(c��|j|jz
}|j|jz}|j|jz
}|j|jz}|jj||||�yr�)rr�rrr�r)rKrrXr�rYr�s      r&�drawEllipsez_PSRenderer.drawEllipse'sb��
�Z�Z�'�*�*�
$��
�Z�Z�'�*�*�
$��
�Z�Z�'�*�*�
$��
�Z�Z�'�*�*�
$�������R��2�b�)r(c�d�|jjt|j�d��y)Nr1)r�)r�r�r�r�r�s  r&r�z_PSRenderer.drawPolygon/s"�������_�Q�X�X�6�q��Ar(c	���t|dd�}|jjs|r�|jj	�}|d|j
|j|jf\}}}}|dvra|d|d}	}t|||	�}
|dk(r||
z}n?|dk(r	||
d	zz}n1|d
k(r|t|||
||	d��z}ntd
t|�z��|jj||||��yy)Nr�r�
textAnchor)r*�	inheritedr-r.r�r�r0r��winansi)�encodingzbad value for text_anchor r�)
�getattrr�r<r��getStater�r�r�rr�rVr�r�)rK�	stringObjr��Sr�r�r�r�r�r.r�s           r&r�z_PSRenderer.drawString2s��� ��+;�A�>���<�<�"�"�n��
�
�&�&�(�A�&'��o�y�{�{�9�;�;�y�~�~�&]�#�K��A�t��"7�7�!"�:���*�
�h��%�d�D��:����%���L�A� �(�*�����N�A� �)�+���{�4���X�W`�a�a�A�$�%A�#�k�BR�%R�S�S��L�L�#�#�A�a��^�#�L�'5r(Nc�F�����
�ddlm�|j��j�j�j
�jf�
t�dd�}��
�fd�}��t�d�j���jdu}�jdu}�j}��fd�}��fd�}	�fd	�}
|d
k(r|�||||��y|dk(r/|r|d
��||||��y|s|r|�||d|��yy|r|d
��r|�y|s|r|�||d|��yy)Nr)�_renderPath�	autocloserc������fi|��Sr�r})�kwdsr��	drawFuncs�paths ���r&�rPz _PSRenderer.drawPath.<locals>.rPIs����t�Y�7�$�7�7r(rKc�.���jgfd�i|��S)NrK�r�)r�r%rKs ��r&�<lambda>z&_PSRenderer.drawPath.<locals>.<lambda>Ps���-�Q�-�-�b�L�8�L�t�L�r(c�,���jgd���S)Nr)r�rKr�)r%rKs��r&r�z&_PSRenderer.drawPath.<locals>.<lambda>Qs���A�,�,�R��H�,�M�r(c�*���jgd��S)Nr)r�r�)r%s�r&r�z&_PSRenderer.drawPath.<locals>.<lambda>Rs���a�.�.�r��.�:�r(�svg)r�r�rI�pdfT)�
forceClose)�	countOnly)�reportlab.graphics.shapesr�r�r4rr8r:r�rJr<r;r�)rKr�rKr�r�r�r�rI�fas�pathFill�
pathStroker�r%r�s ``        @@@r&r�z_PSRenderer.drawPathDs���9��L�L���X�X�q�x�x����A�K�K�@�	��D��R�0�	�	8����t�J�q�{�{�;�H��|�|�4�'�����t�+������L��M��:�
��e���D��v�4�T�2�
��
���d�#��6�t��6��4����6�q�d�3� ���T�*����4����6�q�d�3� r(c
���|j�D�]�\}}|dk(r3|jj|d|d|d|d|d|d��?|dk(r|jj|��`|d	k(r|jj	|���|d
k(r|jj|���|dk(r|jj
|���|dk(r�|rht|ttf�r2t|�dk(r$t|dttf�r|d}|d}nd}|jj||���2|jj���N|d
k(r|jj|���p|dvs��v|jd|jj�}|jd|jj�}|jj!||����y)z\This takes a set of states, and outputs the operators
        needed to set those propertiesrSrr1r0r�r�r�r/r�r�r��strokeDashArrayr�)r.r-r-r.N)r�r�rSrErHrFrGr�r�r�rr�r��getr>r?rD)rK�delta�newState�key�valuer��fontname�fontsizes        r&r�z_PSRenderer.applyStateChangesds��� �+�+�-�*	9�J�C���k�!����&�&�u�Q�x��q��5��8�!&�q��5��8�U�1�X�?��
�%����+�+�E�2��
�%����)�)�%�0���'����'�'��.��(�(����(�(��/��)�)��!�%��e��5�#�e�*�a�-�J�W\�]^�W_�af�gk�`l�Lm� %�a��� %�a��� !���L�L�(�(��u�5��L�L�(�(�*���#����)�)�%�0�
�0�0�!�9�9�Z����1C�1C�D�� �9�9�Z����1G�1G�H�����$�$�X�x�8�U*	9r(c���ddlm}||j�}|jj	|j
|j|j|j|j�y)Nr)�ImageReader)
rur�r�r�rZ�_imager�r�r2r3)rKrWr��ims    r&rZz_PSRenderer.drawImage�sA��3�
����
$�������r�y�y����������U�\�\�Rr(r�)rzr{r|�__doc__r�r�r�r�r�r�r�r�r�r�r�r�rZr}r(r&r�r��se��:�:�< .�\�Zd�!,��QX�&�(�I��B�=�$�$=�*�B�M�$4�@-9�^Sr(r�c��t|�}t|j|jf�}t	||dd|��|j|�y)Nrr�)rr*r2r3r�rx)rR�fnr��kwdr%s     r&�
drawToFiler��s>���A��A��!�'�'�!�(�(�#�$�A���A�q�!�,�/��F�F�2�Jr(c�R�t�}t|||��|j�S)z=Returns a PS as a string in memory, without touching the diskr�)rr�rm)rRr�r!s   r&�drawToStringr��s!���	�A��q�!�,�/��:�:�<�r(�epsoutc�B�ddlm}ddlm}|jdd}gd�|jdd	ddl}|jj|�s|j|�g}t|�D]>}|dddk(s�t||�}|�}	t|dd�}
|j|	|
f��@d}|D]I\}}
||jzd	|zz}
t||
�|s|d
kDrtdt|
�z�|dz
}�K	||jddy#||jddwxYw)
Nr)�
testshapes)�verbose)zTimes-Romanz
Times-BoldzTimes-ItaliczTimes-BoldItalic�Courierr��
getDrawingr�rzrenderPS_%d.epsr0zrenderPS test saved %sr1)�reportlab.graphicsr��reportlab.rl_configr��_FONTS�osr��isdir�mkdir�dirr�r�sepr��printr�)�outDir�shoutr�r��OLDFONTSr��drawings�funcname�funcr��	docstringr�rR�filenames              r&�testr�s&��-�+�� � ��#�H�d�J���a��(���w�w�}�}�V�$��H�H�V�����J��	6�H���"�~��-��z�(�3���&��#�D��2�6�	�����)� 4�5�	6�
��&�	�N�Q�	������):�1�)<�<�H��q��"����	�5�)A�E�(�O�)S�#T�
��F�A�		� (�
���!���x�
���!��s�AD
�7BD
�
D�__main__r1T)r�)r�F)0�__version__r�r�iorr�reportlab.pdfbase.pdfmetricsrrrrurr	r
rr�reportlab.lib.rl_accelr
�reportlab.graphics.renderbaserrrr�r�	reportlabr�reportlab.pdfgen.canvasrrr�r%�ord�chrr'rer*r�r�r�r�r�r�rrz�sysr�argv�outdirr}r(r&�<module>rsW��
��2��� �I�I�P�P�)�V�V�4��1���	�s�� �A���t�q�#�v� �1���A��	
�s�4�y��S��#�c�(�+�	+��c�!�f���A���Q���A��
 ��� -��^^	%�^	%�B1�(����1G�1G�R�
	
�AS�(�AS�F#,�"8�"8��"+�!7�!7��(�:�Z���
�3�8�8�}�Q�����!�������d��
r(

Zerion Mini Shell 1.0