a
    ¥Q•hït  ã                   @   s^  d Z dZddlZddlZddlZddlmZ ddlmZ ddl	m
Z
mZmZmZmZmZmZmZ ddlmZmZ ddlmZmZ dd	lmZ d
Zej ¡  ejZejZi Zi Zi Z i Z!G dd„ de"ƒZ#G dd„ de"ƒZ$dd„ Z%G dd„ dƒZ&dMdd„Z'dd„ Z(G dd„ dƒZ)g Z*G dd„ dƒZ+e,dƒZ-e,dƒZ.e,dƒZ/e,dƒZ0dd „ Z1da2G d!d"„ d"e&ƒZ3d#d$„ Z4d%d&„ Z5dNd'd(„Z6d)d*„ Z7d+d,„ Z8d-d.„ Z9d/d0„ Z:d1d2„ Z;e;d3ƒZ<e* =e;d4ƒe<g¡ dOd5d6„Z>dPd7d8„Z?dQd9d:„Z@d;d<„ ZAdRd>d?„ZBd@dA„ ZCdBdC„ ZDdDdE„ ZEdFdG„ ZFeGe H¡ e H¡ e  H¡ e! H¡ dH�fdIdJ„ZIddKlmJZJ eJeIƒ [JeKdLk�rZeFƒ  eEƒ  dS )Sz3.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                   @   s   e Zd ZdS )Ú	FontErrorN©Ú__name__Ú
__module__Ú__qualname__© r   r   úU/var/www/sistema_ama/venv/lib/python3.9/site-packages/reportlab/pdfbase/pdfmetrics.pyr   '   s   r   c                   @   s   e Zd ZdS )ÚFontNotFoundErrorNr   r   r   r   r   r   )   s   r   c              	   C   s*  t | dƒ}t|ƒdkr@|r(|d  d¡}t|ƒdkr@td|  ƒ‚i }g }dd„ |D ƒ}dd„ |D ƒ}d}|D �]}|dd	… d
krˆd}ql|dd… dkržd}ql|rl| d¡}dd„ |D ƒ}|dd… \}}}	| ¡ \}
}|
dksìJ d| ƒ‚t|ƒ}| ¡ \}
}|
dk�sJ d| ƒ‚zt|ƒ}W n t�y>   t|ƒ}Y n0 |	 ¡ \}
}|
dk�sbJ d| ƒ‚|}| |||f¡ qld}|D ] }|dd	… dk�ršd}|dd	… d
k�r²d}nl|�r€|dd… dk�rÊz| dd¡\}}W n   td| |f ƒ‚Y n0 zt|ƒ}W n   Y n0 |||< �q€||fS )a  Quick 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   úzAFM file %s hasn't enough datac                 S   s   g | ]}|  ¡ ‘qS r   ©Ústrip©Ú.0Úlr   r   r   Ú
<listcomp>=   ó    z parseAFMFile.<locals>.<listcomp>c                 S   s   g | ]}|  ¡  d ¡s|‘qS )Úcomment)ÚlowerÚ
startswithr   r   r   r   r"   >   r#   é   ZStartCharMetricsé   ZEndCharMetricsú;c                 S   s   g | ]}|  ¡ ‘qS r   r   )r    Úchunkr   r   r   r"   H   r#   é   ÚCzbad line in font file %sZWXÚNZStartFontMetricsé   ÚCommentú z-Header information error in afm %s: line='%s')r   ÚlenÚsplitÚ
ValueErrorÚintÚfloatÚappend)ÚafmFileNameÚlinesÚtopLevelZ
glyphLevelZ	inMetricsÚlineÚchunksZcidChunkZ
widthChunkZ	nameChunkr!   r   ÚcidÚwidthÚnameZinHeaderÚleftÚrightr   r   r   ÚparseAFMFile,   sd    


