o
    i                     @   sV   d dl mZ d dlmZ d dlZedZdd Zdd Z	d	d
 Z
dd Zdd ZdS )    )otTables)deepcopyNzfontTools.varLib.instancerc                 C   sv   g }| j d ur| j jng }|D ]}|jdkr dS ||j|j|jf qt| jj	g| }||v r4dS |
| dS )N   TF)ConditionSetConditionTableFormatappend	AxisIndexFilterRangeMinValueFilterRangeMaxValue	frozensetFeatureTableSubstitutionVersionadd)recseenZconditionSetZconditionSetsZcondZ	recordKey r   u/var/www/html/eduruby.in/lip-sync/lip-sync-env/lib/python3.10/site-packages/fontTools/varLib/instancer/featureVars.py_featureVariationRecordIsUnique	   s   

r   c                    sF   | j }| j}||ks| jks| jk rd S t fdd||fD S )Nc                 3   s    | ]
} j |d dV  qdS )F)ZextrapolateN)ZrenormalizeValue).0v	axisLimitr   r   	<genexpr>.   s    
z7_limitFeatureVariationConditionRange.<locals>.<genexpr>)r
   r   maximumminimumtuple)	conditionr   minValuemaxValuer   r   r   $_limitFeatureVariationConditionRange"   s   

r    c                 C   s  d}d}g }ddl m} |ddd}	| jd u r$t | _g | j_d| j_t| jjD ]z\}
}|jdkr|j}|| j	}|j
}|j}|||	}||j  krR|ksUn d}|j|ks_|j|k rcd } nB||v r|| |_t||}|r|\}}||_
||_d}|dks|dkr|| q*d } nq*td|
||j d}|| q*|d ur|r|| j_|sd | _d}nd}|o| }|||fS )NTFr   ) NormalizedAxisTripleAndDistancesr   zWCondition table {0} of FeatureVariationRecord {1} has unsupported format ({2}); ignored)ZfontTools.varLib.instancerr!   r   otr   ConditionCount	enumerater   r	   axisTagr
   r   getdefaultr   r   r    r   logwarningformat)recordZrecIdx
axisLimitsfvarAxesaxisIndexMapapplies
shouldKeepZnewConditionsr!   Zdefault_tripleir   ZaxisIdxr&   r   r   ZtripleZnewRanger   r   	universalr   r   r   "_instantiateFeatureVariationRecord3   sb   








r4   c                    sb  t | fdd|D   fdd D }d}t  }g }d }t| jjD ]U\}}	t|	||||\}
}}|rBt|	|rB||	 |
rx|sx|	jj	dksNJ t
|	j}t|j|	jjD ]\}}t
| jj|j j|_t
|j| jj|j _q[d}|r| nq'|r|r|st }t |_g |j_d|j_||_|| |r|| j_t|| j_d S | `d| _	d S )	Nc                    s   g | ]
}|j  vr|j qS r   )r&   )r   Zaxis)
pinnedAxesr   r   
<listcomp>|   s    z1_instantiateFeatureVariations.<locals>.<listcomp>c                    s   i | ]}|  |qS r   )index)r   r&   )	axisOrderr   r   
<dictcomp>}   s    z1_instantiateFeatureVariations.<locals>.<dictcomp>Fi   Tr   )setZpinnedLocationr%   FeatureVariationsZFeatureVariationRecordr4   r   r   r   r   r   zipZSubstitutionRecordZFeatureListZFeatureRecordZFeatureIndexZFeaturer#   r   r   r$   lenZFeatureVariationCount)tabler.   r-   r/   ZfeatureVariationAppliedZuniqueRecordsZ
newRecordsZdefaultsSubstsr2   r,   r0   r1   r3   r(   r   ZdefaultRecordr   )r8   r5   r   _instantiateFeatureVariationsz   sT   






r?   c                 C   sZ   dD ](}|| vst | | jdd sqtd| t| | j| d j| | |   qd S )N)ZGPOSZGSUBr;   z+Instantiating FeatureVariations of %s tableZfvar)getattrr>   r)   infor?   ZaxesZprune_lookups)Zvarfontr-   ZtableTagr   r   r   instantiateFeatureVariations   s   
rB   )ZfontTools.ttLib.tablesr   r#   copyr   logging	getLoggerr)   r   r    r4   r?   rB   r   r   r   r   <module>   s    
G9