%PDF- %PDF-
Mini Shell

Mini Shell

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

�

��dKL���dZdZddlmZmZmZmZddlmZm	Z	m
Z
ddlmZddl
mZddlmZdZd	�Zer	dd
lmZmZmZmZeee��Zd�ZGd�d�ZGd�de�Zy#ddlZej:d
�Y�0xYw)z3.3.0z�
PDFTextObject is an efficient way to add text to a Canvas. Do not
instantiate directly, obtain one from the Canvas instead.

Progress Reports:
8.83, 2000-01-13, gmcm: created from pdfgen.py
�)�Color�	CMYKColor�CMYKColorSep�toColor)�isBytes�isStr�	asUnicode)�fp_str)�
pdfmetrics)�
rtlSupportNc��|S�N���text�	directions  �=/usr/lib/python3/dist-packages/reportlab/pdfgen/textobject.py�fribidiTextrs���K�)�log2vis�ON�LTR�RTL�rrc�Z�|dvr&t|tj|t�d��S|S)NrT��clean)r�
directionsMap�get�DIR_ONrs  rrrs,��T]�an�Tn�7�4��!2�!2�9�V�!D�4�P�x�tx�xrz.pyfribidi is not installed - RTL not supportedc�x�eZdZdZd�ZdZdd�Zdd�Zdd�Zdd�Z	dd�Z
dd	�Zdd
�Zdd�Z
d�Zd
�Zd�Zd�Zd�Zy)�_PDFColorSetterziAbstracts the color setting operations; used in Canvas and Textobject
    asseumes we have a _code objectc��t|t�r=|jj|�\}}||jvr||j|<|Syr)�
isinstancer�_doc�addColor�_colorsUsed)�self�cmyk�name�snames    r�_checkSeparationz _PDFColorSetter._checkSeparation"sL���d�<�(����+�+�D�1�J�D���4�+�+�+�).�� � ��&��K�	)rNc�2�|j||||f|��y)z�set the fill color useing negative color values
         (cyan, magenta, yellow and darkness value).
         Takes 4 arguments between 0.0 and 1.0��alphaN��setFillColor�r(�c�m�y�kr/s      r�setFillColorCMYKz _PDFColorSetter.setFillColorCMYK-s��
�	�	�A�a��!�9�5�	�	1rc�2�|j||||f|��y)z�set the stroke color useing negative color values
            (cyan, magenta, yellow and darkness value).
            Takes 4 arguments between 0.0 and 1.0r.N��setStrokeColorr2s      r�setStrokeColorCMYKz"_PDFColorSetter.setStrokeColorCMYK3s��
