o
    à’Oju  ã                   @   sb  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¡ dMd5d6„Z>dMd7d8„Z?dMd9d:„Z@d;d<„ ZAdOd>d?„ZBd@dA„ ZCdBdC„ ZDdDdE„ ZEdFdG„ ZFeGe H¡ e H¡ e  H¡ e! H¡ dH�fdIdJ„ZIddKlmJZJ eJeIƒ [JeKdLk�r/eFƒ  eEƒ  dS dS )Pz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                   @   ó   e Zd ZdS )Ú	FontErrorN©Ú__name__Ú
__module__Ú__qualname__© r   r   úb/var/www/html/pharmsmart-cdr-gen/venv/lib/python3.10/site-packages/reportlab/pdfbase/pdfmetrics.pyr   '   ó    r   c                   @   r   )ÚFontNotFoundErrorNr   r   r   r   r   r   )   r   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rCd}q6|dd… dkrNd}q6|r·| d¡}dd„ |D ƒ}|dd… \}}}	| ¡ \}
}|
dksuJ d| ƒ‚t|ƒ}| ¡ \}
}|
dks‰J d| ƒ‚zt|ƒ}W n tyœ   t|ƒ}Y nw |	 ¡ \}
}|
dks­J d| ƒ‚|}| |||f¡ q6d}|D ]G}|dd	… dkrÈd}|dd	… d
krÓd}q¼|�r|dd… dkrÞz
| dd¡\}}W n   td| |f ƒ‚zt|ƒ}W n   Y |||< 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   ó   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%   >   s    é   ÚStartCharMetricsé   ÚEndCharMetricsú;c                 S   r   r   r    )r#   Úchunkr   r   r   r%   H   r&   é   ÚCzbad line in font file %sÚWXÚNÚStartFontMetricsé   ÚCommentú z-Header information error in afm %s: line='%s')r   ÚlenÚsplitÚ
ValueErrorÚintÚfloatÚappend)ÚafmFileNameÚlinesÚtopLevelÚ
glyphLevelÚ	inMetricsÚlineÚchunksÚcidChunkÚ
widthChunkÚ	nameChunkr$   r   ÚcidÚwidthÚnameÚinHeaderÚleftÚrightr   r   r   ÚparseAFMFile,   sj   

ÿ€€rN   c                   @   s.   e Zd Zdd„ Zdd„ Zdd„ Zddd	„Zd
S )ÚTypeFacec                 C   s|   || _ g | _i | _d| _d| _d | _d| _d| _|dkr d| _n|dkr(d| _nd | _|t	v r9d| _
|  |¡ d S d| _
d S )Nr   ÚZapfDingbatsÚZapfDingbatsEncodingÚSymbolÚSymbolEncodingr   )rJ   Ú
glyphNamesÚglyphWidthsÚascentÚdescentÚ
familyNameÚboldÚitalicÚrequiredEncodingÚstandardFontsÚbuiltInÚ_loadBuiltInData©ÚselfrJ   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   ÚwidthsByFontGlyphrU   ÚlistÚkeysrT   Úascent_descentrV   rW   r_   r   r   r   r^   �   s   zTypeFace._loadBuiltInDatac                 C   s   g S )z=Info function, return list of the font files this depends on.r   ©r`   r   r   r   ÚgetFontFiles˜   s   zTypeFace.getFontFilesú.pfbc                 C   sè   |  ¡ | ¡ f}t| dƒr'tj | j¡d }|D ]}t|| ƒr&||   S qzt 	| j
¡}W n5   t| j
ƒ}|rb|  ¡ dkrY|D ]}tj |¡d | }t|ƒrU|}qBd }qBn|  ¡ dkra|}nd }Y |d u rrtd|| j
f ƒ |S )NÚpfbFileNamer   ri   z.afmzCan't find %s for face '%s')r(   ÚupperÚhasattrÚosÚpathÚsplitextrj   r   r   Ú
findT1FilerJ   ÚbruteForceSearchForAFMr   )r`   ÚextÚpossible_extsÚ
r_basenameÚer   ÚafmÚpfbr   r   r   rp   œ   s6   
ÿ
û€€zTypeFace.findT1FileN)ri   )r   r   r   ra   r^   rh   rp   r   r   r   r   rO   u   s
    rO   c                 C   sb   |d u r
