o
    hq                  
   @   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   n/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/fontTools/encodings/codecs.py
<dictcomp>   s    z(ExtendCodec.__init__.<locals>.<dictcomp>c                 s   s    | ]}t |V  qd S N)len)r   r   r   r   r   	<genexpr>   s    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|}| }|rTz||| j| jd}	||	7 }W ||fS  |yQ }
 z%|||d |
j | j| j7 }||
\}}||7 }||d  }W Y d }
~
nd }
~
ww |s||fS )N)errors)r   lookup_errorr
   r   r   start)r   mapperoutput_typeexc_typeinputr   base_error_handlerlengthoutpartereplacementposr   r   r   _map   s$   
zExtendCodec._mapstrictc                 C      |  tjtt||S r	   )r+   r   r   bytesUnicodeEncodeErrorr   r#   r   r   r   r   r   &      zExtendCodec.encodec                 C   r-   r	   )r+   r   r   strUnicodeDecodeErrorr0   r   r   r   r   )   r1   zExtendCodec.decodec                 C   s   t |tr*t|jd |jd D ]}|j|j| }|| jv r(| j| |f  S qn,t |trVt|jd |j| j d D ]}|j|j| }|| j	v rU| j	| |f  S q=| j
|_|)N   )
isinstancer3   ranger   endobjectr   r/   r   r   r   encoding)r   r(   r7   sr   r   r   r   ,   s   


 
zExtendCodec.errorN)r,   )__name__
__module____qualname__r   r+   r   r   r   r   r   r   r   r      s    

r   	shift_jis|   ~   \         i"!  i&   )      ~               big5)rF   rG   rH   rI   rJ   euc_kri   i   )rF            rI   rJ   gb2312   )x_mac_japanese_ttxx_mac_trad_chinese_ttxx_mac_korean_ttxx_mac_simp_chinese_ttxc              	   C   s   t | } | tv rH| tvrCt|  \}}| dd  dksJ | d d |g}|D ]}zt| W n	 ty9   Y q'w t| ||t| <  t|  jS d S )N_ttx)		encodingsnormalize_encoding_extended_encodings_cacher   lookupLookupErrorr   r   )r   r   r   base_encodingsr   r   r   search_functionl   s    
	
r_   )
__doc__r   rX   Codecr   chrrZ   r[   r_   registerr   r   r   r   <module>   sV    5.