o
    Ae                     @   s,  d dl Z G dd deZG dd deZG dd deZG dd	 d	eZG d
d deZG dd deZG dd deZG dd deZ	G dd deZ
G dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG d d! d!eZG d"d# d#eZG d$d% d%eZdS )&    Nc                   @      e Zd ZdZdS )VarLibErrorz%Base exception for the varLib module.N__name__
__module____qualname____doc__ r	   r	   X/home/www/facesmatcher.com/pyenv/lib/python3.10/site-packages/fontTools/varLib/errors.pyr          r   c                   @   r   )VarLibValidationErrorz>Raised when input data is invalid from varLib's point of view.Nr   r	   r	   r	   r
   r      r   r   c                   @   sN   e Zd ZdZdddZedd Zdd Zed	d
 Zedd Z	dd Z
dS )VarLibMergeErrorz=Raised when input data cannot be merged into a variable font.Nc                 K   s8   || _ |si }d|v r|d | _|d= ng | _|| _d S )Nstack)mergerr   causeselfr   kwargsr	   r	   r
   __init__   s   

zVarLibMergeError.__init__c                 C   s   | j S N)r   r   r	   r	   r
   reason   s   zVarLibMergeError.reasonc                 C   sd   | j d ur-| j j| }d|v r|d  r|d  S t|jdr-t|jjdr-|jjjS d| S )Nnamefilezmaster number )r   ttfsZgetBestFullNamehasattrreaderr   r   )r   Zixttfr	   r	   r
   _master_name   s   


zVarLibMergeError._master_namec                    sh   d j v r2d j v r2 fdd j d D d} |}d j v r.| d j d  d}||fS d	S )
Nexpectedgotc                    s   g | ]	}| j d  kqS )r   )r   .0xr   r	   r
   
<listcomp>*   s    z-VarLibMergeError.offender.<locals>.<listcomp>Flocation ())NNr   indexr   )r   r)   Zmaster_namer	   r   r
   offender'   s   

zVarLibMergeError.offenderc                 C   sT   d| j v r(d| j v r(| j\}}| j d | }d| jd  d| j d d|dS dS )	Nr   r    zExpected to see r   ==z, instead saw 
 )r   r*   r   )r   offender_indexr*   r    r	   r	   r
   details3   s
   
$zVarLibMergeError.detailsc                 C   s\   | j \}}d}|rd| d}dt| j}tjd| j d| dd}d| | | j S )	Nr-   z!

The problem is likely to be in z:
z"Couldn't merge the fonts, because z:. This happened while performing the following operation: N   )widthz

)r*   joinreversedr   textwrapfillr   r/   )r   r.   r*   r%   contextbasicr	   r	   r
   __str__;   s   

zVarLibMergeError.__str__r   )r   r   r   r   r   propertyr   r   r*   r/   r8   r	   r	   r	   r
   r      s    

	

r   c                       s$   e Zd ZdZe fddZ  ZS )ShouldBeConstantz9some values were different, but should have been the samec                    s   t  j} jd dks jd u r|S  jd dksJ  j\}} jj| }t fdd jjD }dd | jd  jjj	D }dd | jd  jjj	D }|d	d

| dd

| d S )Nr   z.FeatureCountc                 3   s@    | ]} j d  |v r| j d   jjj jd kr|V  qdS )r   N)r   tableFeatureListZFeatureCountr   )r"   r   r   r	   r
   	<genexpr>V   s    
z+ShouldBeConstant.details.<locals>.<genexpr>c                 S      g | ]}|j qS r	   Z
FeatureTagr!   r	   r	   r
   r$   ^       z,ShouldBeConstant.details.<locals>.<listcomp>r;   c                 S   r?   r	   r@   r!   r	   r	   r
   r$   b   rA   z2
Incompatible features between masters.
Expected: z, z.
Got: z.
)superr/   r   r   r*   r   nextr<   r=   ZFeatureRecordr2   )r   Zbasic_messager.   _Zbad_ttfZgood_ttfZgood_featuresZbad_features	__class__r   r
   r/   L   s,   
zShouldBeConstant.details)r   r   r   r   r9   r/   __classcell__r	   r	   rE   r
   r:   I   s    r:   c                   @   (   e Zd ZdZedd Zedd ZdS )
