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

TSI1 contains the text of the glyph programs in the form of low-level assembly
code, as well as the 'extra' programs 'fpgm', 'ppgm' (i.e. 'prep'), and 'cvt'.

See also https://learn.microsoft.com/en-us/typography/tools/vtt/tsi-tables
   )DefaultTable    )LogMixin)strjointobytestostrc                   6    e Zd ZdddddZdZd Zd Zd	 Zd
 Zy)table_T_S_I__1ppgmcvtreservedfpgm)i  i  i  i  TSI0c                    t        |      }|| j                     }t        |j                  |j                  fd      D ]<  \  }}i }t        |      D ]  \  }\  }	}
}|r| j                  |	   }n|j                  |	      }||kD  r| j                  j                  d|z         R|
dk  rn|
dk(  rm|t        |      dz
  k(  }|r|r|}n|j                  d   d   }n||dz      d   }||k\  sJ d       ||kD  r | j                  j                  d|z         |}||z
  }
ndd	l
m} |j                  d
||
fz        ||||
z    }t        |      |
k(  sJ t        |d      }|s|||<    |r	|| _        6|| _        ? y )N)FTz$textOffset > totalLength; %r skipped   r   r      zentries not sorted by offsetz*nextTextOffset > totalLength; %r truncated)ttLibz&%r textLength (%d) must not be > 32768utf-8encoding)len
indextablezipindicesextra_indices	enumerateextrasgetGlyphNamelogwarning	fontToolsr   
TTLibErrorr   extraProgramsglyphPrograms)selfdatattFonttotalLengthr   r   isExtraprogramsiglyphID
textLength
textOffsetnameisLastnextTextOffsetr   texts                    [/var/www/teggl/fontify/venv/lib/python3.12/site-packages/fontTools/ttLib/tables/T_S_I__1.py	decompileztable_T_S_I__1.decompile   s   $iDOO,
 #!9!9:M!
 <	.GW H8A'8J 4*44GZ;;w/D!..w7D+HH$$%Kd%RS& 6)3w<!#34F"
 .9N .8-E-Ea-H-KN
 *1Q):)Z7W9WW7%3((H4O *5!/*!<J/**@D*CUU  Jj)@A4yJ...TG4%)HTNi4*j %-"%-"y<	.    c                 4   t        | d      si | _        i | _        d}|| j                     }|j	                         }g }t        t        |            D ]y  }t        |      dz  r|dz   }||   }|| j                  v rt        | j                  |   d      }nd}t        |      }	|	dk\  rd}	|j                  ||	t        |      f       ||z   }{ g }
t        | j                  j                               }t        t        |            D ]|  }t        |      dz  r|dz   }||   \  }}|| j                  v rt        | j                  |   d      }nd}t        |      }	|	dk\  rd}	|
j                  ||	t        |      f       ||z   }~ |j                  ||
       |S )Nr$   r5   r      r   r   r   )hasattrr$   r#   r   getGlyphOrderranger   r   appendsortedr   itemsset)r%   r'   r&   r   
glyphNamesr   r+   r/   r2   r-   r   codescodes                r3   compileztable_T_S_I__1.compileU   s   t_-!#D!#DDOO,
))+
s:' 	A4y1}7N  a=Dt)))t11$7'JTJV##
NNAz3t956$;D	  t{{((*+s5z" 	A4y1}7N  qJD$t)))t11$7'JTJV##
  $
CI!>?$;D	 	w.r5   c                 (   t        | j                  j                               }|j                          |D ]  }| j                  |   }|s|j	                  d|       |j                          |j                  |j                  dd             |j                          |j                  d       |j                          |j                           t        | j                  j                               }|D ]  }| j                  |   }|s|j	                  d|       |j                          |j                  |j                  dd             |j                          |j                  d       |j                          |j                           y )NglyphProgram)r/   
extraProgram)	r<   r$   keysnewlinebegintagwrite_noindentreplaceendtagr#   )r%   writerr'   namesr/   r2   extra_namess          r3   toXMLztable_T_S_I__1.toXML   sD   t))..01 
	D%%d+DOONO6NN!!$,,tT":;NNMM.)NNNN
	 T//4467 
	D%%d+DOONO6NN!!$,,tT":;NNMM.)NNNN
	r5   c                    t        | d      si | _        i | _        t        |      j	                  dd      j                  d      }dj                  |dd       }|dk(  r|| j                  |d   <   y |dk(  r|| j                  |d   <   y y )	Nr$   rE   rF   r   rD   r/   rG   )r8   r$   r#   r   rL   splitjoin)r%   r/   attrscontentr'   linesr2   s          r3   fromXMLztable_T_S_I__1.fromXML   s    t_-!#D!#D ((t4::4@yyq%>!04DuV}-^#04DuV}- $r5   N)	__name__
__module____qualname__r   r   r4   rB   rQ   rY    r5   r3   r
   r
      s+    eZPFJ?.B+Z6	5r5   r
   N)
__doc__ r   fontTools.misc.loggingToolsr   fontTools.misc.textToolsr   r   r   r
   r]   r5   r3   <module>rb      s.     0 < <W5X|88 W5r5   