rA   c                   @   s.   e Zd Zdd„ Zdd„ Zdd„ Zddd	„Zd
S )ÚTypeFacec                 C   sz   || _ g | _i | _d| _d| _d | _d| _d| _|dkr@d| _n|dkrPd| _nd | _|t	v rpd| _
|  |¡ nd| _
d S )Nr   ÚZapfDingbatsZZapfDingbatsEncodingÚSymbolZSymbolEncodingr   )r>   Ú
glyphNamesÚglyphWidthsÚascentÚdescentÚ
familyNameÚboldÚitalicÚrequiredEncodingÚstandardFontsÚbuiltInÚ_loadBuiltInData©Úselfr>   r   r   r   Ú__init__v   s"    zTypeFace.__init__c                 C   s:   t |ƒ}tj| | _t| j ¡ ƒ| _tj| \| _| _	dS )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   ZwidthsByFontGlyphrF   ÚlistÚkeysrE   Zascent_descentrG   rH   rP   r   r   r   rO   �   s    zTypeFace._loadBuiltInDatac                 C   s   g S )z=Info function, return list of the font files this depends on.r   ©rQ   r   r   r   ÚgetFontFiles˜   s    zTypeFace.getFontFilesú.pfbc                 C   sì   |  ¡ | ¡ f}t| dƒrNtj | j¡d }|D ]}t|| ƒr0||   S q0zt 	| j
¡}W nn   t| j
ƒ}|rÄ|  ¡ dkr²|D ]*}tj |¡d | }t|ƒrª|}q„d }q„qÈ|  ¡ dkrÈ|}nd }Y n0 |d u rètd|| j
f ƒ |S )NÚpfbFileNamer   rX   z.afmzCan't find %s for face '%s')r%   ÚupperÚhasattrÚosÚpathÚsplitextrY   r   r   Ú
findT1Filer>   ÚbruteForceSearchForAFMr   )rQ   ÚextZpossible_extsZ
r_basenameÚer   ÚafmÚpfbr   r   r   r_   œ   s.    


