o
    ¼ÇhÉ  ã                   @   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   zt | ƒ}| d¡}| ¡  |W S  ty   g  Y S w )z;Determine whether a file has a 'sfnt' resource fork or not.Úsfnt)r   Ú
getIndicesÚcloser   )ÚpathÚreaderÚindices© r   úl/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/fontTools/ttLib/macUtils.pyÚgetSFNTResIndices   s   
ÿr   c                 C   sb   ddl m} g }t| ƒ}|s| | | ¡¡ |S |D ]}| | | |¡¡ q|s/| d|  ¡‚|S )a  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   ÚappendÚTTFontÚ
TTLibError)r   r   ÚfontsÚ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 r'| d| ¡‚| ¡  || _	t
t| ƒ |j¡ || _d S )Nr   r   r   zsfnt resource not found: %s)r   r   r   Ú
isinstanceÚstrÚgetNamedResourceÚgetIndResourcer   r   ÚrsrcÚsuperr   Ú__init__ÚdataÚname)Úselfr   Ú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   ÚfontTools.misc.macResr   r   r   r   r   r   r   r   r   Ú<module>   s    