�	�	�a��!�A�Y�U�	�	3rc�0�|j|||f|��y)zwSet the fill color using positive color description
           (Red,Green,Blue).  Takes 3 arguments between 0.0 and 1.0r.Nr0�r(�r�g�br/s     r�setFillColorRGBz_PDFColorSetter.setFillColorRGB9s��	
���1�Q�q�'���.rc�0�|j|||f|��y)zySet the stroke color using positive color description
           (Red,Green,Blue).  Takes 3 arguments between 0.0 and 1.0r.Nr9r=s     r�setStrokeColorRGBz!_PDFColorSetter.setStrokeColorRGB>s��	
���Q�q��G�%��0rc	��|jr|j|�}t|t�r�|j}||jz||j
z||jz||jzf\}}}}||_|j|�}|r-|jjd|�dt|��d���nY|jjdt||||�z��n-t|t�rR|j|j|j f}	||_|jjdt|	�z�n�t|t"t$f�r�t'|�}
|
dk(r/||_|jjdt|�z�nv|
dk(r/||_|jjdt|�z�nBt)d|z��t+|�r|j-t/|��nt)d|z��|�|j1|�y	t3|d
d	��|j1|j4�y	y	)�?Takes a color object, allowing colors to be referred to by name�/z cs z scnz%s kz%s rg���Unknown color %rNr/)�_enforceColorSpacer$r�density�cyan�magenta�yellow�black�
_fillColorObjr,�_code�appendr
r�red�green�blue�tuple�list�len�
ValueErrorrr1r�setFillAlpha�getattrr/�r(�aColorr/�dr3r4r5r6r*�rgb�ls           rr1z_PDFColorSetter.setFillColorCs����"�"��,�,�V�4�F��f�i�(����A�����}�a����&6��&�-�-���6�<�<��X�G�A�a��!�!'�D���(�(��0�D���
�
�!�!�T�&��)�"D�E��
�
�!�!�&�6�!�Q��1�+=�"=�>�
���
&��:�:�v�|�|�V�[�[�9�C�!'�D���J�J���g��s��3�5�
���d�|�
,��F��A��!�t�%+��"��
�
�!�!�'�F�6�N�":�<��A��%+��"��
�
�!�!�&�6�&�>�"9�:� �!3�f�!<�=�=�
�6�]����g�f�o�.��/�&�8�9�9������e�$�
�V�W�d�
+�
7����f�l�l�+�8rc	��|jr|j|�}t|t�r�|j}||jz||j
z||jz||jzf\}}}}||_|j|�}|r-|jjd|�dt|��d���nY|jjdt||||�z��n-t|t�rR|j|j|j f}	||_|jjdt|	�z�n�t|t"t$f�r�t'|�}
|
dk(r/||_|jjdt|�z�nv|
dk(r/||_|jjdt|�z�nBt)d|z��t+|�r|j-t/|��nt)d|z��|�|j1|�y	t3|d
d	��|j1|j4�y	y	)rErFz CS z SCNz%s Kz%s RGrGrHrINr/)rJr$rrKrLrMrNrO�_strokeColorObjr,rQrRr
rrSrTrUrVrWrXrYrr:r�setStrokeAlphar[r/r\s           rr:z_PDFColorSetter.setStrokeColorgs����"�"��,�,�V�4�F��f�i�(����A�����}�a����&6��&�-�-���6�<�<��X�G�A�a��!�#)�D� ��(�(��0�D���
�
�!�!�T�&��)�"D�E��
�
�!�!�&�6�!�Q��1�+=�"=�>�
���
&��:�:�v�|�|�V�[�[�9�C�#)�D� ��J�J���g��s��3�5�
���d�|�
,��F��A��!�t�'-��$��
�
�!�!�'�F�6�N�":�<��A��'-��$��
�
�!�!�&�6�&�>�"9�:� �!3�f�!<�=�=�
�6�]�������0��/�&�8�9�9�������&�
�V�W�d�
+�
7�������-�8rc��|||f|_|jjdt|�z�|�|j	|�yy)�)Sets the gray level; 0.0=black, 1.0=whitez%s gN)rPrQrRr
rZ�r(�grayr/s   r�setFillGrayz_PDFColorSetter.setFillGray�sE��"�D�$�/����
�
���&�6�$�<�/�0������e�$�rc��|||f|_|jjdt|�z�|�|j	|�yy)rez%s GN)rbrQrRr
rZrfs   r�
setStrokeGrayz_PDFColorSetter.setStrokeGray�sE�� $�d�D�1����
�
���&�6�$�<�/�0������e�$�rc��t|ttf�r
d|cxkrdksntd|z��t	|dd��|�y)Nr�zsetStrokeAlpha invalid value %r�_setStrokeAlphac��yrr��xs r�<lambda>z0_PDFColorSetter.setStrokeAlpha.<locals>.<lambda>���r�r$�float�intrYr[�r(�as  rrcz_PDFColorSetter.setStrokeAlpha�s?���1�e�C�[�)�a��g�A�g��>��B�C�C�6���&�~�6�q�9rc��t|ttf�r
d|cxkrdksntd|z��t	|dd��|�y)NrrlzsetFillAlpha invalid value %r�
_setFillAlphac��yrrros rrqz._PDFColorSetter.setFillAlpha.<locals>.<lambda>�rrrrsrvs  rrZz_PDFColorSetter.setFillAlpha�s>���1�e�C�[�)�a��g�A�g��<�q�@�A�A�4���_�^�4�Q�7rc�,�t|dd��|�y)N�_setStrokeOverprintc��yrrros rrqz4_PDFColorSetter.setStrokeOverprint.<locals>.<lambda>�rrr�r[rvs  r�setStrokeOverprintz"_PDFColorSetter.setStrokeOverprint�s��:���*�>�:�1�=rc�,�t|dd��|�y)N�_setFillOverprintc��yrrros rrqz2_PDFColorSetter.setFillOverprint.<locals>.<lambda>�rrrr~rvs  r�setFillOverprintz _PDFColorSetter.setFillOverprint����8���(��8��;rc�,�t|dd��|�y)N�_setOverprintMaskc��yrrros rrqz2_PDFColorSetter.setOverprintMask.<locals>.<lambda>�rrrr~rvs  r�setOverprintMaskz _PDFColorSetter.setOverprintMask�r�rr)�__name__�
__module__�__qualname__�__doc__r,rJr7r;rArCr1r:rhrjrcrZrr�r�rrrr"r"sW��'����2�4�/�
1�
",�H".�H%�%�:�
8�
>�<�<rr"c���eZdZdZdd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd!d�Zd�Zd"d�Zd#d�Zd�Zd�Zd�Zd�Zd�Zy)$�
PDFTextObjecta�PDF logically separates text and graphics drawing; text
    operations need to be bracketed between BT (Begin text) and
    ET operators. This class ensures text operations are
    properly encapusalted. Ask the canvas for a text object
    with beginText(x, y).  Do not construct one directly.
    Do not use multiple text objects in parallel; PDF is
    not multi-threaded!

    It keeps track of x and y coordinates relative to its origin.Nc���dg|_||_|jj|_|jj|_|jj|_|jj
|_|jj|_t|dd�|_tj|j�}d|_||_|j||�d|_d|_y)N�BTrJ���r)rQ�_canvas�	_fontname�	_fontsize�_leadingr%r'r[rJr�getFont�
_curSubsetr�
setTextOrigin�_textRenderMode�	_clipping)r(�canvasrpr5r�fonts      r�__init__zPDFTextObject.__init__�s����V��
�������/�/������/�/������-�-��
��L�L�%�%��	��<�<�3�3���")�&�1E�d�"K����!�!�$�.�.�1�����"������1�a� � �����rc���|jjd�|jr+|jjd|jdzz�dj	|j�S)z#pack onto one line; used internally�ET�%d TrrH� )rQrRr�r��join�r(s r�getCodezPDFTextObject.getCode�sP���
�
���$���>�>��J�J���g��)=�)=�a�)?�@�A��x�x��
�
�#�#rc�
�|jjr)|jjdt	||�z�n(|jjdt	||�z�|x|_|_|x|_|_y)Nz
1 0 0 1 %s Tmz1 0 0 -1 %s Tm�	r��bottomuprQrRr
�_x0�_x�_y0�_y)r(rpr5s   rr�zPDFTextObject.setTextOrigin�sh���<�<� � ��J�J���o��q�!��<�=��J�J���.���1��=�>�����4�7�����4�7rc���|jjs|}|}|jjdt	||||||�z�|x|_|_|x|_|_y)z3Like setTextOrigin, but does rotation, scaling etc.z%s TmNr�)r(rwr@r3r^�e�fs       r�setTextTransformzPDFTextObject.setTextTransform�sa���|�|�$�$���A���A��
�
���'�F�1�a��A�q�!�$<�<�=�����4�7�����4�7rc��|jr�|jddddk(r�|jdj�}t|�dk(r|jd=n!dj|dd�|jd<t	|d�}t	|d�}||z
}||z}|xj
|zc_|xj|zc_|jjd	t||�z�|xj
|z
c_|xj|z
c_|j
|_	|j|_
y)
axStarts a new line at an offset dx,dy from the start of the
        current line. This does not move the cursor relative to the
        current position, and it changes the current offset of every
        future line drawn (i.e. if you next do a textLine() call, it
        will move the cursor to a position one line lower than the
        position specificied in this call.  r����Nz TdrG�������z%s Td)rQ�splitrXr�rtr�r�rRr