zTypeFace.findT1FileN)rX   )r   r   r   rR   rO   rW   r_   r   r   r   r   rB   u   s   rB   c                 C   sb   |d u rddl m} t| ƒr | S tj | ¡}|D ],}t|ƒs>q0tj ||¡}t|ƒr0|  S q0| S )Nr   ©r   )Úreportlab.rl_configr   r   r\   r]   Úbasenamer   Újoin)ÚfnZ
searchPathZbfnÚdirnameZtfnr   r   r   ÚbruteForceSearchForFile·   s    
rk   c           
   
   C   s¦   ddl m} |D ]�}t|ƒsqt|tj d ƒ}|D ]j}z*t|ƒ\}}|d | kr`|W     S W q4   t ¡ \}}}	d 	t
t|jƒ¡d|   f|_‚ Y q40 q4qdS )zcLooks in all AFM files on path for face with given name.

    Returns AFM file name or None.  Ouch!r   re   z*.[aA][fF][mM]ÚFontNamer0   z, while looking for faceName=%rN)rf   r   r   r   r\   ÚseprA   ÚsysÚexc_inforh   ÚmaprS   Úargs)
ÚfaceNamer   rj   Ú	possiblesÚpossibleZtopDictZ	glyphDictÚtÚvÚbr   r   r   r`   Á   s    
r`   c                   @   sR   e Zd ZdZddd„Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ ZdS )ÚEncodingz1Object to help you create and refer to encodings.Nc                 C   sÂ   || _ d| _|tv r8|d u s$J dƒ‚|| _tj| | _n†|d krTt| _tjt | _njt|ƒr~t	|ƒ}|j | _|jd d … | _n@t
|ƒrœt| _|d d … | _n"t|tƒr¾|j | _|jd d … | _d S )Nr   z2Can't have a base encoding for a standard encoding)r>   ÚfrozenÚstandardEncodingsÚbaseEncodingNamer   Ú	encodingsÚvectorr   r   ÚgetEncodingr
   Ú
isinstancerx   )rQ   r>   ÚbaseÚbaseEncr   r   r   rR   Û   s&    
zEncoding.__init__c                 C   s
   | j | S )z.Return glyph name for that code point, or None)r}   )rQ   Úindexr   r   r   Ú__getitem__ò   s    zEncoding.__getitem__c                 C   s@   | j dksJ dƒ‚| j| |kr<t| jƒ}|||< t|ƒ| _d S )Nr   úCannot modify a frozen encoding)ry   r}   rT   Útuple)rQ   r‚   ÚvalueÚLr   r   r   Ú__setitem__÷   s
    
zEncoding.__setitem__c                 C   s   t | jƒ| _d| _d S ©Nr   )r…   r}   ry   rV   r   r   r   Úfreezeÿ   s    zEncoding.freezec                 C   s    | j |j kot| jƒt|jƒkS ©N)r>   r…   r}   )rQ   Úotherr   r   r   ÚisEqual  s    zEncoding.isEqualc                 C   s6   | j dksJ dƒ‚|}|D ]}|| j|< |d }qdS )zASet a group of character names starting at the code point 'base'.r   r„   r   N)ry   r}   )rQ   r€   ZnewNamesÚidxr>   r   r   r   ÚmodifyRange  s
    
zEncoding.modifyRangec                 C   sv   g }d}t t| jƒƒD ]L}| j| }||j| krF|rb| |¡ g }q|rV| |¡ q|r||g}q|rr| |¡ |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)Úranger1   r}   r6   )rQ   ZotherEncZrangesZcurRangeÚiZglyphr   r   r   ÚgetDifferences  s    



zEncoding.getDifferencesc           
      C   sÂ   ddl m} i }| j}t|ƒ}|  |¡}|g kr:| |¡S g }|D ]:}| |d ¡ |dd… D ]}|dur`| d| ¡ q`qB| |¡|d< |dv r¢| |¡|d< | d	¡|d
< | |¡}	|	S dS )z&Returns a PDF Object representing selfr   ©Úpdfdocr   Nú/ZDifferences)ZMacRomanEncodingZMacExpertEncodingÚWinAnsiEncodingZBaseEncodingrx   ÚType)	Úreportlab.pdfbaser”   r{   r~   r’   ÚPDFNamer6   ÚPDFArrayÚPDFDictionary)
rQ   r”   ÚDr{   r�   ZdifferencesZ	diffArrayr�   Ú	glyphNameZPDr   r   r   ÚmakePDFObject,  s&    


zEncoding.makePDFObject)N)r   r   r   Ú__doc__rR   rƒ   rˆ   rŠ   r�   r�   r’   rž   r   r   r   r   rx   Ù   s   
rx   c                   @   sL   e Zd ZdZdZdZddd„Zddd„Zd	d
„ Zdd„ Z	dd„ Z
dd„ ZdS )ÚFontaD  Represents 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)r   Nc                 C   sf   || _ t|ƒ }| _t|ƒ| _|| _|jr8|jd u r8tn|p>g | _	|  
¡  t| _|dkr\| p^t| _d S )NrC   )ÚfontNameÚgetTypeFaceÚfacer~   ÚencodingÚencNamerN   rL   ÚstandardT1SubstitutionFontsÚsubstitutionFontsÚ_calcWidthsÚ_notdefCharÚ_notdefFont)rQ   r>   rr   r¥   r§   r£   r   r   r   rR   ]  s    
ÿÿþzFont.__init__Úutf8c                 C   s   t | |||d�S )N©r¤   )r   )rQ   ÚtextÚsizer¤   r   r   r   ÚstringWidthi  s    zFont.stringWidthc                 C   s   d| j j| jjf S )Nz<%s %s>)Ú	__class__r   r£   r>   rV   r   r   r   Ú__repr__l  s    zFont.__repr__c              	   C   s�   dgd }| j j}| jj}tdƒD ]b}|| }|dur"z|| }|||< W q" ty‚   ddl}|jjr~t	d| j j
|f ƒ n Y q"0 q"|| _dS )z)Vector of widths for stringWidth functionr   é   Nz3typeface "%s" does not have a glyph "%s", bad font!)r£   rF   r¤   r}   r�   ÚKeyErrorrf   Ú	rl_configÚwarnOnMissingFontGlyphsÚprintr>   Úwidths)rQ   ÚwZgwZvecr‘   r�   r=   Ú	reportlabr   r   r   r¨   o  s    
zFont._calcWidthsc                 C   sV   d}t dƒD ]D}|d tt| j| ƒdƒ }|dkr<|d }|d dkr|d	 }q|S )
z<returns a pretty block in PDF Array format to aid inspectionó   [r²   ó    r«   éÿ   s    ]r'   é   ó   
)r�   ÚbytesrS   r·   )rQ   r­   r‘   r   r   r   Ú_formatWidthsƒ  s    
zFont._formatWidthsc                 C   sÎ   ddl m} dtt|jƒd ƒ }| ¡ }||_| jj|_	d| j
 |_| j ¡ }t|ƒr`|dv rf||_| jjtvršd|_d|_| | j¡|_| j |¡|_| ||¡}|jd j}|||< d	| |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) r   r“   ÚFr   zFont %s)z/MacRomanEncodingz/MacExpertEncodingz/WinAnsiEncodingr¼   Z
