a
    MˆcNm ã                (   @   sL  d Z ddlmZ ddlmZ ddlmZmZ ddlmZm	Z	m
Z
mZmZmZ ddlmZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlZddlZddlZejd Ze e¡ZdZdZ G dd„ de!ƒZ"G dd„ dej#ƒZ$G dd„ de%ƒZ&G dd„ de%ƒZ'dd„ Z(G dd„ de%ƒZ)G dd„ de)ƒZ*G dd„ de)ƒZ+G dd „ d e)ƒZ,G d!d"„ d"e)ƒZ-G d#d$„ d$e-ƒZ.G d%d&„ d&e-ƒZ/G d'd(„ d(e%ƒZ0G d)d*„ d*e0ƒZ1G d+d,„ d,e1ƒZ2G d-d.„ d.e0ƒZ3G d/d0„ d0e0ƒZ4G d1d2„ d2e%ƒZ5G d3d4„ d4e%ƒZ6G d5d6„ d6e%ƒZ7d7d8„ Z8d9d:„ Z9d;d<„ Z:d=d>„ Z;d?d@„ Z<dAdB„ Z=dCdD„ Z>dEdF„ Z?dGdH„ Z@dIdJ„ ZAdKdL„ ZBdMdN„ ZCdOdP„ ZDdQdR„ ZEG dSdT„ dTe%ƒZFG dUdV„ dVeFƒZGG dWdX„ dXeFƒZHdYdZ„ ZId[d\„ ZJG d]d^„ d^eFƒZKG d_d`„ d`eFƒZLG dadb„ dbeFƒZMG dcdd„ ddeMƒZNG dedf„ dfeMƒZOG dgdh„ dheMƒZPG didj„ djeFƒZQG dkdl„ dle%ƒZRdmdn„ ZSdodp„ ZTdqdr„ ZUdsdt„ ZVdudv„ ZWdwdx„ ZXdydz„ ZYG d{d|„ d|e%ƒZZG d}d~„ d~eFƒZ[dd€„ Z\d�d‚„ Z]dƒd„„ Z^d…d†„ Z_G d‡dˆ„ dˆeMƒZ`G d‰dŠ„ dŠeFƒZaG d‹dŒ„ dŒeFƒZbd�dŽ„ Zcd�d�„ Zdd‘d’„ ZeG d“d”„ d”e%ƒZfG d•d–„ d–e%ƒZgG d—d˜„ d˜eFƒZhd™dšd›dœdehƒ fd�džddŸd deHƒ fd¡d¢d deHƒ fd£d¤d¥d¦d§d¨d©dªd«d¬d­d®d¯g d°¢dfd±d²d³d¯g d´¢dfdµd¶d·d¸d¹dºd»d¼d½d¾d¿dÀdeQƒ fdÁdÂdÃdÀde[ƒ fdÄdÅdÆdeNƒ fdÇd4dÀdeaƒ fdÈdÉdÀde`ƒ fdÊd6dÀdePƒ fdËdÌdÀdebƒ fg$Zid™d­d®d¯g d°¢dfdÇd4dÀdeaƒ fdÈdÉdÀde`ƒ fdÊd6dÀdePƒ fdËdÌdÀdebƒ fgZjdÍZkdÎZldÏelekdÐddfdÑdÒdÓdÔdÕdÖd×dØdÙdÚdÛdÜdÝdÞdßdàdádâdãdädådÀdeOƒ fgZmdÏelekdÐddfdÑdÒdÓdÔdÕdÖd×dØdÙdÚdÛdßdàdädådÀdeOƒ fgZndædç„ Zoeoemƒ eoeiƒ G dèdé„ déejpƒZqG dêdë„ dëejpƒZrG dìdí„ díe%ƒZsdîdï„ ZtG dðdñ„ dñesƒZuG dòdó„ dóesƒZvG dôdõ„ dõesƒZwG död÷„ d÷e%ƒZxG dødù„ dùexƒZyG dúdû„ dûexƒZzG düdý„ dýexƒZ{G dþdÿ„ dÿe%ƒZ|g �d ¢Z}�dZ~ee}ƒe~k�sÂJ ‚i Z€e�e~ƒD ]Z‚e‚e€e}e‚ < �qÎg �d¢Zƒ�dZ„eeƒƒe„k�sJ ‚g �d¢Z…�dZ†ee…ƒe†k�s&J ‚g �d¢Z‡�dZˆee‡ƒeˆk�sHJ ‚dS (  a+  cffLib: read/write Adobe CFF fonts

OpenType fonts with PostScript outlines contain a completely independent
font file, Adobe's *Compact Font Format*. So dealing with OpenType fonts
requires also dealing with CFF. This module allows you to read and write
fonts written in the CFF format.

In 2016, OpenType 1.8 introduced the `CFF2 <https://docs.microsoft.com/en-us/typography/opentype/spec/cff2>`_
format which, along with other changes, extended the CFF format to deal with
the demands of variable fonts. This module parses both original CFF and CFF2.

é    )Ússtruct)ÚpsCharStrings)Ú	unionRectÚintRect)ÚbytechrÚbyteordÚ	bytesjoinÚtobytesÚtostrÚsafeEval)ÚTTFont)ÚOTTableWriter)ÚOTTableReader)ÚotTables)ÚBytesIONé   z%
	major:   B
	minor:   B
	hdrSize: B
i  c                   @   s   e Zd ZdS )ÚStopHintCountEventN)Ú__name__Ú
__module__Ú__qualname__© r   r   ú\/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/fontTools/cffLib/__init__.pyr   )   s   r   c                   @   sJ   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S )Ú_DesubroutinizingT2Decompiler)Úop_hintmaskZop_cntrmaskZ
op_rmovetoZ
op_hmovetoZ
op_vmovetoNc                 C   s   t j | |||¡ d S ©N)r   ÚSimpleT2DecompilerÚ__init__)ÚselfÚ
localSubrsÚglobalSubrsÚprivater   r   r   r   1   s    ÿz&_DesubroutinizingT2Decompiler.__init__c                 C   sf  d| _ | jD ]}t| || jƒ qt|dƒrh| j rd| jrdztj | |¡ W n t	yb   | jd= Y n0 d S g |_
tj | |¡ |jd d … }t|j
ƒD ]t\}}|dks¨J ‚||d  dv sÈJ ||d  ƒ‚t||d  ƒtksàJ ‚|d dkrø|d d… }|||d |…< q”| jj�sXd|v �r6|d | d¡d … }n"t|ƒ�rN|d dk�rX| d¡ ||_|`
d S )	NTÚ_desubroutinizedéÿÿÿÿé   r   )ZcallsubrZ	callgsubrÚreturnÚendchar)Úneed_hintcountÚstop_hintcount_opsÚsetattrÚstop_hint_countÚhasattrÚcallingStackr   r   Úexecuter   Ú_patchesÚprogramÚreversedÚtypeÚintr    Úin_cff2ÚindexÚlenÚappendr!   )r   Ú
charStringÚop_nameZdesubroutinizedÚidxZ	expansionr   r   r   r,   5   s6    

 


z%_DesubroutinizingT2Decompiler.executec                 C   s4   | j | jd | j  }tj | |¡ |  ||¡ d S ©Nr"   )r   ÚoperandStackZ	localBiasr   r   Úop_callsubrÚprocessSubr©r   r3   Úsubrr   r   r   r;   [   s    z)_DesubroutinizingT2Decompiler.op_callsubrc                 C   s4   | j | jd | j  }tj | |¡ |  ||¡ d S r9   )r   r:   Z
globalBiasr   r   Úop_callgsubrr<   r=   r   r   r   r?   `   s    z*_DesubroutinizingT2Decompiler.op_callgsubrc                 G   s<   d| _ | jD ]}t| |d ƒ q| jd }t|dƒr8tƒ ‚d S )NFr"   r!   )r&   r'   r(   r+   r*   r   )r   Úargsr7   Úcsr   r   r   r)   e   s    


z-_DesubroutinizingT2Decompiler.stop_hint_countc                 C   s    t j | |¡ | jr|  ¡  d S r   )r   r   r   r&   r)   ©r   r3   r   r   r   r   m   s    z)_DesubroutinizingT2Decompiler.op_hintmaskc                 C   s*   | j d }t|dƒs&|j ||jf¡ d S )Nr"   r!   )r+   r*   r-   r5   r!   )r   r3   r>   rA   r   r   r   r<   r   s    

z)_DesubroutinizingT2Decompiler.processSubr)N)r   r   r   r'   r   r,   r;   r?   r)   r   r<   r   r   r   r   r   -   s   
&r   c                   @   sf   e Zd ZdZddd„Zdd„ Zdd„ Zd	d
„ Zdd„ Zddd„Z	dd„ Z
ddd„Zdd„ Zdd„ ZdS )Ú
CFFFontSeta  A CFF font "file" can contain more than one font, although this is
	extremely rare (and not allowed within OpenType fonts).

	This class is the entry point for parsing a CFF table. To actually
	manipulate the data inside the CFF font, you will want to access the
	``CFFFontSet``'s :class:`TopDict` object. To do this, a ``CFFFontSet``
	object can either be treated as a dictionary (with appropriate
	``keys()`` and ``values()`` methods) mapping font names to :class:`TopDict`
	objects, or as a list.

	.. code:: python

		from fontTools import ttLib
		tt = ttLib.TTFont("Tests/cffLib/data/LinLibertine_RBI.otf")
		tt["CFF "].cff
		# <fontTools.cffLib.CFFFontSet object at 0x101e24c90>
		tt["CFF "].cff[0] # Here's your actual font data
		# <fontTools.cffLib.TopDict object at 0x1020f1fd0>
	
	Nc                 C   s8  || _ t t| d¡| ¡ |durL|r*dnd}| j|krhtd|| jf ƒ‚n| jdv s^J dƒ‚| jdk}|sÆt d| d¡¡d	 | _| 	| j
¡ td
d„ t||d�D ƒƒ| _t||d�| _t|ƒ| _nLt d| d¡¡d	 | _| 	| j
¡ dg| _|j}t||| j|d�| _d| _t||d�| _| j| j_| j| j_dS )ag  Parse a binary CFF file into an internal representation. ``file``
		should be a file handle object. ``otFont`` is the top-level
		:py:class:`fontTools.ttLib.ttFont.TTFont` object containing this CFF file.

		If ``isCFF2`` is passed and set to ``True`` or ``False``, then the
		library makes an assertion that the CFF header is of the appropriate
		version.
		é   Nr#   r   ú2Invalid CFF 'major' version: expected %d, found %d©r   r#   úUnknown CFF formatÚBr   c                 s   s   | ]}t |ƒV  qd S r   ©r
   ©Ú.0Úsr   r   r   Ú	<genexpr>©   ó    z'CFFFontSet.decompile.<locals>.<genexpr>©ÚisCFF2ú>HÚCFF2Font)ÚotFontr   ÚunpackÚcffHeaderFormatÚreadÚmajorÚ
ValueErrorÚstructÚoffSizeÚseekÚhdrSizeÚlistÚIndexÚ	fontNamesÚTopDictIndexÚtopDictIndexÚIndexedStringsÚstringsÚtopDictSizeÚgetGlyphOrderÚGlobalSubrsIndexÚGlobalSubrs)r   ÚfilerS   rP   Úexpected_majorÚcff2GetGlyphOrderr   r   r   Ú	decompileŽ   s:    

ÿÿ

ÿ
zCFFFontSet.decompilec                 C   s
   t | jƒS r   )r4   r_   ©r   r   r   r   Ú__len__¹   s    zCFFFontSet.__len__c                 C   s
   t | jƒS r   )r]   r_   rl   r   r   r   Úkeys¼   s    zCFFFontSet.keysc                 C   s   | j S r   )ra   rl   r   r   r   Úvalues¿   s    zCFFFontSet.valuesc                 C   sb   t |dƒr| ¡ }nDt|tƒrP|}z| j |¡}W qX tyL   t|ƒ‚Y qX0 nt|ƒ‚| j	| S )zp Return TopDict instance identified by name (str) or index (int
		or any object that implements `__index__`).
		Ú	__index__)
r*   rp   Ú
isinstanceÚstrr_   r3   rX   ÚKeyErrorÚ	TypeErrorra   )r   ZnameOrIndexr3   Únamer   r   r   Ú__getitem__Â   s    


zCFFFontSet.__getitem__c                 C   sÜ  || _ |dur8|rdnd}| j|krTtd|| jf ƒ‚n| jdv sJJ dƒ‚| jdk}|jrr|sr| jD ]}| ¡  qd|s~tƒ }nd}t|ƒ}| jj|| |d�}|rØd| _	| 
t t| ¡¡ | ¡ | _| 
t d	| j¡¡ n2d
| _	d
| _| 
t t| ¡¡ | 
t d| j¡¡ |�sDtƒ }	| jD ]}
|	 |
¡ �q| 
|	j|| |d�¡ | 
|¡ |�sb| 
| ¡ ¡ | 
| jj|| |d�¡ | jD ],}t|dƒ�rœ|jdu �r€| ¡ }||_�q€| |¡}|D ]}| 
|¡ �q¼| |¡ dS )at  Write the object back into binary representation onto the given file.
		``file`` should be a file handle object. ``otFont`` is the top-level
		:py:class:`fontTools.ttLib.ttFont.TTFont` object containing this CFF file.

		If ``isCFF2`` is passed and set to ``True`` or ``False``, then the
		library makes an assertion that the CFF header is of the appropriate
		version.
		Nr#   r   rE   rF   rG   rO   é   rQ   é   rH   Úcharset)rS   rW   rX   ZrecalcBBoxesra   ÚrecalcFontBBoxrb   Ú	CFFWriterÚgetCompilerr\   Úaddr   ÚpackrU   ÚgetDataLengthrd   rY   rZ   r^   r_   r5   rg   r*   ry   re   ÚgetChildrenÚtoFile)r   rh   rS   rP   ri   ÚtopDictrc   ÚwriterZtopCompilerr_   ru   ry   ÚchildrenÚchildr   r   r   ÚcompileÒ   sZ    	
ÿÿ









zCFFFontSet.compilec                 C   s¶   |j d| jd� | ¡  |j d| jd� | ¡  | jD ]B}|jdt|ƒd� | ¡  | | }| |¡ | d¡ | ¡  q6| ¡  | d¡ | ¡  | j	 |¡ | d¡ | ¡  dS )zËWrite the object into XML representation onto the given
		:class:`fontTools.misc.xmlWriter.XMLWriter`.

		.. code:: python

			writer = xmlWriter.XMLWriter(sys.stdout)
			tt["CFF "].cff.toXML(writer)

		rW   ©ÚvalueÚminorÚCFFFont©ru   rg   N)
Ú	simpletagrW   Únewliner‰   r_   Úbegintagr
   ÚtoXMLÚendtagrg   )r   Ú	xmlWriterÚfontNameÚfontr   r   r   r�     s"    





zCFFFontSet.toXMLc                 C   s8  || _ t| dƒsd| _t| dƒs&d| _|dk�r–| jdkr¬t| dƒsJd| _t| dƒsZd| _t| d	ƒsltƒ | _t| d
ƒs„g | _t	ƒ | _
|d }| j |¡ t| jd�}d|_nb| jdk�rt| dƒsÈd| _t| d	ƒsÚtƒ | _t| d
ƒsìdg| _| j j}t| j|d�}t	d|ƒ| _
| j
 |¡ |D ].}t|tƒ�r2�q|\}}}| |||¡ �qt|dƒ�r4|jd jdu �r4|j}	|	D ]}
t|
dƒ�rv|j|
j_�qvnž|d	k�rtj}t| d	ƒ�sºtƒ | _|D ]@}t|tƒ�rÒ�q¾|\}}}|ƒ }| |||¡ | j |¡ �q¾n2|dk�rt|d ƒ| _n|dk�r4t|d ƒ| _dS )z?Reads data from the XML element into the ``CFFFontSet`` object.rW   r   r‰   r   rŠ   rZ   rx   r\   rg   r_   ru   )rg   Nr#   rw   rR   )rg   rj   ÚVarStoreÚPrivaterˆ   )rS   r*   rW   r‰   rZ   r\   rf   rg   r_   r`   ra   r5   ÚTopDictry   re   rq   rr   ÚfromXMLÚFDArrayÚvstorer”   r•   r   ÚT2CharStringr1   )r   ru   ÚattrsÚcontentrS   r’   r‚   rj   ÚelementÚfdArrayÚfontDictZsubrCharStringClassr>   r   r   r   r—   .  sv    










