HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib/python3.10/site-packages/PIL/__pycache__/PcfFontFile.cpython-310.pyc
o

wee�@s�ddlZddlmZmZddlmZddlmZddlmZ	ddlm
ZddlmZ
d	ZdZd
ZdZdZd
ZdZdZdZdZdd�dd�dd�dd�gZdd�ZGdd�dej�ZdS)�N�)�FontFile�Image)�i8)�i16be)�i16le)�i32be)�i32leifcp����� �@��cCs|dd?S)N�����bitsrr�H/home/arjun/projects/env/lib/python3.10/site-packages/PIL/PcfFontFile.py�<lambda>,srcC�|dd?d@S)N�r���rrrrrr-�cCr)N�r���rrrrrr.rcCr)N�?ri����rrrrrr/rcCs|||�d|��S)N�)�index)�s�orrr�sz3sr$csNeZdZdZdZd�fdd�	Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
�ZS)�PcfFontFilez(Font file plugin for the X11 PCF format.�name�	iso8859-1c	s"||_t|�d��}|tkrd}t|��t���t|�d��}i|_t|�D] }t|�d��}t|�d��t|�d��t|�d��f|j|<q'||_	|�
�|_|��}|�
|�}	|��}
t|
�D]-\}}|dur�||\}
}}}}}}}|df||||
||fdd|
|f|	|f|j|<qadS)Nrznot a PCF filer)�charset_encoding�l32�read�	PCF_MAGIC�SyntaxError�super�__init__�toc�range�fp�_load_properties�info�
_load_metrics�
_load_bitmaps�_load_encoding�	enumerate�glyph)�selfr1r(�magic�msg�count�i�type�metrics�bitmaps�encoding�ch�ix�xsize�ysize�left�right�width�ascent�descent�
attributes��	__class__rrr.<sF
0


�

���zPcfFontFile.__init__cCsX|j|\}}}|j}|�|�t|�d��}|d@r!tt}}ntt}}||||fS)Nr)r/r1�seekr)r*�b16�b32�l16)r9�tag�format�size�offsetr1�i16�i32rrr�
_getformatjs

zPcfFontFile._getformatc
	Cs�i}|�t�\}}}}||�d��}g}t|�D]}|�||�d��t|�d��||�d��f�q|d@rA|�d|d@tj�|�||�d���}	|D]\}
}}t	|	|
�}
|r^t	|	|�}|||
<qM|S)Nrrr)
rX�PCF_PROPERTIESr*r0�appendrrN�io�SEEK_CURr$)
r9�
propertiesr1rSrVrW�nprops�pr=�data�kr"�vrrrr2ys0


zPcfFontFile._load_propertiesc
Cs^g}|�t�\}}}}|j}|d@dkrct||�d���D]C}t|�d��d}t|�d��d}	t|�d��d}
t|�d��d}t|�d��d}|	|}
||}||
|||	|
||df�q|St||�d���D]@}||�d��}||�d��}	||�d��}
||�d��}||�d��}||�d��}|	|}
||}||
|||	|
|||f�ql|S)Ni�rr
rrrr)rX�PCF_METRICSrZr0r*r)r9r?r1rSrVrWrZr=rFrGrHrIrJrDrErKrrrr4�s2�zPcfFontFile._load_metricscCs,g}|�t�\}}}}||�d��}|t|�krd}t|��g}	t|�D]}
|	�||�d���q$g}td�D]}
|�||�d���q7|d@}|d@}
||
}|	�|�|�|�}t|
}d}|rdd}t|�D]+}
||
dd�\}}|	|
|
d�\}}|�t�	d||f|||�d|||���qh|S)	NrzWrong number of bitmapsrrz1;R�1r
�raw)
rX�PCF_BITMAPSr*�len�OSErrorr0rZ�
BYTES_PER_ROWr�	frombytes)r9r?r@r1rSrVrW�nbitmapsr;�offsetsr=�bitmap_sizes�bitorder�padindex�
bitmapsizer`�pad�moderDrE�b�errrr5�s8

"�zPcfFontFile._load_bitmapsc	s�|�t�\�}�}���d�����d��}}���d�����d��}}���d��||d||d}dgtd|�}��fdd�t|�D�}	t|t|��D]"}
z|	tt|
g��|j	��}|dkrm|||
<WqUt
ywYqUw|S)Nr
rrcsg|]	}���d���qS)r
)r*)�.0�_�r1rVrr�
<listcomp>�sz.PcfFontFile._load_encoding.<locals>.<listcomp>i��)rX�PCF_BDF_ENCODINGSr*�minr0rg�ord�	bytearray�decoder(�UnicodeDecodeError)r9rSrW�	first_col�last_col�	first_row�last_row�	nencodingrA�encoding_offsetsr=�encoding_offsetrrwrr6�s&���zPcfFontFile._load_encoding)r')�__name__�
__module__�__qualname__�__doc__r&r.rXr2r4r5r6�
__classcell__rrrLrr%7s.%-r%)r[�rr�_binaryrrrOrrQrrPr	r)r+rY�PCF_ACCELERATORSrcrf�PCF_INK_METRICSry�PCF_SWIDTHS�PCF_GLYPH_NAMES�PCF_BDF_ACCELERATORSrir$r%rrrr�<module>s0