U
    Fvfu                     @   s   d dl mZ d dlZd dlZd dlmZ d dlmZ dZdd Z	dd	 Z
d
d Zdd Zdd Zejdddgdd Zejdddgdd ZdS )    )BytesION)_afm)font_managers  StartFontMetrics 2.0
Comment Comments are ignored.
Comment Creation Date:Mon Nov 13 12:34:11 GMT 2017
FontName MyFont-Bold
EncodingScheme FontSpecific
FullName My Font Bold
FamilyName Test Fonts
Weight Bold
ItalicAngle 0.0
IsFixedPitch false
UnderlinePosition -100
UnderlineThickness 56,789
Version 001.000
Notice Copyright  2017 No one.
FontBBox 0 -321 1234 369
StartCharMetrics 3
C 0 ; WX 250 ; N space ; B 0 0 0 0 ;
C 42 ; WX 1141 ; N foo ; B 40 60 800 360 ;
C 99 ; WX 583 ; N bar ; B 40 -10 543 210 ;
EndCharMetrics
EndFontMetrics
c                  C   s(   d} |  d}t|}|| ks$td S )Nu   приветutf8)encoder   Z_to_strAssertionError)Zinp_strbyte_strret r
   =/tmp/pip-unpacked-wheel-7vhvci0g/matplotlib/tests/test_afm.pytest_nonascii_str$   s    

r   c                  C   sH   t t} t| }|ddddddddd	d
ddddddgddksDtd S )Ng       @zMyFont-BoldZFontSpecificzMy Font Boldz
Test FontsZBoldg        FigEdL@z001.000s   Copyright  2017 No one.r   ii  iq     )s   StartFontMetricss   FontNames   EncodingSchemes   FullName
   FamilyNames   Weights   ItalicAngles   IsFixedPitchs   UnderlinePositions   UnderlineThicknesss   Versions   Notices   FontBBoxs   StartCharMetrics)r   AFM_TEST_DATAr   _parse_headerr   )fhheaderr
   r
   r   test_parse_header.   s$    

r   c               
   C   s   t t} t|  t| }|ddddddgfdddddd	gfd
dddddgfdddddddgfdddddd	gfd
dddddgfdfkstd S )Ng     @o@spacer   g     ԑ@foo(   <   i   ih  g     8@barii     )r   *   c   )r   r   r   )r   r   r   r   Z_parse_char_metricsr   )r   Zmetricsr
   r
   r   test_parse_char_metricsC   s    

r   c                  C   s.   t t} t| }|jd= | dks*td S )Nr   zMy Font)r   r   r   AFMZ_headerZget_familynamer   )r   fontr
   r
   r   test_get_familyname_guessedR   s    
r   c                  C   s0   t ttdd} td| jdks,td S )Ns   Weight Bold
s   Weight Custom
 normal)	r   r   r   r   replacefmZafmFontPropertyZweightr   )r   r
   r
   r   &test_font_manager_weight_normalizationY   s    
r$   afm_datas   nope
really nopes   StartFontMetrics 2.0
Comment Comments are ignored.
Comment Creation Date:Mon Nov 13 12:34:11 GMT 2017
FontName MyFont-Bold
EncodingScheme FontSpecificc              	   C   s,   t | }tt t| W 5 Q R X d S )N)r   pytestZraisesRuntimeErrorr   r   )r%   r   r
   r
   r   test_bad_afm_   s    r(   s   StartFontMetrics 2.0
Comment Comments are ignored.
Comment Creation Date:Mon Nov 13 12:34:11 GMT 2017
Aardvark bob
FontName MyFont-Bold
EncodingScheme FontSpecific
StartCharMetrics 3s   StartFontMetrics 2.0
Comment Comments are ignored.
Comment Creation Date:Mon Nov 13 12:34:11 GMT 2017
ItalicAngle zero degrees
FontName MyFont-Bold
EncodingScheme FontSpecific
StartCharMetrics 3c              	   C   s@   t | }|tj t| W 5 Q R X t|jdks<td S )N   )	r   Zat_levelloggingERRORr   r   lenrecordsr   )r%   Zcaplogr   r
   r
   r   test_malformed_headerq   s    r.   )ior   r&   r*   Z
matplotlibr   r   r#   r   r   r   r   r   r$   markZparametrizer(   r.   r
   r
   r
   r   <module>   s0   

