%PDF- %PDF-
Direktori : /usr/lib/python3/dist-packages/PIL/__pycache__/ |
Current File : //usr/lib/python3/dist-packages/PIL/__pycache__/ImageFont.cpython-312.pyc |
� ��e�� � �V � d dl mZ d dlZd dlZd dlZd dlZd dlmZ d dlm Z d dl mZ d dlm Z ddlmZ dd lmZmZ G d � de� ZdZ dd lmZ d� Z G d� d� Z G d� d� Z G d� d� Zd� Zdd�Z d� Z!dd�Z"y# e$ r"ZddlmZ ej4 e� ZY dZ[�RdZ[ww xY w)� )�annotationsN)�IntEnum)�BytesIO)�Path)�BinaryIO� )�Image)�is_directory�is_pathc � � e Zd ZdZdZy)�Layoutr r N)�__name__� __module__�__qualname__�BASIC�RAQM� � �//usr/lib/python3/dist-packages/PIL/ImageFont.pyr r + s � � �E��Dr r i@B )� _imagingft)� DeferredErrorc �P � t � t | � t kD r d}t |� �y y )Nztoo many characters in string)�MAX_STRING_LENGTH�len� ValueError)�text�msgs r �_string_length_checkr ; s, � ��$��T��5F�)F�-����o�� *G�$r c �0 � e Zd ZdZd� Zd� Zdd�Zd� Zd� Zy) � ImageFontzPIL font wrapperc �� � t |d� 5 }d }dD ]b }|r|j � t j j |� d |z }t j |� }|s�S|j dv s�b n |r|j � d}t |� �|| _ | j ||� |j � d d d � y # t $ r Y ��w xY w# 1 sw Y y xY w)N�rb)z.pngz.gifz.pbmr ��1�Lzcannot find glyph data file)�open�close�os�path�splitextr �mode� Exception�OSError�file�_load_pilfont_data)�self�filename�fp�image�ext�fullnamer s r � _load_pilfontzImageFont._load_pilfontT s� � � �(�D� !� �R��E�/� #����K�K�M��!�w�w�/�/��9�!�<�s�B�H�!�J�J�x�0�E� ����z�!9�� #� ��K�K�M�3���c�l�"� �D�I��#�#�B��.��K�K�M�- � �� !� ���� � �s; �C�:C�"C�%C�4AC� C�C�C�C�C c �� � |j � dk7 r d}t |� �|j � j d� g | _ |j � }|r|dk( rn| j j |� �4|j d� }|j dvr d}t |� �|j � t j j |j |� | _ y )Ns PILfont zNot a PILfont file� ;s DATA i r# zinvalid font image mode) �readline�SyntaxError�split�info�append�readr+ � TypeError�loadr �core�font�im)r0 r. r3 r �s�datas r r/ zImageFont._load_pilfont_datam s� � ��=�=�?�l�*�&�C��c�"�"�� � ����d�#��� ��� � ��A���Y����I�I���Q�� � �y�y��"�� �:�:�Z�'�+�C��C�.� � � � ���J�J�O�O�E�H�H�d�3�� r c � � t |� t j | j j |� � | j j ||� S )a� Create a bitmap for the text. If the font uses antialiasing, the bitmap should have mode ``L`` and use a maximum value of 255. Otherwise, it should have mode ``1``. :param text: Text to render. :param mode: Used by some graphics drivers to indicate what mode the driver prefers; if empty, the renderer may return either mode. Note that the mode is always a string, to simplify C-level implementations. .. versionadded:: 1.1.5 :return: An internal PIL storage memory instance as defined by the :py:mod:`PIL.Image.core` interface module. )r r �_decompression_bomb_checkrB �getsize�getmask)r0 r r+ �args�kwargss r rI zImageFont.getmask� s@ � �$ �T�"� �'�'�� � �(9�(9�$�(?�@��y�y� � ��t�,�,r c �` � t |� | j j |� \ }}dd||fS )a� Returns bounding box (in pixels) of given text. .. versionadded:: 9.2.0 :param text: Text to render. :param mode: Used by some graphics drivers to indicate what mode the driver prefers; if empty, the renderer may return either mode. Note that the mode is always a string, to simplify C-level implementations. :return: ``(left, top, right, bottom)`` bounding box r �r rB rH �r0 r rJ rK �width�heights r �getbboxzImageFont.getbbox� s3 � � �T�"�� � �)�)�$�/� ��v��!�U�F�"�"r c �X � t |� | j j |� \ }}|S )z� Returns length (in pixels) of given text. This is the amount by which following text should be offset. .. versionadded:: 9.2.0 rM rN s r � getlengthzImageFont.getlength� s) � � �T�"�� � �)�)�$�/� ��v��r N�� ) r r r �__doc__r6 r/ rI rQ rS r r r r r Q s � ���24�2-�,#�$ r r c � � e Zd ZdZ d dd�Zd� Zd� Zd� Zd� Zdd�Z dd �Z dd �Z dd�Z dd�Z d � Zd� Zd� Zd� Zy)�FreeTypeFontz3FreeType font wrapper (requires _imagingft service)Nc �\ � ����� �dk r d}t |� �|� _ �� _ �� _ �� _ �t j t j fvr1t j �t j rYt j �nH�t j k( r5t j s%t j d� t j ��� _ ���� �fd�}t |� r�t |t � rt! |� }t"