| Server IP : 202.61.199.114 / Your IP : 216.73.217.139 Web Server : nginx/1.22.1 System : Linux de.arni-solutions.de 6.1.0-49-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.174-1 (2026-05-26) x86_64 User : web20 ( 1018) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /usr/local/lib/python3.9/dist-packages/matplotlib/__pycache__/ |
Upload File : |
a
���h4A � @ s� d Z ddlmZ ddlZddlZddlmZ e�e�Z dd� Z
dd � Zd
d� Zdd
� Z
dd� Zdd� Zdd� Zedd�Zde_ dej_ dej_ dej_ dd� Zdd� Zedd�Zd e_ d!ej_ d"ej_ d#ej_ d$d%� Zd&d'� ZG d(d)� d)�ZdS )*aL
A python interface to Adobe Font Metrics Files.
Although a number of other Python implementations exist, and may be more
complete than this, it was decided not to go with them because they were
either:
1) copyrighted or used a non-BSD compatible license
2) had too many dependencies and a free standing lib was needed
3) did more than needed and it was easier to write afresh rather than
figure out how to get just what was needed.
It is pretty easy to use, and has no external dependencies:
>>> import matplotlib as mpl
>>> from pathlib import Path
>>> afm_path = Path(mpl.get_data_path(), 'fonts', 'afm', 'ptmr8a.afm')
>>>
>>> from matplotlib.afm import AFM
>>> with afm_path.open('rb') as fh:
... afm = AFM(fh)
>>> afm.string_width_height('What the heck?')
(6220.0, 694)
>>> afm.get_fontname()
'Times-Roman'
>>> afm.get_kern_dist('A', 'f')
0
>>> afm.get_kern_dist('A', 'y')
-92.0
>>> afm.get_bbox_char('!')
[130, -9, 238, 676]
As in the Adobe Font Metrics File Format Specification, all dimensions
are given in units of 1/1000 of the scale factor (point size) of the font
being used.
� )�
namedtupleN� )� uni2type1c C s t t| ��S �N)�int�float��x� r
�9/usr/local/lib/python3.9/dist-packages/matplotlib/_afm.py�_to_int0 s r c C s$ t | t�r| �d�} t| �dd��S )Nzlatin-1�,�.)�
isinstance�bytes�decoder �replacer r
r
r � _to_float9 s
r c C s
| � d�S )N�utf8)r r r
r
r �_to_strD s r c C s | � dd�} dd� | �� D �S )N� ,� c S s g | ]}t |��qS r
)r ��.0�valr
r
r �
<listcomp>J � z$_to_list_of_ints.<locals>.<listcomp>)r �split��sr
r
r �_to_list_of_intsH s r c C s dd� | � � D �S )Nc S s g | ]}t |��qS r
)r r r
r
r r N r z&_to_list_of_floats.<locals>.<listcomp>)r r r
r
r �_to_list_of_floatsM s r! c C s | � � �� dv rdS dS d S )N)s false� 0s noFT)�lower�stripr r
r
r �_to_boolQ s r% c C s& t ttttt ttt t tdd� tt t t t t t t tttd�}i }d}| D ]�}|�� }|�d�r\qD|�dd�}|d }|r�|d kr�td
��d}t |�dkr�|d }nd
}z|| }W n" t
y� t�d|� Y qDY n0 z||�||<