þ




zCFFFontSet.fromXMLc                 C   s8  d| _ | jj}td|ƒ}| jj|_|| _|d }t|dƒrB|j}nd}tt	ƒ}||_
||_tD ]:}|d }||vr^||jv r„|j|= t||ƒr^t||ƒ q^t|dƒ�sVtƒ  }	|_d|	_|j|	_|	|j_|j}
|
jrÞ|	|
j_n|	|
_tƒ }| d¡ |	 |¡ ||_ttƒ}tD ]B}|d }||v�r||jv �r:|j|= t||ƒ�rt||ƒ �qn®|j}	ttƒ}|	D ]š}| d¡ |j ¡ D ]0}||j
v�r€|j|= t||ƒ�r€t||ƒ �q€|j}tD ]B}|d }||v�r¼||jv �ræ|j|= t||ƒ�r¼t||ƒ �q¼�qhtƒ }| j||dd� | d¡ | j ||dd� dS )	zåConverts this object from CFF format to CFF2 format. This conversion
		is done 'in-place'. The conversion cannot be reversed.

		This assumes a decompiled CFF table. (i.e. that the object has been
		filled via :meth:`decompile`.)r#   Nr   r•   r   r˜   TrO   )!rW   rS   re   r`   ra   Úitemsr*   r•   Ú
buildOrderÚtopDictOperators2Úorderrj   ÚtopDictOperatorsÚrawDictÚdelattrÚFDArrayIndexr˜   rc   rg   rž   ÚCharStringsÚcharStringsAreIndexedÚcharStringsIndexÚFontDictÚsetCFF2r5   ÚprivateDictOperators2ÚprivateDictOperatorsrn   r   r†   r[   rk   )r   rS   rj   ZtopDictDatar‚   ZprivateDictZopOrderÚentryÚkeyrž   ÚcharStringsrŸ   ZprivateOpOrderrh   r   r   r   ÚconvertCFFToCFF2r  sz    











zCFFFontSet.convertCFFToCFF2c                 C   sâ   | j D ]Ì}| | }|j}|jD ]N}| |¡\}}| ¡  t|jdg ƒ}t||j|jƒ}| 	|¡ |j
|_|`
qt|dƒr¬|jD ]*}	|	j}
t|
dƒr–|
`d|
jv r~|
jd= q~q|j}
t|
dƒrÀ|
`d|
jv r|
jd= q| j ¡  d S )NÚSubrsr˜   )r_   r¨   ry   ÚgetItemAndSelectorrk   Úgetattrr    r   r   r,   r!   r.   r*   r˜   r•   r³   r¥   rg   Úclear)r   r’   r“   rA   ÚgÚcÚ_ZsubrsZ
decompilerÚfdÚpdr   r   r   ÚdesubroutinizeÂ  s0    









zCFFFontSet.desubroutinize)N)N)N)r   r   r   Ú__doc__rk   rm   rn   ro   rv   r†   r�   r—   r²   r¼   r   r   r   r   rC   x   s   
+
?
DPrC   c                   @   s(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	r{   zUHelper class for serializing CFF data to binary. Used by
	:meth:`CFFFontSet.compile`.c                 C   s   g | _ || _d S r   )ÚdatarP   ©r   rP   r   r   r   r   ã  s    zCFFWriter.__init__c                 C   s   | j  |¡ d S r   )r¾   r5   )r   Útabler   r   r   r}   ç  s    zCFFWriter.addc           	      C   sR  d }d}t   td|¡ |d }d}|g}| jD ]f}t|dƒrd|| ¡  }t|tƒrp|jrp| ¡ | _n|t	|ƒ }t|dƒr†| 
||¡ |}| |¡ q.||kr q¦|}qt   td¡ | ¡ }| jrÖt d| j¡| jd< n"t|d ƒ| _t d	| j¡| jd< dg}| jD ]:}t|d
ƒ�r | |¡ n
| |¡ | | ¡ | ¡ �q||k�sNJ ‚d S )Nr   z CFFWriter.toFile() iteration: %dr   r   ÚsetPosz#CFFWriter.toFile() writing to file.rQ   r"   rH   r�   )ÚlogÚDEBUGr¾   r*   r   rq   ÚTopDictIndexCompilerrP   rd   r4   rÁ   r5   ÚtellrY   r~   ÚcalcOffSizerZ   r�   Úwrite)	r   rh   ZlastPosListÚcountÚposZposListÚitemÚendPosÚbeginr   r   r   r�   ê  s@    




zCFFWriter.toFileN)r   r   r   r½   r   r}   r�   r   r   r   r   r{   à  s   r{   c                 C   s2   | dk rd}n | dk rd}n| dk r*d}nd}|S )Né   r   i   r#   i   rD   rx   r   )ZlargestOffsetrZ   r   r   r   rÆ     s    rÆ   c                   @   s:   e Zd ZdZddd„Zdd„ Zdd„ Zd	d
„ Zdd„ ZdS )ÚIndexCompilerz‚Base class for writing CFF `INDEX data <https://docs.microsoft.com/en-us/typography/opentype/spec/cff2#5-index-data>`_
	to binary.Nc                 C   sB   |d u r$t |dƒr$|j}|d us$J ‚|| _|  ||¡| _|| _d S ©NrP   )r*   rP   ÚgetItemsr    Úparent)r   r    rc   rÑ   rP   r   r   r   r   !  s    zIndexCompiler.__init__c                 C   s   |S r   r   ©r   r    rc   r   r   r   rÐ   )  s    zIndexCompiler.getItemsc                 C   sT   | j rLd}|g}| j D ]2}t|dƒr2|| ¡  }n|t|ƒ }| |¡ qng }|S )Nr   r   )r    r*   r   r4   r5   )r   rÉ   ÚoffsetsrÊ   r   r   r   Ú
getOffsets,  s    

zIndexCompiler.getOffsetsc                 C   sV   | j rd}nd}| jrN|  ¡ d }t|ƒ}|d t| jƒd |  | d }n|}|S )Nrx   r#   r"   r   )rP   r    rÔ   rÆ   r4   )r   Z	countSizeZ
lastOffsetrZ   Ú
dataLengthr   r   r   r   ;  s$    ÿþýýÿzIndexCompiler.getDataLengthc           	      C   sÌ   |   ¡ }| jr t|t| jƒƒ nt|t| jƒƒ | jrÈt|d ƒ}t||ƒ | }tj	}|D ]2}|d|ƒ|d … }t|ƒ| ks„J ‚| 
|¡ q\| jD ]0}t|dƒr°| |¡ q–t|dd�}| 
|¡ q–d S )Nr"   ú>lr�   Úlatin1©Úencoding)rÔ   rP   ÚwriteCard32r4   r    ÚwriteCard16rÆ   Ú
writeCard8rY   r~   rÇ   r*   r�   r	   )	r   rh   rÓ   rZ   r~   ÚoffsetÚ	binOffsetrÊ   r¾   r   r   r   r�   P  s$    


zIndexCompiler.toFile)N)	r   r   r   r½   r   rÐ   rÔ   r   r�   r   r   r   r   rÎ     s   
rÎ   c                   @   s   e Zd Zdd„ ZdS )ÚIndexedStringsCompilerc                 C   s   |j S r   ©rc   rÒ   r   r   r   rÐ   j  s    zIndexedStringsCompiler.getItemsN)r   r   r   rÐ   r   r   r   r   rß   h  s   rß   c                       sH   e Zd ZdZdd„ Zdd„ Z‡ fdd„Z‡ fdd	„Z‡ fd
d„Z‡  Z	S )rÄ   z/Helper class for writing the TopDict to binary.c                 C   s$   g }|D ]}|  | || ¡¡ q|S r   ©r5   r|   ©r   r    rc   ÚoutrÊ   r   r   r   rÐ   q  s    zTopDictIndexCompiler.getItemsc                 C   s$   g }| j D ]}| | |¡¡ q
|S r   ©r    Úextendr€   )r   rc   r„   r‚   r   r   r   r€   w  s    
z TopDictIndexCompiler.getChildrenc                    s.   | j rd| jd  ¡ g}|S tt| ƒ ¡ S d S ©Nr   )rP   r    r   ÚsuperrÄ   rÔ   )r   rÓ   ©Ú	__class__r   r   rÔ   }  s    zTopDictIndexCompiler.getOffsetsc                    s*   | j r| jd  ¡ }|S tt| ƒ ¡ S d S ræ   )rP   r    r   rç   rÄ   )r   rÕ   rè   r   r   r   „  s    z"TopDictIndexCompiler.getDataLengthc                    s,   | j r| jd  |¡ ntt| ƒ |¡ d S ræ   )rP   r    r�   rç   rÄ   ©r   rh   rè   r   r   r�   ‹  s    zTopDictIndexCompiler.toFile)
r   r   r   r½   rÐ   r€   rÔ   r   r�   Ú__classcell__r   r   rè   r   rÄ   n  s   rÄ   c                   @   s0   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
S )ÚFDArrayIndexCompilerz¨Helper class for writing the
	`Font DICT INDEX <https://docs.microsoft.com/en-us/typography/opentype/spec/cff2#10-font-dict-index-font-dicts-and-fdselect>`_
	to binary.c                 C   s$   g }|D ]}|  | || ¡¡ q|S r   rá   râ   r   r   r   rÐ   —  s    zFDArrayIndexCompiler.getItemsc                 C   s$   g }| j D ]}| | |¡¡ q
|S r   rä   )r   rc   r„   rŸ   r   r   r   r€   �  s    
z FDArrayIndexCompiler.getChildrenc                 C   sº   |   ¡ }| jr t|t| jƒƒ nt|t| jƒƒ t|d ƒ}t||ƒ | }tj	}|D ]2}|d|ƒ|d … }t|ƒ| ks~J ‚| 
|¡ qV| jD ]$}t|dƒrª| |¡ q�| 
|¡ q�d S )Nr"   rÖ   r�   )rÔ   rP   rÚ   r4   r    rÛ   rÆ   rÜ   rY   r~   rÇ   r*   r�   )r   rh   rÓ   rZ   r~   rÝ   rÞ   rÊ   r   r   r   r�   £  s     