BasicFontsr•   N)r˜   r”   Úreprr1   ZfontMappingZPDFType1FontÚNamer£   r>   ZBaseFontr¡   Z__Comment__r¤   rž   r   rx   rM   Z	FirstCharZLastCharrš   r·   ZWidthsÚ
addObjectsZFontDescriptorÚ	ReferenceZ
idToObjectÚdict)rQ   Údocr”   ZinternalNameZpdfFontrb   ÚrefZfontDictr   r   r   rÄ   Ž  s$    

zFont.addObjects)N)r«   )r   r   r   rŸ   Ú
_multiByteÚ_dynamicFontrR   r¯   r±   r¨   rÀ   rÄ   r   r   r   r   r    Q  s   

r    é€   r   é   r+   c              
   C   sØ   t ||  ƒtks$t || d  ƒ|krPtd|ttƒt|ƒ| ||  || d  f ƒ‚|tkr\d S | d } || d  d> || d  d> B || d  B d> ||  B }| d } | | t|ƒkrÌtd|| |t|ƒf ƒ‚| | | fS )Nr   zGBad pfb file'%s' expected chr(%d)chr(%d) at char %d, got chr(%d)chr(%d)rÌ   r+   é   é   z1Bad pfb file'%s' needed %d+%d bytes have only %d!)ÚchrÚ
PFB_MARKERr3   ÚordÚPFB_EOFr1   )ÚpÚdÚmri   r!   r   r   r   Ú	_pfbCheckµ  s    $,8rÖ   c                   @   s8   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ ZdS )ÚEmbeddedType1FacezcA Type 1 font other than one of the basic 14.

    Its glyph data will be embedded in the PDF file.c                 C   sZ   t  | d ¡ t|tƒ}t|tƒ}tj |¡| _tj |¡| _d | _	|  
|¡ |  |¡ d S r‹   )rB   rR   r	   r   r\   r]   Úabspathr7   rY   rL   Ú_loadGlyphsÚ_loadMetrics)rQ   r7   rY   r   r   r   rR   Å  s    


zEmbeddedType1Face.__init__c                 C   s   | j | jgS r‹   )r7   rY   rV   r   r   r   rW   Ò  s    zEmbeddedType1Face.getFontFilesc           	      C   s¾   t |ƒ}t|ƒsJ d| ƒ‚t|dƒ}td|t|ƒ\}}t||t|ƒ\}}t||t|ƒ\}}t||t|ƒ |||… |||…  |||…  | _t| jƒ| _	|| | _
|| | _|| | _dS )ziLoads in binary glyph data, and finds the four length
        measurements needed for the font descriptorzfile %s not foundrw   r   N)rk   r   r   rÖ   Ú	PFB_ASCIIÚ
PFB_BINARYrÒ   Ú_binaryDatar1   Ú_lengthÚ_length1Ú_length2Ú_length3)	rQ   rY   rÔ   Ús1Úl1Ús2Úl2Zs3Úl3r   r   r   rÙ   Õ  s    
&

zEmbeddedType1Face._loadGlyphsc                 C   sä  t |ƒ}t|ƒ\}}|d | _|d | _| dd¡| _| dd¡| _| dd¡| _| dd¡| _| d	d¡| _	| d
d¡| _
| dg d¢¡}| ¡ }g | _|D ]}| j t|ƒ¡ qži }|D ]\}}	}
|	||
< q¼|| _t| ¡ ƒ| _| j ¡  | dd¡dk�ràtdu �r:zddlm} |a~W n   i atdƒ‚Y n0 dgd }i }i }|D ]V\}}	}
d|  k�rrdk�rPn n.|
||< t |
d¡}|du�rP|||< |||< �qPt d| j ¡}tj |||¡ || _t||ƒ}t|ƒ dS )z Loads in and parses font metricsrl   Z
FamilyNameZAscenderéè  Z	Descenderr   Ú	CapHeightÚItalicAngleÚstemVÚXHeightÚFontBBox)r   r   rç   rç   ZEncodingSchemeNZ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¼   zrl-dynamic-%s-encoding) rk   rA   r>   rI   ÚgetrG   rH   Ú	capHeightÚitalicAnglerê   ÚxHeightr2   Úbboxr6   r4   rF   rT   rU   rE   ÚsortÚ_postScriptNames2UnicodeZreportlab.pdfbase._glyphlistrí   r3   r|   Únormalize_encodingr   Ú	RL_CodecsZadd_dynamic_codecrL   rx   ÚregisterEncoding)rQ   r7   r9   Z	glyphDataZstrBboxÚtokensÚtokrF   r<   r=   r>   rí   ÚnamesÚexZrexÚcodeÚur¥   Úencr   r   r   rÚ   ç  s^    