r�r�)r(�dx�dy�L�lastDx�lastDys      r�
moveCursorzPDFTextObject.moveCursor�s	���:�:�$�*�*�R�.���-�u�4��
�
�2��$�$�&�A��1�v�q�y��J�J�r�N�!#����3�B����
�
�2���1�R�5�\�F��1�R�5�\�F�
�&�L�B��&�L�B�

�H�H���H��H�H���H�	
�
�
���'�F�2��s�O�3�4�	
���B������B����(�(����(�(��rc�(�|j|d�y)z�Starts a new line dx away from the start of the
        current line - NOT from the current point! So if
        you call it in mid-sentence, watch out.rN)r�)r(r�s  r�setXPoszPDFTextObject.setXPoss��	
����1�rc�2�|j|jfS)z:Returns current text position relative to the last origin.)r�r�r�s r�	getCursorzPDFTextObject.getCursors��������!�!rc�2�|j|jfS)zRReturns a tuple giving the text position of the start of the
        current line.)r�r�r�s r�getStartOfLinezPDFTextObject.getStartOfLines�����$�(�(�#�#rc��|jS)z7Returns current x position relative to the last origin.)r�r�s r�getXzPDFTextObject.getX����w�w�rc��|jS)z7Returns current y position relative to the last origin.)r�r�s r�getYzPDFTextObject.getY!r�rc�$�||_||_tj|j�}|jrd|_y|jjj|�}|jj|�dt|��d��y)z�Sets the font and fontSize
        Raises a readable exception if an illegal font
        is supplied.  Font names are case-sensitive! Keeps track
        of font anme and size for metrics.r�r�z TfN)r�r�rr��_dynamicFontr�r�r%�getInternalFontNamerQrRr
)r(�
psfontname�sizer��pdffontnames     r�_setFontzPDFTextObject._setFont%sk��
$�������!�!�$�.�.�1����� �D�O��,�,�+�+�?�?�
�K�K��J�J���K����F�Grc	�X�||_||_|�|dz}||_tj|j�}|j
rd|_y|jjj|�}|jj|�dt|��dt|��d��y)z�Sets the font.  If leading not specified, defaults to 1.2 x
        font size. Raises a readable exception if an illegal font
        is supplied.  Font names are case-sensitive! Keeps track
        of font anme and size for metrics.Ng333333�?r�r�� Tf � TL)
