
    h                     H   S r SSKJrJrJrJrJr  SSKJr  SSK	J
r
  SSKJr  SSKJrJr  SSKJr  SS	KrSS	Kr\R(                  " \5      rS
r\R0                  " \5      rSr\R0                  " \5      r " S S\
R                  5      r " S S\5      r\ " S S\5      5       rg	)a  Compiles/decompiles SVG table.

https://docs.microsoft.com/en-us/typography/opentype/spec/svg

The XML format is:

.. code-block:: xml

        <SVG>
                <svgDoc endGlyphID="1" startGlyphID="1">
                        <![CDATA[ <complete SVG doc> ]]
                </svgDoc>
        ...
                <svgDoc endGlyphID="n" startGlyphID="m">
                        <![CDATA[ <complete SVG doc> ]]
                </svgDoc>
        </SVG>
    )	bytesjoinsafeEvalstrjointobytestostr)sstruct   )DefaultTable)Sequence)	dataclassastuple)BytesIONzj
	>   # big endian
	version:                  H
	offsetToSVGDocIndex:      L
	reserved:                 L
z
	>   # big endian
	startGlyphID:             H
	endGlyphID:               H
	svgDocOffset:             L
	svgDocLength:             L
c                   0    \ rS rSrSrS rS rS rS rSr	g)	table_S_V_G_5   zScalable Vector Graphics table

The ``SVG`` table contains representations for glyphs in the SVG
image format.