ÿ



zEmbeddedType1Face._loadMetricsc                 C   s¦   ddl m} | ¡ }| j|_| j|jd< | j|jd< | j|jd< | 	|d| j
 ¡}| d| j| j| jd| | j¡| | j¡| j| j| j|d	œ¡}| 	|d
| j ¡}|S )zFAdd whatever needed to PDF file, and return a FontDescriptor referencer   r“   ZLength1ZLength2ZLength3z	fontFile:z/FontDescriptoré"   )r—   ZAscentrè   ZDescentZFlagsrì   rl   ré   ZStemVrë   ZFontFilezfontDescriptor:)r˜   r”   Z	PDFStreamrÝ   Úcontentrß   Ú
dictionaryrà   rá   rÅ   rY   r›   rG   rï   rH   rš   rò   r™   r>   rð   rê   rñ   )rQ   rÇ   r”   ZfontFileZfontFileRefZfontDescriptorZfontDescriptorRefr   r   r   rÄ   $  s,    

õzEmbeddedType1Face.addObjectsN)	r   r   r   rŸ   rR   rW   rÙ   rÚ   rÄ   r   r   r   r   r×   Á  s   =r×   c                 C   s8   t | tƒsJ d|  ƒ‚| t| j< | jtvr4t| jƒ d S )NzNot a TypeFace: %s)r   rB   Ú
_typefacesr>   rM   ÚregisterFontFamily)r£   r   r   r   ÚregisterTypeFaceB  s    