zFDArrayIndexCompiler.toFilec                 C   s   || j jd< d S )Nr˜   ©rÑ   r¥   ©r   rÉ   rË   r   r   r   rÁ   ·  s    zFDArrayIndexCompiler.setPosN)r   r   r   r½   rÐ   r€   r�   rÁ   r   r   r   r   rì   ’  s
   rì   c                   @   s   e Zd ZdZdd„ ZdS )ÚGlobalSubrsCompilerz¤Helper class for writing the `global subroutine INDEX <https://docs.microsoft.com/en-us/typography/opentype/spec/cff2#9-local-and-global-subr-indexes>`_
	to binary.c                 C   s*   g }|D ]}|  | j¡ | |j¡ q|S r   ©r†   rP   r5   Úbytecode©r   r    rc   rã   rA   r   r   r   rÐ   ¿  s
    zGlobalSubrsCompiler.getItemsN)r   r   r   r½   rÐ   r   r   r   r   rï   »  s   rï   c                   @   s   e Zd ZdZdd„ ZdS )ÚSubrsCompilerz£Helper class for writing the `local subroutine INDEX <https://docs.microsoft.com/en-us/typography/opentype/spec/cff2#9-local-and-global-subr-indexes>`_
	to binary.c                 C   s   || j j }|| j jd< d S ©Nr³   )rÑ   rÉ   r¥   )r   rÉ   rË   rÝ   r   r   r   rÁ   Ë  s    zSubrsCompiler.setPosN)r   r   r   r½   rÁ   r   r   r   r   ró   Ç  s   ró   c                   @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚCharStringsCompilerzžHelper class for writing the `CharStrings INDEX <https://docs.microsoft.com/en-us/typography/opentype/spec/cff2#9-local-and-global-subr-indexes>`_
	to binary.c                 C   s*   g }|D ]}|  | j¡ | |j¡ q|S r   rð   rò   r   r   r   rÐ   Ó  s
    zCharStringsCompiler.getItemsc                 C   s   || j jd< d S ©Nr¨   rí   rî   r   r   r   rÁ   Ú  s    zCharStringsCompiler.setPosN)r   r   r   r½   rÐ   rÁ   r   r   r   r   rõ   Ð  s   rõ   c                   @   sX   e Zd ZdZeZddd„Zdd„ Zdd„ Zd	d
„ Z	dd„ Z
dd„ Zddd„Zdd„ ZdS )r^   z¡This class represents what the CFF spec calls an INDEX (an array of
	variable-sized objects). `Index` items can be addressed and set using
	Python list indexing.Nc                 C   s8  |d u |d u ksJ ‚g | _ | jj}|d u r.d S || _t td|| ¡ ¡ || _|r\t|ƒ}nt	|ƒ}|dkrpd S d g| | _ t
|ƒ}t td||¡ |dks¨J d| ƒ‚g  | _}dd|  }t|d ƒD ]2}| |¡}	||	 }	t d|	¡\}
| t|
ƒ¡ qÊ| ¡ d | _| | j|d	  ¡ t td
|| ¡ ¡ d S )Núloading %s at %sr   z    index count: %s offSize: %srx   zoffSize too large: %só    r   ú>Lr"   ú    end of %s at %s)r    ré   r   Ú_isCFF2rÂ   rÃ   rÅ   rh   Ú
readCard32Ú
readCard16Ú	readCard8rÓ   ÚrangerV   rY   rT   r5   r1   Ú
offsetBaser[   )r   rh   rP   ru   rÈ   rZ   rÓ   Úpadr3   ÚchunkrÝ   r   r   r   r   å  s6    


zIndex.__init__c                 C   s
   t | jƒS r   )r4   r    rl   r   r   r   rm     s    zIndex.__len__c                 C   s†   | j | }|d ur|S | j| | j }| j|d  | j|  }| j}| |¡ | |¡}t|ƒ|kshJ ‚|  ||||¡}|| j |< |S ©Nr   )r    rÓ   r   rh   r[   rV   r4   ÚproduceItem)r   r3   rÊ   rÝ   Úsizerh   r¾   r   r   r   rv     s    



zIndex.__getitem__c                 C   s   || j |< d S r   ©r    )r   r3   rÊ   r   r   r   Ú__setitem__  s    zIndex.__setitem__c                 C   s   |S r   r   )r   r3   r¾   rh   rÝ   r   r   r   r    s    zIndex.produceItemc                 C   s   | j  |¡ dS )zAdd an item to an INDEX.N)r    r5   )r   rÊ   r   r   r   r5     s    zIndex.appendc                 C   s   | j | |||d�S ©NrO   ©ÚcompilerClass©r   rc   rÑ   rP   r   r   r   r|     s    zIndex.getCompilerc                 C   s   | j dd…= dS )zEmpty the INDEX.Nr  rl   r   r   r   r¶   !  s    zIndex.clear)NN)N)r   r   r   r½   rÎ   r
  r   rm   rv   r  r  r5   r|   r¶   r   r   r   r   r^   Þ  s   

r^   c                       sR   e Zd ZdZeZejZejZ	d‡ fdd„	Z
dd„ Zdd„ Zd	d
„ Zdd„ Z‡  ZS )rf   aä  This index contains all the global subroutines in the font. A global
	subroutine is a set of ``CharString`` data which is accessible to any
	glyph in the font, and are used to store repeated instructions - for
	example, components may be encoded as global subroutines, but so could
	hinting instructions.

	Remember that when interpreting a ``callgsubr`` instruction (or indeed
	a ``callsubr`` instruction) that you will need to add the "subroutine
	number bias" to number given:

	.. code:: python

		tt = ttLib.TTFont("Almendra-Bold.otf")
		u = tt["CFF "].cff[0].CharStrings["udieresis"]
		u.decompile()

		u.toXML(XMLWriter(sys.stdout))
		# <some stuff>
		# -64 callgsubr <-- Subroutine which implements the dieresis mark
		# <other stuff>

		tt["CFF "].cff[0].GlobalSubrs[-64] # <-- WRONG
		# <T2CharString (bytecode) at 103451d10>

		tt["CFF "].cff[0].GlobalSubrs[-64 + 107] # <-- RIGHT
		# <T2CharString (source) at 103451390>

	("The bias applied depends on the number of subrs (gsubrs). If the number of
	subrs (gsubrs) is less than 1240, the bias is 107. Otherwise if it is less
	than 33900, it is 1131; otherwise it is 32768.",
	`Subroutine Operators <https://docs.microsoft.com/en-us/typography/opentype/otspec180/cff2charstr#section4.4>`)
	Nc                    s8   t t| ƒj||d� || _|| _|r*|| _|r4|| _d S r  )rç   rf   r   r   r    ÚfdSelectrž   )r   rh   r   r    r  rž   rP   rè   r   r   r   L  s    zGlobalSubrsIndex.__init__c                 C   sn   | j d ur| j }nJt| dƒrX| jd urXt| dƒrF| jd urF| j| }nd}| j| j}nd }| j||| jd�S )Nrž   r  r   ©r    r   )r    r*   rž   r  r•   Ú	subrClassr   )r   r3   r¾   rh   rÝ   r    ÚfdIndexr   r   r   r  V  s    
zGlobalSubrsIndex.produceItemc                 C   s|   |  d¡ | ¡  tt| ƒƒD ]X}| | }| ¡ rD|jd|dd� n|jd|d� | ¡  | |¡ | d¡ | ¡  qdS )zåWrite the subroutines index into XML representation onto the given
		:class:`fontTools.misc.xmlWriter.XMLWriter`.

		.. code:: python

			writer = xmlWriter.XMLWriter(sys.stdout)
			tt["CFF "].cff[0].GlobalSubrs.toXML(writer)

		zDThe 'index' attribute is only for humans; it is ignored when parsed.Ú
CharStringr   )r3   Úraw©r3   N)Úcommentr�   rÿ   r4   ÚneedsDecompilationrŽ   r�   r�   )r   r‘   Úir>   r   r   r   r�   c  s    
ÿ

zGlobalSubrsIndex.toXMLc                 C   s0   |dkrd S |   ¡ }| |||¡ |  |¡ d S )Nr  )r  r—   r5   )r   ru   r›   rœ   r>   r   r   r   r—   |  s
    zGlobalSubrsIndex.fromXMLc                 C   s$   d }t | dƒr| j| }| | |fS )Nr  )r*   r  )r   r3   Úselr   r   r   r´   ƒ  s    

z#GlobalSubrsIndex.getItemAndSelector)NNNNNN)r   r   r   r½   rï   r
  r   rš   r  ÚcharStringClassr   r  r�   r—   r´   rë   r   r   rè   r   rf   &  s   !  ÿ
rf   c                   @   s   e Zd ZdZeZdS )Ú
SubrsIndexz³This index contains a glyph's local subroutines. A local subroutine is a
	private set of ``CharString`` data which is accessible only to the glyph to
	which the index is attached.N)r   r   r   r½   ró   r
  r   r   r   r   r  Š  s   r  c                       s6   e Zd ZdZeZd
‡ fdd„	Zdd„ Zdd	„ Z‡  Z	S )r`   aS  This index represents the array of ``TopDict`` structures in the font
	(again, usually only one entry is present). Hence the following calls are
	equivalent:

	.. code:: python

		tt["CFF "].cff[0]
		# <fontTools.cffLib.TopDict object at 0x102ed6e50>
		tt["CFF "].cff.topDictIndex[0]
		# <fontTools.cffLib.TopDict object at 0x102ed6e50>

	Nr   c                    s¶   |d u |d u ksJ ‚|| _ |d urž|rž|| _g | _| jj}t td|| ¡ ¡ || _d}d g| | _d|g| _	| ¡ | _
| | j
| ¡ t td|| ¡ ¡ ntt| ƒj||d� d S )Nr÷   r   r   rú   rO   )rj   rû   r    ré   r   rÂ   rÃ   rÅ   rh   rÓ   r   r[   rç   r`   r   )r   rh   rj   ZtopSizerP   ru   rÈ   rè   r   r   r   ¢  s    

zTopDictIndex.__init__c                 C   s*   t | j||| j| j| jd�}| |¡ |S r  )r–   rc   rg   rj   rû   rk   )r   r3   r¾   rh   rÝ   Útopr   r   r   r  ¶  s    þ
zTopDictIndex.produceItemc                 C   sL   t t| ƒƒD ]:}|jd|d� | ¡  | |  |¡ | d¡ | ¡  qd S ©Nr«   r  ©rÿ   r4   rŽ   r�   r�   r�   ©r   r‘   r  r   r   r   r�   ½  s    
zTopDictIndex.toXML)NNr   N)
r   r   r   r½   rÄ   r
  r   r  r�   rë   r   r   rè   r   r`   ’  s     ÿr`   c                   @   s(   e Zd ZeZdd„ Zdd„ Zdd„ ZdS )r§   c                 C   sL   t t| ƒƒD ]:}|jd|d� | ¡  | |  |¡ | d¡ | ¡  qd S r  r  r  r   r   r   r�   Ê  s    
zFDArrayIndex.toXMLc                 C   s*   t | j||| j| j| jd�}| |¡ |S ©N)rP   r™   )r«   rc   rg   rû   r™   rk   )r   r3   r¾   rh   rÝ   rŸ   r   r   r   r  Ò  s    þ
zFDArrayIndex.produceItemc                 C   sN   |dkrd S t ƒ }|D ](}t|tƒr&q|\}}}| |||¡ q|  |¡ d S )Nr«   )r«   rq   rr   r—   r5   )r   ru   r›   rœ   rŸ   r�   r   r   r   r—   Ù  s    

zFDArrayIndex.fromXMLN)r   r   r   rì   r
  r�   r  r—   r   r   r   r   r§   Æ  s   r§   c                   @   sF   e 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S )ÚVarStoreDataNc                 C   s   || _ d | _|| _tƒ | _d S r   )rh   r¾   Ú
otVarStorer   r“   )r   rh   r  r   r   r   r   ç  s    zVarStoreData.__init__c                 C   sL   | j rHt| j ƒ}| j  |¡| _i }t| j|ƒ}t ¡ | _| j || j	¡ | S r   )
rh   rý   rV   r¾   r   Úotr”   r  rk   r“   )r   ÚlengthZglobalStateÚreaderr   r   r   rk   í  s    

zVarStoreData.decompilec                 C   s$   t ƒ }| j || j¡ | ¡ | _d S r   )r   r  r†   r“   Z
getAllDatar¾   )r   rƒ   r   r   r   r†   ø  s    zVarStoreData.compilec                 C   s   | j  || j¡ d S r   )r  r�   r“   )r   r‘   ru   r   r   r   ÚwriteXMLÿ  s    zVarStoreData.writeXMLc                 C   sB   t  ¡ | _|D ].}t|tƒr|\}}}| j |||| j¡ qqd S r   )r   r”   r  rq   Útupler—   r“   )r   ru   r›   rœ   rÑ   r�   r   r   r   ÚxmlRead  s    


zVarStoreData.xmlReadc                 C   s
   t | jƒS r   ©r4   r¾   rl   r   r   r   rm     s    zVarStoreData.__len__c                 C   s"   |d u rd}| j j| }|j}|S ræ   )r  ZVarDataZVarRegionCount)r   ZvsIndexZvarDataÚ
