%PDF- %PDF-
Mini Shell

Mini Shell

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

�

��e�t��n�dZdZddlZddlZddlZddlmZddlmZddl	m
Z
mZmZm
Z
mZmZmZmZddlmZmZddlmZmZdd	lmZd
Zej4j7�ej8Zej:ZiZiZiZ iZ!Gd�de"�Z#Gd
�de"�Z$d�Z%Gd�d�Z&d6d�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 �Z5d7d!�Z6d"�Z7d#�Z8d$�Z9d%�Z:d&�Z;e;d'�Z<e*j{e;d(�e<g�d6d)�Z>d6d*�Z?d6d+�Z@d,�ZAd8d-�ZBd.�ZCd/�ZDd0�ZEd1�ZFeGej��ej��e j��e!j���2�fd3�ZIdd4lmJZJeJeI�[JeKd5k(reF�eE�yy)9z3.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��eZdZy)�	FontErrorN��__name__�
__module__�__qualname__���>/usr/lib/python3/dist-packages/reportlab/pdfbase/pdfmetrics.pyrr'���rrc��eZdZy)�FontNotFoundErrorNrrrrrr)rrrc	�J�t|d�}t|�dkr2|r|djd�}t|�dkrtd|z��i}g}|D�cgc]}|j	���}}|D�cgc]$}|j�j
d�r�#|��&}}d}|D]�}|dddk(rd}�|dd	d
k(rd}�|s�|jd�}|D�cgc]}|j	���}}|dd\}	}
}|	j�\}}|d
k(s
Jd|z��t|�}
|
j�\}}|dk(s
Jd|z��	t|�}|j�\}}|dk(s
Jd|z��|}|j|
||f���d}|D]J}|dddk(rd}|dddk(rd}�|s�|dddk(r		|jdd�\}}	t|�}|||<�L||fScc}wcc}wcc}w#t$rt|�}Y��wxYw#td|�d|�d���xYw#Y�OxYw)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 data�comment��StartCharMetrics��EndCharMetrics�;��Czbad line in font file %s�WX�N�StartFontMetrics��Comment� z Header information error in afm z: line='�')
r	�len�split�
ValueError�strip�lower�
startswith�int�float�append)�afmFileName�lines�topLevel�
glyphLevel�l�	inMetrics�line�chunks�chunk�cidChunk�
widthChunk�	nameChunkr �cid�width�name�inHeader�left�rights                   r�parseAFMFilerM,s���
�{�C�0�E�
�5�z�1�}��%��(�.�.��.�%��u�:�q�=��>��L�M�M��H��J� %�&�1�Q�W�W�Y�&�E�&��E�1�Q�W�W�Y�%9�%9�)�%D�Q�E�E�E��I��2����"�:�+�+��I�
�!�B�Z�+�
+��I�
��Z�Z��_�F�17�8��e�k�k�m�8�F�8�.4�Q�q�k�+�H�j�)��>�>�#�D�A�q���8�>�7�$�>�>�8��a�&�C��#�#�%�D�A�q���9�?�8�4�?�?�9�
!��A���
�?�?�$�D�A�q���8�>�7�$�>�>�8��D����s�E�4�0�1�92�>�H��#����"�:�+�+��H���"�:�+�+��H�
��A�a�y�I�%�t�
h�"�j�j��Q�/���e�
��E�
��#�H�T�N�#�$
�j�!�!��m
'��E��9���
!��a���
!��*
h� �T_�ae�!f�g�g��
��sB�G�2$G#�G#�G(�G-�2H�H�-H�H�H�H"c�&�eZdZd�Zd�Zd�Zdd�Zy)�TypeFacec��||_g|_i|_d|_d|_d|_d|_d|_|dk(rd|_n|dk(rd|_nd|_|tvrd|_
|j|�yd|_
y)Nr�ZapfDingbats�ZapfDingbatsEncoding�Symbol�SymbolEncodingr!)rI�
glyphNames�glyphWidths�ascent�descent�
familyName�bold�italic�requiredEncoding�
standardFonts�builtIn�_loadBuiltInData��selfrIs  r�__init__zTypeFace.__init__vs�����	�������������
�����	�����>�!�$:�D�!�
�X�
�$4�D�!�$(�D�!��=� ��D�L��!�!�$�'��D�Lrc���t|�}tj||_t	|jj��|_tj|\|_|_	y)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�widthsByFontGlyphrV�list�keysrU�ascent_descentrWrXr`s  rr_zTypeFace._loadBuiltInData�sT���4�y��$�6�6�t�<����t�/�/�4�4�6�7���#,�#;�#;�D�#A� ���D�Lrc��gS)z=Info function, return list of the font files this depends on.r�ras r�getFontFileszTypeFace.getFontFiles�s���	rc�v�|j�|j�f}t|d�rHtjj|j�d}|D]}t||z�s�||zcS	tj|j�}�td|�d|j�d��|S#t|j�}|rf|j�dk(r=|D]7}tjj|�d|z}t|�r|}�6d}�9n|j�dk(r|}nd}Y��xYw)N�pfbFileNamer�.pfbz.afmzCan't find z for face 'r1)
r6�upper�hasattr�os�path�splitextrmrr�
findT1FilerI�bruteForceSearchForAFMr)ra�ext�
possible_exts�
r_basename�er �afm�pfbs        rrtzTypeFace.findT1File�s������c�i�i�k�2�
��4�
�&����)�)�$�*:�*:�;�A�>�J�"�
*���Z�!�^�,�%��>�)�
*�	��$�$�T�Y�Y�/�A�
�9��c�4�9�9�E�F����!
	�(����3�C���9�9�;�&�(�*�%�� �g�g�.�.�s�3�A�6��:��$�S�>� #�A� $�A�%��Y�Y�[�F�*��A���s
�6B5�5BD8N)rn)rrrrbr_rkrtrrrrOrOus���4B��rrOc���|�ddlm}t|�r|Stjj|�}|D]=}t
|�s�tjj||�}t|�s�;|cS|S)Nr�r)�reportlab.rl_configrrrqrr�basenamer�join)�fn�
searchPath�bfn�dirname�tfns     r�bruteForceSearchForFiler��si����U���}�R�i�
�'�'�
�
�2�
�C��&���� �(��g�g�l�l�7�3�'���S�>�#�:�&��Irc	�b�ddlm}|D]Q}t|�s�t|tj
zdz�}|D]}	t
|�\}}|d|k(r|ccS�!�Sy#tj�\}}}	djtt|j��d|zzf|_�xYw)zcLooks in all AFM files on path for face with given name.

    Returns AFM file name or None.  Ouch!rr}z*.[aA][fF][mM]�FontNamer0z, while looking for faceName=%rN)