ddl m} t| ƒr| S tj | ¡}|D ]}t|ƒsqtj ||¡}t|ƒr.|  S q| S )Nr   ©r   )Úreportlab.rl_configr   r   rm   rn   Úbasenamer   Újoin)ÚfnÚ
searchPathÚbfnÚdirnameÚtfnr   r   r   ÚbruteForceSearchForFile·   s   
r�   c           
   
   C   sž   ddl m} |D ]D}t|ƒsqt|tj d ƒ}|D ]1}zt|ƒ\}}|d | kr0|W     S W q   t ¡ \}}}	d 	t
t|jƒ¡d|   f|_‚ qdS )zcLooks in all AFM files on path for face with given name.

    Returns AFM file name or None.  Ouch!r   rx   z*.[aA][fF][mM]ÚFontNamer7   z, while looking for faceName=%rN)ry   r   r   r   rm   ÚseprN   ÚsysÚexc_infor{   Úmaprb   Úargs)
ÚfaceNamer   r   Ú	possiblesÚpossibleÚtopDictÚ	glyphDictÚtÚvÚbr   r   r   rq   Á   s    
ÿøýrq   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 r|d u sJ dƒ‚|| _tj| | _d S |d kr,t| _tjt | _d S t|ƒrBt	|ƒ}|j | _|jd d … | _d S t
|ƒrRt| _|d d … | _d S t|tƒre|j | _|jd d … | _d S d S )Nr   z2Can't have a base encoding for a standard encoding)rJ   ÚfrozenÚstandardEncodingsÚbaseEncodingNamer   Ú	encodingsÚvectorr   r   ÚgetEncodingr
   Ú
isinstancer�   )r`   rJ   ÚbaseÚbaseEncr   r   r   ra   Û   s(   
ýzEncoding.__init__c                 C   s
   | j | S )z.Return glyph name for that code point, or None)r•   )r`   Úindexr   r   r   Ú__getitem__ò   s   
zEncoding.__getitem__c                 C   sD   | j dks	J dƒ‚| j| |kr t| jƒ}|||< t|ƒ| _d S d S )Nr   úCannot modify a frozen encoding)r‘   r•   rd   Útuple)r`   rš   ÚvalueÚLr   r   r   Ú__setitem__÷   s   
ýzEncoding.__setitem__c                 C   s   t | jƒ| _d| _d S ©Nr   )r�   r•   r‘   rg   r   r   r   Úfreezeÿ   s   
zEncoding.freezec                 C   s    | j |j kot| jƒt|jƒkS ©N)rJ   r�   r•   )r`   Ú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)r‘   r•   )r`   r˜   ÚnewNamesÚidxrJ   r   r   r   ÚmodifyRange  s   

þzEncoding.modifyRangec                 C   sv   g }d}t t| jƒƒD ]&}| j| }||j| kr#|r"| |¡ g }q|r+| |¡ q|r1||g}q|r9| |¡ |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)Úranger8   r•   r=   )r`   ÚotherEncÚrangesÚcurRangeÚiÚ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| ¡ q0q!| |¡|d< |dv rQ| |¡|d< | d	¡|d
< | |¡}	|	S )z&Returns a PDF Object representing selfr   ©Úpdfdocr   Nú/ÚDifferences)ÚMacRomanEncodingÚMacExpertEncodingÚWinAnsiEncodingÚBaseEncodingr�   ÚType)	Úreportlab.pdfbaser±   r“   r–   r¯   ÚPDFNamer=   ÚPDFArrayÚPDFDictionary)
r`   r±   ÚDr“   r™   ÚdifferencesÚ	diffArrayr©   Ú	glyphNameÚPDr   r   r   ÚmakePDFObject,  s*   

€ý
zEncoding.makePDFObjectr£   )r   r   r   Ú__doc__ra   r›   r    r¢   r¥   r¨   r¯   rÂ   r   r   r   r   r�   Ù   s    
r�   c                   @   sP   e Zd 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   FNc                 C   sf   || _ t|ƒ }| _t|ƒ| _|| _|jr|jd u rtn|pg | _	|  
¡  t| _|dkr.| p/t| _d S )NrP   )ÚfontNameÚgetTypeFaceÚfacer–   ÚencodingÚencNamer]   r[   ÚstandardT1SubstitutionFontsÚsubstitutionFontsÚ_calcWidthsÚ_notdefCharÚ_notdefFont)r`   rJ   rˆ   rÉ   rË   rÇ   r   r   r   ra   ^  s   
ÿÿþzFont.__init__Úutf8c                 C   s   t | |||d�S )N©rÈ   )r   )r`   ÚtextÚsizerÈ   r   r   r   ÚstringWidthj  s   zFont.stringWidthc                 C   s   d| j j| jjf S )Nz<%s %s>)Ú	__class__r   rÇ   rJ   rg   r   r   r   Ú__repr__m  s   zFont.__repr__c              	   C   s’   dgd }| j j}| jj}tdƒD ]2}|| }|durCz
|| }|||< W q tyB   ddl}|jjr?t	d| j j
|f ƒ n	 Y qw q|| _dS )z)Vector of widths for stringWidth functionr   é   Nz3typeface "%s" does not have a glyph "%s", bad font!)rÇ   rU   rÈ   r•   r©   ÚKeyErrorry   Ú	rl_configÚwarnOnMissingFontGlyphsÚprintrJ   Úwidths)r`   ÚwÚgwÚvecr­   rÀ   rI   Ú	reportlabr   r   r   rÌ   p  s$   
€ûü