numRegionsr   r   r   ÚgetNumRegions  s
    zVarStoreData.getNumRegions)NN)
r   r   r   r   rk   r†   r#  r%  rm   r(  r   r   r   r   r  å  s   

r  c                   @   s6   e Zd Zddd„Zdd„ Zdd„ Zdd	„ Zd
d„ ZdS )ÚFDSelectNc                 C   sœ  |�rŒt |ƒ| _| jdkr@ddlm} |d| |¡ƒ ¡ | _�q˜| jdkrÖd g| }t|ƒ}d }d }t|ƒD ]8}	t|ƒ}
|d ur˜t||
ƒD ]}|||< qŠ|
}t |ƒ}ql|d urÎt|ƒ}
t||
ƒD ]}|||< qÀ|| _n´| jdk�rxd g| }t|ƒ}d }d }t|ƒD ]>}	t|ƒ}
|d u�r4t||
ƒD ]}|||< �q$|
}t|ƒ}�q|d u�rpt|ƒ}
t||
ƒD ]}|||< �q`|| _nd�s˜J d| ƒ‚n|| _g | _d S )Nr   )ÚarrayrH   rD   rx   Fzunsupported FDSelect format: %s)	rþ   Úformatr*  rV   ÚtolistÚgidArrayrý   rÿ   rü   )r   rh   Ú	numGlyphsr+  r*  r-  ÚnRangesrº   Úprevr  ÚfirstÚglyphIDr   r   r   r     sT    









zFDSelect.__init__c                 C   s
   t | jƒS r   )r4   r-  rl   r   r   r   rm   J  s    zFDSelect.__len__c                 C   s
   | j | S r   ©r-  rB   r   r   r   rv   M  s    zFDSelect.__getitem__c                 C   s   || j |< d S r   r3  )r   r3   ÚfdSelectValuer   r   r   r  P  s    zFDSelect.__setitem__c                 C   s   | j  |¡ d S r   )r-  r5   )r   r4  r   r   r   r5   S  s    zFDSelect.append)NNN)r   r   r   r   rm   rv   r  r5   r   r   r   r   r)    s
   
1r)  c                   @   sf   e Zd ZdZddd„Zdd„ Zdd„ Zd	d
„ ZeZdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ ZdS )r¨   añ  The ``CharStrings`` in the font represent the instructions for drawing 
	each glyph. This object presents a dictionary interface to the font's
	CharStrings, indexed by glyph name:

	.. code:: python
	
		tt["CFF "].cff[0].CharStrings["a"]
		# <T2CharString (bytecode) at 103451e90>

	See :class:`fontTools.misc.psCharStrings.T1CharString` and
	:class:`fontTools.misc.psCharStrings.T2CharString` for how to decompile,
	compile and interpret the glyph drawing instructions in the returned objects.

	Nc	                 C   sŒ   || _ || _|d urZt||||||d�| _i  | _}	tt|ƒƒD ]}
|
|	||
 < q@d| _n.i | _d| _|| _|d urz|| _	|d urˆ|| _
d S )NrO   r   r   )r   ÚvarStorer  rª   r±   rÿ   r4   r©   r    r  rž   )r   rh   ry   r   r    r  rž   rP   r5  r±   r  r   r   r   r   g  s"    ÿ
zCharStrings.__init__c                 C   s   t | j ¡ ƒS r   )r]   r±   rn   rl   r   r   r   rn   ~  s    zCharStrings.keysc                 C   s   | j r| jS t| j ¡ ƒS d S r   )r©   rª   r]   r±   ro   rl   r   r   r   ro   �  s    zCharStrings.valuesc                 C   s
   || j v S r   )r±   )r   ru   r   r   r   Úhas_key‡  s    zCharStrings.has_keyc                 C   s
   t | jƒS r   )r4   r±   rl   r   r   r   rm   Œ  s    zCharStrings.__len__c                 C   s   | j | }| jr| j| }|S r   )r±   r©   rª   )r   ru   r6   r   r   r   rv   �  s    

zCharStrings.__getitem__c                 C   s*   | j r| j| }|| j|< n
|| j|< d S r   )r©   r±   rª   )r   ru   r6   r3   r   r   r   r  •  s    
zCharStrings.__setitem__c                 C   sZ   | j r| j| }| j |¡S t| dƒrDt| dƒr>| j| j}qHd}nd }| j| |fS d S )Nrž   r  r   )r©   r±   rª   r´   r*   ÚfdSelectIndex)r   ru   r3   r  r   r   r   r´   œ  s    


zCharStrings.getItemAndSelectorc                 C   sœ   t |  ¡ ƒ}|D ]†}|  |¡\}}| ¡ r2dg}ng }|d u rV| dd|fg| ¡ n| dd|fd|fg| ¡ | ¡  | |¡ | d¡ | ¡  qd S )N)r  r   r  ru   r7  )Úsortedrn   r´   r  rŽ   r�   r�   r�   )r   r‘   Únamesru   ZcharStrr7  r  r   r   r   r�   ª  s     þ

zCharStrings.toXMLc           
   	   C   s¸   |D ]®}t |tƒrq|\}}}|dkr(qd}t| dƒrlzt|d ƒ}W n ty\   d}Y n0 | j| j}n| j}|d }tj	}||| j
d�}	|	 |||¡ |dkrª||	_|	| |< qd S )Nr  r"   rž   r7  r   ru   r  )rq   rr   r*   r   rs   rž   r•   r    r   rš   r   r—   r7  )
r   ru   r›   rœ   r�   ZfdIDr    Ú	glyphNamer  r6   r   r   r   r—   ½  s0    



þzCharStrings.fromXML)NN)r   r   r   r½   r   rn   ro   r6  Ú__contains__rm   rv   r  r´   r�   r—   r   r   r   r   r¨   W  s    ÿ
r¨   c                 C   s   t |  d¡ƒS r  )r   rV   )rh   r   r   r   rþ   Ù  s    rþ   c                 C   s   t  d|  d¡¡\}|S )NrQ   r#   ©rY   rT   rV   ©rh   rˆ   r   r   r   rý   Ý  s    rý   c                 C   s   t  d|  d¡¡\}|S )Nrù   rx   r<  r=  r   r   r   rü   â  s    rü   c                 C   s   |   t|ƒ¡ d S r   )rÇ   r   r=  r   r   r   rÜ   ç  s    rÜ   c                 C   s   |   t d|¡¡ d S ©NrQ   ©rÇ   rY   r~   r=  r   r   r   rÛ   ë  s    rÛ   c                 C   s   |   t d|¡¡ d S ©Nrù   r?  r=  r   r   r   rÚ   ï  s    rÚ   c                 C   s   t | ƒS r   )r   r‡   r   r   r   Ú	packCard8ó  s    rA  c                 C   s   t  d| ¡S r>  ©rY   r~   r‡   r   r   r   Ú
packCard16÷  s    rC  c                 C   s   t  d| ¡S r@  rB  r‡   r   r   r   Ú
packCard32û  s    rD  c                 C   s(   i }| D ]\}}}}}||f||< q|S r   r   ©rÀ   ÚdÚopru   ÚargÚdefaultÚconvr   r   r   ÚbuildOperatorDictÿ  s    rK  c                 C   sT   i }| D ]F\}}}}}t |tƒr:t|d ƒt|d ƒ }nt|ƒ}||f||< q|S ©Nr   r   )rq   r$  r   rE  r   r   r   ÚbuildOpcodeDict  s    
rM  c                 C   s&   g }| D ]\}}}}}|  |¡ q|S r   )r5   )rÀ   ÚlrG  ru   rH  rI  rJ  r   r   r   r¡     s    r¡   c                 C   s,   i }| D ]\}}}}}|d ur|||< q|S r   r   rE  r   r   r   ÚbuildDefaults  s
    
rO  c                 C   s$   i }| D ]\}}}}}|||< q|S r   r   rE  r   r   r   ÚbuildConverters   s    
rP  c                   @   s4   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ ZdS )ÚSimpleConverterc              	   C   sN   t |dƒs|  ||¡S |j}| ¡ }z|  ||¡W | |¡ S | |¡ 0 d S )Nrh   )r*   Ú_readrh   rÅ   r[   )r   rÑ   rˆ   rh   rÉ   r   r   r   rV   )  s    

þzSimpleConverter.readc                 C   s   |S r   r   ©r   rÑ   rˆ   r   r   r   rR  3  s    zSimpleConverter._readc                 C   s   |S r   r   rS  r   r   r   rÇ   6  s    zSimpleConverter.writec                 C   s   |j ||d� | ¡  d S )Nr‡   )rŒ   r�   ©r   r‘   ru   rˆ   r   r   r   ÚxmlWrite9  s    zSimpleConverter.xmlWritec                 C   s   |d S ©Nrˆ   r   ©r   ru   r›   rœ   rÑ   r   r   r   r%  =  s    zSimpleConverter.xmlReadN)r   r   r   rV   rR  rÇ   rU  r%  r   r   r   r   rQ  '  s
   
rQ  c                   @   s,   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	S )
ÚASCIIConverterc                 C   s   t |dd�S ©NÚasciirØ   rI   rS  r   r   r   rR  C  s    zASCIIConverter._readc                 C   s   t |dd�S rY  ©r	   rS  r   r   r   rÇ   F  s    zASCIIConverter.writec                 C   s"   |j |t|dd�d� | ¡  d S )NrZ  rØ   r‡   ©rŒ   r
   r�   rT  r   r   r   rU  I  s    zASCIIConverter.xmlWritec                 C   s   t |d dd�S )Nrˆ   rZ  rØ   r[  rW  r   r   r   r%  M  s    zASCIIConverter.xmlReadN©r   r   r   rR  rÇ   rU  r%  r   r   r   r   rX  A  s   rX  c                   @   s,   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	S )
ÚLatin1Converterc                 C   s   t |dd�S ©Nr×   rØ   rI   rS  r   r   r   rR  S  s    zLatin1Converter._readc                 C   s   t |dd�S r_  r[  rS  r   r   r   rÇ   V  s    zLatin1Converter.writec                 C   s<   t |dd�}|dv r"t dd|¡}|j||d� | ¡  d S )Nr×   rØ   )ÚNoticeÚ	Copyrightz	[\r\n]\s+ú r‡   )r
   ÚreÚsubrŒ   r�   rT  r   r   r   rU  Y  s
    zLatin1Converter.xmlWritec                 C   s   t |d dd�S )Nrˆ   r×   rØ   r[  rW  r   r   r   r%  `  s    zLatin1Converter.xmlReadNr]  r   r   r   r   r^  Q  s   r^  c                 C   s&   zt | ƒ}W n   t| ƒ}Y n0 |S r   )r1   Úfloat)rL   rˆ   r   r   r   ÚparseNumd  s
    rf  c                 C   s`   g }| D ]>}t |tƒrq|\}}}|d  ¡ }dd„ |D ƒ}| |¡ qt|ƒdkr\|d }|S )Nrˆ   c                 S   s   g | ]}t |ƒ‘qS r   )Úeval©rK   Úvalr   r   r   Ú
<listcomp>s  rN   z"parseBlendList.<locals>.<listcomp>r   r   )rq   rr   Úsplitr5   r4   )rL   Ú	valueListr�   ru   r›   rœ   Ú	blendListr   r   r   ÚparseBlendListl  s    

rn  c                   @   s   e Zd Zdd„ Zdd„ ZdS )ÚNumberConverterc                 C   s„   t |tƒrj| |¡ | ¡  | ¡  d dd„ |D ƒ¡}|jt|d� | ¡  | ¡  | 	|¡ | ¡  n|j||d� | ¡  d S )Nrb  c                 S   s   g | ]}t |ƒ‘qS r   ©rr   rh  r   r   r   rj  €  rN   z,NumberConverter.xmlWrite.<locals>.<listcomp>r‡   ©
rq   r]   rŽ   r�   ÚindentÚjoinrŒ   ÚkBlendDictOpNameÚdedentr�   )r   r‘   ru   rˆ   Ú
blendValuer   r   r   rU  {  s    



zNumberConverter.xmlWritec                 C   s.   |  dd ¡}|d u rt|ƒ}nt|d ƒ}|S rV  )Úgetrn  rf  )r   ru   r›   rœ   rÑ   ÚvalueStringrˆ   r   r   r   r%  Š  s
    
zNumberConverter.xmlReadN©r   r   r   rU  r%  r   r   r   r   ro  z  s   ro  c                   @   s   e Zd Zdd„ Zdd„ ZdS )ÚArrayConverterc                 C   sª   |r|t |d tƒr|| |¡ | ¡  | ¡  |D ].}d dd„ |D ƒ¡}|jt|d� | ¡  q0| ¡  | 	|¡ | ¡  n*d dd„ |D ƒ¡}|j||d� | ¡  d S )Nr   rb  c                 S   s   g | ]}t |ƒ‘qS r   rp  rh  r   r   r   rj  š  rN   z+ArrayConverter.xmlWrite.<locals>.<listcomp>r‡   c                 S   s   g | ]}t |ƒ‘qS r   rp  rh  r   r   r   rj  ¡  rN   rq  )r   r‘   ru   rˆ   rl  rv  r   r   r   rU  ”  s    



zArrayConverter.xmlWritec                 C   s8   |  dd ¡}|d u rt|ƒ}n| ¡ }dd„ |D ƒ}|S )Nrˆ   c                 S   s   g | ]}t |ƒ‘qS r   )rf  )rK   rˆ   r   r   r   rj  «  rN   z*ArrayConverter.xmlRead.<locals>.<listcomp>)rw  rn  rk  )r   ru   r›   rœ   rÑ   rx  rl  ro   r   r   r   r%  ¥  s    
zArrayConverter.xmlReadNry  r   r   r   r   rz  “  s   rz  c                   @   s   e Zd Zdd„ Zdd„ ZdS )ÚTableConverterc                 C   s2   |  |¡ | ¡  | |¡ | |¡ | ¡  d S r   )rŽ   r�   r�   r�   rT  r   r   r   rU  ±  s
    


zTableConverter.xmlWritec                 C   s<   |   ¡ ƒ }|D ](}t|tƒrq|\}}}| |||¡ q|S r   )ÚgetClassrq   rr   r—   )r   ru   r›   rœ   rÑ   Úobr�   r   r   r   r%  ¸  s    


zTableConverter.xmlReadNry  r   r   r   r   r{  ¯  s   r{  c                   @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )ÚPrivateDictConverterc                 C   s   t S r   )ÚPrivateDictrl   r   r   r   r|  Ä  s    zPrivateDictConverter.getClassc           
      C   s|   |\}}|j }|j}z
|j}W n ty4   d }Y n0 t|j||||d�}| |¡ | |¡}	t|	ƒ|ksnJ ‚| 	|	¡ |S r  )
rh   rû   r™   ÚAttributeErrorr  rc   r[   rV   r4   rk   )
r   rÑ   rˆ   r  rÝ   rh   rP   r™   Zprivr¾   r   r   r   rR  Ç  s    

ÿ


zPrivateDictConverter._readc                 C   s   dS )N)r   r   r   rS  r   r   r   rÇ   ×  s    zPrivateDictConverter.writeN©r   r   r   r|  rR  rÇ   r   r   r   r   r~  Â  s   r~  c                   @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )ÚSubrsConverterc                 C   s   t S r   )r  rl   r   r   r   r|  Ý  s    zSubrsConverter.getClassc                 C   s(   |j }|j}| |j| ¡ t||d�S r  )rh   rû   r[   rÝ   r  )r   rÑ   rˆ   rh   rP   r   r   r   rR  à  s    zSubrsConverter._readc                 C   s   dS ræ   r   rS  r   r   r   rÇ   æ  s    zSubrsConverter.writeNr�  r   r   r   r   r‚  Û  s   r‚  c                   @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )ÚCharStringsConverterc              
   C   s„   |j }|j}|j}t|dd ƒ}|j}t|dƒrP|j}t|dƒrF|j}	nd }	d }
nd\}	}|j}
| 	|¡ t
||||
|	|||d�}|S )Nr”   r˜   r)  )NN)rP   r5  )rh   rû   ry   rµ   rg   r*   r˜   r)  r•   r[   r¨   )r   rÑ   rˆ   rh   rP   ry   r5  r   rž   r  r    r±   r   r   r   rR  ì  s$    


ÿzCharStringsConverter._readc                 C   s   dS ræ   r   rS  r   r   r   rÇ     s    zCharStringsConverter.writec           	      C   sp   t |dƒr,|j}t |dƒr"|j}nd }d }n|jd d   }}}td d |j|||t|dd ƒd�}| |||¡ |S )Nr˜   r)  r”   )r5  )r*   r˜   r)  r•   r¨   rg   rµ   r—   )	r   ru   r›   rœ   rÑ   rž   r  r    r±   r   r   r   r%    s    

ÿzCharStringsConverter.xmlReadN©r   r   r   rR  rÇ   r%  r   r   r   r   rƒ  ê  s   rƒ  c                   @   s,   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	S )
ÚCharsetConverterc                 C   s”  t |dƒ}|dk�r|j}|j}| |¡ t td|¡ t|ƒ}|dkrZt|||j|ƒ}n(|dksj|dkr~t	|||j||ƒ}nt
‚t|ƒ|ks’J ‚t td| ¡ ¡ i }g }	|D ]`}
|
|v rþ||
 }|
