
    #j                         d dl Z d dlZd dlmZ d dlmZmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZ  ej        d          Z e j        e          Zd	ed
efdZded
dfdZ G d d          ZdS )    N)Iterable)ClassVarcast)glyphname2unicode)ENCODINGPDFKeyError)	PSLiteralz[0-9a-fA-F]+namereturnc                 @   t          | t                    s"t          d|  dt          |                      |                     d          d         } |                     d          }t          |          dk    r(d                    t          t          |                    S | t          v rt          |          S | 
                    d          r|                     d          t                                        r~t                    d	z  dk    rhfd
t          dt                    d	          D             }|D ]}t          |           t          t           |          }d                    |          S n| 
                    d          r{|                     d          }t                              |          rLd	t          |          cxk    rdk    r2n n/t#          |d          }t          |           t!          |          S t          d|  d          )a  Converts Adobe glyph names to Unicode numbers.

    In contrast to the specification, this raises a KeyError instead of return
    an empty string when the key is unknown.
    This way the caller must explicitly define what to do
    when there is not a match.

    Reference:
    https://github.com/adobe-type-tools/agl-specification#2-the-mapping

    :returns unicode character if name resembles something,
    otherwise a KeyError
    z Could not convert unicode name "z?" to character because it should be of type str but is of type .r   _    uni   c                 H    g | ]}t          ||d z            d          S )r      base)int).0iname_without_unis     [/home/rurouni/.hermes/hermes-agent/venv/lib/python3.11/site-packages/pdfminer/encodingdb.py
<listcomp>z name2unicode.<locals>.<listcomp>1   sD        $QQY/b999      u   r   r   z6" to character because it does not match specification)
isinstancestrr	   typesplitlenjoinmapname2unicoder   
startswithstripHEXADECIMALmatchrange#raise_key_error_for_invalid_unicodechrr   )r   
componentsunicode_digitsdigit
charactersname_without_uunicode_digitr   s          @r   r(   r(      sJ    dC   
Dt D D7;DzzD D
 
 	

 ::c??1DCJ
:wws<44555	"	"	" &&			 &::e,,-.. 	'37G3H3H13LPQ3Q3Q   q#&6"7"7;;  N ( ; ;3E::::S.11J77:&&&			 &C^,, 	&c.6I6I1N1N1N1NQ1N1N1N1N1NR888M/>>>}%%%
	*4 	* 	* 	*  r   r5   c                 N    d| cxk     rdk     rn dS t          d|  d          dS )zUnicode values should not be in the range D800 through DFFF because
    that is used for surrogate pairs in UTF-16

    :raises KeyError if unicode digit is invalid
    i  i   zUnicode digit z8 is invalid because it is in the range D800 through DFFFNr   )r5   s    r   r.   r.   H   sY     }$$$$u$$$$$$3] 3 3 3
 
 	
 %$r   c            
          e Zd ZU i Zeeeef                  ed<   i Z	eeeef                  ed<   i Z
eeeef                  ed<   i Zeeeef                  ed<   eD ]/\  ZZZZZ ee          Zereee<   eree	e<   eree
e<   ereee<   0ee	e
edZeeeeeef         f                  ed<   e	 dded	ee         dz  d
eeef         fd            ZdS )
EncodingDBstd2unicodemac2unicodewin2unicodepdf2unicode)StandardEncodingMacRomanEncodingWinAnsiEncodingPDFDocEncoding	encodingsNr   diffr   c                    | j                             || j                  }|r|                                }d}|D ]}t	          |t
                    r|}t	          |t                    rv	 t          t          t          |j
                            ||<   nE# t          t          f$ r1}t                              t          |                     Y d }~nd }~ww xY w|dz  }|S )Nr   r   )rA   getr9   copyr!   r   r
   r(   r   r"   r   KeyError
ValueErrorlogdebug)clsr   rB   cid2unicodecidxes          r   get_encodingzEncodingDB.get_encodingl   s     m''co>> 	%**,,KC  a%% CC9-- *+7S!&8I8I+J+JC(($j1 * * *		#a&&))))))))*1HCs   +*BC''CC)N)__name__
__module____qualname__r9   r   dictr   r"   __annotations__r:   r;   r<   r   r   stdmacwinpdfr(   crA   classmethodr   objectrO    r   r   r8   r8   U   s        ,.K$sCx.)...,.K$sCx.)...,.K$sCx.)...,.K$sCx.)...$, 	! 	! c3SL 	! K 	! K 	! K 	! K ('&%	6 6IxS$sCx.012     )-  v% 
c3h	   [  r   r8   )loggingrecollections.abcr   typingr   r   pdfminer.glyphlistr   pdfminer.latin_encr   pdfminer.pdfexceptionsr	   pdfminer.psparserr
   compiler+   	getLoggerrP   rH   r"   r(   r   r.   r8   r\   r   r   <module>rg      s#    				 $ $ $ $ $ $ ! ! ! ! ! ! ! ! 0 0 0 0 0 0 ' ' ' ' ' ' . . . . . . ' ' ' ' ' 'bj))g!!5s 5s 5 5 5 5p

s 

t 

 

 

 

* * * * * * * * * *r   