a
    ZXh	                     @   sL   d Z ddlZddlZddlmZ eeZdZdd Z	G dd	 d	ejZ
dS )
ag  TSI{0,1,2,3,5} are private tables used by Microsoft Visual TrueType (VTT)
tool to store its hinting source data.

TSI0 is the index table containing the lengths and offsets for the glyph
programs and 'extra' programs ('fpgm', 'prep', and 'cvt') that are contained
in the TSI1 table.

See also https://learn.microsoft.com/en-us/typography/tools/vtt/tsi-tables
    N   )DefaultTablez>HHLc                 C   s   t | t ||fS N)int)glyphID
textLength
textOffset r	   d/var/www/viveiro_mudafortebrasil/venv/lib/python3.9/site-packages/fontTools/ttLib/tables/T_S_I__0.pyfixlongs   s    r   c                   @   s2   e Zd ZdgZdd Zdd Zdd Zdd	 Zd
S )table_T_S_I__0ZTSI1c              	   C   s   |d j }g }tt}t|| }||d krb|| d }tdt| d|d  d| d t|D ]>}t	t
t|d |  \}	}
}||	|
|f ||d  }qjt|dksJ |d d	ksJ d
|d d | _|dd  | _d S )NZmaxp   zINumber of glyphPrograms differs from the number of glyphs in the font by z (z programs vs. z	 glyphs).r   )  r      4W zbad magic number)	numGlyphsstructcalcsize
tsi0Formatlenlogwarningabsranger   unpackappendindicesextra_indices)selfdatattFontr   r   sizeZ
numEntriesdiff_r   r   r   r	   r	   r
   	decompile   s2    


ztable_T_S_I__0.decompilec                 C   sv   t | dsdS d}| jD ]\}}}|tt||| }q|ttddd }| jD ]\}}}|tt||| }qR|S )Nr       r   r   r   )hasattrr   r   packr   r   )r   r!   r    indexr   r   r	   r	   r
   compile2   s    
ztable_T_S_I__0.compilec                 C   s   || _ || _d S r   )r   r   )r   r   r   r	   r	   r
   set?   s    ztable_T_S_I__0.setc                 C   s   | d |  d S )Nz-This table will be calculated by the compiler)commentnewline)r   writerr!   r	   r	   r
   toXMLD   s    
ztable_T_S_I__0.toXMLN)__name__
__module____qualname__Zdependenciesr%   r*   r+   r/   r	   r	   r	   r
   r      s
   r   )__doc__loggingr    r   	getLoggerr0   r   r   r   r   r	   r	   r	   r
   <module>   s   