FoundANonezAone of the values in a list was empty when it shouldn't have beenc                 C   (   dd | j d D d}|| |fS )Nc                 S   s   g | ]}|d u qS r   r	   r!   r	   r	   r
   r$   r       z'FoundANone.offender.<locals>.<listcomp>r    Tr(   r   r)   r	   r	   r
   r*   p      zFoundANone.offenderc                 C   &   | j | j}}|d  d|d  dS Nr   r+   r    r,   r   r   r   r   r   r	   r	   r
   r/   u      zFoundANone.detailsNr   r   r   r   r9   r*   r/   r	   r	   r	   r
   rI   m       
rI   c                   @   rH   )NotANonezBone of the values in a list was not empty when it should have beenc                 C   rJ   )Nc                 S   s   g | ]}|d uqS r   r	   r!   r	   r	   r
   r$      rK   z%NotANone.offender.<locals>.<listcomp>r    Tr(   rL   r	   r	   r
   r*   ~   rM   zNotANone.offenderc                 C   rN   rO   rP   rQ   r	   r	   r
   r/      rR   zNotANone.detailsNrS   r	   r	   r	   r
   rU   {   rT   rU   c                   @   r   )MismatchedTypeszdata had inconsistent typesNr   r	   r	   r	   r
   rV      r   rV   c                   @   r   )LengthsDifferz*a list of objects had inconsistent lengthsNr   r	   r	   r	   r
   rW      r   rW   c                   @   r   )
KeysDifferz$a list of objects had different keysNr   r	   r	   r	   r
   rX      r   rX   c                   @   r   )InconsistentGlyphOrderz0the glyph order was inconsistent between mastersNr   r	   r	   r	   r
   rY      r   rY   c                   @   r   )InconsistentExtensionsz6the masters use extension lookups in inconsistent waysNr   r	   r	   r	   r
   rZ      r   rZ   c                       s.   e Zd ZdZd fdd	Zedd Z  ZS )UnsupportedFormatz6an OpenType subtable (%s) had a format I didn't expectNc                    s*   t  j|fi | | jsdg| _d S d S )Nz.Format)rB   r   r   r   rE   r	   r
   r      s   zUnsupportedFormat.__init__c                 C   s4   | j | jd  }d| jv r|d| jd d7 }|S )NZsubtablevaluer&   r'   )r   r   )r   sr	   r	   r
   r      s   
zUnsupportedFormat.reasonr   )r   r   r   r   r   r9   r   rG   r	   r	   rE   r
   r[      s
    r[   c                   @   r   )InconsistentFormatszBan OpenType subtable (%s) had inconsistent formats between mastersNr   r	   r	   r	   r
   r^      r   r^   c                   @   s   e Zd ZdS )VarLibCFFMergeErrorN)r   r   r   r	   r	   r	   r
   r_      s    r_   c                   @      e Zd ZdZdd ZdS )VarLibCFFDictMergeErrorz/Raised when a CFF PrivateDict cannot be merged.c                 C   s6   d| d| d}|D ]	}|d| 7 }q|f| _ d S )NzFor the Private Dict key 'z!', the default font value list:
	z5
had a different number of values than a region font:z
	args)r   keyr\   values	error_msgZregion_valuer	   r	   r
   r      s   z VarLibCFFDictMergeError.__init__Nr   r   r   r   r   r	   r	   r	   r
   ra          ra   c                   @   r`   )VarLibCFFPointTypeMergeErrorzKRaised when a CFF glyph cannot be merged because of point type differences.c                 C   0   d| d| d| d| d| d}|f| _ d S )NGlyph '': 'z' at point index  in master index z+ differs from the default font point type ''rb   )r   Z
point_typeZpt_indexm_indexdefault_type
glyph_namerf   r	   r	   r
   r         z%VarLibCFFPointTypeMergeError.__init__Nrg   r	   r	   r	   r
   ri      rh   ri   c                   @   r`   )VarLibCFFHintTypeMergeErrorzJRaised when a CFF glyph cannot be merged because of hint type differences.c                 C   rj   )Nrk   rl   z' at index rm   z* differs from the default font hint type 'rn   rb   )r   Z	hint_typeZ	cmd_indexro   rp   rq   rf   r	   r	   r
   r      rr   z$VarLibCFFHintTypeMergeError.__init__Nrg   r	   r	   r	   r
   rs      rh   rs   c                   @   r   )VariationModelErrorz(Raised when a variation model is faulty.Nr   r	   r	   r	   r
   rt      r   rt   )r4   	Exceptionr   r   r   r:   rI   rU   rV   rW   rX   rY   rZ   r[   r^   r_   ra   ri   rs   rt   r	   r	   r	   r
   <module>   s&    =$