a
    w=ic                  
   @   s   d Z ddlZddlZG dd dejZdedededed	ed
ededdfdeded	ed
ededdfded	ededed
ededdfdeded	ed
ededdfdZi Zdd Ze	e dS )zExtend the Python codecs module with a few encodings that are used in OpenType (name table)
but missing from Python.  See https://github.com/fonttools/fonttools/issues/236 for details.    Nc                   @   s8   e Zd Zdd Zdd ZdddZddd	Zd
d ZdS )ExtendCodecc                 C   sh   || _ || _|| _dd | D | _tdd | D | _tj	| j | j
| jd| _t|| j d S )Nc                 S   s   i | ]\}}||qS  r   ).0kvr   r   k/home/droni/.local/share/virtualenvs/DPS-5Je3_V2c/lib/python3.9/site-packages/fontTools/encodings/codecs.py
<dictcomp>       z(ExtendCodec.__init__.<locals>.<dictcomp>c                 s   s   | ]}t |V  qd S N)len)r   r   r   r   r   	<genexpr>   r	   z'ExtendCodec.__init__.<locals>.<genexpr>)nameencodedecode)r   base_encodingmappingitemsreversemaxvaluesmax_lencodecs	CodecInfor   r   inforegister_errorerror)selfr   r   r   r   r   r   __init__	   s    zExtendCodec.__init__c              
   C   s   t |}t|}| }|rz"||| j| jd}	||	7 }W qW q |y }
 zJ|||d |
j | j| j7 }||
\}}||7 }||d  }W Y d }
~
qd }
~
0 0 q||fS )N)errors)r   lookup_errorr   r   r   start)r   Zmapperoutput_typeexc_typeinputr   Zbase_error_handlerlengthoutpartereplacementposr   r   r   _map   s    
$zExtendCodec._mapstrictc                 C   s   |  tjtt||S r
   )r*   r   r   bytesUnicodeEncodeErrorr   r#   r   r   r   r   r   $   s    zExtendCodec.encodec                 C   s   |  tjtt||S r
   )r*   r   r   strUnicodeDecodeErrorr.   r   r   r   r   '   s    zExtendCodec.decodec                 C   s   t |trTt|jd |jd D ]0}|j|j| }|| jv r | j| |f  S q nXt |trt|jd |j| j d D ]0}|j|j| }|| j	v rz| j	| |f  S qz| j
|_|d S )N   )
isinstancer0   ranger    endobjectr   r-   r   r   r   encoding)r   r'   r4   sr   r   r   r   *   s    


 
zExtendCodec.errorN)r+   )r+   )__name__
__module____qualname__r   r*   r   r   r   r   r   r   r   r      s
   	

r   	shift_jis|   ~   \         i"!  i&   )      ~               big5)rC   rD   rE   rF   rG   euc_kri   i   )rC            rF   rG   gb2312   )Zx_mac_japanese_ttxZx_mac_trad_chinese_ttxZx_mac_korean_ttxZx_mac_simp_chinese_ttxc              	   C   s   t | } | tv r| tvrt|  \}}| dd  dks:J | d d |g}|D ]>}zt| W n tyv   Y qNY n0 t| ||t| <  qqNt|  jS d S )NZ_ttx)		encodingsnormalize_encoding_extended_encodings_cacher   lookupLookupErrorr   r   )r   r   r   Zbase_encodingsr   r   r   search_function]   s    
	

rV   )
__doc__r   rP   Codecr   chrrR   rS   rV   registerr   r   r   r   <module>   sL   3	"