�reportlab.rl_settingsrrrrq�seprM�sys�exc_infor��maprd�args)
�faceNamerr��	possibles�possible�topDict�	glyphDict�t�v�bs
          rruru�s���3������ �(��G�b�f�f�,�/?�?�@�	�!�	�H�
�%1�(�%;�"����:�&�(�2�#�O�3�	���
��l�l�n���!�A��(�(�3�s�1�6�6�?�3�4U�X`�4`�`�b����s�A�AB.c�B�eZdZdZdd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zy)�Encodingz1Object to help you create and refer to encodings.Nc��||_d|_|tvr)|�Jd��||_tj
||_y|dk(r(t|_tj
t|_yt|�r1t|�}|j|_|jdd|_yt|�rt|_|dd|_yt|t�r&|j|_|jdd|_yy)Nrz2Can't have a base encoding for a standard encoding)
rI�frozen�standardEncodings�baseEncodingNamer�	encodings�vectorr
r�getEncodingr�
isinstancer�)rarI�base�baseEncs    rrbzEncoding.__init__�s�����	�����$�$��<�U�!U�U�<�$(�D�!�#�-�-�d�3�D�K�
�T�\�$3�D�!�#�-�-�o�>�D�K�
�4�[�!�$�'�G�$+�L�L�D�!�!�.�.��+�D�K�
�4�[�$3�D�!��q�'�D�K�
��h�
'�$(�I�I�D�!��+�+�a�.�D�K�(rc� �|j|S)z.Return glyph name for that code point, or None)r�)ra�indexs  r�__getitem__zEncoding.__getitem__�s���{�{�5�!�!rc��|jdk(sJd��|j||k7r+t|j�}|||<t|�|_yy)Nr�Cannot modify a frozen encoding)r�r�rf�tuple)rar��value�Ls    r�__setitem__zEncoding.__setitem__�sR���{�{�a��B�!B�B���;�;�u��u�$��T�[�[�!�A��A�e�H���(�D�K�%rc�F�t|j�|_d|_y�Nr!)r�r�r�rjs r�freezezEncoding.freeze�s���D�K�K�(�����rc��|j|jk(xr+t|j�t|j�k(S�N)rIr�r�)ra�others  r�isEqualzEncoding.isEquals1���y�y�%�*�*�$�P��t�{�{�);�U�5�<�<�=P�)P�Prc�j�|jdk(sJd��|}|D]}||j|<|dz}�y)zASet a group of character names starting at the code point 'base'.rr�r!N)r�r�)rar��newNames�idxrIs     r�modifyRangezEncoding.modifyRangesE���{�{�a��B�!B�B�����	�D�#�D�K�K�����'�C�	rc� �g}d}tt|j��D]U}|j|}||j|k(r|s�'|j|�g}�;|r|j|��O|s�R||g}�W|r|j|�|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)�ranger2r�r:)ra�otherEnc�ranges�curRange�i�glyphs      r�getDifferenceszEncoding.getDifferencess��������s�4�;�;�'�(�
	*�A��K�K��N�E��h�o�o�a�(�(���M�M�(�+�!�H���O�O�E�*�� !�5�z�H�
	*���M�M�(�#��
rc��ddlm}i}|j}t|�}|j	|�}|gk(r|j|�Sg}|D]7}|j
|d�|ddD]}|��|j
d|z���9|j|�|d<|dvr|j|�|d<|jd	�|d
<|j|�}	|	S)z&Returns a PDF Object representing selfr��pdfdocr!N�/�Differences)�MacRomanEncoding�MacExpertEncoding�WinAnsiEncoding�BaseEncodingr��Type)	�reportlab.pdfbaser�r�r�r��PDFNamer:�PDFArray�
PDFDictionary)
rar��Dr�r��differences�	diffArrayr��	glyphName�PDs
          r�
makePDFObjectzEncoding.makePDFObject,s���	-����0�0���.�/���)�)�'�2���"���>�>�"2�3�3��I�$�
:��� � ��q��*�!&�q�r��:�I� �,�!�(�(��y��9�:�
:� &���y�9�A�m���#]�]�$*�N�N�3C�$D��.�!����z�2�A�f�I��%�%�a�(�B��Irr�)rrr�__doc__rbr�r�r�r�r�r�r�rrrr�r��s.��;�)�."�
#��Q���<rr�c�@�eZdZdZdZdZd
d�Zdd�Zd�Zd�Z	d�Z
d	�Zy)�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|�|_||_|jr|j�tn|xsg|_	|j�t|_|dk(xr|xst|_y)NrQ)
�fontName�getTypeFace�facer��encoding�encNamer^r\�standardT1SubstitutionFonts�substitutionFonts�_calcWidths�_notdefChar�_notdefFont)rarIr�r�r�r�s      rrbz
Font.__init__]s�����
�&�x�0�0��t�y�"�7�+��
����'+�|�|��8M�8M�8U�#>�):�)@�b�	
��	
����&�����/�8�D�G�K��rc� �t||||��S)N�r�)r)ra�text�sizer�s    r�stringWidthzFont.stringWidthis��$�T�4���I�Irc�d�d|jj�d|jj�d�S)N�<r0�>)�	__class__rr�rIrjs r�__repr__z
Font.__repr__ls�� �N�N�3�3�T�Y�Y�^�^�D�Drc	�^�dgdz}|jj}|jj}t	d�D]}||}|��	||}|||<�||_y#t
$rEddl}|jjr'td|jj�d|�d��n	Y�mwxYw)z)Vector of widths for stringWidth functionr�Nz
typeface "z" does not have a glyph "z", bad font!)r�rVr�r�r��KeyErrorr~�	rl_config�warnOnMissingFontGlyphs�printrI�widths)ra�w�gw�vecr�r�rH�	reportlabs        rr�zFont._calcWidthsos����C�#�I��
�Y�Y�
"�
"���m�m�"�"���s��	�A��A��I��$���y�M�E� �A�a�D�	�����
 ��.� �*�*�B�B��W[�W`�W`�We�We�gp�q�r����s�

A�AB,�+B,c��d}td�D]B}|dztt|j|�d�z}|dk(r|dz}|dzdk(s�>|d	z}�D|S)
z<returns a pretty block in PDF Array format to aid inspection�[r�� �utf8�s ]r$��
)r��bytesrdr�)rar�r�s   r�
_formatWidthszFont._formatWidths�sg�����s��	$�A��$�;��s�4�;�;�q�>�':�6�!B�B�D��C�x��e�|���2�v��|��e�|��	$��rc��ddlm}dtt|j�dz�z}|j�}||_|jj|_	d|jz|_|jj�}t|�r|dvr||_|jjt vrNd|_d|_|j'|j(�|_|jj-|�|_|j1||�}|j2dj4}|||<d	|z|j|j<y
)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��reprr2�fontMapping�PDFType1Font�Namer�rI�BaseFontr��__Comment__r�r�rr�r]�	FirstChar�LastCharr�r��Widths�
addObjects�FontDescriptor�	Reference�
idToObject�dict)ra�docr��internalName�pdfFontry�ref�fontDicts        rrzFont.addObjects�s��
	-��T�#�c�o�o�"6�q�"8�9�9���%�%�'��#����9�9�>�>���'�$�-�-�7����M�M�'�'�)���Q�x�1� ]�]� �G���y�y�~�~��.� !�G��"�G��#�_�_�T�[�[�9�G�N�%)�Y�Y�%9�%9�#�%>�G�"��m�m�G�\�2���>�>�,�/�4�4��!(����*-�|�);�����
�
�&rr��r�)rrrr��
_multiByte�_dynamicFontrbr�r�r�r�rrrrr�r�Qs4����J��L�
H�J�E��(	� <rr��r!�r)c��t||�tk7st||dz�|k7r3td|tt�t|�|||||dzfz��|tk(ry|dz}||dzdz||dzdzz||dzzdz||z}|dz}||zt|�kDrtd|||t|�fz��|||zfS)Nr!zGBad pfb file'%s' expected chr(%d)chr(%d) at char %d, got chr(%d)chr(%d)rr)��z1Bad pfb file'%s' needed %d+%d bytes have only %d!)�chr�
PFB_MARKERr4�ord�PFB_EOFr2)�p�d�mr�r?s     r�	_pfbCheckr$�s7��
�1�Q�4�y�*���A�a��c�F��Q���d�hj�kn�oy�kz�{~�@A�|B�CD�EF�GH�EI�JK�LM�NO�LO�JP�hQ�Q�R�	R��'�z�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�z��N�RT�UV�WX�Y\�]^�Y_�Q`�`�a�a��a��c�6�Mrc�.�eZdZdZd�Zd�Zd�Zd�Zd�Zy)�EmbeddedType1FacezcA Type 1 font other than one of the basic 14.

    Its glyph data will be embedded in the PDF file.c�R�tj|d�t|t�}t|t�}tj
j
|�|_tj
j
|�|_d|_	|j|�|j|�yr�)rOrbr
rrqrr�abspathr;rmr\�_loadGlyphs�_loadMetrics)rar;rms   rrbzEmbeddedType1Face.__init__�sz�����$��%�"�+�l�;��!�+�l�;���7�7�?�?�;�7����7�7�?�?�;�7��� $�������%����+�&rc�2�|j|jgSr�)r;rmrjs rrkzEmbeddedType1Face.getFontFiles�s��� � �$�"2�"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
|_y)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 �_binaryDatar2�_length�_length1�_length2�_length3)	rarmr"�s1�l1�s2�l2�s3�l3s	         rr)zEmbeddedType1Face._loadGlyphs�s���.�k�:����%�H�':�[�'H�H�%��+�s�+���1�Q�y��5���B��2�a�
�;�7���B��2�a�	�+�6���B��"�Q�w�{�+��R��8�A�b��H�,�Q�r�"�X�5����4�+�+�,����2���
��2���
��2���
rc��t|�}t|�\}}|d|_|d|_|j	dd�|_|j	dd�|_|j	dd�|_|j	dd�|_|j	d	d�|_	|j	d
d�|_
|j	dgd��}|j�}g|_|D]&}|jjt|���(i}|D]\}}	}
|	||
<�
||_t!|j#��|_|j$j'�|j	d
d�dk(r�t(�
	ddlm}|a~dgdz}i}
i}|D]=\}}	}
d|cxkrdks�n�|
||<t(j	|
d�}|��4|||<||
|<�?t1j2d|jz�}t4j6j9||
|�||_t=||�}t?|�yy#iat/d��xYw)z Loads in and parses font metricsr��
FamilyName�Ascender���	Descenderr�	CapHeight�ItalicAngle�stemV�XHeight�FontBBox)rrr=r=�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�r�zrl-dynamic-%s-encoding) r�rMrIrY�getrWrX�	capHeight�italicAnglerA�xHeightr3�bboxr:r8rVrfrgrU�sort�_postScriptNames2Unicode�reportlab.pdfbase._glyphlistrFr4r��normalize_encodingr�	RL_Codecs�add_dynamic_codecr\r��registerEncoding)rar;r=�	glyphData�strBbox�tokens�tokrVrGrHrIrF�names�ex�rex�code�ur��encs                   rr*zEmbeddedType1Face._loadMetrics�sJ��.�k�:�� ,�[� 9���9��Z�(��	�"�<�0����l�l�:�t�4����|�|�K��3���!���k�4�8���#�<�<�
�q�9����\�\�'�1�-��
��|�|�I�t�4����,�,�z�?�;���������	��	'�C��I�I���S��X�&�	'���"+�	&��S�%�� %�K���	&�&����{�/�/�1�2����������<�<�(�$�/�>�A�'�/�
�O�/A�,�*��F�S�L�E��B��C�'0�
%�#��u�d��d�<�C�<�"&�E�$�K�0�4�4�T�$�?�A��}�$%��D�	� $��1��

%� �2�2�3K�d�i�i�3W�X�G����1�1�'�"�S�A�$+�D�!��7�E�*�C��S�!�;B���/1�,�$�L���s�;	H3�3Ic�|�ddlm}|j�}|j|_|j
|jd<|j|jd<|j|jd<|j|d|jz�}|jd|j|j|jd|j|j �|j#|j$�|j&|j(|j*|d	��}|j|d
|j$z�}|S)zFAdd whatever needed to PDF file, and return a FontDescriptor referencerr��Length1�Length2�Length3z	fontFile:z/FontDescriptor�")r��Ascentr?�Descent�FlagsrCr�r@�StemVrB�FontFilezfontDescriptor:)r�r��	PDFStreamr/�contentr1�
dictionaryr2r3r
rmr�rWrHrXr�rKr�rIrIrArJ)rarr��fontFile�fontFileRef�fontDescriptor�fontDescriptorRefs       rrzEmbeddedType1Face.addObjects$s��,��#�#�%���+�+���)-������I�&�)-������I�&�)-������I�&��m�m�H�k�D�<L�<L�.L�M���-�-�%��[�[�����l�l�����t�y�y�1��~�~�d�i�i�0��*�*��J�J��l�l�#�/��� �M�M�.�:K�d�i�i�:W�X�� � rN)	rrrr�rbrkr)r*rrrrr&r&�s!��8�'�4��$;"�z!rr&c��t|t�s
Jd|z��|t|j<|jtvrt|j�yy)NzNot a TypeFace: %s)r�rO�
_typefacesrIr]�registerFontFamily)r�s r�registerTypeFacerqBsJ���d�H�%�B�';�d�'B�B�%� �J�t�y�y���9�9�
�%�	�4�9�9�%�&rc�8�t|t�s
Jd|z��|jtvrK|j	t|j�r|j�yt
d|jz��|t|j<|j�y)NzNot an Encoding: %sz>Encoding "%s" already registered with a different name vector!)r�r�rI�
_encodingsr�r�r)r\s rrRrRJsv���c�8�$�A�&;�c�&A�A�$�
�x�x�:���;�;�z�#�(�(�+�,��J�J�L��\�_b�_g�_g�g�h�h�"�
�3�8�8���
�
�rc��ddlm}|s|}|j�}|s
|xs|xs|}|s|}|s|}|j|dd|�|j|dd|�|j|dd|�|j|dd|�y)Nr)�fontsr!)�
reportlab.librur6�
addMapping)�family�normalrZr[�
boldItalicrus      rrprpWs���#��F�6�
�\�\�^�F��F�$<�d�$<�f�z�����F�6�	���V�Q��6�*�	���V�Q��4�(�	���V�Q��6�*�	���V�Q��:�.rc�b�|j}|jrl|jj}|tvrW|t
vr3t
|}|jst
d|�d|�d|����|t|<n|xt
|<t|<n	|t|<|jrt|j�yy)zGRegisters a font, including setting up info for accelerated stringWidthzAttempt to register fonts r0z
 for face N)	r�rr�rI�_fonts�
_dynFaceNamesr4rrp)�fontr�r��ofonts    r�registerFontr�cs����}�}�H�����9�9�>�>���6�!��=�(�%�h�/���)�)�$�V[�]a�ck�%l�m�m�',�F�8�$�=A�A�
�h�'�&��*:���x�����	�4�=�=�)�	rc��	t|S#t$r�|tvr@t|�}tj
|\|_|_|_t|�|cYSt|�}|ridD]4}tjj|�d|z}t|�s�4nt�s
Jd|z��t||�}t|�|cYS�wxYw)z-Lazily construct known typefaces if not found)rnz.PFBrzfile %s not found!)ror�r]rOr�standardFontAttributesrYrZr[rqrurqrrrsrr&)r�r�rzryr{s     rr�r�{s�����(�#�#�����}�$��H�%�D�8A�8X�8X�Ya�8b�5�T�_�d�i����T�"��K�)��2�C��)�-�A��'�'�*�*�3�/��2�Q�6�C� ��~�u�-�!��~�A�';�c�'A�A�~�(��c�2�� ��&����+�s��AC�AC�1C�Cc�v�	t|S#t$r$|tvrt|�}t	|�|cYS�wxYw)z-Lazily construct known encodings if not found)rsr�r�r�rR)r�r\s  rr�r��sD��	��'�"�"�����'�'��7�#�C��S�!��J���s��)8�8c��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)rd�type�asciir�r\r�r
r�)r�r�r~s   r�findFontAndRegisterr��sq���8�}�H���>�S� �Z�"H�5�QY�?�"Z�Z� ��x� �D�����H�h��(=�(=�>���H�h��8������Krc�J�	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��s,��-��h�����-�"�8�,�,�-�s��"�"rQrSc���t|�}	|j}|j}|r|dz}||z||zfS||fS#|jj}|jj}Y�ExYw)Ng@�@)r�rWrXr�)r��fontSizer~rWrX�norms      r�getAscentDescentr��ss���8��D�$������,�,�����~���d�{�G�D�L�(�(��w����$����!�!���)�)�#�#��s	�:�.A*c� �t||�dS)Nr�r��r�r�s  r�	getAscentr������H�X�.�q�1�1rc� �t||�dSr�r�r�s  r�
getDescentr��r�rc�`�ttj��}|j�|S)zReturns what's in there)rfr|rgrL)�regs r�getRegisteredFontNamesr��s ��
�v�{�{�}�
�C��H�H�J��Jrc�<�t|�j|||��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�Krc
�v�td�ttj��}|j	�|D]}td|��t�td�tt
j��}|j	�|D]}td|��t�td�ttj��}|j	�|D]R}t|}td|j�d|jj�d|jj�d���Ty)	NzRegistered Encodings:z   zRegistered Typefaces:zRegistered Fonts:z    z (r��))r�rfrsrgrLror|r�r�rIr�)rgr��facesr��k�keyr~s       r�dumpFontDatar��s���	�
!�"��
���!�"�D��I�I�K����
�e�G���
�G�	�
!�"�����"�#�E�	�J�J�L����
�e�H���
�G�	�
���V�[�[�]��A��F�F�H��V���c�{��
�$�-�-���������AS�AS�T�U�Vrc��ddl}tddD]�}|j�}t|�j}|D]}d}|D]}||t	|�z}��|j�}td||z
z�|j�}|D]}t|�j
|d�}	�|j�}td||z
z�t���y)Nrr!zslow stringWidth took %0.4f�
z'class lookup and stringWidth took %0.4f)�timer]r�r�rr�r�)
�textsr�r��t0r�r�r7�ch�t1r9s
          r�test3widthsr��s����!�!�A�&����Y�Y�[���H��$�$���	%�D��B��
%���!�C��G�*�_��
%�	%��Y�Y�[��
�+�r�B�w�7�8�
�Y�Y�[���	9�D���"�.�.�t�R�8�B�	9�
�Y�Y�[��
�7�2��7�C�D�
��+rc�>�td�j�}tdt|�z�td�t	|g�t�|j�}tdt|�dt|�zt|�zfz�t	|�y)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�r2r�r3)�rawdata�wordss  r�testStringWidthAlgorithmsr�s����B�C�H�H�J�G�	�
��G��
,�-�	�
#�$���	��	�G��M�M�O�E�	�
C�s�5�z�SV�WZ�[b�Wc�Sc�dg�hm�dn�Sn�Fo�
o�p���rc���td�}t|�t|jdd�td�}t|j�t|�t	�y)N�	Helveticar��Wombat)rOrqr�rUr�)�helv�wombats  r�testr�sL���K� �D��T��	�$�/�/�!�B�
� �
�h�
�F�	�&�
�
���V���Nr)rorsr|r}c���|j�D]3\}}t�|}|j�|j|��5tj
j
�yr�)�items�globals�clear�updaterrP�reset_dynamic_codecs)�
initial_dictsr�r�r"s    r�_resetr�'sS���"�"�$����!�
�)�A�,��	���	�	���������,�,�.r)�register_reset�__main__r�)NNNNr)L�__version__r�rqr�r�r�r�reportlab.lib.loggerr�reportlab.lib.utilsrrrrr	r
rrr~r
r�reportlab.lib.rl_accelrrrr�rP�registerr]r�rorsr|r}�	ExceptionrrrMrOr�rur�r�r�rrr-r.r r$rMr&rqrRrpr�r�r�r�r�r��extendr�r�r�r�r�r�r�r�r�r�copyr�r�rrrr�<module>r�s���

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

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

Zerion Mini Shell 1.0