§
    èƒñj$  ã                   óÄ   — d dl mZ d dlmZ d dlZd dlZd dl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  ej        e¦  «        Zed„ ¦   «         Z G d	„ d
e¦  «        ZdS )é    )ÚTTFont)ÚBytesION)Úcontextmanager)ÚTTC_V1ÚTTC_V1_1ÚTTC_V2ÚTTC_V2_1ÚreadTTCHeaderÚwriteTTCHeader)Útable_D_S_I_G_)ÚtimestampNowc              #   óú   K  — t          ¦   «         }g }	 | D ]=}|j        r4d|v r0|                     ||j        f¦  «         ||d         _        d|_        Œ>|V — |D ]\  }}||_        ŒdS # |D ]\  }}||_        Œw xY w)a,  Pin a single ``head.modified`` timestamp across an iterable of TTFonts.

    When several fonts are saved together with ``recalcTimestamp=True``, each
    one restamps its own ``head`` table via ``timestampNow()``, whose
    granularity is one second. If the wall clock ticks between two fonts'
    ``head.compile()`` calls they get different ``modified`` values, which
    defeats byte-identical table sharing (``shareTables=True``) and makes the
    saved size non-deterministic.

    This reads ``timestampNow()`` once (so ``SOURCE_DATE_EPOCH`` is still
    honored) and applies it to every font that would have recalculated its own
    timestamp, suppressing the per-font restamp for the duration. Each font's
    ``recalcTimestamp`` flag is restored on exit, even if the body raises; the
    pinned ``modified`` value is left in place, matching a normal recalc save.
    Fonts with ``recalcTimestamp`` falsy, or without a ``head`` table, are left
    untouched (their ``head`` is not even loaded).

    See https://github.com/fonttools/fonttools/issues/4110.
    ÚheadFN)r   ÚrecalcTimestampÚappendÚmodified)ÚfontsÚnowÚrestoreÚfontr   s        ú[/data/share/cad/hardware/.venv/lib/python3.11/site-packages/fontTools/ttLib/ttCollection.pyÚ_sharedModifiedTimestampr      sÇ   è è € õ* ‰.Œ.€CØ€Gð3Øð 	-ð 	-ˆDØÔ#ð -¨°$¨¨ð —’  dÔ&:Ð;Ñ<Ô<Ð<Ø(+��V”Ô%Ø',�Ô$øØˆ	ˆ	ˆ	à%,ð 	3ð 	3Ñ!ˆD�/Ø#2ˆDÔ Ð ð	3ð 	3ø Wð 	3ð 	3Ñ!ˆD�/Ø#2ˆDÔ Ð ð	3øøøs   ”AA) Á)A:c                   óZ   — e Zd ZdZdd„Zd„ Zd„ Zd„ Zdd	„Zdd„Z	d„ Z
d„ Zd„ Zd„ Zd„ ZdS )ÚTTCollectionaï  Object representing a TrueType Collection / OpenType Collection.
    The main API is self.fonts being a list of TTFont instances.

    For TTC versions 1.1 and 2.1, ``fonts`` contains the preferred extended
    font list and ``legacyFonts`` contains the compatibility font list. To
    write one of these versions, set both attributes; FontTools does not derive
    legacy fonts automatically.

    If shareTables is True, then different fonts in the collection
    might point to the same table object if the data for the table was
    the same in the font file.  Note, however, that this might result
    in suprises and incorrect behavior if the different fonts involved
    have different GlyphOrder.  Use only if you know what you are doing.
    NFc                 óL  — g x}| _         |€d S d|vs
J |¦   «         ‚d}t          |d¦  «        st          |d¦  «        }d}|ri nd }t          |¦  «        }t	          |d|j        ¦  «        }t          |¦  «        D ]'}	t          |f|	|dœ|¤Ž}
|                     |
¦  «         Œ(t          |d¦  «        rIg | _	        t          |j        ¦  «        D ]-}	t          |f|	|ddœ|¤Ž}
| j	                             |
¦  «         Œ.|j
        t          t          fv red | _        |j        d	k    rSt          d
