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

TSI5 contains the VTT character groups.

See also https://learn.microsoft.com/en-us/typography/tools/vtt/tsi-tables
    )safeEval   )DefaultTableNc                   @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )
table_T_S_I__5c                 C   sp   |d j }t|d| ksJ td}|| tjdkr"|  i | _t|D ]}|| | j|	|< q)d S )Nmaxp   Hbig)
	numGlyphslenarray	frombytessys	byteorderbyteswapglyphGroupingrangegetGlyphName)selfdatattFontr
   ai r   S/var/www/vscode/kcb/lib/python3.10/site-packages/fontTools/ttLib/tables/T_S_I__5.py	decompile   s   



ztable_T_S_I__5.decompilec                 C   sV   |  }td}tt|D ]}|| j|| d qtjdkr'|	  |
 S )Nr   r   r	   )getGlyphOrderr   r   r   appendr   getr   r   r   tobytes)r   r   
glyphNamesr   r   r   r   r   compile   s   

ztable_T_S_I__5.compilec                 C   s:   t | j }|D ]}|jd|| j| d |  q	d S )N
glyphgroup)namevalue)sortedr   keys	simpletagnewline)r   writerr   names	glyphNamer   r   r   toXML$   s   
ztable_T_S_I__5.toXMLc                 C   s6   t | dsi | _|dkrd S t|d | j|d < d S )Nr   r"   r$   r#   )hasattrr   r   )r   r#   attrscontentr   r   r   r   fromXML,   s
   
ztable_T_S_I__5.fromXMLN)__name__
__module____qualname__r   r!   r,   r0   r   r   r   r   r      s
    	r   )__doc__fontTools.misc.textToolsr    r   r   r   r   r   r   r   r   <module>   s    