CoolFace
Apppublic

Aluode/PerceptionLabPortable

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
PcfFontFile.cpython-310.pyc48 linesDownload Raw Back to __pycache__
1o

2��Yi9�@s�UddlmZddlZddlmZmZddlmZddlmZ	ddlm3ZddlmZ
dd	lmZd4ZerAddlmZddlmZd
ZdZdZdZdZdZdZdZdZdZdd�dd�dd�dd�gZde d<d&d"d#�Z!Gd$d%�d%ej�Z"dS)'�)�annotationsN�)�FontFile�Image)�i8)�i16be)�i16le)�i32be)�i32leF)�Callable)�BinaryIOifcp����� �@��cCs|dd?S)N�����bitsrr�yE:\DocsHouse\542 percep lab latest\PerceptionLab\PerceptionLab_Portable\python_embed\Lib\site-packages\PIL/PcfFontFile.py�<lambda>2srcC�|dd?d@S)N�r�����rrrrrr3�cCr)N�r�����rrrrrr4rcCr)N�?ri����rrrrrr5rzlist[Callable[[int], int]]�
BYTES_PER_ROW�s�bytes�o�int�returncCs|||�d|��S)N�)�index)r$r&rrr�sz9sr+csZeZdZdZdZdd�fdd	�
Zddd�Zd dd�Zd!dd�Zd"dd�Z	d#dd�Z5�ZS)$�PcfFontFilez(Font file plugin for the X11 PCF format.�name�	iso8859-1�fpr�charset_encoding�strc	s"||_t|�d��}|tkrd}t|��t���t|�d��}i|_t|�D] }t|�d��}t|�d��t|�d��t|�d��f|j|<q'||_	|�6�|_|��}|�
|�}	|��}7t|8�D]-\}}|dur�||\}
}}}}}}}|df||||
||fdd|
|f|	|f|j|<qadS)Nrznot a PCF filer)r0�l32�read�	PCF_MAGIC�SyntaxError�super�__init__�toc�ranger/�_load_properties�info�
_load_metrics�
_load_bitmaps�_load_encoding�	enumerateZglyph)�selfr/r0�magic�msg�count�i�type�metrics�bitmaps�encoding�chZix�xsize�ysize�left�right�width�ascent�descent�9attributes��	__class__rrr7BsF100111213�1415���zPcfFontFile.__init__�tagr'r(�Dtuple[BinaryIO, int, Callable[[bytes], int], Callable[[bytes], int]]cCsX|j|\}}}|j}|�|�t|�d��}|d@r!tt}}ntt}}||||fS)Nr)r8r/�seekr2r3�b16�b32�l16)r@rT�format�size�offsetr/�i16�i32rrr�16_getformatps1718zPcfFontFile._getformat�dict[bytes, bytes | int]cs�i}|�t�\�}}����d��}��fdd�t|�D�}|d@r-��d|d@tj������d���}|D]\}}}	|rEt||	�n|	}19|20|t||�<q9|S)Nrcs4g|]}���d��t��d�����d��f�qS)rr)r3r��.0�_�r/r^rr�21<listcomp>�s4z0PcfFontFile._load_properties.<locals>.<listcomp>r)r_�PCF_PROPERTIESr3r9rV�io�SEEK_CURr+)r@�22propertiesrZr]Znprops�p�data�kr$�vZproperty_valuerrdrr:�szPcfFontFile._load_properties�3list[tuple[int, int, int, int, int, int, int, int]]c23Cs^g}|�t�\}}}}|j}|d@dkrct||�d���D]C}t|�d��d}t|�d��d}	t|�d��d}24t|�d��d}t|�d��d}|	|}
||}||
|||	|25||df�q|St||�d���D]@}||�d��}||�d��}	||�d��}26||�d��}||�d��}||�d��}|	|}
||}||
|||	|27|||f�ql|S)Ni�rr
rrrr)r_�PCF_METRICS�appendr9r3r)r@rFr/rZr]r^rprDrLrMrNrOrPrJrKrQrrrr<�s2�zPcfFontFile._load_metricsrF�list[Image.Image]cs|�t�\�}}����d��}|t|�krd}t|����fdd�t|�D�}��fdd�td�D�}|d@}|d@}	||	}28|�|29���|30�}t|	}d}
|rTd	}
g}t|�D]+}||dd31�\}}|||d32�\}}|�t�	d	||f|||�d|
||���qZ|S)NrzWrong number of bitmapsc�g|]	}���d���qS�r�r3rardrrre��z-PcfFontFile._load_bitmaps.<locals>.<listcomp>crrrsrtrardrrre�rurrz1;R�1r
�raw)33r_�PCF_BITMAPSr3�len�OSErrorr9rpr#r�	frombytes)r@rFrZr]ZnbitmapsrB�offsetsZbitmap_sizesZbitorderZpadindexZ34bitmapsizerk�pad�moderGrDrJrK�b�errdrr=�s03536"�zPcfFontFile._load_bitmaps�list[int | None]c	s�|�t�\�}�}���d�����d��}}���d�����d��}}���d��||d||d}dgtd|�}��fdd�t|�D�}	t|t|��D]"}37z|	tt|38g��|j	��}|dkrm|||39<WqUt40ywYqUw|S)Nr
rrcrr)r
rtra�r/r]rrre�ruz.PcfFontFile._load_encoding.<locals>.<listcomp>i��)r_�PCF_BDF_ENCODINGSr3�minr9ry�ord�	bytearray�decoder0�UnicodeDecodeError)r@rZr^Z	first_colZlast_col�	first_row�last_rowZ	nencodingrHZencoding_offsetsrDZencoding_offsetrr�rr>�s&���zPcfFontFile._load_encoding)r.)r/rr0r1)rTr'r(rU)r(r`)r(rn)rFrnr(rq)r(r�)�__name__�41__module__�__qualname__�__doc__r-r7r_r:r<r=r>�
__classcell__rrrRrr,=s42.434445%*r,)r$r%r&r'r(r%)#�46__future__rrg�rr�_binaryrrrWrrYr	rXr47r2�
TYPE_CHECKING�collections.abcr�typingrr4rfZPCF_ACCELERATORSrorxZPCF_INK_METRICSr�ZPCF_SWIDTHSZPCF_GLYPH_NAMESZPCF_BDF_ACCELERATORSr#�__annotations__r+r,rrrr�<module>s:�48
Aluode/PerceptionLabPortable · CoolFace