a
    ׶a                     @   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dS )#    Nc                   @   s   e Zd ZdZdS )VarLibErrorz%Base exception for the varLib module.N__name__
__module____qualname____doc__ r   r   g/Users/vegardjervell/Documents/master/model/venv/lib/python3.9/site-packages/fontTools/varLib/errors.pyr      s   r   c                   @   s   e Zd ZdZdS )VarLibValidationErrorz>Raised when input data is invalid from varLib's point of view.Nr   r   r   r   r	   r
      s   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   s   | j d ur~| j j| }d|v rZ|d drZ|d drZ|d dd |d d S t|jdr~t|jjdr~|jjjS d| S )Nname       filezmaster number )r   ttfsZgetDebugNamehasattrreaderr   r   )r   ixZttfr   r   r	   _master_name   s    
 
zVarLibMergeError._master_namec                    sD   d j v r@d j v r@ fdd j d D d}| |fS dS )Nexpectedgotc                    s   g | ]}| j d  kqS )r   )r   .0xr   r   r	   
<listcomp>.       z-VarLibMergeError.offender.<locals>.<listcomp>F)NN)r   indexr   )r   r&   r   r   r	   offender+   s    zVarLibMergeError.offenderc                 C   sT   d| j v rPd| j v rP| 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	   details4   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'   locationcontextbasicr   r   r	   __str__<   s    

zVarLibMergeError.__str__)N)r   r   r   r   r   propertyr   r   r'   r,   r6   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   | j d dks| jd u r t jS | j\}}| jj| }| 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.FeatureCountr   c                 S   s   g | ]
}|j qS r   Z
FeatureTagr!   r   r   r	   r$   U   s   z,ShouldBeConstant.details.<locals>.<listcomp>c                 S   s   g | ]
}|j qS r   r9   r!   r   r   r	   r$   Y   s   z2
Incompatible features between masters.
Expected: z, z.
Got: z.
)
r   r   superr,   r'   r   tableZFeatureListZFeatureRecordr/   )r   r+   r'   Zbad_ttfZgood_ttfZgood_featuresZbad_features	__class__r   r	   r,   M   s"    
zShouldBeConstant.details)r   r   r   r   r7   r,   __classcell__r   r   r=   r	   r8   J   s   r8   c                   @   s(   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   s0   | j d }dd |d D d}|| |fS )Nr   c                 S   s   g | ]}|d u qS r   r   r!   r   r   r	   r$   j   r%   z'FoundANone.offender.<locals>.<listcomp>r    T)argvr&   r   )r   r   r&   r   r   r	   r'   g   s    
zFoundANone.offenderc                 C   s2   | j d | j dd   }}|d  d|d  dS )Nr   r   r(   r    r)   argsr   r   r   r   r   r	   r,   m   s    zFoundANone.detailsN)r   r   r   r   r7   r'   r,   r   r   r   r	   r@   d   s
   
r@   c                   @   s   e Zd ZdZdS )MismatchedTypeszdata had inconsistent typesNr   r   r   r   r	   rE   s   s   rE   c                   @   s   e Zd ZdZdS )LengthsDifferz*a list of objects had inconsistent lengthsNr   r   r   r   r	   rF   w   s   rF   c                   @   s   e Zd ZdZdS )
KeysDifferz$a list of objects had different keysNr   r   r   r   r	   rG   {   s   rG   c                   @   s   e Zd ZdZdS )InconsistentGlyphOrderz0the glyph order was inconsistent between mastersNr   r   r   r   r	   rH      s   rH   c                   @   s   e Zd ZdZdS )InconsistentExtensionsz6the masters use extension lookups in inconsistent waysNr   r   r   r   r	   rI      s   rI   c                   @   s   e Zd ZdZedd ZdS )UnsupportedFormatz6an OpenType subtable (%s) had a format I didn't expectc                 C   s(   | j d | j dd   }}| j|d  S )Nr   r   Zsubtable)rC   r   rD   r   r   r	   r      s    zUnsupportedFormat.reasonN)r   r   r   r   r7   r   r   r   r   r	   rJ      s   rJ   c                   @   s   e Zd ZdZdS )rJ   zBan OpenType subtable (%s) had inconsistent formats between mastersNr   r   r   r   r	   rJ      s   c                   @   s   e Zd ZdS )VarLibCFFMergeErrorN)r   r   r   r   r   r   r	   rK      s   rK   c                   @   s   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
	rB   )r   keyvaluevalues	error_msgZregion_valuer   r   r	   r      s    z VarLibCFFDictMergeError.__init__Nr   r   r   r   r   r   r   r   r	   rL      s   rL   c                   @   s   e Zd ZdZdd ZdS )VarLibCFFPointTypeMergeErrorzKRaised when a CFF glyph cannot be merged because of point type differences.c                 C   s0   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_namerP   r   r   r	   r      s    z%VarLibCFFPointTypeMergeError.__init__NrQ   r   r   r   r	   rR      s   rR   c                   @   s   e Zd ZdZdd ZdS )VarLibCFFHintTypeMergeErrorzJRaised when a CFF glyph cannot be merged because of hint type differences.c                 C   s0   d| d| d| d| d| d}|f| _ d S )NrS   rT   z' at index rU   z* differs from the default font hint type 'rV   rB   )r   Z	hint_typeZ	cmd_indexrW   rX   rY   rP   r   r   r	   r      s    z$VarLibCFFHintTypeMergeError.__init__NrQ   r   r   r   r	   rZ      s   rZ   c                   @   s   e Zd ZdZdS )VariationModelErrorz(Raised when a variation model is faulty.Nr   r   r   r   r	   r[      s   r[   )r1   	Exceptionr   r
   r   r8   r@   rE   rF   rG   rH   rI   rJ   rK   rL   rR   rZ   r[   r   r   r   r	   <module>   s"   >	