
     i!                         d dl mZ d dlmZ d dlmZ d dlmZ ddlm	Z	 ddlm
Z
 d dlZd	Zd
ZdZdZdZdZ G d d          Z G d de          Z G d de	j	                  ZdS )    )sstruct)floatToFixedToStr)safeEval)partial   )DefaultTable)grUtilsNz/
    >        # big endian
    version: 16.16F
zR
    >
    version: 16.16F
    compression:L    # compression scheme or reserved 
zz
    >
    attNum:     B    # Attribute number of first attribute
    num:        B    # Number of attributes in this run
zz
    >
    attNum:     H    # Attribute number of first attribute
    num:        H    # Number of attributes in this run
ao  
    >
    subboxBitmap:   H    # Which subboxes exist on 4x4 grid
    diagNegMin:     B    # Defines minimum negatively-sloped diagonal (si)
    diagNegMax:     B    # Defines maximum negatively-sloped diagonal (sa)
    diagPosMin:     B    # Defines minimum positively-sloped diagonal (di)
    diagPosMax:     B    # Defines maximum positively-sloped diagonal (da)
a  
    >
    left:           B    # xi
    right:          B    # xa
    bottom:         B    # yi
    top:            B    # ya
    diagNegMin:     B    # Defines minimum negatively-sloped diagonal (si)
    diagNegMax:     B    # Defines maximum negatively-sloped diagonal (sa)
    diagPosMin:     B    # Defines minimum positively-sloped diagonal (di)
    diagPosMax:     B    # Defines maximum positively-sloped diagonal (da)
c                       e Zd ZdS )_ObjectN__name__
__module____qualname__     i/srv/www/vhosts/g4struct/public_html/venv/lib/python3.11/site-packages/fontTools/ttLib/tables/G__l_a_t.pyr   r   8           Dr   r   c                       e Zd ZdS )_DictNr   r   r   r   r   r   <   r   r   r   c                   J    e Zd ZdZddZd Zd Zd Zd Zd Z	d	 Z
d
 Zd ZdS )table_G__l_a_tzsGraphite Glyph Attributes table

    See also https://graphite.sil.org/graphite_techAbout#graphite-font-tables
    Nc                 T    t           j                             | |           d| _        d S Nr   )r   __init__scheme)selftags     r   r   ztable_G__l_a_t.__init__F   s&    !**4555r   c                    t          j        t          ||            t          t	          | j        d                    | _        | j        dk    rt          | j        t                    }n| j        dk    rt          | j        t                    }n\| j        dk    rQt          j        |          \  }| _        t          j        t          ||            | j        dz  dk    | _        | j        }|d         }i | _        d	}t%          ||dd                    D ]8\  }} ||||                   | j        |                    |          <   |dz  }9d S )
N   )precisionBitsffffff?fmt333333@      @r   Glocr   )r   unpack2Glat_format_0floatr   versionr   decompileAttributes12Glat_format_1_entryGlat_format_23_entryr	   
decompressr   Glat_format_3compressionhasOctaboxesdecompileAttributes3
attributeszipgetGlyphName)r   datattFontdecodergloccountses           r   	decompileztable_G__l_a_t.decompileJ   sO   tT222.t|2NNNOO<3d8>QRRRGG\S  d8>RSSSGG\S  ")"4T":":T4;OM4666!%!1A!5! ;D/Gf~d122h'' 	 	DAq:A'$qs):L:LDOF//667QJEE	 	r   c                    t                      }t          |          dk    rt          j        ||t	                                \  }}t          |j        |j        |j        z             }t          |          d|j        z  k    rRt          j	        d|j        z  |          }|
                    t          ||                     |d|j        z  d          }t          |          dk    |S )N      >%dh)r   lenr   r'   r   rangeattNumnumstructunpack_fromupdater4   )r   r6   r#   r3   r<   keysvalss          r   r+   z$table_G__l_a_t.decompileAttributes12^   s    WW
