o
    hi                     @   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rdddlZeejdkrVee  ddlZee j dS 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   w/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/fontTools/varLib/interpolate_layout.py<lambda>   s    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sgJ 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   )axesmap_forward).0namevdsr   r   
<dictcomp>-   s   " z&interpolate_layout.<locals>.<dictcomp>zInternal location: %szNormalized location: %szBuilding interpolated tablesGPOS)hasattrfontTools.designspaceLibr   fromfiler   loginfor   r   base_idxr	   itemsr   normalizeLocationinternal_axis_supportsVariationModelnormalized_master_locsmappingr   mergeTables)	designspacelocmaster_findermappedr   master_fontsfontmodelmergerr   r   r   interpolate_layout   s*   





r0   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
sOtj| jd d | _
|| jd dd }i }| jD ]}|d\}}	t|	||< q^t| 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_filenameDESIGNSPACEzInput TTF files)metavarhelp	locationsLOCATION+zAxis locations (e.g. wdth=120)r5   typenargsr6   z-oz--outputOUTPUTz=Output font file (defaults to <designspacename>-instance.ttf)z-lz
--loglevelLEVELINFOz Logging level (defaults to INFO))r5   defaultr6   z-instance.ttf)levelc                 S   s   |  dd ddS )N
master_ufomaster_ttf_interpolatablez.ufoz.ttf)replacer   r   r   r   r   g   s    zmain.<locals>.<lambda>=zSaving font %s)	fontToolsr1   argparsesysArgumentParsermain__doc__add_argumentstr
parse_argsoutputospathsplitextr3   loglevelr7   splitfloatr0   r   r   save)argsr1   rF   rG   parserfinderr)   argtagvalr-   r   r   r   rI   >   sT   

rI   __main__   r
   )rJ   fontTools.ttLibr   fontTools.varLibr   r   r   r   fontTools.varLib.mergerr   os.pathrO   loggingcopyr   pprintr	   	getLoggerr   r0   rI   __name__rG   lenargvexitdoctesttestmodfailedr   r   r   r   <module>   s$    

.7