¦  «        | _        |                     |j        d	¦  «         |                     |j        ¦  «        | j        _        |                     d¦  «        s|r|                     ¦   «          d S d S d S )NÚ
fontNumberFÚreadÚrbTÚ	numFonts2)r   Ú_tableCache)r   r    Ú_useLegacyTTCr   ÚDSIGÚlazy)r   ÚhasattrÚopenr
   ÚgetattrÚnumFontsÚranger   r   ÚlegacyFontsÚVersionr   r	   ÚdsigÚulDsigOffsetr   Úseekr   ÚulDsigLengthÚdataÚgetÚclose)ÚselfÚfileÚshareTablesÚkwargsr   ÚcloseStreamÚ
tableCacheÚheaderr'   Úir   s              r   Ú__init__zTTCollection.__init__I   sõ  € ØÐˆ�”
Øˆ<ØˆFà 6Ð)Ð)Ð)¨6Ñ)Ô)Ð)àˆÝ�t˜VÑ$Ô$ð 	Ý˜˜dÑ#Ô#ˆDØˆKà&Ð0�R�R¨Dˆ
å˜tÑ$Ô$ˆÝ˜6 ;°´Ñ@Ô@ˆÝ�x‘”ð 	ð 	ˆAÝ˜$ÐO¨1¸*ÐOÐOÈÐOÐOˆDØ�LŠL˜ÑÔÐÐå�6˜;Ñ'Ô'ð 
	.Ø!ˆDÔÝ˜6œ?Ñ+Ô+ð .ð .�ÝØðà Ø *Ø"&ð	ð ð
 ðð �ð Ô ×'Ò'¨Ñ-Ô-Ð-Ð-àŒ>�f¥hÐ/Ð/Ð/Ø/3ˆDŒIØÔ" aÒ'Ð'Ý*¨6Ñ2Ô2�”	Ø—	’	˜&Ô-¨qÑ1Ô1Ð1Ø!%§¢¨6Ô+>Ñ!?Ô!?�”	”ð �zŠz˜&Ñ!Ô!ð 	 kð 	Ø�JŠJ‰LŒLˆLˆLˆLð	ð 	ð 	ð 	ó    c                 ó   — | S ©N© ©r2   s    r   Ú	__enter__zTTCollection.__enter__x   s   € Øˆr;   c                 ó.   — |                       ¦   «          d S r=   )r1   )r2   ÚtypeÚvalueÚ	tracebacks       r   Ú__exit__zTTCollection.__exit__{   s   € Ø�
Š
‰Œˆˆˆr;   c                 ó’   — | j         D ]}|                     ¦   «          Œt          | dd¦  «        D ]}|                     ¦   «          Œd S )Nr)   r>   )r   r1   r&   )r2   r   s     r   r1   zTTCollection.close~   sV   € Ø”Jð 	ð 	ˆDØ�JŠJ‰LŒLˆLˆLÝ˜D -°Ñ4Ô4ð 	ð 	ˆDØ�JŠJ‰LŒLˆLˆLð	ð 	r;   Tc           	      ó²  — t          |d¦  «        sd}t          |d¦  «        }n|}t          ¦   «         }|ri nd}t          | d¦  «        }t          | d¦  «        r|rt          nt          }n|rt
          nt          }|r| j        ng }t          g |¢| j	        ¢¦  «        5  t          ||rt          |¦  «        nt          | j	        ¦  «        |t          | j	        ¦  «        ¬¦  «        }|r,|                     ¦   «         dt          | j	        ¦  «        z  z
  nd}	g }
|D ]V}|
                     |                     ¦   «         ¦  «         |                     ||¬¦  «         |                     d	d
