B
    0uf  ã               @   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   s8   yt | ƒ}| d¡}| ¡  |S  tk
r2   g S X dS )z;Determine whether a file has a 'sfnt' resource fork or not.ÚsfntN)r   Z
getIndicesÚcloser   )ÚpathÚreaderÚindices© r
   úZ/home/ankuromar296_gmail_com/myenv/lib/python3.7/site-packages/fontTools/ttLib/macUtils.pyÚgetSFNTResIndices   s    
r   c             C   sd   ddl m} g }t| ƒ}|s.| | | ¡¡ n2x|D ]}| | | |¡¡ q4W |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 k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
   