d t|ƒ |v râ|d7 }qÄ|d ||
< |
d t|ƒ }
d||
< |	 |
¡ q°|	}nT|�s*d|jv�r>|dk�s8J ‚d }n.|dk�rNt}n|dk�r^t}n|dk�rlt}|�r�t|ƒ|jk�r�|d |j… }|S )	NÚROSr#   zloading charset at %sr   r   z    charset end at %sú#r¨   )r*   r.  rh   r[   rÂ   rÃ   rþ   ÚparseCharset0rc   ÚparseCharsetÚNotImplementedErrorr4   rÅ   rr   r5   r¥   ÚcffISOAdobeStringsÚcffIExpertStringsÚcffExpertSubsetStrings)r   rÑ   rˆ   ÚisCIDr.  rh   r+  ry   ZallNamesZ
newCharsetr:  Únr   r   r   rR    sL    






zCharsetConverter._readc                 C   s   dS ræ   r   rS  r   r   r   rÇ   H  s    zCharsetConverter.writec                 C   s   |  d¡ | ¡  d S )Nz8charset is dumped separately as the 'GlyphOrder' element)r  r�   rT  r   r   r   rU  K  s    
zCharsetConverter.xmlWritec                 C   s   d S r   r   rW  r   r   r   r%  R  s    zCharsetConverter.xmlReadNr]  r   r   r   r   r…    s   .r…  c                   @   s,   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	S )
ÚCharsetCompilerc                 C   s\   |d dksJ ‚t |jdƒ}t|||ƒ}t|||ƒ}t|ƒt|ƒk rL|| _n|| _|| _d S )Nr   ú.notdefr†  )r*   ÚdictObjÚpackCharset0ÚpackCharsetr4   r¾   rÑ   )r   rc   ry   rÑ   rŽ  Údata0r¾   r   r   r   r   X  s    zCharsetCompiler.__init__c                 C   s   || j jd< d S )Nry   rí   rî   r   r   r   rÁ   c  s    zCharsetCompiler.setPosc                 C   s
   t | jƒS r   r&  rl   r   r   r   r   f  s    zCharsetCompiler.getDataLengthc                 C   s   |  | j¡ d S r   ©rÇ   r¾   rê   r   r   r   r�   i  s    zCharsetCompiler.toFileN©r   r   r   r   rÁ   r   r�   r   r   r   r   r�  V  s   r�  c                 C   s|   d }t tdfttdfttdfg}t| ƒ}|D ]J\}}}|d urB qx||krLq,|}t|ƒD ]}| | || krXd } q,qXq,|S )Nr   r   r#   )ÚcffISOAdobeStringCountr‹  ÚcffExpertStringCountrŒ  ÚcffExpertSubsetStringCountr�  r4   rÿ   )ry   ZpredefinedCharSetValZpredefinedCharSetsZlcsZcntZpcsÚcsvr  r   r   r   ÚgetStdCharSetm  s"    ýrœ  c                 C   s   t | dd … ƒS )NrD   )r1   ©ru   rc   r   r   r   ÚgetCIDfromName‚  s    rž  c                 C   s
   |  | ¡S r   )ÚgetSIDr�  r   r   r   ÚgetSIDfromName†  s    r   c                 C   sJ   d}t |ƒg}|rt}nt}| dd … D ]}| t|||ƒƒ¡ q(t|ƒS rL  )rA  rž  r   r5   rC  r   )ry   rŽ  rc   Úfmtr¾   Ú	getNameIDru   r   r   r   r“  Š  s    
r“  c                 C   sì   d}g }d }d}|rt }nt}| dd … D ]R}|||ƒ}	|d u rF|	}n2|d |	krx|| }
|
dkrfd}| ||
f¡ |	}|	}q*|r¤|| }
|
dkr–d}| ||
f¡ t|ƒg}|dkr¼t}nt}|D ]\}}
| t|ƒ||
ƒ ¡ qÄt|ƒS )Nr   r   éÿ   r#   )rž  r   r5   rA  rC  r   )ry   rŽ  rc   r¡  Úrangesr1  Úendr¢  ru   ÚSIDÚnLeftr¾   Ú	nLeftFuncr   r   r   r”  —  s<    

r”  c                 C   sj   dg}|r>t | d ƒD ]$}t|ƒ}| dt|ƒ d¡ ¡ qn(t | d ƒD ]}t|ƒ}| || ¡ qJ|S ©Nr‘  r   Zcidrw   )rÿ   rý   r5   rr   Úzfill)r.  rh   rc   rŽ  ry   r  ÚCIDr¦  r   r   r   rˆ  ¼  s    rˆ  c                 C   s¢   dg}d}|dkrt }nt}|| k ržt|ƒ}||ƒ}	|rjt|||	 d ƒD ]}
| dt|
ƒ d¡ ¡ qJn&t|||	 d ƒD ]}| || ¡ q|||	 d }q|S r©  )rþ   rý   rÿ   r5   rr   rª  )r.  rh   rc   rŽ  r¡  ry   rÈ   r¨  r1  r§  r«  r¦  r   r   r   r‰  É  s    r‰  c                   @   s,   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	S )
ÚEncodingCompilerc                 C   sZ   t |tƒrJ ‚t|jj||jƒ}t|jj||jƒ}t|ƒt|ƒk rJ|| _n|| _|| _	d S r   )
rq   rr   ÚpackEncoding0r’  ry   rc   ÚpackEncoding1r4   r¾   rÑ   )r   rc   rÙ   rÑ   r•  Zdata1r   r   r   r   ß  s    zEncodingCompiler.__init__c                 C   s   || j jd< d S )NÚEncodingrí   rî   r   r   r   rÁ   é  s    zEncodingCompiler.setPosc                 C   s
   t | jƒS r   r&  rl   r   r   r   r   ì  s    zEncodingCompiler.getDataLengthc                 C   s   |  | j¡ d S r   r–  rê   r   r   r   r�   ï  s    zEncodingCompiler.toFileNr—  r   r   r   r   r¬  Ý  s   
r¬  c                   @   s,   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	S )
ÚEncodingConverterc                 C   s¤   |dkrdS |dkrdS |dks$J ‚|j }| |¡ t td|¡ t|ƒ}|d@ }|r^tdƒ‚|d@ }|dkr‚t|j|||jƒ}n|dkrœt	|j|||jƒ}|S d S )	Nr   ÚStandardEncodingr   ÚExpertEncodingzloading Encoding at %sé€   z*Encoding supplements are not yet supportedé   )
rh   r[   rÂ   rÃ   rþ   rŠ  ÚparseEncoding0ry   rc   ÚparseEncoding1)r   rÑ   rˆ   rh   r¡  ÚhaveSupplementrÙ   r   r   r   rR  õ  s,    

ÿ
ÿzEncodingConverter._readc                 C   s   |dkrdS |dkrdS dS )Nr±  r   r²  r   r   rS  r   r   r   rÇ     s
    zEncodingConverter.writec                 C   sˆ   |dv r"|j ||d� | ¡  d S | |¡ | ¡  tt|ƒƒD ]0}|| }|dkr@|j dt|ƒ|d� | ¡  q@| |¡ | ¡  d S )N)r±  r²  r‹   r‘  Úmap)Úcoderu   )rŒ   r�   rŽ   rÿ   r4   Úhexr�   )r   r‘   ru   rˆ   r¹  r:  r   r   r   rU    s    


zEncodingConverter.xmlWritec           	      C   sZ   d|v r|d S dgd }|D ]6}t |tƒr.q|\}}}t|d ƒ}|d }|||< q|S )Nru   r‘  rÍ   r¹  )rq   rr   r   )	r   ru   r›   rœ   rÑ   rÙ   r�   r¹  r:  r   r   r   r%  "  s    



zEncodingConverter.xmlReadNr]  r   r   r   r   r°  ó  s   r°  c                 C   sF   t |ƒ}dgd }td|d ƒD ] }t |ƒ}|dkr | | ||< q |S )Nr‘  rÍ   r   r   ©rþ   rÿ   )ry   rh   r·  rc   ZnCodesrÙ   r2  r¹  r   r   r   rµ  0  s    
rµ  c           
      C   sl   t |ƒ}dgd }d}t|ƒD ]H}t |ƒ}t |ƒ}	t|||	 d ƒD ]}| | ||< |d }qD|d }q|S )Nr‘  rÍ   r   r»  )
ry   rh   r·  rc   r/  rÙ   r2  r  r¹  r§  r   r   r   r¶  :  s    


r¶  c           	      C   s¶   d}i }t t|ƒƒD ]}|| }|dkr|||< qg }| dd … D ]}| |¡}| |¡ qB|rv|d d u rv| ¡  q\t|ƒtt|ƒƒg}|D ]}|d u ržd}| t|ƒ¡ qŽt|ƒS )Nr   r‘  r   r"   ©rÿ   r4   rw  r5   ÚpoprA  r   )	ry   rÙ   rc   r¡  Úmr¹  ru   Úcodesr¾   r   r   r   r­  H  s$    


