
    ZMh                    `    d Z ddlmZ ddlmZ ddlmZmZ dd
Z G d dej                  Z	dS )z*
Parse X Bitmap Distribution Format (BDF)
    )annotations)BinaryIO   )FontFileImagefr   returnqtuple[str, int, tuple[tuple[int, int], tuple[int, int, int, int], tuple[int, int, int, int]], Image.Image] | Nonec                   	 |                                  }|sd S |                    d          rn/|dd                                                              d          }i }	 |                                  }|r|                    d          rnT|                    d          }||dz   d                             d          ||d |                             d          <   t                      }	 |                                  }|r|                    d	          rn||d d         z  }:d
 |d                                         D             \  }}}}	d |d                                         D             \  }
}|
|f||	 |z
  ||z   |	 fdd||ff}	 t          j        d||f|dd          }n'# t          $ r t          j
        d||f          }Y nw xY w|t          |d                   ||fS )NTs	   STARTCHAR	   asciis   BITMAP    r   s   ENDCHARc              3  4   K   | ]}t          |          V  d S Nint.0ps     O/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/PIL/BdfFontFile.py	<genexpr>zbdf_char.<locals>.<genexpr>G   s(      $J$JSVV$J$J$J$J$J$J    BBXc              3  4   K   | ]}t          |          V  d S r   r   r   s     r   r   zbdf_char.<locals>.<genexpr>K   s(      881A888888r   DWIDTHr   1hexENCODING)readline
startswithstripdecodefind	bytearraysplitr   	frombytes
ValueErrornewr   )r   sidpropsibitmapwidthheightx_dispy_dispdwxdwybboxims                 r   bdf_charr7      s:   JJLL 	4<<%% 	 
122		g	&	&B EEJJLL 	ALL++ 	FF4LL'(Q}';';G'D'Daell7##$E [[FJJLL 	ALL,, 	!CRC&	 %K$JU5\5G5G5I5I$J$J$J!E666 98h 5 5 7 7888HC 
c
	&6!56>F7;	
AufD-_S5&/65#FF - - -YsUFO,,- s5$%%tR//s   F/ /!GGc                  $     e Zd ZdZd fdZ xZS )BdfFontFilez(Font file plugin for the X11 BDF format.fpr   r	   Nonec                   t                                                       |                                }|                    d          sd}t	          |          i }g }	 |                                }|r|                    d          rn|                    d          }||dz   d                             d          ||d |                             d          <   |d |         d	v rL|                    d
          dk     r3|                    ||dz   d                             d                     	 t          |          }|sd S |\  }}	\  }
}}}d|	cxk    rt          | j
                  k     rn n|
|||f| j
        |	<   O)Ns   STARTFONT 2.1znot a valid BDF fileTs   ENDPROPERTIESr   r   r   r   )s   COMMENTs	   COPYRIGHTs   LogicalFontDescriptionr   )super__init__r    r!   SyntaxErrorr$   r#   appendr7   lenglyph)selfr:   r*   msgr,   commentsr-   cr+   chxydstsrcr6   	__class__s                 r   r>   zBdfFontFile.__init___   s   KKMM||,-- 	#(Cc"""	CA %566 tA+,QURZ=+?+?+H+HE!BQB%,,w''(!u22266344q88OOAa!ebjM$8$8$A$ABBB	C	2A )*&BNRcBB((((TZ(((((!#S#r!1
2	2r   )r:   r   r	   r;   )__name__
__module____qualname____doc__r>   __classcell__)rK   s   @r   r9   r9   \   sC        222 2 2 2 2 2 2 2 2 2r   r9   N)r   r   r	   r
   )
rO   
__future__r   typingr    r   r   r7   r9    r   r   <module>rU      s   (  # " " " " "              ;0 ;0 ;0 ;0|2 2 2 2 2(# 2 2 2 2 2r   