¦  «         ŒWg }| j	        D ]V}|                     |                     ¦   «         ¦  «         |                     ||¬¦  «         |                     d	d
¦  «         ŒW	 ddd¦  «         n# 1 swxY w Y   |                     |¦  «         |rJ|                     t#          j        dt          |
¦  «        z  g|
¢R Ž ¦  «         |                     |	¦  «         |                     t#          j        dt          |¦  «        z  g|¢R Ž ¦  «         |t          t          fv �r	| j        ��t          | j        d¦  «        r| j        j        }n| j                             d¦  «        }|d|rt          |
¦  «        nt          |¦  «        z  z   }|                     d	d
¦  «         |                     ¦   «         }|                     |¦  «         |                     |¦  «         |                     d¦  «         |                     t#          j        dt          |¦  «        |¦  «        ¦  «         |r'|                     |                     ¦   «         ¦  «         |                     ¦   «          dS )z•Save the font to disk. Similarly to the constructor,
        the 'file' argument can be either a pathname or a writable
        file object.
        ÚwriteNÚwbr)   r+   )Úversionr   é   )r7   r   é   z>%dLr/   s   DSIGz>2L)r$   r%   r   r	   r   r   r   r)   r   r   r   ÚlenÚtellr   Ú_saver-   rH   ÚstructÚpackr+   r/   ÚcompileÚgetvaluer1   )r2   r3   r4   Úfinalr7   ÚhasLegacyFontsrJ   r)   Úoffsets_offsetÚoffsets2_offsetÚlegacyOffsetsr   Úoffsetsr/   Údsig_header_fields_offsetÚdsig_offsets                   r   ÚsavezTTCollection.save„   sñ  € õ
 �t˜WÑ%Ô%ð 	ØˆEÝ˜˜dÑ#Ô#ˆDˆDð ˆEÝ‘9”9ˆDà&Ð0�R�R¨Dˆ
õ !  }Ñ5Ô5ˆÝ�4˜Ñ Ô ð 	=Ø"0Ð<•h�hµfˆGˆGà"0Ð<•h�hµfˆGØ*8Ð@�dÔ&Ð&¸bˆõ &Ð&A¨Ð&A°d´jÐ&AÑBÔBð 	 ð 	 Ý+ØØ$2ÐG•�KÑ Ô Ð ½¸D¼J¹¼ØÝ˜dœj™/œ/ð	ñ ô ˆNð 6DÐM�—	’	‘”˜a¥# d¤j¡/¤/Ñ1Ñ1Ð1Èð ð ˆMØ#ð  ð  �Ø×$Ò$ T§Y¢Y¡[¤[Ñ1Ô1Ð1Ø—
’
˜4¨J�
Ñ7Ô7Ð7Ø—	’	˜!˜Q‘”��ØˆGØœ
ð  ð  �Ø—’˜tŸyšy™{œ{Ñ+Ô+Ð+Ø—
’
˜4¨J�
Ñ7Ô7Ð7Ø—	’	˜!˜Q‘”��ð ð!	 ð 	 ð 	 ñ 	 ô 	 ð 	 ð 	 ð 	 ð 	 ð 	 ð 	 øøøð 	 ð 	 ð 	 ð 	 ð* 	�	Š	�.Ñ!Ô!Ð!Øð 	'Ø�JŠJ•v”{ 6­C°Ñ,>Ô,>Ñ#>ÐOÀÐOÐOÐOÑPÔPÐPØ�IŠI�oÑ&Ô&Ð&Ø�
Š
•6”;˜v­¨G©¬Ñ4Ð?°wÐ?Ð?Ð?Ñ@Ô@Ð@à•v�xÐ(Ð(Ñ(¨T¬YÑ-Bå�t”y &Ñ)Ô)ð /Ø”y”~��à”y×(Ò(¨Ñ.Ô.�ð )7¸Ø&4ÐF•�MÑ"Ô"Ð"½#¸g¹,¼,ñ:ñ )Ð%ð �IŠI�a˜‰OŒOˆOØŸ)š)™+œ+ˆKà�JŠJ�tÑÔÐà�IŠIÐ/Ñ0Ô0Ð0à�JŠJ�wÑÔÐà�JŠJ•v”{ 5­#¨d©)¬)°[ÑAÔAÑBÔBÐBàð 	)Ø�KŠK˜Ÿš™œÑ(Ô(Ð(Ø�
Š
‰Œˆˆˆs   ÂD4GÇG#Ç&G#ú
c                 ó0  — ddl m} |                     ||¬¦  «        }|rNddlm} d                     |                     d¦  «        d d…         ¦  «        }|                     d|¬¦  «         n|                     d¦  «         |                     ¦   «          |                     ¦   «          | j	        D ]&} |j
        |fd	d