r­  c                 C   s  d}i }t t|ƒƒD ]}|| }|dkr|||< qg }d }d}	| dd … D ]H}| |d¡}|d u rh|}n&|	d |krŽ|	| }
| ||
f¡ |}|}	qJ|	| }
| ||
f¡ |rÈ|d d dkrÈ| ¡  qªt|ƒtt|ƒƒg}|D ]*\}}
|dkrôd}| t|ƒt|
ƒ ¡ qàt|ƒS )Nr   r‘  r   r"   r¼  )ry   rÙ   rc   r¡  r¾  r¹  ru   r¤  r1  r¥  r§  r¾   r   r   r   r®  _  s8    

r®  c                   @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )ÚFDArrayConverterc                 C   s^   z
|j }W n ty    d }Y n0 |j}|j}| |¡ t||d�}||_|j|_|j|_|S r  )	r”   r€  rh   rû   r[   r§   r™   rc   rg   )r   rÑ   rˆ   r™   rh   rP   rž   r   r   r   rR  ƒ  s    


zFDArrayConverter._readc                 C   s   dS ræ   r   rS  r   r   r   rÇ   ‘  s    zFDArrayConverter.writec                 C   s8   t ƒ }|D ](}t|tƒrq
|\}}}| |||¡ q
|S r   )r§   rq   rr   r—   )r   ru   r›   rœ   rÑ   rž   r�   r   r   r   r%  ”  s    

zFDArrayConverter.xmlReadNr„  r   r   r   r   rÀ  �  s   rÀ  c                   @   s,   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	S )
ÚFDSelectConverterc                 C   s    |j }| |¡ t||jƒ}|S r   )rh   r[   r)  r.  )r   rÑ   rˆ   rh   r  r   r   r   rR     s    
zFDSelectConverter._readc                 C   s   dS ræ   r   rS  r   r   r   rÇ   ¦  s    zFDSelectConverter.writec                 C   s    |  |d|jfg¡ | ¡  d S ©Nr+  )rŒ   r+  r�   rT  r   r   r   rU  «  s    zFDSelectConverter.xmlWritec           	      C   s$   t |d ƒ}d }d }t|||ƒ}|S rÂ  )r   r)  )	r   ru   r›   rœ   rÑ   r¡  rh   r.  r  r   r   r   r%  ¯  s
    zFDSelectConverter.xmlReadNr]  r   r   r   r   rÁ  ž  s   rÁ  c                   @   s,   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	S )
ÚVarStoreConverterc                 C   s$   |j }| |¡ t|ƒ}| ¡  |S r   )rh   r[   r  rk   )r   rÑ   rˆ   rh   r5  r   r   r   rR  ¹  s
    
zVarStoreConverter._readc                 C   s   dS ræ   r   rS  r   r   r   rÇ   À  s    zVarStoreConverter.writec                 C   s   |  ||¡ d S r   )r#  rT  r   r   r   rU  Ã  s    zVarStoreConverter.xmlWritec                 C   s   t ƒ }| ||||¡ |S r   )r  r%  )r   ru   r›   rœ   rÑ   r5  r   r   r   r%  Æ  s    zVarStoreConverter.xmlReadNr]  r   r   r   r   rÃ  ·  s   rÃ  c                 C   s.   d}t |ƒg}| D ]}| t |ƒ¡ qt|ƒS ræ   )rA  r5   r   )ÚfdSelectArrayr¡  r¾   r3   r   r   r   ÚpackFDSelect0Ì  s
    
rÅ  c           
      C   s¬   d}g }t | ƒ}d}t|ƒD ]&}| | }||kr| ||g¡ |}q|d }t|ƒg}| tt |ƒƒ¡ |D ](}	| t|	d ƒ¡ | t|	d ƒ¡ ql| t|ƒ¡ t|ƒS )NrD   r"   r   r   )r4   rÿ   r5   rA  rC  r   ©
rÄ  r¡  ZfdRangesZlenArrayZlastFDIndexr  r  ZsentinelGIDr¾   ZfdRanger   r   r   ÚpackFDSelect3Ô  s"    
rÇ  c           
      C   s¬   d}g }t | ƒ}d}t|ƒD ]&}| | }||kr| ||g¡ |}q|d }t|ƒg}| tt |ƒƒ¡ |D ](}	| t|	d ƒ¡ | t|	d ƒ¡ ql| t|ƒ¡ t|ƒS )Nrx   r"   r   r   )r4   rÿ   r5   rA  rD  rC  r   rÆ  r   r   r   ÚpackFDSelect4é  s"    
rÈ  c                   @   s,   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	S )
ÚFDSelectCompilerc                 C   sŒ   |j }|j}|dkr t|ƒ| _nb|dkr4t|ƒ| _nN|dkrHt|ƒ| _n:t|ƒ}t|ƒ}t|ƒt|ƒk rv|| _d|_ n|| _d|_ || _d S )Nr   rD   rx   )r+  r-  rÅ  r¾   rÇ  rÈ  r4   rÑ   )r   r  rÑ   r¡  rÄ  r•  Zdata3r   r   r   r      s     zFDSelectCompiler.__init__c                 C   s   || j jd< d S )Nr)  rí   rî   r   r   r   rÁ     s    zFDSelectCompiler.setPosc                 C   s
   t | jƒS r   r&  rl   r   r   r   r     s    zFDSelectCompiler.getDataLengthc                 C   s   |  | j¡ d S r   r–  rê   r   r   r   r�     s    zFDSelectCompiler.toFileNr—  r   r   r   r   rÉ  þ  s   rÉ  c                   @   s,   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	S )
ÚVarStoreCompilerc                 C   s6   || _ |js| ¡  tt|jƒƒ|jg}t|ƒ| _d S r   )rÑ   r¾   r†   rC  r4   r   )r   ÚvarStoreDatarÑ   r¾   r   r   r   r   "  s    þzVarStoreCompiler.__init__c                 C   s   || j jd< d S )Nr”   rí   rî   r   r   r   rÁ   ,  s    zVarStoreCompiler.setPosc                 C   s
   t | jƒS r   r&  rl   r   r   r   r   /  s    zVarStoreCompiler.getDataLengthc                 C   s   |  | j¡ d S r   r–  rê   r   r   r   r�   2  s    zVarStoreCompiler.toFileNr—  r   r   r   r   rÊ     s   
rÊ  c                   @   s   e Zd Zdd„ Zdd„ ZdS )ÚROSConverterc                 C   s<   |\}}}|  |dt|ƒfdt|ƒfd|fg¡ | ¡  d S ©NZRegistryZOrderZ
Supplementr\  )r   r‘   ru   rˆ   Úregistryr£   Z
supplementr   r   r   rU  8  s    


ýþzROSConverter.xmlWritec                 C   s   |d |d t |d ƒfS rÍ  )r   rW  r   r   r   r%  C  s    zROSConverter.xmlReadNry  r   r   r   r   rÌ  6  s   rÌ  )é   ZmaxstackÚnumberNN)é   é   r†  )r¦  r¦  rÐ  ))rÑ  é   ZSyntheticBaserÐ  NN)r   Úversionr¦  NNr`  r¦  )rÑ  r   ra  )r#   ZFullNamer¦  NN))rÑ  é&   ÚFontNamer¦  NN)rD   Z
FamilyNamer¦  NN)rx   ÚWeightr¦  NN))rÑ  r   ZisFixedPitchrÐ  r   N))rÑ  r#   ZItalicAnglerÐ  r   N))rÑ  rD   ZUnderlinePositionrÐ  iœÿÿÿN))rÑ  rx   ZUnderlineThicknessrÐ  é2   N))rÑ  rw   Z	PaintTyperÐ  r   N))rÑ  é   ZCharstringTyperÐ  r#   N)rÑ  é   Ú
FontMatrixr*  )çü©ñÒMbP?r   r   rÜ  r   r   )é   ZUniqueIDrÐ  NNrw   ÚFontBBox)r   r   r   r   ))rÑ  é   ZStrokeWidthrÐ  r   N)é   ZXUIDr*  NN))rÑ  é   Z
PostScriptr¦  NN))rÑ  é   ZBaseFontNamer¦  NN))rÑ  é   ZBaseFontBlendÚdeltaNN))rÑ  é   ÚCIDFontVersionrÐ  r   N))rÑ  é    ÚCIDFontRevisionrÐ  r   N))rÑ  é!   ÚCIDFontTyperÐ  r   N))rÑ  é"   ÚCIDCountrÐ  i"  Né   ry   rÐ  ))rÑ  é#   ZUIDBaserÐ  NNé   r¯  é   r•   )rÐ  rÐ  )rÑ  é%   )rÑ  é$   r˜   é   é   r”   Zblendrã  )râ  ÚvsindexrÐ  NNrm  )rÙ  Z
BlueValuesrä  NN)rÚ  Z
OtherBluesrä  NN)rß  ZFamilyBluesrä  NN)é	   ZFamilyOtherBluesrä  NN))rÑ  rö  Z	BlueScalerÐ  g}?5^ºI¤?N))rÑ  é
   Z	BlueShiftrÐ  rÚ  N))rÑ  é   ZBlueFuzzrÐ  r   N)r÷  ZStdHWrÐ  NN)rø  ZStdVWrÐ  NN))rÑ  rÑ  Z	StemSnapHrä  NN))rÑ  rÝ  Z	StemSnapVrä  NN))rÑ  rà  Z	ForceBoldrÐ  r   N))rÑ  rí  ZForceBoldThresholdrÐ  NN))rÑ  rï  ZlenIVrÐ  NN))rÑ  ró  ZLanguageGrouprÐ  r   N))rÑ  rð  ZExpansionFactorrÐ  g¸…ëQ¸®?N))rÑ  é   ZinitialRandomSeedrÐ  r   N)rÓ  ÚdefaultWidthXrÐ  r   N)rá  ÚnominalWidthXrÐ  r   Nrù  r³   c                 C   sŠ   t t| ƒƒD ]x}| | \}}}}}|d ur,q|dv r<tƒ }n6|dkrLtƒ }n&|dkr\tƒ }n|dkrjd }ndsrJ ‚|||||f| |< qd S )N)rä  r*  rÐ  r¦  rm  F)rÿ   r4   rz  ro  rX  )rÀ   r  rG  ru   rH  rI  rJ  r   r   r   ÚaddConverters­  s    rü  c                   @   s   e Zd ZeeƒZdS )ÚTopDictDecompilerN)r   r   r   rK  r¤   Ú	operatorsr   r   r   r   rý  Ã  s   rý  c                   @   s   e Zd ZeeƒZdS )ÚPrivateDictDecompilerN)r   r   r   rK  r®   rþ  r   r   r   r   rÿ  Ç  s   rÿ  c                   @   sb   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d„ Zdd„ ZdS )ÚDictCompilerr   Nc           	      C   s®   |rt |tƒsJ ‚|d u r6t|dƒr6|j}|d us6J ‚|| _|| _|| _|| _i }|jD ]J}t||d ƒ}|d u rrqX|j	| }| 
||¡}||j |¡kršqX|||< qX|| _d S rÏ   )rq   rb   r*   rP   r’  rc   rÑ   r£   rµ   Ú
convertersrÇ   Údefaultsrw  r¥   )	r   r’  rc   rÑ   rP   r¥   ru   rˆ   rJ  r   r   r   r   Î  s(    


zDictCompiler.__init__c                 C   s   d S r   r   rî   r   r   r   rÁ   ä  s    zDictCompiler.setPosc                 C   s   t |  d¡ƒS )Nr   )r4   r†   rl   r   r   r   r   ç  s    zDictCompiler.getDataLengthc                 C   sâ   t   td| jj|¡ | j}g }| jjD ]®}| |¡}|d u r>q&| j| \}}t	|t
ƒr®t|ƒ}t|ƒ|ksrJ dƒ‚t|ƒD ]0}	||	 }
||	 }t| d|
 ƒ}| ||ƒ¡ qznt| d| ƒ}| ||ƒ¡ | |¡ q&t|ƒ}|S )Nz-- compiling %s for %szvalue doesn't match arg typeZarg_)rÂ   rÃ   ré   r   r¥   r’  r£   rw  Úopcodesrq   r$  r4   rÿ   rµ   r5   r   )r   Úreasonr¥   r¾   ru   rˆ   rG  ZargTyperN  r  rH  ÚvZ
arghandlerr   r   r   r†   ê  s*    

zDictCompiler.compilec                 C   s   |   d¡}| |¡ d S )Nr�   )r†   rÇ   )r   rh   r¾   r   r   r   r�   	  s    
zDictCompiler.toFilec                 C   sJ   t |tƒr>dd„ |D ƒ}| tdƒ¡ | ttƒ¡ t|ƒ}nt|ƒ}|S )Nc                 S   s   g | ]}t |ƒ‘qS r   ©ÚencodeNumberrh  r   r   r   rj  	  rN   z+DictCompiler.arg_number.<locals>.<listcomp>r   )rq   r]   r5   r  r   ÚblendOpr   )r   Únumr¾   Zdatumr   r   r   Ú
arg_number	  s    

zDictCompiler.arg_numberc                 C   s   t  | j |¡¡S r   )r   ÚencodeIntCFFrc   rŸ  )r   rL   r   r   r   Úarg_SID	  s    zDictCompiler.arg_SIDc                 C   s&   g }|D ]}|  |  |¡¡ qt|ƒS r   )r5   r
  r   )r   rˆ   r¾   r	  r   r   r   Ú	arg_array	  s    zDictCompiler.arg_arrayc                 C   sn   |sdS |d }t |tƒr&|  |¡}n@g }d}|D ]}| || ¡ |}q2g }|D ]}| t|ƒ¡ qRt|ƒS )NrN   r   )rq   r]   Úarg_delta_blendr5   r  r   )r   rˆ   Zval0r¾   rã   Úlastr  r	  r   r   r   Ú	arg_delta	  s    
zDictCompiler.arg_deltac                 C   s,  t |d ƒ}t |ƒ}|| d }|| jkrˆt| jd | ƒ}g }tt |ƒ|ƒ}|dkrXq†|d|… }|  |¡}	| |	¡ ||d… }q@n dg| }
dg| }d}d}||k ræ|| d }|| |
|< |}|| dd… ||< |d7 }q¤|
}|D ]}| |¡ qîdd„ |D ƒ}| t|ƒ¡ | tt	ƒ¡ |S )a'  A delta list with blend lists has to be *all* blend lists.

		The value is a list is arranged as follows::

			[
				[V0, d0..dn]
				[V1, d0..dn]
				...
				[Vm, d0..dn]
			]

		``V`` is the absolute coordinate value from the default font, and ``d0-dn``
		are the delta values from the *n* regions. Each ``V`` is an absolute
		coordinate from the default font.

		We want to return a list::

			[
				[v0, v1..vm]
				[d0..dn]
				...
				[d0..dn]
				numBlends
				blendOp
			]

		where each ``v`` is relative to the previous default font value.
		r   r   Nc                 S   s   g | ]}t |ƒ‘qS r   r  rh  r   r   r   rj  l	  rN   z0DictCompiler.arg_delta_blend.<locals>.<listcomp>)
r4   ÚmaxBlendStackr1   Úminr  rå   r5   r  r   r  )r   rˆ   Z
numMastersZ	numBlendsZnumStackZnumBlendValuesrã   ZnumValZvalListZout1Z	firstListZ	deltaListr  ZprevValÚdefaultValueZrelValueListrm  r   r   r   r  +	  s<    





zDictCompiler.arg_delta_blend)N)r   r   r   r  r   rÁ   r   r†   r�   r
  r  r  r  r  r   r   r   r   r   Ë  s   

r   c                 C   s"   t | tƒrt | ¡S t | ¡S d S r   )rq   re  r   ZencodeFloatr  )r	  r   r   r   r  r	  s    

r  c                   @   s   e Zd ZeeƒZdd„ ZdS )ÚTopDictCompilerc                 C   sú  | j }g }| jjd u r¬t| jdƒrr| jjrrt| jdƒr<d }nt| jjƒ}|d u rh| t|| jj| ƒ¡ n
|| jd< t| jdƒrÔ| jj	rÔ| jj	}t
|tƒsÔ| t||| ƒ¡ n(t| jdƒrÔ| jj}t|| ƒ}| |¡ t| jdƒ�r4| jj}t|ƒdk�r | jj}	| jjD ]}
| |	|
 j¡ �qt|| ƒ}| |¡ t| jdƒ�r†g }| jj}	| jjD ]}
| |	|
 ¡ �qVt||| |d�}| |¡ t| jd	ƒ�r¾| jj || ¡}| |¡ | | |¡¡ t| jd
ƒ�rö| jj || ¡}| |¡ | | |¡¡ |S )Nry   r†  r¯  r”   r)  r   r¨   rO   r˜   r•   )rP   r’  rj   r*   ry   rœ  r5   r�  r¥   r¯  rq   rr   r¬  r”   rÊ  r)  r4   r¨   r7  rÉ  rõ   r˜   r|   rå   r€   r•   )r   rc   rP   r„   ZcharsetCoderÙ   rË  ZvarStoreCompr  r±   ru   ZfdSelectCompr    ZcharStringsCompZfdArrayIndexCompÚprivCompr   r   r   r€   }	  sX    





ÿ


zTopDictCompiler.getChildrenN)r   r   r   rM  r¤   r  r€   r   r   r   r   r  y	  s   r  c                       s.   e Zd ZeeƒZd‡ fdd„	Zdd„ Z‡  ZS )ÚFontDictCompilerNc           	         sº   t t| ƒj||||d� g }| j}tt|jƒt|jƒ ƒD ]^}||jv rT| 	|¡ q:|j
 |¡}|d ur~|j| }| ||¡}t||d ƒ|kr:| 	|¡ q:|r¶t dd t|ƒ¡ ¡ d S )NrO   z:Some CFF FDArray/FontDict keys were ignored upon compile: rb  )rç   r  r   r’  r8  Úsetr  r£   r¥   r5   r  rw  rV   rµ   rÂ   Úwarningrs  )	r   r’  rc   rÑ   rP   ÚignoredNamesru   rI  rJ  rè   r   r   r   ¹	  s$    

ÿÿzFontDictCompiler.__init__c                 C   s>   g }t | jdƒr:| jj || ¡}| |¡ | | |¡¡ |S ©Nr•   )r*   r’  r•   r|   r5   rå   r€   )r   rc   r„   r  r   r   r   r€   Ù	  s    
zFontDictCompiler.getChildren)N)	r   r   r   rM  r¤   r  r   r€   rë   r   r   rè   r   r  ¶	  s    r  c                   @   s(   e Zd ZeZeeƒZdd„ Zdd„ Z	dS )ÚPrivateDictCompilerc                 C   s"   || }||f| j jd< || _d S r  )rÑ   r¥   rÉ   )r   rÉ   rË   r  r   r   r   rÁ   ç	  s    zPrivateDictCompiler.setPosc                 C   s*   g }t | jdƒr&| | jj || ¡¡ |S rô   )r*   r’  r5   r³   r|   )r   rc   r„   r   r   r   r€   ì	  s    zPrivateDictCompiler.getChildrenN)
r   r   r   ÚmaxStackLimitr  rM  r®   r  rÁ   r€   r   r   r   r   r  â	  s   r  c                   @   sH   e Zd Zddd„Zdd„ Zdd„ Zddd	„Zd
d„ Zdd„ Zdd„ Z	dS )ÚBaseDictNc                 C   sd   |d u |d u ksJ ‚i | _ g | _|| _|d u r2d S || _|| _|d ur`t td| jj|¡ || _	d S )Nr÷   )
r¥   Ú	skipNamesrc   rû   rh   rÂ   rÃ   ré   r   rÝ   )r   rc   rh   rÝ   rP   r   r   r   r   õ	  s    zBaseDict.__init__c                 C   sF   t   td| jjt|ƒ¡ |  | j| ¡}| |¡ | ¡ | _	|  
¡  d S )Nz    length %s is %d)rÂ   rÃ   ré   r   r4   ÚdecompilerClassrc   rk   ZgetDictr¥   ÚpostDecompile)r   r¾   Údecr   r   r   rk   
  s
    

