a
    w=ic  ã                   @   sD   d Z ddlmZ ddlmZmZ dd„ Zdd„ ZG dd	„ d	eƒZd
S )z0ttLib.macUtils.py -- Various Mac-specific stuff.é    )ÚBytesIO)ÚResourceReaderÚResourceErrorc                 C   s<   z t | ƒ}| d¡}| ¡  |W S  ty6   g  Y S 0 dS )z;Determine whether a file has a 'sfnt' resource fork or not.ÚsfntN)r   Z
getIndicesÚcloser   )ÚpathÚreaderÚindices© r
   úi/home/droni/.local/share/virtualenvs/DPS-5Je3_V2c/lib/python3.9/site-packages/fontTools/ttLib/macUtils.pyÚgetSFNTResIndices   s    
r   c                 C   s`   ddl m} g }t| ƒ}|s.| | | ¡¡ n.|D ]}| | | |¡¡ q2|s\| d|  ¡‚|S )züGiven a pathname, return a list of TTFont objects. In the case
	of a flat TTF/OTF file, the list will contain just one font object;
	but in the case of a Mac font suitcase it will contain as many
	font objects as there are sfnt resources in the file.
	r   ©ÚttLibzno fonts found in file '%s')Ú	fontToolsr   r   ÚappendZTTFontÚ
TTLibError)r   r   ZfontsZsfntsÚindexr
   r
   r   ÚopenTTFonts   s    r   c                       s    e Zd ZdZ‡ fdd„Z‡  ZS )ÚSFNTResourceReaderz3Simple read-only file wrapper for 'sfnt' resources.c                    sx   ddl m} t|ƒ}t|tƒr,| d|¡}n| d|¡}|d u rN| d| ¡‚| ¡  || _	t
t| ƒ |j¡ || _d S )Nr   r   r   zsfnt resource not found: %s)r   r   r   Ú
isinstanceÚstrZgetNamedResourceZgetIndResourcer   r   ÚrsrcÚsuperr   Ú__init__ÚdataÚname)Úselfr   Zres_name_or_indexr   r   r   ©Ú	__class__r
   r   r   (   s    
zSFNTResourceReader.__init__)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ú__classcell__r
   r
   r   r   r   $   s   r   N)	r"   Úior   ZfontTools.misc.macResr   r   r   r   r   r
   r
   r
   r   Ú<module>   s
   