o
    sh                     @  sP   d dl mZ d dlZd dlmZ ddlmZmZ dZdddZ	G dd dZ
dS )    )annotationsN)BinaryIO   )Image_binaryi   fpr   values7tuple[int, int, int, int, int, int, int, int, int, int]returnNonec                 C  s.   |D ]}|dk r|d7 }|  t| qdS )z0Write network order (big-endian) 16-bit sequencer   i   N)writer   o16be)r   r   v r   `/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/PIL/FontFile.pyputi16   s
   r   c                   @  sF   e Zd ZU dZdZded< dddZdddZdddZdddZ	dS )FontFilez)Base class for raster font file handlers.NzImage.Image | Nonebitmapr
   r   c                 C  s   i | _ d gd | _d S )N   )infoglyph)selfr   r   r   __init__)   s   	zFontFile.__init__ixint`tuple[tuple[int, int], tuple[int, int, int, int], tuple[int, int, int, int], Image.Image] | Nonec                 C  s
   | j | S )N)r   )r   r   r   r   r   __getitem__5   s   
	zFontFile.__getitem__c                 C  s  | j rdS d } }}d}| jD ]4}|rD|\}}}}	t||d |d  }||d |d   }|tkr?|d7 }|d |d  }t||}q|}
|| }|
dkrU|dkrUdS || _td|
|f| _ dgd | _d }}tdD ]Y}| | }|r|\}}}}	|d |d  }||}}|| }|tkrd|| }}||}}|}|d | |d | |d | |d | f}| j 	|	
|| |||f| j|< qodS )zCreate metrics and bitmapNr   r         1r   )r   r   maxWIDTHysizer   newmetricsrangepastecrop)r   hwmaxwidthlinesr   ddstsrcimxsizer"   xyixxx0y0sr   r   r   compile@   sN   



,zFontFile.compilefilenamestrc                 C  s   |    | jsd}t|| jtj|d d d ttj|d d dC}|d |d| j	 d	
d
 |d tdD ]}| j| }|sTt|d qEt||d |d  |d   qEW d   dS 1 sow   Y  dS )z	Save fontzNo bitmap createdr   z.pbmPNGz.pilwbs   PILfont
z;;;;;;z;
asciis   DATA
r   )
r   r   r   r   r   r   r   r   r   r   r   r   N)r8   r   
ValueErrorsaveospathsplitextopenr   r"   encoder%   r$   r   )r   r9   msgr   idmr   r   r   r?   q   s    


 "zFontFile.save)r
   r   )r   r   r
   r   )r9   r:   r
   r   )
__name__
__module____qualname____doc__r   __annotations__r   r   r8   r?   r   r   r   r   r   $   s   
 


1r   )r   r   r   r	   r
   r   )
__future__r   r@   typingr    r   r   r!   r   r   r   r   r   r   <module>   s   