zFont._calcWidthsc                 C   sV   d}t 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©   Úbytesrb   rÛ   )r`   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|ƒr0|dv r3||_| jjtvrMd|_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â   Ú
BasicFontsr²   N)r¹   r±   Úreprr8   ÚfontMappingÚPDFType1FontÚNamerÇ   rJ   ÚBaseFontrÅ   Ú__Comment__rÈ   rÂ   r   r�   r\   Ú	FirstCharÚLastCharr»   rÛ   ÚWidthsÚ
addObjectsÚFontDescriptorÚ	ReferenceÚ
idToObjectÚdict)r`   Údocr±   ÚinternalNameÚpdfFontru   ÚrefÚfontDictr   r   r   rò   �  s$   

zFont.addObjectsr£   ©rÏ   )r   r   r   rÃ   Ú
_multiByteÚ_dynamicFontÚshapablera   rÓ   rÕ   rÌ   ræ   rò   r   r   r   r   rÄ   Q  s    

rÄ   é€   r   é   r0   c              
   C   sØ   t ||  ƒtkst || d  ƒ|kr(td|ttƒt|ƒ| ||  || d  f ƒ‚|tkr.d S | d } || d  d> || d  d> B || d  B d> ||  B }| d } | | t|ƒkrftd|| |t|ƒf ƒ‚| | | fS )Nr   zGBad pfb file'%s' expected chr(%d)chr(%d) at char %d, got chr(%d)chr(%d)r  r0   é   é   z1Bad pfb file'%s' needed %d+%d bytes have only %d!)ÚchrÚ
PFB_MARKERr:   ÚordÚPFB_EOFr8   )ÚpÚdÚmr|   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£   )rO   ra   r	   r   rm   rn   Úabspathr>   rj   r[   Ú_loadGlyphsÚ_loadMetrics)r`   r>   rj   r   r   r   ra   Æ  s   


zEmbeddedType1Face.__init__c                 C   s   | j | jgS r£   )r>   rj   rg   r   r   r   rh   Ó  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 foundr�   r   N)r�   r   r   r  Ú	PFB_ASCIIÚ
PFB_BINARYr  Ú_binaryDatar8   Ú_lengthÚ_length1Ú_length2Ú_length3)	r`   rj   r	  Ús1Úl1Ús2Úl2Ú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|ƒ¡ qOi }|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ƒ‚dgd }i }i }|D ]'\}}	}
d|  kr²dkrÊn q£|
||< t |
d¡}|durÊ|||< |||< q£t d| j ¡}tj |||¡ || _t||ƒ}t|ƒ dS dS )z Loads in and parses font metricsr‚   Ú
FamilyNameÚAscenderéè  Ú	Descenderr   Ú	CapHeightÚItalicAngleÚstemVÚXHeightÚFontBBox)r   r   r  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â   zrl-dynamic-%s-encoding) r�   rN   rJ   rX   ÚgetrV   rW   Ú	capHeightÚitalicAngler#  ÚxHeightr9   Úbboxr=   r;   rU   rd   re   rT   ÚsortÚ_postScriptNames2UnicodeÚreportlab.pdfbase._glyphlistr(  r:   r”   Únormalize_encodingr   Ú	RL_CodecsÚadd_dynamic_codecr[   r�   ÚregisterEncoding)r`   r>   r@   Ú	glyphDataÚstrBboxÚtokensÚtokrU   rH   rI   rJ   r(  ÚnamesÚexÚrexÚcodeÚurÉ   Úencr   r   r   r  è  sb   