r  c                 C   s`   t | tƒsJ d|  ƒ‚| jtv rJ|  t| j ¡r:|  ¡  q\td| j ƒ‚n| t| j< |  ¡  d S )NzNot an Encoding: %sz>Encoding "%s" already registered with a different name vector!)r   rx   r>   Ú
_encodingsr�   rŠ   r   )rþ   r   r   r   r÷   J  s    


r÷   c                 C   s€   ddl m} |s| }|  ¡ } |s,|p*|p*|}|s4|}|s<|}| | dd|¡ | | dd|¡ | | dd|¡ | | dd|¡ d S )Nr   )Úfontsr   )Úreportlab.libr  r%   Ú
addMapping)ÚfamilyZnormalrJ   rK   Z
boldItalicr  r   r   r   r  W  s    r  c                 C   s~   | j }| jrb| jj}|tvrj|tv rPt| }|jsFtd|| |f ƒ‚q`|t|< qj|  t|< t|< n| t|< | jrzt| j ƒ dS )zGRegisters a font, including setting up info for accelerated stringWidthz+Attempt to register fonts %r %r for face %rN)	r¡   rÊ   r£   r>   Ú_fontsÚ_dynFaceNamesr3   rÉ   r  )Úfontr¡   rr   Zofontr   r   r   ÚregisterFontc  s    
r  c                 C   s¾   z
t |  W S  ty¸   | tv rNt| ƒ}tj|  \|_|_|_t	|ƒ | Y S t
| ƒ}|r²dD ]$}tj |¡d | }t|ƒr^ q„q^t|ƒs˜J d| ƒ‚t||ƒ}t	|ƒ | Y S ‚ Y n0 dS )z-Lazily construct known typefaces if not found)rX   z.PFBr   zfile %s not found!N)r  r³   rM   rB   r   ZstandardFontAttributesrI   rJ   rK   r  r`   r\   r]   r^   r   r×   )rr   r£   rc   rb   rd   r   r   r   r¢   {  s$    

r¢   c                 C   sD   z
t |  W S  ty>   | tv r8t| ƒ}t|ƒ | Y S ‚ Y n0 dS )z-Lazily construct known encodings if not foundN)r  r³   rz   rx   r÷   )r¥   rþ   r   r   r   r~   –  s    
r~   c                 C   sZ   t | ƒ} t| ƒt u s$J dt| ƒ ƒ‚t| ƒ}|jrBt| | |jƒ}nt| | tƒ}t|ƒ |S )z-search for and register a font given its namez$fontName=%s is not required type str)rS   ÚtypeÚasciir¢   rL   r    r   r  )r¡   r£   r  r   r   r   ÚfindFontAndRegister£  s    r  c                 C   s*   z
t |  W S  ty$   t| ƒ Y S 0 dS )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.N)r
  r³   r  )r¡   r   r   r   ÚgetFont±  s    
r  rC   rD   c                 C   s^   t | ƒ}z|j}|j}W n   |jj}|jj}Y n0 |rR|d }|| || fS ||fS d S )Ng     @�@)r  rG   rH   r£   )r¡   ÚfontSizer  rG   rH   Znormr   r   r   ÚgetAscentDescentÀ  s    
r  c                 C   s   t | |ƒd S )Nr   ©r  ©r¡   r  r   r   r   Ú	getAscentÎ  s    r  c                 C   s   t | |ƒd S r‰   r  r  r   r   r   Ú
getDescentÑ  s    r  c                  C   s   t t ¡ ƒ} |  ¡  | S )zReturns what's in there)rT   r
  rU   ró   )Úregr   r   r   ÚgetRegisteredFontNamesÔ  s    r  r«   c                 C   s   t |ƒj| ||d�S )zjCompute width of string in points;
    not accelerated as fast enough because of instanceStringWidthT1/TTFr¬   )r  r¯   )r­   r¡   r  r¤   r   r   r   r¯   Ú  s    r¯   c                  C   sº   t dƒ tt ¡ ƒ} |  ¡  | D ]}t d|ƒ q t ƒ  t dƒ tt ¡ ƒ}| ¡  |D ]}t d|ƒ qVt ƒ  t dƒ tt ¡ ƒ}| ¡  |D ](}t| }t d|j|jj	|j
j	f ƒ qŒd S )NzRegistered Encodings:z   zRegistered Typefaces:zRegistered Fonts:z    %s (%s/%s))r¶   rT   r  rU   ró   r  r
  r¡   r£   r>   r¤   )rU   r¥   Zfacesrr   ÚkÚkeyr  r   r   r   ÚdumpFontDataß  s$    r  c           
      C   s°   dd l }tdd… D ]–}|  ¡ }t|ƒj}| D ]"}d}|D ]}||t|ƒ  }q:q.|  ¡ }td||  ƒ |  ¡ }| D ]}t|ƒ |d¡}	qv|  ¡ }td||  ƒ tƒ  qd S )Nr   r   zslow stringWidth took %0.4fé
   z'class lookup and stringWidth took %0.4f)ÚtimerM   r  r·   rÑ   r¶   r¯   )
Ztextsr  r¡   Út0r¸   r­   rå   ÚchÚt1ræ   r   r   r   Útest3widthsö  s     
r"  c                  C   sl   t dƒ ¡ } tdt| ƒ ƒ tdƒ t| gƒ tƒ  |  ¡ }tdt|ƒdt| ƒ t|ƒ f ƒ t|ƒ d S )Nz-../../rlextra/rml2pdf/doc/rml_user_guide.prepzrawdata length %dztest one huge string...z7test %d shorter strings (average length %0.2f chars)...g      ð?)ÚopenÚreadr¶   r1   r"  r2   )ÚrawdataÚwordsr   r   r   ÚtestStringWidthAlgorithms  s    
$r'  c                  C   sF   t dƒ} t| ƒ t| jdd… ƒ t dƒ}t|jƒ t|ƒ tƒ  d S )NÚ	Helveticar   é   ZWombat)rB   r  r¶   rE   r  )ZhelvZwombatr   r   r   Útest  s    
r*  )r  r  r
  r  c                 C   s<   |   ¡ D ]$\}}tƒ | }| ¡  | |¡ qtj ¡  d S r‹   )ÚitemsÚglobalsÚclearÚupdater   rö   Zreset_dynamic_codecs)Zinitial_dictsr  rv   rÔ   r   r   r   Ú_reset'  s
    
r/  )Úregister_resetÚ__main__)N)NNNN)N)N)N)r«   )LÚ__version__rŸ   r\   rn   r|   r˜   r   Zreportlab.lib.loggerr   Úreportlab.lib.utilsr   r   r   r   r   r	   r
   r   rf   r   r   Úreportlab.lib.rl_accelr   r   r   r©   rö   ÚregisterrM   rz   r  r  r
  r  Ú	Exceptionr   r   rA   rB   rk   r`   rx   r¦   r    rÏ   rÐ   rÛ   rÜ   rÒ   rÖ   rô   r×   r  r÷   r  r  r¢   r~   r  r  rª   Úextendr  r  r  r  r¯   r  r"  r'  r*  rÆ   Úcopyr/  r0  r   r   r   r   r   Ú<module>   s‚   (
IB

w_ 




üÿ

