o
    Ë53S#  ã                   @   sF   d Z ddlmZ ddlmZ ddlmZ dd„ Zedkr!eƒ  dS dS )	uq  
This is a utility to 'can' the widths data for certain CID fonts.
Now we're using Unicode, we don't need 20 CMAP files for each Asian
language, nor the widths of the non-normal characters encoded in each
font.  we just want a dictionary of the character widths in a given
font which are NOT 1000 ems wide, keyed on Unicode character (not CID).

Running off CMAP files we get the following widths...::

    >>> font = UnicodeCIDFont('HeiseiMin-W3')
    >>> font.stringWidth(unicode(','), 10)
    2.5
    >>> font.stringWidth(unicode('m'), 10)
    7.7800000000000002
    >>> font.stringWidth(u'æ�±äº¬', 10)
    20.0
    >>> 

é    )Úpprint)ÚdefaultUnicodeEncodings)ÚUnicodeCIDFontc                  C   sÔ   g } |   d¡ t ¡ D ]I\}\}}td|||f ƒ t|ƒ}|jj}|jj}i }| ¡ D ]\}}	| 	|	d¡}
|
dkr@|
|t
|ƒ< q,tdt|ƒ ƒ |   d|t|ƒf ¡ qd | ¡d }tddƒ |¡ td	ƒ d S )
NzwidthsByUnichar = {}zhandling %s : %s : %siè  z$created font width map (%d items).  zwidthsByUnichar["%s"] = %sÚ
zcanned_widths.pyÚwzwrote canned_widths.py)Úappendr   ÚitemsÚprintr   ÚfaceÚ_explicitWidthsÚencodingÚ_cmapÚgetÚchrÚlenÚreprÚjoinÚopenÚwrite)ÚbufÚfontNameÚlanguageÚencNameÚfontÚwidthsByCIDÚcmapÚnonStandardWidthsByUnicharÚ	codePointÚcidÚwidthÚsrc© r!   úR/var/www/html/env/lib/python3.10/site-packages/reportlab/pdfbase/_can_cmap_data.pyÚrun   s$   
€r#   Ú__main__N)	Ú__doc__r   ÚppÚreportlab.pdfbase._cidfontdatar   Úreportlab.pdfbase.cidfontsr   r#   Ú__name__r!   r!   r!   r"   Ú<module>   s   
ÿ