r�r�r�rr�r�r�r�r%r�rQrRr
)r(r�r��leadingr�r�s      r�setFontzPDFTextObject.setFont4s���
$�������?��S�j�G���
��!�!�$�.�.�1����� �D�O��,�,�+�+�?�?�
�K�K��J�J���+�v�d�|�V�T[�_�]�^rc�`�||_|jjdt|�z�y)zAdjusts inter-character spacingz%s TcN)�
_charSpacerQrRr
)r(�	charSpaces  r�setCharSpacezPDFTextObject.setCharSpaceEs%��$���	
���	�	�7�V�I�%6�6�	7rc�`�||_|jjdt|�z�y)z�Adjust inter-word spacing.  This can be used
        to flush-justify text - you get the width of the
        words, and add some space between them.z%s TwN)�
_wordSpacerQrRr
)r(�	wordSpaces  r�setWordSpacezPDFTextObject.setWordSpaceJs'��$����
�
���'�F�9�$5�5�6rc�f�d|z|_|jjdt|�z�y)zStretches text out horizontally�dz%s TzN)�_horizScalerQrRr
)r(�
horizScales  r�
setHorizScalezPDFTextObject.setHorizScaleQs+����+����
�
���'�F�:�$6�6�7rc�`�||_|jjdt|�z�y)z*How far to move down at the end of a line.z%s TLN)r�rQrRr
)r(r�s  r�
setLeadingzPDFTextObject.setLeadingVs$����
��
�
���'�F�7�O�3�4rc���|dvsJd��|dz|jk7r|dz}|dz|_|j|k7r&||_|jjd|z�yy)a�Set the text rendering mode.

        0 = Fill text
        1 = Stroke text
        2 = Fill then stroke
        3 = Invisible
        4 = Fill text and add to clipping path
        5 = Stroke text and add to clipping path
        6 = Fill then stroke and add to clipping path
        7 = Add to clipping path

        after we start clipping we mustn't change the mode back until after the ET
        )rrl�rGrH���z!mode must be in (0,1,2,3,4,5,6,7)rHr�N)r�r�rQrR)r(�modes  r�setTextRenderModezPDFTextObject.setTextRenderMode[sn���(�(�M�*M�M�(��1�H�t�~�~�%��A�I�D�!�A�X�D�N�����%�#'�D� ��J�J���g��n�-�&rc��||_|j|z
|_|jjdt	|�z�y)z=Move text baseline up or down to allow superscript/subscriptsz%s TsN)�_riser�rQrRr
)r(�rises  r�setRisezPDFTextObject.setRisers3����
��'�'�D�.����
�
���'�F�4�L�0�1rc��tr>|jdvr0t|tj|jt�d��}|j
}t
j|j�}g}|jr�|j||j�D]�\}}||jk7rc|j||j�}|j|�dt|j ��dt|j"��d��||_|jd|j%|�z����n�|j&r�|j|jj)|j*��dt|j ��dt|j"��d��|jd|j-|�z��n@|}t/|�r	|j1d�}t
j8||g|j:z�D]�\}}||k7re|j|jj)|j*��dt|j ��dt|j"��d��|}|jd|j%|�z���||k7rc|j|jj)|j��dt|j ��dt|j"��d��dj=|�S#t2$ra}	|	j4d	d
\}
}t3|	j4dd
|	j4d
�d|t7|
d
z
d�|
�d||
|�d|||d
z��fz��d}	~	wwxYw)z%Generates PDF text output operator(s)rTrr�r�r�z(%s) Tj�utf8r�rHN�
�
rz-->z<--)rrrrr r�rr�r�r��splitStringr%r��getSubsetInternalNamerRr
r�r��_escape�
_multiByter��fontName�formatForPdfr�decode�UnicodeDecodeError�args�max�
unicode2T1�substitutionFontsr�)
r(r�canvr��R�subset�tr��fcr��i�jr�s
             r�_formatTextzPDFTextObject._formatTextxs-���t�~�~��6��4��!2�!2�4�>�>�&�!I�PT�U�D��|�|���!�!�$�.�.�1�������!�-�-�d�D�I�I�>�
6�	����4�?�?�*�"&�"<�"<�V�T�Y�Y�"O�K��H�H��f�T�^�^�>T�V\�]a�]j�]j�Vk�l�m�&,�D�O�����T�\�\�!�_�4�5�
6��_�_�
�H�H��	�	�-�-�d�m�m�<��t�~�~�&��t�}�}�%��
�

�H�H�Y��!2�!2�4�!8�8�9��B��t�}�K��;�;�v�.�D�
#�-�-�d�D�6�$�:P�:P�3P�Q�
6���1��b�5��H�H����1N�1N�q�z�z�1Z�\b�cg�cq�cq�\r�tz�{�|I�|I�uJ�K�L��B�����T�\�\�!�_�4�5�	
6�
�R�x����T�Y�Y�-J�-J�4�>�>�-Z�\b�cg�cq�cq�\r�tz�{�|I�|I�uJ�K�L��x�x��{���*�K��&�&��1�+�C�A�a�,�q�v�v�b�q�z�QR�QW�QW�XY�QZ�[_�`c�de�fh�dh�ij�`k�lm�[n�os�tu�vw�ox�y}�~�AB�CE�AE�zF�<G�;I�0I�K�K��K�s�L�	N�'AN�Nc�p�|jj|j|��|xrdxsd���y)z3prints string at current point, ignores text cursorz T*r�N)rQrRr)r(r�TStars   r�_textOutzPDFTextObject._textOut�s1���
�
���D�$4�$4�T�$:�U�_�u�=R�PR�=R�T�Urc���|j|jj||j|j�z|_|j
j
|j|��y)z9prints string at current point, text cursor moves across.N)r�r��stringWidthr�r�rQrRr�r(rs  r�textOutzPDFTextObject.textOut�sJ���'�'�D�L�L�4�4�T�4�>�>�4�>�>�Z�Z����
�
���$�*�*�4�0�1rc�H�|j|_|jjr|j|j
z
|_n|j|j
z|_|j|_|jjd|j|�z�y)zyprints string at current point, text cursor moves down.
        Can work with no argument to simply move the cursor down.z%s T*N)
r�r�r�r�r�r�r�rQrRrr
s  r�textLinezPDFTextObject.textLine�su���(�(����<�<� � ��g�g��
�
�-�D�G��g�g��
�
�-�D�G��7�7���	
�
�
���'�D�$4�$4�T�$:�:�;rc�4�t|�rKt|�j�jd�}|dk(rC|D�cgc]}|j���}}n%t	|t
tf�r|}nddk(sJd��D]}|j|��ycc}w)aprints multi-line or newlined strings, moving down.  One
        comon use is to quote a multi-line block in your Python code;
        since this may be indented, by default it trims whitespace
        off each line and from the beginning; set trim=0 to preserve
        whitespace.r�rlrz4argument to textlines must be string,, list or tupleN)rr	�stripr�r$rVrWr
)r(�stuff�trim�lines�s�lines      r�	textLineszPDFTextObject.textLines�s�����<��e�$�*�*�,�2�2�5�9�E��Q�w�,1�2�q�����2��2�
��u�T�l�
+��E��a�4�O�O�O�4��	 �D��M�M�$��	 ��3s�Bc�"�|jdgk7S)z=PDFTextObject is true if it has something done after the initr�)rQr�s r�__nonzero__zPDFTextObject.__nonzero__�s���z�z�d�V�#�#rc��|jjjd�|jjj	|d|�y)N�transparency�ca)r�r%�ensureMinPdfVersion�
_extgstate�set�r(�vs  rryzPDFTextObject._setFillAlpha�s6�������-�-�n�=������#�#�D��a�0rc�R�|jjj|d|�y)N�OP�r�rrrs  rr|z!PDFTextObject._setStrokeOverprint���������#�#�D��a�0rc�R�|jjj|d|�y)N�opr"rs  rr�zPDFTextObject._setFillOverprint�r#rc�b�|jjj|d|xrdxsd�y)N�OPMrlrr"rs  rr�zPDFTextObject._setOverprintMask�s&�������#�#�D��q�w�Q�|�!�<r)rrNr)r)r�)rl) r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr
rrryr|r�r�rrrr�r��s���E�� $���&�P�"�$�
��
H�_�"8�
7�8�
5�
.�.2�)�VV�2�
<�" �($�1�1�1�=rr�) �__version__r��reportlab.lib.colorsrrrr�reportlab.lib.utilsrrr	�reportlab.lib.rl_accelr
�reportlab.pdfbaser�reportlab.rl_configrrr�
pyfribidi2rr r�DIR_LTRr�DIR_RTL�dictr�warnings�warnr"r�rrr�<module>r4s���
��	��I�H�9�9�)�(�*�
���
�H�T�T���W�5�
�	y�K<�K<�Zt=�O�t=��cH����
�
�F�G�s�A$�$A>

Zerion Mini Shell 1.0