zBaseDict.decompilec                 C   s   d S r   r   rl   r   r   r   r   	
  s    zBaseDict.postDecompilec                 C   s   | j | |||d�S r  r	  r  r   r   r   r|   
  s    zBaseDict.getCompilerc                 C   sˆ   |d d… |dd …   kr$dkr0n nt |ƒ‚| j |d ¡}|d u rR| j |¡}|d u rbt |ƒ‚| j| }| | |¡}t| ||ƒ |S )Nr#   éþÿÿÿÚ__)r€  r¥   rw  r  r  rV   r(   )r   ru   rˆ   rJ  r   r   r   Ú__getattr__
  s    (
zBaseDict.__getattr__c                 C   sŠ   | j D ]F}|| jv rqt| |d ƒ}|d u r4|dkr4q| j| }| |||¡ qt| jƒt| j ƒ }|r†| dd t	|ƒ¡ ¡ | 
¡  d S )Nry   zsome keys were ignored: %srb  )r£   r  rµ   r  rU  r  r¥   r  rs  r8  r�   )r   r‘   ru   rˆ   rJ  r  r   r   r   r�    
  s    



ÿzBaseDict.toXMLc                 C   s*   | j | }| |||| ¡}t| ||ƒ d S r   )r  r%  r(   )r   ru   r›   rœ   rJ  rˆ   r   r   r   r—   8
  s    
zBaseDict.fromXML)NNNN)N)
r   r   r   r   rk   r   r|   r$  r�   r—   r   r   r   r   r  ó	  s   

r  c                       sj   e Zd ZdZeeƒZeeƒZe	Z
eeƒZeZd‡ fdd„	Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z‡  ZS )r–   a  The ``TopDict`` represents the top-level dictionary holding font
	information. CFF2 tables contain a restricted set of top-level entries
	as described `here <https://docs.microsoft.com/en-us/typography/opentype/spec/cff2#7-top-dict-data>`_,
	but CFF tables may contain a wider range of information. This information
	can be accessed through attributes or through the dictionary returned
	through the ``rawDict`` property:

	.. code:: python

		font = tt["CFF "].cff[0]
		font.FamilyName
		# 'Linux Libertine O'
		font.rawDict["FamilyName"]
		# 'Linux Libertine O'

	More information is available in the CFF file's private dictionary, accessed
	via the ``Private`` property:

	.. code:: python

		tt["CFF "].cff[0].Private.BlueValues
		# [-15, 0, 515, 515, 666, 666]
	
	Nc                    s^   t t| ƒj||||d� || _|| _|rFttƒ| _|ƒ | _t	tƒ| _
nttƒ| _t	tƒ| _
d S r  )rç   r–   r   rj   rg   rO  r¢   r  ry   r¡   r£   r¤   )r   rc   rh   rÝ   rg   rj   rP   rè   r   r   r   ^
  s    

zTopDict.__init__c                 C   s   | j S )z.Returns a list of glyph names in the CFF font.)ry   rl   r   r   r   re   k
  s    zTopDict.getGlyphOrderc                 C   sH   | j  d¡}|d u rd S | j |¡ | jr8t| jƒ| _nt| jƒ| _d S rö   )r¥   rw  rh   r[   rû   rü   r.  rý   )r   rÝ   r   r   r   r   o
  s    zTopDict.postDecompilec                 C   sR   t | dƒr|  ¡  t | dƒr$dg| _t | dƒr8t | dƒsBg d¢| _t | |¡ d S )Nr¨   r†  r¯  )ræ  rè  rê  rì  )r*   ÚdecompileAllCharStringsr  r  r�   )r   r‘   r   r   r   r�   z
  s    


zTopDict.toXMLc                 C   sD   t | j ¡ ƒD ]0\}}z| ¡  W q   t d|¡ ‚ Y q0 qd S )NzError in charstring %s)Ú	enumerater¨   ro   rk   rÂ   Úerror)r   r  r6   r   r   r   r%  †
  s    zTopDict.decompileAllCharStringsc                 C   sp   d }| j  ¡ D ]0}| | j ¡}|d ur|d ur:t||ƒ}q|}q|d u r^| jd d d … | _ntt|ƒƒ| _d S )NrÞ  )r¨   ro   Z
calcBoundsr   r  rÞ  r]   r   )r   ZfontBBoxr6   Zboundsr   r   r   rz   �
  s    zTopDict.recalcFontBBox)NNNNNN)r   r   r   r½   rO  r¤   r  rP  r  r  r
  r¡   r£   rý  r  r   re   r   r�   r%  rz   rë   r   r   rè   r   r–   >
  s     ÿ	r–   c                       sH   e Zd Zi ZeeƒZeZg d¢Z	dgZ
eZd‡ fdd„	Zdd„ Z‡  ZS )	r«   )rÖ  rÛ  r×  r•   r•   Nc                    s,   t t| ƒj||||d� || _|  |¡ d S r  )rç   r«   r   r™   r¬   )r   rc   rh   rÝ   rg   rP   r™   rè   r   r   r   Â
  s    zFontDict.__init__c                 C   s&   |r| j | _d| _n| j| _d| _d S )NTF)Ú	orderCFF2r£   rû   ÚorderCFFr¿   r   r   r   r¬   È
  s
    zFontDict.setCFF2)NNNNNN)r   r   r   r  rP  r¤   r  r  r
  r)  r(  rý  r  r   r¬   rë   r   r   rè   r   r«   Ÿ
  s     ÿr«   c                       sT   e Zd ZeeƒZeeƒZeeƒZ	e
ZeZd‡ fdd„	Zedd„ ƒZd	dd„Z‡  ZS )
r  Nc                    s\   t t| ƒj||||d� || _|rDttƒ| _ttƒ| _d  | _	| _
nttƒ| _ttƒ| _d S r  )rç   r  r   r™   rO  r­   r  r¡   r£   rû  rú  r®   )r   rc   rh   rÝ   rP   r™   rè   r   r   r   Ù
  s    


zPrivateDict.__init__c                 C   s   | j S r   )rû   rl   r   r   r   r2   ç
  s    zPrivateDict.in_cff2c                 C   s.   |d u rt | dƒr| j}nd}| j |¡}|S )Nrõ  r   )r*   rõ  r™   r(  )r   Úvir'  r   r   r   r(  ë
  s    
zPrivateDict.getNumRegions)NNNNN)N)r   r   r   rO  r®   r  rP  r  r¡   r£   rÿ  r  r  r
  r   Úpropertyr2   r(  rë   r   r   rè   r   r  Ò
  s     ÿ
r  c                   @   sJ   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S )rb   zSID -> string mapping.Nc                 C   s.   |d u rg }ndd„ t |dd�D ƒ}|| _d S )Nc                 S   s   g | ]}t |d d�‘qS )r×   rØ   rI   rJ   r   r   r   rj  þ
  s   ÿz+IndexedStrings.__init__.<locals>.<listcomp>FrO   )r^   rc   )r   rh   rc   r   r   r   r   ú
  s    
