
    ;3h                         d dl Z d dlZd dlmZmZ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y)    N)DictIterableOptionalcast)glyphname2unicode)ENCODINGPDFKeyError)	PSLiteralz[0-9a-fA-F]+namereturnc           	         t        | t              st        d| dt        |             | j	                  d      d   } | j	                  d      }t        |      dkD  rdj                  t        t        |            S | t        v r	t        |    S | j                  d      r| j                  d      }t        j                  |      rt        |      d	z  dk(  rt        dt        |      d	      D cg c]  }t        |||d	z    d
       }}|D ]  }t!        |        t        t"        |      }dj                  |      S | j                  d      r`| j                  d      }t        j                  |      r:d	t        |      cxk  rdk  r&n n#t        |d
      }t!        |       t#        |      S t        d| z        c c}w )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      )baseu   zXCould not convert unicode name "%s" to character because it does not match specification)
isinstancestrr
   typesplitlenjoinmapname2unicoder   
startswithstripHEXADECIMALmatchrangeint#raise_key_error_for_invalid_unicodechr)	r   
componentsname_without_uniiunicode_digitsdigit
charactersname_without_uunicode_digits	            S/var/www/html/audio-gradio/venv/lib/python3.12/site-packages/pdfminer/encodingdb.pyr    r       s    dC <@$t*N
 	

 ::c?1DCJ
:wws<455	"	" &&		::e,-.37G3H13LPQ3Q q#&6"7; $QQ/b9N  ( ;3E:;S.1J77:&&		C^,c.6I1NQ1NR8M/>}%%
	*,0	1 #s   .F<r0   c                 <    d| cxk  rdk  rn yt        d| z        y)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   zHUnicode digit %d is invalid because it is in the range D800 through DFFFNr	   )r0   s    r1   r'   r'   G   s1     }$u$35BC
 	
 %    c            
          e Zd ZU i Zeeef   ed<   i Zeeef   ed<   i Z	eeef   ed<   i Z
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s)ee
e<   / eee	e
dZe	 ddedeee      d	eeef   fd
       Zy)
EncodingDBstd2unicodemac2unicodewin2unicodepdf2unicode)StandardEncodingMacRomanEncodingWinAnsiEncodingPDFDocEncodingNr   diffr   c                    | j                   j                  || j                        }|ri|j                         }d}|D ]R  }t	        |t
              r|}t	        |t              s'	 t        t        t        |j                              ||<   |dz  }T |S # t        t        f$ r(}t        j                  t        |             Y d }~;d }~ww xY w)Nr   r   )	encodingsgetr6   copyr   r&   r   r    r   r   r   KeyError
ValueErrorlogdebug)clsr   r>   cid2unicodecidxes          r1   get_encodingzEncodingDB.get_encodingk   s     mm''coo>%**,KC a%C9-*+7S!&&8I+JC( 1HC  %j1 *		#a&))*s   %&BC#CC)N)__name__
__module____qualname__r6   r   r&   r   __annotations__r7   r8   r9   r   r   stdmacwinpdfr    cr@   classmethodr   r   objectrL    r3   r1   r5   r5   T   s    "$Kc3h$"$Kc3h$"$Kc3h$"$Kc3h$$, 	! c3S K K K K	! ('&%	I  ,0 x'( 
c3h	 r3   r5   )loggingretypingr   r   r   r   pdfminer.glyphlistr   pdfminer.latin_encr   pdfminer.pdfexceptionsr
   pdfminer.psparserr   compiler#   	getLoggerrM   rE   r   r    r&   r'   r5   rX   r3   r1   <module>rb      sp     	 1 1 0 ' . 'bjj)g!5s 5s 5p

s 

t 

* *r3   