%PDF- %PDF-
Mini Shell

Mini Shell

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

�

��d�2���dZdZddlZddlmZddlmZddlmZm	Z	ddl
mZmZm
Z
ddlmZdd	lmZdd
lmZddd
dd�ZGd�de�ZGd�de�ZGd�de�ZGd�de�Zd�ZGd�de�Zd�Zedk(re�yy)z3.3.0aLRoutines to print code page (character set) drawings. Predates unicode.

To be sure we can accurately represent characters in various encodings
and fonts, we need some routines to display all those characters.
These are defined herein.  The idea is to include flowable, drawable
and graphic objects for single and multi-byte fonts. �N)�Canvas)�Flowable)�
pdfmetrics�cidfonts)�Group�String�Rect)�Widget)�colors)�int2Byte�winansi�macroman�	macexpert�pdfdoc)�WinAnsiEncoding�MacRomanEncoding�	MacExpert�PDFDocc�*�eZdZdZd�Zd�Zd�Zdd�Zy)�
CodeChartBasezrBasic bits of drawing furniture used by
    single and multi-byte versions: ability to put letters
    into boxes.c�T�|jdz|jz}|t|�k(rt|�|_nt|�dz|_|jd|jzz|_|jd|jzz|_g|_t|jdz�D]*}|jj||jz��,g|_
t|jdz�D]*}|jj||jz��,y)z&Work out x and y positions for drawingg�?��N)�
codePoints�charsPerRow�int�rows�boxSize�width�height�ylist�range�append�xlist)�selfr�row�cols    �:/usr/lib/python3/dist-packages/reportlab/lib/codecharts.py�
calcLayoutzCodeChartBase.calcLayout#s�������$�t�'7�'7�7���3�t�9���D�	�D�I��D�	�A�
�D�I��\�\�Q�t�'7�'7�%7�8��
��l�l�a��	�	�k�2�����
�����Q��'�	2�C��J�J���c�D�L�L�0�1�	2���
���)�)�A�-�.�	2�C��J�J���c�D�L�L�0�1�	2�c�.�|jrd|zSd|zS)N�%02Xz%d)�hex)r%�byts  r(�
formatBytezCodeChartBase.formatByte8s���8�8��C�<���#�:�r*c
���|j|jzt|�z
}t|�D]}|j	d��d}d}|j
j
|j|jdz�|D�]}|��|j
jd�|j
jd|z|jz|j|z
dz
|jz|j|jdd��|j
jd�nK	|j
j|dz|jz|j|z
d	z
|jz|�|dz}||jk(s��|dz}d}��y#|j
jd�|j
jd|z|jz|j|z
dz
|jz|j|jdd��|j
j|dz|jz|j|z
d	z
|jzd
�|j
jd�Y��xYw)z]Fills boxes in order.  None means skip a box.
        Empty boxes at end get filled with grayNr��?g�������?r��stroke�fill���?g�?�?)rr�lenr"r#�canv�setFont�fontNamer�setFillGray�rect�drawCentredString)r%�charList�extraNeeded�ir&r'�chs       r(�	drawCharszCodeChartBase.drawChars>s���y�y�4�#3�#3�3�c�(�m�C���{�#�	"�A��O�O�D�!�	"������	�	���$�-�-�����)<�=��	�B��z��	�	�%�%�c�*��	�	����#�����5��	�	�C��!�8K�t�|�|�7[��L�L�$�,�,�q�q��B��	�	�%�%�c�*�/��I�I�/�/� ��W����4�!�Y�Y��_�u�4����D�����'�C��d�&�&�&��A�g����5	��	/��I�I�)�)�#�.��I�I�N�N�A�c�E�T�\�\�#9�D�I�I��O�a�<O�SW�S_�S_�;_����d�l�l�1�1�#�F��I�I�/�/� ��W����4�!�Y�Y��_�u�4����D���
�I�I�)�)�#�.�s� A
F
�
C$I1c��|jjd�|jjd|jd|j|j
dd��|jjdd|j
|jddd��|jjd�|jj
dd|j
z�d}t|j�D]�}|jr|j|}n|j||jz�}|jjd	|j
z|j|z
d
z
|j
z|���t|j�D]X}|jj|dz|j
z|jdz|j
z|j|���Z|rn|jj
d
d	|j
z�|jjd	|j
z|jdz|j
z|�yy)z4Writes little labels in the top row and first column皙�����?r���r)r4r3r5zHelvetica-Obliqueg�?g�?r1r6g�?zHelvetica-BoldObliqueN)
r9r<r=r!rrr:r"r�	rowLabelsr/rr>)r%�topLeftr.r&�labelr's      r(�
drawLabelszCodeChartBase.drawLabelsds����	�	���c�"��	�	���q�$�*�*�R�.�$�*�*�d�l�l��ST��U��	�	���q�!�T�\�\�4�:�:�b�>��!��L��	�	���c�"�	
�	�	���-�e�d�l�l�.B�C�������#�	*�C��~�~����s�+������d�.>�.>�(>�?���I�I�'�'��d�l�l�(:�)-���S��4�)?�4�<�<�(O�(-�
*�	*���)�)�*�	*�C��I�I�'�'��s��d�l�l�(B�)-���T�)9�T�\�\�(I�(,����(<�
*�	*���I�I���5�c�D�L�L�6H�I��I�I�'�'��d�l�l�(:�)-���T�)9�T�\�\�(I�(/�
*�r*N)�)�__name__�
__module__�__qualname__�__doc__r)r/rCrJ�r*r(rrs���2�*�$�L*r*rc��eZdZ		dd�Zd�Zy)�SingleByteEncodingChartc�X�d|_||_||_|jdz|jz|_||_||_||_d|_tjtj|j|j|j��|j�y)N��-)r�faceName�encodingNamer;rrr-rGr�registerFont�Fontr))r%rVrWrrr-s      r(�__init__z SingleByteEncodingChart.__init__�s������ ��
�(����
�
��+�d�.?�.?�?��
�&���������������
����
�
�04�
�
�04�0A�0A�!C�	"�
	
���r*c���|j�dgdzttttt	dd����z}|j
}tj||�}tj|�d��fd�}|D�cgc]
}||���}}|j|�|jj|j|j�ycc}w)N� rTrc�$��|�y�|d��dS)N�replace)�errorsrrP)�txt�decoders �r(�
decodeFuncz0SingleByteEncodingChart.draw.<locals>.decodeFunc�s����{���s�9�5�a�8�8r*)rJ�list�maprr"rW�adobe2codec�get�codecs�lookuprCr9�gridr$r!)r%r?�encNamerbrBras     @r(�drawzSingleByteEncodingChart.draw�s���������6�B�;��c�(�D��r�3��4H�&I�!J�J��
�#�#���/�/�'�7�3���-�-��(��+��	9�.6�6�r�J�r�N�6��6�	
���x� ��	�	���t�z�z�4�:�:�.��7s�CN)�	Helveticar��r)rLrMrNrZrkrPr*r(rRrR�s��:K�12��$/r*rRc�"�eZdZdZd�Zd�Zd�Zy)�KutenRowCodeChartafFormats one 'row' of the 94x94 space used in many Asian encodings.aliases

    These deliberately resemble the code charts in Ken Lunde's "Understanding
    CJKV Information Processing", to enable manual checking.  Due to the large
    numbers of characters, we don't try to make one graphic with 10,000 characters,
    but rather output a sequence of these.c��||_d|_d|_d|_d|_gd�|_d|_||_||_	tj|j|j�}tj|�|jd	z|jz|_