$ii!mmoc4;;GAt18ae#344D4yyAI%%)6AE>DAA!!#dD//222AIKK( $ii!mm r   c                    | j         rt          j        t          |t	                                \  }}t          |j                                      d          }g |_        t          |          D ]Y}t          |          dk    rDt          j        t          |t	                                \  }}|j                            |           Z|                     |t                    }| j         r||_        |S )N1   )r1   r   r'   Glat_format_3_octabox_metricsr   binsubboxBitmapr:   subboxesrC   rB   Glat_format_3_subbox_entryappendr+   r-   octabox)r   r6   onumsubbsubboxattrss          r   r2   z#table_G__l_a_t.decompileAttributes3i   s     		.o&CT799UUGAt((..s33FAJ6]] . .t99>>#*?2D'))$ $LFD J%%f---**41EFF 	EMr   c                    t          j        t          |           }| j        dk    rt	          | j        t                    }nn| j        dk    rt	          | j        t                    }nG| j        dk    r<| j        dz  | j        rdndz   | _	        t          j        t          |           }| j        }g }t          t          | j                            D ]P}|                    t          |                     | || j        |                    |                             z  }Q|                    t          |                     |d                             |           | j        dk    rt%          j        | j        |          }|S )	Nr!   r"   r$   r%      r   r   r&   )r   packr(   r*   r   compileAttributes12r,   r   r1   r0   r/   compileAttributes3rC   rB   r3   rS   r5   setr	   compress)r   r7   r6   encoderglocsns         r   compileztable_G__l_a_t.compiley   se   |M400<3d6<OPPPGG\S  d6<OPPPGG\S   $r 14;L6SaaRSTD<t44D-Gs4?++,, 	E 	EALLT###GGDOF,?,?,B,BCDDDDDSYYv5!!!<3#DK66Dr   c           
          d}t          j        |          D ]X}|t          j        ||d         |d         d          t	          j        dt          |d                   z  g|d         R  z   z  }Y|S )Nr   r   r   )rD   rE   rA   r@   )r	   entriesr   r\   rF   rB   )r   rY   r#   r6   r<   s        r   r]   z"table_G__l_a_t.compileAttributes12   s    '' 	 	AGL1ad&C&CDDv{#ad))#H'(tH H H  DD r   c                 V   | j         r|j        }t          j        t          |          }t          |j                                      d          }t          |          D ]*}|t          j        t          |j
        |                   z  }+nd}||                     |t                    z   S )NrL    )r1   rT   r   r\   rN   rO   rP   r:   rC   rR   rQ   r]   r-   )r   rY   rU   r6   rV   rW   s         r   r^   z!table_G__l_a_t.compileAttributes3   s     	A< =qAAD((..s33F6]] P P%?AOOOP Dd..u6JKKKKr   c           	         |                     d| j        | j                   |                                 t	          | j                                        fd          D ]\  }}|                    d|           |                                 t          |d          r@|j	        }t          j        t                    \  }}}i }	|D ]5}
|
dk    r	d	                    t          ||
          d
z  dz            |	|
<   6d                    |j                  |	d<    |j        di |	 |                                 t          j        t                     \  }}}|j        D ]V}i }	|D ].}
d	                    t          ||
          d
z  dz            |	|
<   / |j         di |	 |                                 W|                    d           |                                 t	          |                                          D ]1\  }
}|                     d|
|           |                                 2|                    d           |                                  d S )Nr*   )r*   compressionSchemec                 :                         | d                   S r   )
getGlyphID)xr7   s    r   <lambda>z&table_G__l_a_t.toXML.<locals>.<lambda>   s    63D3DQqT3J3J r   )keyglyph)namerT   rP   z{:.3f}%      Y@   z{:0X}bitmap	octaboxes	attribute)indexvalue)ru   )rT   )	simpletagr*   r   newlinesortedr3   itemsbegintaghasattrrT   r   	getformatrN   formatgetattrrP   rR   rQ   endtag)r   writerr7   rc   arU   formatstringnamesfixesrJ   kr;   vs     `          r   toXMLztable_G__l_a_t.toXML   s   DLDKXXXO!!##)J)J)J)J
 
 
 !	 !	DAq OOG!O,,,NNq)$$ !I-4->1. .*eU  L LAN** '..wq!}}u/Ds/JKKDGG!(!?!?X44t444   -4->.. .*eU  % %AD" P P"+"2"271a==53H33N"O"OQ$F$77$777NN$$$$k***   qwwyy)) ! !1  AQ ???    MM'"""NNC!	 !	r   c                    |dk    rNt          t          |d                             | _        t          t          |d                             | _        |dk    rd S t          | d          si | _        |d         }t                      }|D ]}t          |t                    s|\  }}}	|dk    rJt          t          |d                             }
t          t          |d                             }|||
<   o|d	k    r6d
| _
        t                      }t          |d         d          |_        g |_        |d= |                                D ]A\  }
}t          ||
t          t          |d d                   dz  dz  dz                        B|	D ]}t          |t                    s|\  }}}	t                      }|                                D ]A\  }
}t          ||
t          t          |d d                   dz  dz  dz                        B|j                            |           ||_        || j        |<   d S )Nr*   rj   rp   r3   rq   rv   rw   rx   ru   Trt   r   g     o@rr   g      ?)r)   r   r*   intr   r~   r3   r   
isinstancetupler1   r   rP   rQ   r|   setattrrS   rT   )r   rq   rY   contentr7   gnamer3   elementr   
subcontentr   r   rU   sos                 r   fromXMLztable_G__l_a_t.fromXML   sQ   9 %	*:!;!;<<DLhu-@'ABBCCDK7??Ft\** 	! DOfWW
 	' 	'Ggu-- %,"C
k!!w0011w0011 !
1##$(!II!$U8_b!9!9
(O!KKMM L LDAqAq#eAcrcFmme&;e&Cc&I"J"JKKKK) * *G%gu55 ! /6,S% B % Q Q1As53B3==5+@5+H3+N'O'OPPPPJ%%b))))%&
"!+r   )N)r   r   r   __doc__r   r=   r+   r2   rd   r]   r^   r   r   r   r   r   r   r   @   s         
     (	 	 	     ,  	L 	L 	L$ $ $L#, #, #, #, #,r   r   )fontTools.miscr   fontTools.misc.fixedToolsr   fontTools.misc.textToolsr   	functoolsr   rh   r   r	   rF   r(   r/   r,   r-   rN   rR   r   dictr   r   r   r   r   <module>r      s=   " " " " " " 7 7 7 7 7 7 - - - - - -                   
 
 ! 
 	 	 	 	 	 	 	 		 	 	 	 	D 	 	 	k, k, k, k, k,\. k, k, k, k, k,r   