See also https://learn.microsoft.com/en-us/typography/opentype/spec/stat
c           	         / U l         [        R                  " [        US [         U 5        U R
                  S:w  a   [        R                  SU R
                  5        U R                  =p4[        R                  " SXUS-    5      S   U l
        US-  nU R                  S:  Ga2  XS  n/ n[        U R                  5       HN  nUU[        -  US-   [        -   n[        R                  " [        U[        5       5      n	UR                  U	5        MP     U H  n
U
R                   U-   nXR"                  -   nXU nSnUR%                  S5      (       a<  SS Kn[)        U5      nUR+                  S SUS	9 nUR-                  5       nS S S 5        AS
n[/        US5      nU R                   R                  [1        XR2                  U
R4                  U5      5        M     g g ! , (       d  f       N]= f)Nr   z9Unknown SVG table version '%s'. Decompiling as version 0.>H   r	   F   r)fileobjTutf_8)docListr   unpackSVG_format_0SVG_format_0SizeversionlogwarningoffsetToSVGDocIndexstruct
numEntriesrangedoc_index_entry_format_0Sizedoc_index_entry_format_0DocumentIndexEntryappendsvgDocOffsetsvgDocLength
startswithgzipr   GzipFilereadr   SVGDocumentstartGlyphID
endGlyphID)selfdatattFontpossubTableStartdata2entriesirecord_datadocIndexEntryentrystartenddoc
compressedr+   bytesIO	gunzippers                     O/var/www/html/env/lib/python3.13/site-packages/fontTools/ttLib/tables/S_V_G_.py	decompiletable_S_V_G_.decompile>   s    	|T*;+;%<dC<<1KKK #666 --dq.AB1Eq??QJEG4??+#2367!e263
 !(,k;M;O! }- , !**]:000o"
>>+..%clGtS'Bi'nn. C!%JC)##%7%79I9I:V ! . CBs   -G
G#	c                 ^   Sn[         n/ n/ n[        U R                  5      n[        R                  " SU5      nUR                  U5        [        U5      [        U-  -   n0 n	[        U SS5      n
[        U R                  5       GHO  u  p[        U[        [        45      (       a  [        U6 nXR                  U'   [        UR                  SS9nU
(       d  UR                  (       a|  UR!                  S5      (       df  SS Kn[%        5       nUR'                  S SUSS	9 nUR)                  U5        S S S 5        UR+                  5       n[        U5      [        U5      :  a  UnAA[        U5      nX;   a  X   nOUnUU-  nUX'   UR                  U5        [        R                  " S
UR,                  UR.                  UU5      nUR                  U5        GMR     UR1                  U5        [3        U5      nSn[        R                  " SX#U5      nUU/n[3        U5      nU$ ! , (       d  f       N= f)Nr   r   r?   Fr   )encodingr   w)r   mtimez>HHLLz>HLL)r   lenr   r!   packr'   r$   getattr	enumerate
isinstancelisttupler.   r   r2   r?   r*   r+   r   r,   writegetvaluer/   r0   extendr   )r1   r3   r   r    r   	entryListr"   datum	curOffsetseenDocsallCompressedr8   r>   docBytesr+   r@   gzippergzipped	docLength	docOffsetr;   
svgDocDatareservedheaderr2   s                            rB   compiletable_S_V_G_.compilem   s    	 	&
D*-J!=
!JJ	lE:-FA#e}--!3'"%Qsxx':H9L9L: : !) ]]4gQ]G7MM(+ H!**,w<#h-/&HWHI#$.	%	Y&	%."x(KK))3>>9iE U#= .> 	!y)
VW8L
#3 HGs   H
H,	c                    [        U R                  5       H  u  p4[        U[        [        45      (       a  [        U6 nX@R                  U'   UR                  UR                  S.nUR                  (       a  SUS'   UR                  " S0 UD6  UR                  5         UR                  UR                  5        UR                  5         UR                  S5        UR                  5         M     g )N)r/   r0   r	   r?   svgDoc)rc   )rL   r   rM   rN   rO   r.   r/   r0   r?   begintagnewline
writecdatar2   endtag)r1   writerr3   r8   r>   attrss         rB   toXMLtable_S_V_G_.toXML   s    -FA#e}--!3'"%Q%(%5%5S^^TE~~&'l#OO..NNchh'NNMM(#NN .    c                 n   US:X  a  [        U S5      (       d  / U l        [        U5      nUR                  5       n[	        US   5      n[	        US   5      n[        [        UR                  SS5      5      5      nU R                  R                  [        XVXx5      5        g [        R                  SX5        g )Nrc   r   r/   r0   r?   0zUnknown %s %s)hasattrr   r   stripintboolr   getr'   r.   r   r   )	r1   nameri   contentr3   r>   startGIDendGIDr?   s	            rB   fromXMLtable_S_V_G_.fromXML   s    84++!'"C))+C501H|,-Fhuyys'CDEJLLC6 NOKK7rl   )r   r"   N)
__name__
__module____qualname____firstlineno____doc__rC   r`   rj   rx   __static_attributes__ rl   rB   r   r   5   s    -^4l8rl   r   c                        \ rS rSrS rS rSrg)r&      c                 <    S U l         S U l        S U l        S U l        g )Nr/   r0   r(   r)   r1   s    rB   __init__DocumentIndexEntry.__init__   s!       rl   c                 v    SU R                   < SU R                  < SU R                  < SU R                  < 3$ )NzstartGlyphID: z, endGlyphID: z, svgDocOffset: z, svgDocLength: r   r   s    rB   __repr__DocumentIndexEntry.__repr__   s.       $//43D3DdFWFWY	
rl   )r0   r/   r)   r(   N)rz   r{   r|   r}   r   r   r   r   rl   rB   r&   r&      s    !
rl   r&   c                   N    \ rS rSr% \\S'   \\S'   \\S'   Sr\\S'   S r	S r
S	rg
)r.      r2   r/   r0   Fr?   c                 $    [        U 5      S S U   $ N   )r   )r1   indexs     rB   __getitem__SVGDocument.__getitem__   s    t}Ra ''rl   c                     gr   r   r   s    rB   __len__SVGDocument.__len__   s    rl   r   N)rz   r{   r|   r}   str__annotations__rq   r?   rr   r   r   r   r   rl   rB   r.   r.      s&    
IOJ(rl   r.   ) r~   fontTools.misc.textToolsr   r   r   r   r   fontTools.miscr    r
   collections.abcr   dataclassesr   r   ior   r!   logging	getLoggerrz   r   r   calcsizer   r%   r$   r   objectr&   r.   r   rl   rB   <module>r      s   & R Q "  $ *    ! ##L1    '//0HI H8<,, H8V
 
 (  rl   