|j�y#d|_d|_Y�DxYw)
N�^���)�00�20�40�60�80rrlrrU)r&rrrrrGr-rVrWr�CIDFontrrXr;r)�r%r&rVrW�fonts     r(rZzKutenRowCodeChart.__init__�s�����������������	�3������ ��
�(���	2��#�#�D�M�M�4�3D�3D�E�D��#�#�D�)�
�
�
��+�d�.?�.?�?��
������	2�'�D�M� 1�D����?B4�4Cc���g}|jjd�dkDrAtdd�D]0}t|dz�t|dz�z}|j	|��2|S|j	dgdz�|S)z1Works out the character values for this kuten row�EUC���r�_�Nrr�rW�findr"rr#)r%r&�cellsr'rBs     r(�makeRowzKutenRowCodeChart.makeRow�s}�������!�!�%�(�2�-��Q��|�
!���c�C�i�(�8�C��G�+<�<�����R� �
!���
�L�L�$��"��%��r*c��|jd|jz��dg|j|j�z}|j|�|jj|j|j�y)NzR%d�rH�rJr&r�rCr9rir$r!�r%r?s  r(rkzKutenRowCodeChart.draw�sZ���������!1��2��6�D�L�L����2�2�����x� ��	�	���t�z�z�4�:�:�.r*N�rLrMrNrOrZr�rkrPr*r(rprp�s��.��,� 	/r*rpc�"�eZdZdZd�Zd�Zd�Zy)�
Big5CodeChartz�Formats one 'row' of the 94x160 space used in Big 5

    These deliberately resemble the code charts in Ken Lunde's "Understanding
    CJKV Information Processing", to enable manual checking.c��||_d|_d|_d|_d|_d|_||_||_gd�|_	tj|j|j�}tj|�|jd	z|jz|_
|j�y#d|_d|_Y�DxYw)
Nr�rsrm�
r)
�4�5�6�7�A�B�C�D�E�FrlrrU)r&rrrrr-rVrWrGrr{rrXr;r)r|s     r(rZzBig5CodeChart.__init__�s�����������������	���� ��
�(���B���	2��#�#�D�M�M�4�3D�3D�E�D��#�#�D�)�
�
�
��+�d�.?�.?�?��
������	2�'�D�M� 1�D��r~c��g}|jjd�dkDrIdD]B}td�D]2}|dz|z}t|�t|�z}|j	|��4�D|S|j	dgdz�|S)zLWorks out the character values for this Big5 row.
        Rows start at 0xA1�B5r�)
�ru��r����
rn�rmNr�r�)r%r&r��y�xr'rBs       r(r�zBig5CodeChart.makeRows��������!�!�$�'�"�,�0�
%���r��%�A��B�$�q�&�C�!�#���#��6�B��L�L��$�%�
%���
�L�L�$��#��&��r*c��|jd|jz��|j|j�}|j|�|jj|j|j�y)Nr,r�r�r�s  r(rkzBig5CodeChart.drawsQ��������� 1��2��<�<����)�����x� ��	�	���t�z�z�4�:�:�.r*Nr�rPr*r(r�r��s��@��*� /r*r�c	���|j�	tj|�}|jd�|j||tj||d�ddd��|jd�|j|dd�|j|||�|j�y#t$r-t	j
|�}tj|�Y��wxYw)z�Helper for stringwidth tests on Asian fonts.

    Registers font if needed.  Then draws the string,
    and a box around it derived from the stringWidth functionrErmrrr2N)
�	saveStater�getFont�KeyErrorr�UnicodeCIDFontrXr<r=�stringWidthr:�
drawString�restoreState)�msg�canvasr�r�r;r}s      r(�hBoxTextr�s���
����&��!�!�(�+��
���s��
�K�K��!�J�*�*�3��"�=�b��q�K�Q�
���q��
�N�N�8�R��#�
���a��#��
������&��&�&�x�0������%�&�s�B,�,3C"�!C"c��eZdZdZd�Zd�Zy)�
CodeWidgetz Block showing all the charactersc�<�d|_d|_d|_d|_y)Nrr�)r�r�rr )r%s r(rZzCodeWidget.__init__3s����������
���r*c
��|jdz}|jdz}t�}|jt	|j
|j|j|jdtj���td�D]t}td�D]d}|dz|z}|dkDs�t|j
||zz|j|j||zz
zt|��}|j|��f�v|S)Ng0@)�	fillColor�strokeColorrmr\)rr r�addr	r�r�r�blackr"rr)r%�dx�dy�gr�r��	charValue�ss        r(rkzCodeWidget.draw9s���
�Z�Z�$�
��
�[�[�4�
���G��	���d�4�6�6�4�6�6�4�:�:�t�{�{�!�v�|�|�=�	>��r��	�A��2�Y�
����F�Q�J�	��r�>��t�v�v��B���#�v�v����q��t�);�<�h�y�>Q�S�A��E�E�!�H�
�	��r*N)rLrMrNrOrZrkrPr*r(r�r�1s��*��
r*r�c�R�td�}|jdd�|jddd�t�}|j	|dd�td�	�}|j	|dd
�tdd�
�}|j	|dd�|j�t
d�y)Nzcodecharts.pdfzHelvetica-Bold��Hi�zTesting code page chartsi�r\)ri,�r)rr-�dzsaved codecharts.pdf)rr:r�rR�drawOn�save�print)�c�cc1�cc2�cc3s    r(�testr�Ms����� �A��I�I���#��L�L��S�4�5�
!�
#�C��J�J�q�"�c��
!�b�
1�C��J�J�q�"�c��
!�b�a�
8�C��J�J�q�"�c���F�F�H�	�
 �!r*�__main__)�__version__rOrg�reportlab.pdfgen.canvasr�reportlab.platypusr�reportlab.pdfbaserr�reportlab.graphics.shapesrrr	�reportlab.graphics.widgetbaser
�
reportlab.libr�reportlab.lib.utilsrrerrRrpr�r�r�r�rLrPr*r(�<module>r�s���

��	9���*�'�2�9�9�0� �(� �!��
�	��d*�H�d*�L)/�m�)/�X8/�
�8/�v//�M�//�d�(���8"�:�Z���F�r*

Zerion Mini Shell 1.0