a
    w=ic                     @   s   d Z ddlmZ ddlmZmZmZmZ ddlm	Z	 ddl
ZddlZddlmZ ddlmZ edZd	d
 dfddZdddZedkrddlZeejdkree  ddlZee j dS )z:
Interpolate OpenType Layout tables (GDEF / GPOS / GSUB).
    )TTFont)modelsVarLibErrorload_designspaceload_masters)InstancerMergerN)deepcopy)pformatz#fontTools.varLib.interpolate_layoutc                 C   s   | S )N sr
   r
   t/home/droni/.local/share/virtualenvs/DPS-5Je3_V2c/lib/python3.9/site-packages/fontTools/varLib/interpolate_layout.py<lambda>       r   Fc           	         s   t | drnddlm} || } t|  td td t| |}t| j	 }tdt
| |s fdd| D }td	t
| t| j}td
t
| t j}d|j j	 ksJ t|||}td |||dg |S )a  
	Interpolate GPOS from a designspace file and location.

	If master_finder is set, it should be a callable that takes master
	filename as found in designspace file and map it to master font
	binary as to be opened (eg. .ttf or .otf).

	If mapped is False (default), then location is mapped using the
	map element of the axes in designspace file.  If mapped is True,
	it is assumed that location is in designspace's internal space and
	no mapping is performed.
	sourcesr   )DesignSpaceDocumentzBuilding interpolated fontzLoading master fontszLocation: %sc                    s"   i | ]\}}| j | |qS r
   )ZaxesZmap_forward).0namevZdsr
   r   
<dictcomp>+   r   z&interpolate_layout.<locals>.<dictcomp>zInternal location: %szNormalized location: %szBuilding interpolated tablesZGPOS)hasattrZfontTools.designspaceLibr   fromfiler   loginfor   r   Zbase_idxr	   itemsr   ZnormalizeLocationZinternal_axis_supportsZVariationModelZnormalized_master_locsmappingr   ZmergeTables)	ZdesignspacelocZmaster_findermappedr   Zmaster_fontsfontmodelZmergerr
   r   r   interpolate_layout   s*    





r!   c                 C   s  ddl m} ddl}ddl}|jdtjd}|jdddd	 |jd
dtddd |jddddd	 |jdddddd |	| } | j
stj| jd d | _
|| jd dd }i }| jD ]}|d\}}	t|	||< qt| j||}
td| j
 |
| j
 dS )z>Interpolate GDEF/GPOS/GSUB tables for a point on a designspacer   )configLoggerNz#fonttools varLib.interpolate_layout)descriptiondesignspace_filenameZDESIGNSPACEzInput TTF files)metavarhelp	locationsZLOCATION+zAxis locations (e.g. wdth=120)r%   typenargsr&   z-oz--outputZOUTPUTz=Output font file (defaults to <designspacename>-instance.ttf)z-lz
--loglevelZLEVELINFOz Logging level (defaults to INFO))r%   defaultr&   z-instance.ttf)levelc                 S   s   |  dd ddS )NZ
master_ufoZmaster_ttf_interpolatablez.ufoz.ttf)replacer   r
   r
   r   r   W   r   zmain.<locals>.<lambda>=zSaving font %s)Z	fontToolsr"   argparsesysArgumentParsermain__doc__add_argumentstr
parse_argsoutputospathsplitextr$   loglevelr'   splitfloatr!   r   r   save)argsr"   r0   r1   parserfinderr   argtagvalr   r
   r
   r   r3   <   s>    


r3   __main__   )N)r4   ZfontTools.ttLibr   ZfontTools.varLibr   r   r   r   ZfontTools.varLib.mergerr   os.pathr9   loggingcopyr   pprintr	   	getLoggerr   r!   r3   __name__r1   lenargvexitdoctesttestmodfailedr
   r
   r
   r   <module>   s    
-
'