i|¤Ž |                     ¦   «          Œ'|                     d¦  «         |                     ¦   «          |                     ¦   «          d S )Nr   )Ú	xmlWriter)Ú
newlinestr)rJ   ú.rL   ÚttCollection)ÚttLibVersionÚwriteVersionF)ÚfontTools.miscr_   Ú	XMLWriterÚ	fontToolsrJ   ÚjoinÚsplitÚbegintagÚnewliner   Ú_saveXMLÚendtagr1   )	r2   Ú
fileOrPathr`   rd   r5   r_   ÚwriterrJ   r   s	            r   ÚsaveXMLzTTCollection.saveXMLÔ   s-  € Ø,Ð,Ð,Ð,Ð,Ð,à×$Ò$ Z¸JÐ$ÑGÔGˆàð 	,Ø)Ð)Ð)Ð)Ð)Ð)à—h’h˜wŸ}š}¨SÑ1Ô1°"°1°"Ô5Ñ6Ô6ˆGØ�OŠO˜N¸ˆOÑAÔAÐAÐAà�OŠO˜NÑ+Ô+Ð+Ø�ŠÑÔÐØ�ŠÑÔÐà”Jð 	ð 	ˆDØˆDŒM˜&Ð?Ð?¨uÐ?¸Ð?Ð?Ð?Ø�NŠNÑÔÐÐà�Š�nÑ%Ô%Ð%Ø�ŠÑÔÐà�Š‰Œˆˆˆr;   c                 ó   — | j         |         S r=   ©r   ©r2   Úitems     r   Ú__getitem__zTTCollection.__getitem__ì   ó   € ØŒz˜$ÔÐr;   c                 ó   — || j         |<   d S r=   rr   )r2   rt   rC   s      r   Ú__setitem__zTTCollection.__setitem__ï   s   € Ø ˆŒ
�4ÑÐÐr;   c                 ó   — | j         |         S r=   rr   rs   s     r   Ú__delitem__zTTCollection.__delitem__ò   rv   r;   c                 ó*   — t          | j        ¦  «        S r=   )rM   r   r?   s    r   Ú__len__zTTCollection.__len__õ   s   € Ý�4”:‰ŒÐr;   c                 ó*   — t          | j        ¦  «        S r=   )Úiterr   r?   s    r   Ú__iter__zTTCollection.__iter__ø   s   € Ý�D”JÑÔÐr;   )NF)T)r]   T)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r:   r@   rE   r1   r\   rp   ru   rx   rz   r|   r   r>   r;   r   r   r   9   sØ   € € € € € ðð ð-ð -ð -ð -ð^ð ð ðð ð ðð ð ðNð Nð Nð Nð`ð ð ð ð0 ð  ð  ð!ð !ð !ð ð  ð  ðð ð ð ð  ð  ð  ð  r;   r   )ÚfontTools.ttLib.ttFontr   Úior   rP   ÚloggingÚ
contextlibr   ÚfontTools.ttLib.sfntr   r   r   r	   r
   r   ÚfontTools.ttLib.tables.D_S_I_G_r   ÚfontTools.misc.timeToolsr   Ú	getLoggerr€   Úlogr   Úobjectr   r>   r;   r   ú<module>rŽ      s/  ðØ )Ð )Ð )Ð )Ð )Ð )Ø Ð Ð Ð Ð Ð Ø €€€Ø €€€Ø %Ð %Ð %Ð %Ð %Ð %ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ;Ð :Ð :Ð :Ð :Ð :Ø 1Ð 1Ð 1Ð 1Ð 1Ð 1à€gÔ˜Ñ!Ô!€ð ð!3ð !3ñ „ð!3ðH@ ð @ ð @ ð @ ð @ �6ñ @ ô @ ð @ ð @ ð @ r;   