ÿ
€
ã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°   ÚLength1ÚLength2ÚLength3z	fontFile:z/FontDescriptoré"   )r¸   ÚAscentr!  ÚDescentÚFlagsr%  r‚   r"  ÚStemVr$  ÚFontFilezfontDescriptor:)r¹   r±   Ú	PDFStreamr  Úcontentr  Ú
dictionaryr  r  rô   rj   r¼   rV   r*  rW   r»   r-  rº   rJ   r+  r#  r,  )r`   r÷   r±   ÚfontFileÚfontFileRefÚfontDescriptorÚfontDescriptorRefr   r   r   rò   %  s,   

õzEmbeddedType1Face.addObjectsN)	r   r   r   rÃ   ra   rh   r  r  rò   r   r   r   r   r  Â  s    =r  c                 C   s<   t | tƒsJ d|  ƒ‚| t| j< | jtvrt| jƒ d S d S )NzNot a TypeFace: %s)r—   rO   Ú
_typefacesrJ   r\   ÚregisterFontFamily)rÇ   r   r   r   ÚregisterTypeFaceC  s
   

ýrQ  c                 C   s`   t | tƒsJ d|  ƒ‚| jtv r%|  t| j ¡r|  ¡  d S td| j ƒ‚| t| j< |  ¡  d S )NzNot an Encoding: %sz>Encoding "%s" already registered with a different name vector!)r—   r�   rJ   Ú
_encodingsr¥   r¢   r   )r>  r   r   r   r4  K  s   

r4  c                 C   s€   ddl m} |s
| }|  ¡ } |s|p|p|}|s|}|s|}| | dd|¡ | | dd|¡ | | dd|¡ | | dd|¡ d S )Nr   )Úfontsr   )Úreportlab.librS  r(   Ú
addMapping)ÚfamilyÚnormalrY   rZ   Ú
boldItalicrS  r   r   r   rP  X  s   rP  c                 C   s€   | j }| jr0| jj}|tvr/|tv r't| }|js"td|| |f ƒ‚|t|< n|  t|< t|< n| t|< | jr>t| j ƒ dS dS )zGRegisters a font, including setting up info for accelerated stringWidthz+Attempt to register fonts %r %r for face %rN)	rÅ   rþ   rÇ   rJ   Ú_fontsÚ_dynFaceNamesr:   rý   rP  )ÚfontrÅ   rˆ   Úofontr   r   r   ÚregisterFontd  s   
€ür]  c                 C   s¶   zt |  W S  tyZ   | tv r't| ƒ}tj|  \|_|_|_t	|ƒ | Y S t
| ƒ}|rYdD ]}tj |¡d | }t|ƒrA nq/t|ƒsLJ d| ƒ‚t||ƒ}t	|ƒ | Y S ‚ w )z-Lazily construct known typefaces if not found)ri   z.PFBr   zfile %s not found!)rO  r×   r\   rO   r   ÚstandardFontAttributesrX   rY   rZ   rQ  rq   rm   rn   ro   r   r  )rˆ   rÇ   rv   ru   rw   r   r   r   rÆ   |  s&   

ërÆ   c                 C   s<   zt |  W S  ty   | tv rt| ƒ}t|ƒ | Y S ‚ w )z-Lazily construct known encodings if not found)rR  r×   r’   r�   r4  )rÉ   r>  r   r   r   r–   —  s   
ùr–   c                 C   sZ   t | ƒ} t| ƒt u sJ dt| ƒ ƒ‚t| ƒ}|jr!t| | |jƒ}nt| | tƒ}t|ƒ |S )z-search for and register a font given its namez$fontName=%s is not required type str)rb   ÚtypeÚasciirÆ   r[   rÄ   r   r]  )rÅ   rÇ   r[  r   r   r   ÚfindFontAndRegister¤  s   ra  c                 C   s&   zt |  W S  ty   t| ƒ Y S w )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.)rY  r×   ra  )rÅ   r   r   r   ÚgetFont²  s
   
ÿrb  rP   rR   c                 C   sV   t | ƒ}z|j}|j}W n   |jj}|jj}Y |r'|d }|| || fS ||fS )Ng     @�@)rb  rV   rW   rÇ   )rÅ   ÚfontSizer[  rV   rW   Únormr   r   r   ÚgetAscentDescentÁ  s   

re  c                 C   ó   t | |ƒd S )Nr   ©re  ©rÅ   rc  r   r   r   Ú	getAscentÏ  ó   ri  c                 C   rf  r¡   rg  rh  r   r   r   Ú
getDescentÒ  rj  rk  c                  C   s   t t ¡ ƒ} |  ¡  | S )zReturns what's in there)rd   rY  re   r.  )Úregr   r   r   ÚgetRegisteredFontNamesÕ  s   rm  rÏ   c                 C   s   t |ƒj| ||d�S )zjCompute width of string in points;
    not accelerated as fast enough because of instanceStringWidthT1/TTFrÐ   )rb  rÓ   )rÑ   rÅ   rc  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|ƒ q+t ƒ  t dƒ tt ¡ ƒ}| ¡  |D ]}t| }t d|j|jj	|j
j	f ƒ qFd S )NzRegistered Encodings:z   zRegistered Typefaces:zRegistered Fonts:z    %s (%s/%s))rÚ   rd   rR  re   r.  rO  rY  rÅ   rÇ   rJ   rÈ   )re   rÉ   Úfacesrˆ   ÚkÚkeyr[  r   r   r   ÚdumpFontDataà  s&   þrq  c           
      C   s°   dd l }tdd… D ]K}|  ¡ }t|ƒj}| D ]}d}|D ]
}||t|ƒ  }qq|  ¡ }td||  ƒ |  ¡ }| D ]
}t|ƒ |d¡}	q;|  ¡ }td||  ƒ tƒ  q
d S )Nr   r   zslow stringWidth took %0.4fé
   z'class lookup and stringWidth took %0.4f)Útimer\   rb  rÛ   r  rÚ   rÓ   )
Útextsrs  rÅ   Út0rÜ   rÑ   r  ÚchÚt1r  r   r   r   Útest3widths÷  s$   
ÿërx  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Ú   r8   rx  r9   )Ú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   é   ÚWombat)rO   rQ  rÚ   rT   rq  )ÚhelvÚwombatr   r   r   Útest  s   

rƒ  )rO  rR  rY  rZ  c                 C   s<   |   ¡ D ]\}}tƒ | }| ¡  | |¡ qtj ¡  d S r£   )ÚitemsÚglobalsÚclearÚupdater   r2  Úreset_dynamic_codecs)Úinitial_dictsro  rŽ   r	  r   r   r   Ú_reset(  s
   
rŠ  )Úregister_resetÚ__main__r£   )NNNNrü   )LÚ__version__rÃ   rm   r„   r”   r¹   r   Úreportlab.lib.loggerr   Úreportlab.lib.utilsr   r   r   r   r   r	   r
   r   ry   r   r   Úreportlab.lib.rl_accelr   r   r   rÍ   r2  Úregisterr\   r’   rO  rR  rY  rZ  Ú	Exceptionr   r   rN   rO   r�   rq   r�   rÊ   rÄ   r  r  r  r  r  r  r/  r  rQ  r4  rP  r]  rÆ   r–   ra  rb  rÎ   Úextendre  ri  rk  rm  rÓ   rq  rx  r}  rƒ  rö   ÚcopyrŠ  r‹  r   r   r   r   r   Ú<module>   s†   (
I
B
w` 




ü
ÿ

þ