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   Z/var/www/html/optinet_system/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    