þzIndexedStrings.__init__c                 C   s   t | d | dd�S )NFrO   )rß   rl   r   r   r   r|     s    zIndexedStrings.getCompilerc                 C   s
   t | jƒS r   )r4   rc   rl   r   r   r   rm     s    zIndexedStrings.__len__c                 C   s"   |t k rt| S | j|t   S d S r   )ÚcffStandardStringCountÚcffStandardStringsrc   )r   r¦  r   r   r   rv   
  s    zIndexedStrings.__getitem__c                 C   sn   t | dƒs|  ¡  t|dd�}|tv r0t| }n:|| jv rF| j| }n$t| jƒt }| j |¡ || j|< |S )NÚstringMappingr×   rØ   )	r*   ÚbuildStringMappingr
   ÚcffStandardStringMappingr.  r4   rc   r,  r5   )r   rL   r¦  r   r   r   rŸ    s    



zIndexedStrings.getSIDc                 C   s   | j S r   rà   rl   r   r   r   Ú
getStrings  s    zIndexedStrings.getStringsc                 C   s2   i | _ tt| jƒƒD ]}|t | j | j| < qd S r   )r.  rÿ   r4   rc   r,  rB   r   r   r   r/  !  s    z!IndexedStrings.buildStringMapping)N)r   r   r   r½   r   r|   rm   rv   rŸ  r1  r/  r   r   r   r   rb   ö
  s   

rb   (‡  r‘  ÚspaceÚexclamÚquotedblÚ
numbersignÚdollarÚpercentÚ	ampersandÚ
quoterightÚ	parenleftÚ
parenrightÚasteriskÚplusÚcommaÚhyphenÚperiodÚslashÚzeroÚoneÚtwoÚthreeÚfourÚfiveÚsixÚsevenÚeightÚnineÚcolonÚ	semicolonÚlessÚequalÚgreaterÚquestionÚatÚArH   ÚCÚDÚEÚFÚGÚHÚIÚJÚKÚLÚMÚNÚOÚPÚQÚRÚSÚTÚUÚVÚWÚXÚYÚZÚbracketleftÚ	backslashÚbracketrightÚasciicircumÚ
underscoreÚ	quoteleftÚaÚbr¸   rF  ÚeÚfr·   Úhr  ÚjÚkrN  r¾  r�  ÚoÚpÚqÚrrL   ÚtÚur  ÚwÚxÚyÚzÚ	braceleftÚbarÚ
bracerightÚ
asciitildeÚ
exclamdownÚcentÚsterlingÚfractionÚyenÚflorinÚsectionÚcurrencyÚquotesingleÚquotedblleftÚguillemotleftÚguilsinglleftÚguilsinglrightÚfiÚflÚendashÚdaggerÚ	daggerdblÚperiodcenteredÚ	paragraphÚbulletÚquotesinglbaseÚquotedblbaseÚquotedblrightÚguillemotrightÚellipsisÚperthousandÚquestiondownÚgraveÚacuteÚ
circumflexÚtildeÚmacronÚbreveÚ	dotaccentÚdieresisÚringÚcedillaÚhungarumlautÚogonekÚcaronÚemdashÚAEÚordfeminineÚLslashÚOslashÚOEÚordmasculineÚaeÚdotlessiÚlslashÚoslashÚoeÚ
germandblsÚonesuperiorÚ
logicalnotÚmuÚ	trademarkÚEthÚonehalfÚ	plusminusÚThornÚ
onequarterÚdivideÚ	brokenbarÚdegreeÚthornÚthreequartersÚtwosuperiorÚ
registeredÚminusÚethÚmultiplyÚthreesuperiorÚ	copyrightÚAacuteÚAcircumflexÚ	AdieresisÚAgraveÚAringÚAtildeÚCcedillaÚEacuteÚEcircumflexÚ	EdieresisÚEgraveÚIacuteÚIcircumflexÚ	IdieresisÚIgraveÚNtildeÚOacuteÚOcircumflexÚ	OdieresisÚOgraveÚOtildeÚScaronÚUacuteÚUcircumflexÚ	UdieresisÚUgraveÚYacuteÚ	YdieresisÚZcaronÚaacuteÚacircumflexÚ	adieresisÚagraveÚaringÚatildeÚccedillaÚeacuteÚecircumflexÚ	edieresisÚegraveÚiacuteÚicircumflexÚ	idieresisÚigraveÚntildeÚoacuteÚocircumflexÚ	odieresisÚograveÚotildeÚscaronÚuacuteÚucircumflexÚ	udieresisÚugraveÚyacuteÚ	ydieresisÚzcaronÚexclamsmallÚHungarumlautsmallÚdollaroldstyleÚdollarsuperiorÚampersandsmallÚ
AcutesmallÚparenleftsuperiorÚparenrightsuperiorÚtwodotenleaderÚonedotenleaderÚzerooldstyleÚoneoldstyleÚtwooldstyleÚthreeoldstyleÚfouroldstyleÚfiveoldstyleÚsixoldstyleÚsevenoldstyleÚeightoldstyleÚnineoldstyleÚcommasuperiorÚthreequartersemdashÚperiodsuperiorÚquestionsmallÚ	asuperiorÚ	bsuperiorÚcentsuperiorÚ	dsuperiorÚ	esuperiorÚ	isuperiorÚ	lsuperiorÚ	msuperiorÚ	nsuperiorÚ	osuperiorÚ	rsuperiorÚ	ssuperiorÚ	tsuperiorÚffÚffiÚfflÚparenleftinferiorÚparenrightinferiorÚCircumflexsmallÚhyphensuperiorÚ
GravesmallÚAsmallÚBsmallÚCsmallÚDsmallÚEsmallÚFsmallÚGsmallÚHsmallÚIsmallÚJsmallÚKsmallÚLsmallÚMsmallÚNsmallÚOsmallÚPsmallÚQsmallÚRsmallÚSsmallÚTsmallÚUsmallÚVsmallÚWsmallÚXsmallÚYsmallÚZsmallÚcolonmonetaryÚ	onefittedÚrupiahÚ
TildesmallÚexclamdownsmallÚcentoldstyleÚLslashsmallÚScaronsmallÚZcaronsmallÚDieresissmallÚ
BrevesmallÚ
CaronsmallÚDotaccentsmallÚMacronsmallÚ
figuredashÚhypheninferiorÚOgoneksmallÚ	RingsmallÚCedillasmallÚquestiondownsmallÚ	oneeighthÚthreeeighthsÚfiveeighthsÚseveneighthsÚonethirdÚ	twothirdsÚzerosuperiorÚfoursuperiorÚfivesuperiorÚsixsuperiorÚsevensuperiorÚeightsuperiorÚninesuperiorÚzeroinferiorÚoneinferiorÚtwoinferiorÚthreeinferiorÚfourinferiorÚfiveinferiorÚsixinferiorÚseveninferiorÚeightinferiorÚnineinferiorÚcentinferiorÚdollarinferiorÚperiodinferiorÚcommainferiorÚAgravesmallÚAacutesmallÚAcircumflexsmallÚAtildesmallÚAdieresissmallÚ
AringsmallÚAEsmallÚCcedillasmallÚEgravesmallÚEacutesmallÚEcircumflexsmallÚEdieresissmallÚIgravesmallÚIacutesmallÚIcircumflexsmallÚIdieresissmallÚEthsmallÚNtildesmallÚOgravesmallÚOacutesmallÚOcircumflexsmallÚOtildesmallÚOdieresissmallÚOEsmallÚOslashsmallÚUgravesmallÚUacutesmallÚUcircumflexsmallÚUdieresissmallÚYacutesmallÚ
ThornsmallÚYdieresissmallz001.000z001.001z001.002z001.003ZBlackZBoldZBookZLightZMediumZRegularZRomanZSemiboldi‡  )år‘  r2  r3  r4  r5  r6  r7  r8  r9  r:  r;  r<  r=  r>  r?  r@  rA  rB  rC  rD  rE  rF  rG  rH  rI  rJ  rK  rL  rM  rN  rO  rP  rQ  rR  rS  rH   rT  rU  rV  rW  rX  rY  rZ  r[  r\  r]  r^  r_  r`  ra  rb  rc  rd  re  rf  rg  rh  ri  rj  rk  rl  rm  rn  ro  rp  rq  rr  rs  r¸   rF  rt  ru  r·   rv  r  rw  rx  rN  r¾  r�  ry  rz  r{  r|  rL   r}  r~  r  r  r€  r�  r‚  rƒ  r„  r…  r†  r‡  rˆ  r‰  rŠ  r‹  rŒ  r�  rŽ  r�  r�  r‘  r’  r“  r”  r•  r–  r—  r˜  r™  rš  r›  rœ  r�  rž  rŸ  r   r¡  r¢  r£  r¤  r¥  r¦  r§  r¨  r©  rª  r«  r¬  r­  r®  r¯  r°  r±  r²  r³  r´  rµ  r¶  r·  r¸  r¹  rº  r»  r¼  r½  r¾  r¿  rÀ  rÁ  rÂ  rÃ  rÄ  rÅ  rÆ  rÇ  rÈ  rÉ  rÊ  rË  rÌ  rÍ  rÎ  rÏ  rÐ  rÑ  rÒ  rÓ  rÔ  rÕ  rÖ  r×  rØ  rÙ  rÚ  rÛ  rÜ  rÝ  rÞ  rß  rà  rá  râ  rã  rä  rå  ræ  rç  rè  ré  rê  rë  rì  rí  rî  rï  rð  rñ  rò  ró  rô  rõ  rö  r÷  rø  rù  rú  rû  rü  rý  rþ  rÿ  r   r  r  r  r  r  r  r  r  r	  r
  r  éå   )¦r‘  r2  r  r  r  r  r  r  r  r  r  r  r>  r?  r@  rŠ  r  r  r  r  r  r  r  r  r  r  rL  rM  r   r!  r"  r#  r$  r%  r&  r'  r(  r)  r*  r+  r,  r-  r.  r/  r0  r1  r”  r•  r2  r3  r4  r5  r6  r7  r8  r9  r:  r;  r<  r=  r>  r?  r@  rA  rB  rC  rD  rE  rF  rG  rH  rI  rJ  rK  rL  rM  rN  rO  rP  rQ  rR  rS  rT  rU  rV  rW  rX  rY  rZ  r[  r\  r]  r^  r_  r`  ra  rb  rc  rd  re  rÅ  rÂ  rÊ  rf  rg  rh  ri  rj  rk  rl  rm  r½  rË  rÐ  rn  ro  rp  rq  rr  rs  rt  ru  rv  rw  rx  ry  rz  r{  r|  r}  r~  r  r€  r�  r‚  rƒ  r„  r…  r†  r‡  rˆ  r‰  rŠ  r‹  rŒ  r�  rŽ  r�  r�  r‘  r’  r“  r”  r•  r–  r—  r˜  r™  rš  r›  rœ  r�  rž  rŸ  r   r¡  é¦   )Wr‘  r2  r  r  r  r  r  r  r>  r?  r@  rŠ  r  r  r  r  r  r  r  r  r  r  rL  rM  r   r!  r"  r$  r%  r&  r'  r(  r)  r*  r+  r,  r-  r.  r/  r0  r1  r”  r•  r2  r3  r4  r5  r7  rS  rT  rU  rX  ra  rb  rÅ  rÂ  rÊ  rg  rh  ri  rj  rk  rl  rm  r½  rË  rÐ  rn  ro  rp  rq  rr  rs  rt  ru  rv  rw  rx  ry  rz  r{  r|  r}  r~  r  r€  r�  éW   )‰r½   ZfontTools.miscr   r   ZfontTools.misc.arrayToolsr   r   ZfontTools.misc.textToolsr   r   r   r	   r
   r   ZfontTools.ttLibr   ZfontTools.ttLib.tables.otBaser   r   ZfontTools.ttLib.tablesr   r   Úior   rY   Úloggingrc  rÃ   Ú	getLoggerr   rÂ   rU   r  Ú	Exceptionr   r   r   ÚobjectrC   r{   rÆ   rÎ   rß   rÄ   rì   rï   ró   rõ   r^   rf   r  r`   r§   r  r)  r¨   rþ   rý   rü   rÜ   rÛ   rÚ   rA  rC  rD  rK  rM  r¡   rO  rP  rQ  rX  r^  rf  rn  ro  rz  r{  r~  r‚  rƒ  r…  r�  rœ  rž  r   r“  r”  rˆ  r‰  r¬  r°  rµ  r¶  r­  r®  rÀ  rÁ  rÃ  rÅ  rÇ  rÈ  rÉ  rÊ  rÌ  r¤   r¢   rt  r  r®   r­   rü  ZDictDecompilerrý  rÿ  r   r  r  r  r  r  r–   r«   r  rb   r-  r,  r4   r0  rÿ   Z_ir‹  r˜  rŒ  r™  r�  rš  r   r   r   r   Ú<module>   sš   

K  j1K$)	Hd42@ /=%=
""Û*ùéï (=,Ka3$4
A
 
"
