U
    Q»{j¤  ã                   @   sF   d dl mZ d dlmZmZ d dlZdZe e¡ZG dd„ de	ƒZ
dS )é    )Ússtruct)ÚreadHexÚsafeEvalNa  
	>
	originOffsetX: h	# The x-value of the point in the glyph relative to its
						# lower-left corner which corresponds to the origin of
						# the glyph on the screen, that is the point on the
						# baseline at the left edge of the glyph.
	originOffsetY: h	# The y-value of the point in the glyph relative to its
						# lower-left corner which corresponds to the origin of
						# the glyph on the screen, that is the point on the
						# baseline at the left edge of the glyph.
	graphicType:  4s	# e.g. "png "
c                   @   s>   e Zd Zddd„Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ ZdS )ÚGlyphNr   c	           
      C   s°   || _ || _|| _|| _|| _|| _|| _|| _| jd k	r¬| jd dkrX| jd d… | _t| jƒdkr~ddl	m
}	 |	 d¡‚n.t| jƒdk r¬|  jdd dt| jƒ … 7  _d S )Néÿÿÿÿú é   r   ©ÚttLibz7Glyph.graphicType must not be longer than 4 characters.z    )ÚgidÚ	glyphNameÚreferenceGlyphNameÚoriginOffsetXÚoriginOffsetYÚrawdataÚgraphicTypeÚ	imageDataÚlenÚ	fontToolsr
   Ú
TTLibError)
Úselfr   r   r   r   r   r   r   r   r
   © r   ú_/var/www/html/bwave/python/venv/lib/python3.8/site-packages/fontTools/ttLib/tables/sbixGlyph.pyÚ__init__   s$    
ÿzGlyph.__init__c                 C   s   | j dkp| j dkS )zHReturns True if this glyph is a reference to another glyph's image data.ZdupeÚflip)r   )r   r   r   r   Úis_reference_type9   s    zGlyph.is_reference_typec                 C   sÈ   |  | j¡| _| jd kr.ddlm} | d¡‚t| jƒdkr¼t| jƒtk r`ddlm} | d¡‚t	 
t| jd t… | ¡ |  ¡ r¦t 
d| jtd … ¡\}|  |¡| _n| jtd … | _d | _| `| `d S )Nr   r	   zNo table data to decompilezGlyph header too short.ú>H)ZgetGlyphNamer   r   r   r   r
   r   r   ÚsbixGlyphHeaderFormatSizer   ÚunpackÚsbixGlyphHeaderFormatr   Ústructr   r   )r   ÚttFontr
   r   r   r   r   Ú	decompile=   s(    


  ÿzGlyph.decompilec                 C   s–   | j d kr ddlm} | d¡‚t d| | j ¡¡| _| jd krFd}nFt	 t
| ¡}|  ¡ rt|t d| | j¡¡7 }n| jd k	s‚t‚|| j7 }|| _d S )Nr   r	   z&Can't compile Glyph without glyph namer   ó    )r   r   r
   r   r    ÚpackÚ
getGlyphIDr   r   r   r   r   r   r   ÚAssertionErrorr   )r   r!   r
   r   r   r   r   ÚcompileY   s    



zGlyph.compilec                 C   sª   | j d kr&|jd| jd� | ¡  d S |jd| j | j| j| jd� | ¡  |  ¡ rd|jd| jd� n(| d¡ | ¡  | 	| j
¡ | d¡ | ¡  | d¡ | ¡  d S )NZglyph)Úname)r   r(   r   r   Úref)Ú	glyphnameÚhexdata)r   Z	simpletagr   ÚnewlineZbegintagr   r   r   r   Zdumphexr   Zendtag)r   Z	xmlWriterr!   r   r   r   ÚtoXMLl   s*    
û


zGlyph.toXMLc                 C   sj   |dkr8t d|d  d ƒ}t d| |¡¡| _|| _n.|dkrLt|ƒ| _nddlm} | 	d| ¡‚d S )	Nr)   z'''r*   r   r+   r   r	   zcan't handle '%s' element)
r   r    r$   r%   r   r   r   r   r
   r   )r   r(   ÚattrsÚcontentr!   r*   r
   r   r   r   ÚfromXMLˆ   s    zGlyph.fromXML)NNr   r   NNNr   )	Ú__name__Ú
__module__Ú__qualname__r   r   r"   r'   r-   r0   r   r   r   r   r      s           ÷
"r   )ZfontTools.miscr   ZfontTools.misc.textToolsr   r   r    r   Úcalcsizer   Úobjectr   r   r   r   r   Ú<module>   s
   
