
    )i              	       4   S SK r S SKrS SKrS SKJr  S SKJrJrJrJ	r	J
r
JrJrJrJrJrJrJr  SSKJr  SSKJr  SSKJr  SSKJr  SS	KJr  SS
KJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJ r   SSK!J"r"  SSK!J#r#  SSK!J$r$  SSK!J%r%  SSK!J&r&  SSK!J'r'  SSK!J(r(J)r)  SSK!J*r*  SSK+J,r,  SSK+J-r-  SSK+J.r.  SSK+J/r/  SSK+J0r0  SSK+J1r1  SSK+J2r2  SSK3J4r4J5r5  SS K3J6r6  SS!K3J7r7  SS"K3J8r8  SS#K3J9r9  \(       a  SS$K:J;r;  \ Rx                  " \=5      r>S%\	\?   S&\\@\A4   4S' jrBS%\	\?   S&\\@\\A\54   4   4S( jrC " S) S*5      rD " S+ S,\1\@   5      rES-rFS.S/S0.rGS1\HS&\\@\\\A\@4      4   4S2 jrI " S3 S45      rJ " S5 S65      rK " S7 S8\"5      rL " S9 S:\L5      rM\-" S;5      rN\-" S<5      rO\\\@\A4   \\P\A4   4   rQ " S= S>5      rR " S? S@\R5      rS " SA SB\S5      rT " SC SD\T5      rU " SE SF\S5      rV " SG SH\R5      rWSI\\P   S&S4SJ jrX\=SK:X  a  \X" \R                  5        gg)L    N)BytesIO)AnyBinaryIODictIterableIteratorListMappingOptionalTupleUnioncastTYPE_CHECKING   )settings)CMap)CMapBase)CMapDB)
CMapParser)FileUnicodeMap)IdentityUnicodeMap)
UnicodeMap)
EncodingDB)name2unicodeFONT_METRICS)PDFException)	PDFStream)
dict_value)	int_value)
list_value)	num_value)resolve1resolve_all)stream_value)KWD)LIT)PSEOF)	PSKeyword)	PSLiteral)PSStackParser)literal_name)MatrixPoint)Rect)apply_matrix_norm)choplist)nunpack)PDFResourceManagerseqreturnc                    0 n/ nU  H  n[        U[        5      (       a;  U(       a2  US   n[        U5       H  u  pVXa[        [        U5      U-   '   M     / nMQ  MS  [        U[        [
        45      (       d  Mp  UR                  U5        [        U5      S:X  d  M  Uu  pGn[        [        [        U5      [        [        U5      S-   5       H  nXaU'   M	     / nM     U$ )z;Build a mapping of character widths for horizontal writing.   r   )	
isinstancelist	enumerater   intfloatappendlenrange)r4   widthsrvchar1iwchar2s           P/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/pdfminer/pdffont.py
get_widthsrI   :   s    !FAa"'lFQ344U+a/0 +	 
 C<((HHQK1v{$%!qtC/c51AA1EFA !1I G  M    c                    0 n/ nU  H  n[        U[        5      (       aM  U(       aD  US   n[        [        SU5      5       H"  u  nu  pgnXgU44U[	        [
        U5      U-   '   M$     / nMc  Me  [        U[
        [        45      (       d  M  UR                  U5        [        U5      S:X  d  M  Uu  pIpgn[        [	        [
        U5      [	        [
        U	5      S-   5       H
  nXgU44X'   M     / nM     U$ )z9Build a mapping of character widths for vertical writing.r7   r8      r   )
r9   r:   r;   r1   r   r<   r=   r>   r?   r@   )
r4   rA   rB   rC   rD   rE   rF   vxvyrG   s
             rH   get_widths2rO   O   s    -/FAa"(1(1a.(A$Q45Bx=F4U+a/0 )B	 
 C<((HHQK1v{,-)qbtC/c51AA1EFA!"HFI G  MrJ   c            	       N    \ rS rSr\S\S\\\\4   \\\	4   4   4S j5       r
Srg)FontMetricsDBd   fontnamer5   c                     [         U   $ Nr   )clsrS   s     rH   get_metricsFontMetricsDB.get_metricse   s    H%%rJ    N)__name__
__module____qualname____firstlineno__classmethodstrr   r   objectr<   rW   __static_attributes__rY   rJ   rH   rQ   rQ   d   s=    &3 &5c6k1BDcN1R+S & &rJ   rQ   c                       \ rS rSr\" S5      r\" S5      r\" S5      r\" S5      r\" S5      r	\" S5      r
\" S5      r\" S	5      rS
\SS4S jrS\\\4   4S jrS\S\SS4S jrSrg)Type1FontHeaderParserk   s   begins   ends   defs   puts   dicts   arrays   readonlys   fordatar5   Nc                 >    [         R                  " X5        0 U l        g rU   )r+   __init___cid2unicode)selfre   s     rH   rg   Type1FontHeaderParser.__init__v   s    t*,.rJ   c                      U R                  5       u  p [        [        [        U5      5      U R
                  U'   M<  ! [         a     U R
                  $ f = f! [         a(  n[        R                  [	        U5      5         SnANJSnAff = f)a5  Parse the font encoding.

The Type1 font encoding maps character codes to character names. These
character names could either be standard Adobe glyph names, or
character names associated with custom CharStrings for this font. A
CharString is a sequence of operations that describe how the character
should be drawn. Currently, this function returns '' (empty string)
for character names that are associated with a CharStrings.

Reference: Adobe Systems Incorporated, Adobe Type 1 Font Format

:returns mapping of character identifiers (cid's) to unicode characters
N)	
nextobjectr(   r   r   r_   rh   KeyErrorlogdebug)ri   cidnamees       rH   get_encoding"Type1FontHeaderParser.get_encoding{   s     "oo/")5d3o)F!!#&   
      "		#a&!!"s&   > &A 
AA
B#BBpostokenc                     X R                   L a^  U R                  S5      u  u  p4u  p5[        U[        5      (       a1  [        U[        5      (       a  U R                  U[        U5      45        g )N   )KEYWORD_PUTpopr9   r<   r*   add_resultsr,   )ri   ru   rv   _keyvalues         rH   
do_keyword Type1FontHeaderParser.do_keyword   sX    $$$%)XXa["Xaz#s##
5)(D(D  #|E':!;<rJ   )rh   )rZ   r[   r\   r]   r&   KEYWORD_BEGINKEYWORD_ENDKEYWORD_DEFry   KEYWORD_DICTKEYWORD_ARRAYKEYWORD_READONLYKEYWORD_FORr   rg   r   r<   r_   rs   r)   r   ra   rY   rJ   rH   rc   rc   k   s    MMf+Kf+Kf+Kw<LMM;'f+KX $ 
!d38n !2c )  rJ   rc   )0123456789.rr   ze-N-z
Identity-Hz
Identity-V)z	DLIdent-Hz	DLIdent-Vre   c                 $   0 n[        U 5      n/ n UR                  S5      nU(       d   U$ [        U5      nUS::  a  X1U'   / nM5  US:X  ag  SnSnU(       aP  [        UR                  S5      5      nUS-	  US-  4 H  n	U	S:X  a  SnM  [        U	   n
U
c   eXj-  nM!     U(       a  MP  [	        U5      nOS	U::  a  US
::  a  US-
  nO[        UR                  S5      5      nSU::  a  US::  a  US-
  S-  U-   S-   nOSU::  a  US::  a  US-
  S-  * U-
  S-
  nOi[        UR                  S5      5      nSU::  a  US-  nUS:X  a	  US-  U-  nO5US-  US-  -  [
        R                  " SUR                  S5      5      S   -  nUR                  U5        GM  )Nr          T      F                   l                        >Hrx   r   )r   readordNIBBLESr=   structunpackr>   )re   dfpstackcb0sloopbnnibbler~   b1b2s                 rH   getdictr      s   ,.A	B%'E
GGAJH HG V8bEE8AD
Oq&!b&)ABw$!(%111 * $ !HE2X")HERWWQZBbyR3Ys(qB.4rSy8/*R/#5_"9#IB8!GbLE"HrRx/&--bggaj2QRS2TTEUM rJ   c                   ^    \ rS rSrSr " S S5      rS\S\SS4S	 jrS
\	S\
\\4   4S jrSrg)CFFFont   (  z.notdefspaceexclamquotedbl
numbersigndollarpercent	ampersand
quoteright	parenleft
parenrightasteriskpluscommahyphenperiodslashzeroonetwothreefourfivesixseveneightninecolon	semicolonlessequalgreaterquestionatABCDEFGHIJKLMNOPQRSTUVWXYZbracketleft	backslashbracketrightasciicircum
underscore	quoteleftar   r   r   rr   fghrE   jklmr   opqrB   r   turC   rF   xyz	braceleftbar
braceright
asciitilde
exclamdowncentsterlingfractionyenflorinsectioncurrencyquotesinglequotedblleftguillemotleftguilsinglleftguilsinglrightfiflendashdagger	daggerdblperiodcentered	paragraphbulletquotesinglbasequotedblbasequotedblrightguillemotrightellipsisperthousandquestiondowngraveacute
circumflextildemacronbreve	dotaccentdieresisringcedillahungarumlautogonekcaronemdashAEordfeminineLslashOslashOEordmasculineaedotlessilslashoslashoe
germandblsonesuperior
logicalnotmu	trademarkEthonehalf	plusminusThorn
onequarterdivide	brokenbardegreethornthreequarterstwosuperior
registeredminusethmultiplythreesuperior	copyrightAacuteAcircumflex	AdieresisAgraveAringAtildeCcedillaEacuteEcircumflex	EdieresisEgraveIacuteIcircumflex	IdieresisIgraveNtildeOacuteOcircumflex	OdieresisOgraveOtildeScaronUacuteUcircumflex	UdieresisUgraveYacute	YdieresisZcaronaacuteacircumflex	adieresisagravearingatildeccedillaeacuteecircumflex	edieresisegraveiacuteicircumflex	idieresisigraventildeoacuteocircumflex	odieresisograveotildescaronuacuteucircumflex	udieresisugraveyacute	ydieresiszcaronexclamsmallHungarumlautsmalldollaroldstyledollarsuperiorampersandsmall
Acutesmallparenleftsuperiorparenrightsuperiortwodotenleaderonedotenleaderzerooldstyleoneoldstyletwooldstylethreeoldstylefouroldstylefiveoldstylesixoldstylesevenoldstyleeightoldstylenineoldstylecommasuperiorthreequartersemdashperiodsuperiorquestionsmall	asuperior	bsuperiorcentsuperior	dsuperior	esuperior	isuperior	lsuperior	msuperior	nsuperior	osuperior	rsuperior	ssuperior	tsuperiorffffifflparenleftinferiorparenrightinferiorCircumflexsmallhyphensuperior
GravesmallAsmallBsmallCsmallDsmallEsmallFsmallGsmallHsmallIsmallJsmallKsmallLsmallMsmallNsmallOsmallPsmallQsmallRsmallSsmallTsmallUsmallVsmallWsmallXsmallYsmallZsmallcolonmonetary	onefittedrupiah
TildesmallexclamdownsmallcentoldstyleLslashsmallScaronsmallZcaronsmallDieresissmall
Brevesmall
CaronsmallDotaccentsmallMacronsmall
figuredashhypheninferiorOgoneksmall	RingsmallCedillasmallquestiondownsmall	oneeighththreeeighthsfiveeighthsseveneighthsonethird	twothirdszerosuperiorfoursuperiorfivesuperiorsixsuperiorsevensuperioreightsuperiorninesuperiorzeroinferioroneinferiortwoinferiorthreeinferiorfourinferiorfiveinferiorsixinferiorseveninferioreightinferiornineinferiorcentinferiordollarinferiorperiodinferiorcommainferiorAgravesmallAacutesmallAcircumflexsmallAtildesmallAdieresissmall
AringsmallAEsmallCcedillasmallEgravesmallEacutesmallEcircumflexsmallEdieresissmallIgravesmallIacutesmallIcircumflexsmallIdieresissmallEthsmallNtildesmallOgravesmallOacutesmallOcircumflexsmallOtildesmallOdieresissmallOEsmallOslashsmallUgravesmallUacutesmallUcircumflexsmallUdieresissmallYacutesmall
ThornsmallYdieresissmallz001.000z001.001z001.002z001.003BlackBoldBookLightMediumRegularRomanSemiboldc                   h    \ rS rSrS\SS4S jrS\4S jrS\4S jr	S\S\
4S	 jrS\\
   4S
 jrSrg)CFFFont.INDEXi`  r   r5   Nc                    Xl         / U l        [        R                  " SU R                   R	                  S5      5      u  p#[        US-   5       H@  nU R                  R                  [        U R                   R	                  U5      5      5        MB     U R                   R                  5       S-
  U l	        U R                   R                  U R                  U R                  S   -   5        g )Nz>HBr8   r   r7   )r   offsetsr   r   r   r@   r>   r2   tellbaseseek)ri   r   countoffsizerE   s        rH   rg   CFFFont.INDEX.__init__a  s    G&(DL%}}UDGGLLODU519%##GDGGLL,A$BC &*DIGGLLT\\"%556rJ   c                     S[        U 5      -  $ )Nz<INDEX: size=%d>)r?   ri   s    rH   __repr__CFFFont.INDEX.__repr__k  s    %D	11rJ   c                 2    [        U R                  5      S-
  $ Nr   )r?   r9  rA  s    rH   __len__CFFFont.INDEX.__len__n  s    t||$q((rJ   rE   c                     U R                   R                  U R                  U R                  U   -   5        U R                   R	                  U R                  US-      U R                  U   -
  5      $ rE  )r   r<  r;  r9  r   )ri   rE   s     rH   __getitem__CFFFont.INDEX.__getitem__q  sP    GGLLT\\!_4577<<QU 3dll1o EFFrJ   c                 R   ^  [        U 4S j[        [        T 5      5       5       5      $ )Nc              3   .   >#    U  H
  nTU   v   M     g 7frU   rY   ).0rE   ri   s     rH   	<genexpr>)CFFFont.INDEX.__iter__.<locals>.<genexpr>v  s     :)9AQ)9s   )iterr@   r?   rA  s   `rH   __iter__CFFFont.INDEX.__iter__u  s    :s4y)9:::rJ   )r;  r   r9  )rZ   r[   r\   r]   r   rg   r_   rB  r<   rF  bytesrI  r   rQ  ra   rY   rJ   rH   INDEXr7  `  sS    	x 	D 		2c 	2	)S 	)	G 	G 	G	;huo 	;rJ   rT  rq   r   r5   Nc                 
   Xl         X l        [        R                  " SU R                  R	                  S5      5      u  p4pVU R                  R	                  US-
  5        U R                  U R                  5      U l        U R                  U R                  5      U l        U R                  U R                  5      U l        U R                  U R                  5      U l	        [        U R                  S   5      U l        U R                  R                  SS/5      u  nU R                  R                  SS/5      u  nU R                  R                  SS/5      u  n	U R                  R                  [        [        U	5      5        U R                  U R                  5      U l        [#        U R                   5      U l        0 U l        0 U l        U R                  R                  [        [        U5      5        U R                  R	                  S5      n
U
S:X  a  [        R                  " S	U R                  R	                  S5      5      u  n[+        [        R                  " S	U-  U R                  R	                  U5      5      5       H!  u  pXR&                  U'   XR(                  U'   M#     OU
S
:X  a  [        R                  " S	U R                  R	                  S5      5      u  nSn[-        U5       Ho  n[        R                  " SU R                  R	                  S5      5      u  nn[-        XU-   S-   5       H$  nXR&                  U'   XR(                  U'   US-  nM&     Mq     O[/        SU
-  5      e0 U l        0 U l        U R                  R                  [        [        U5      5        U R                  R	                  S5      n
U
S:X  a  U R$                  S-
  n[+        [        [4        [        S4   [        R                  " SSU-  -   U R                  R	                  SU-  5      5      5      5       H9  u  nnUS-  nU R7                  U5      nXR0                  U'   UU R2                  U'   M;     g U
S
:X  a  [        R                  " S	U R                  R	                  S5      5      u  nSn[-        U5       H  n[        R                  " SU R                  R	                  S5      5      u  nn[-        XU-   S-   5       H6  nU R7                  U5      nXR0                  U'   UU R2                  U'   US-  nM8     M     g U
S:X  a   [9        SU
45      5       e[/        SU
-  5      e)NBBBBr   r   r   r      r       r      BBrx   zunsupported encoding format: %r.>r      	Unhandledzunsupported charset format: %r)rq   r   r   r   r   rT  
name_index
dict_indexstring_index
subr_indexr   top_dictgetr<  r   r<   
charstringr?   nglyphscode2gidgid2coder;   r@   
ValueErrorname2gidgid2namer   getstrr_   )ri   rq   r   _major_minorhdrsizer>  charset_posencoding_poscharstring_posformatr   codegidrE   firstnleftsidsidnames                      rH   rg   CFFFont.__init__x  s"   	-3]]6477<<PQ?-S*Wq[!**TWW-**TWW- JJtww/**TWW- 23**2s3--++B4 MM--b1#6T#~./**TWW-4??+T#|,-aW==dggll1o6DQ(sQwQ)PQ&)d#%)c"  R w==dggll1o6DQD1X!'tTWW\\!_!E (9:C*-MM$')-MM#&AID ;  >GHHT#{+,aWq A'U38_fmmC#'M477<<PQTUPUCV&WX
c q++c*),g&%,c". 	! w==dggll1o6DQC1X!'tTWW\\!_!E (9:C"kk#.G-0MM'*)0DMM#&1HC	 ;  	 w4#{F3445=FGGrJ   rw  c                     U[        U R                  5      :  a  U R                  U   $ U R                  U[        U R                  5      -
     $ rU   )r?   STANDARD_STRINGSr`  )ri   rw  s     rH   rk  CFFFont.getstr  sI     T**++((--  s4+@+@'A!ABBrJ   )rd  rf  r_  r   rg  rj  rq   ri  r^  re  r`  ra  rb  )rZ   r[   r\   r]   r{  rT  r_   r   rg   r<   r   rS  rk  ra   rY   rJ   rH   r   r      sT    HT; ;0MS Mh M4 M^C# C%U
"3 CrJ   r   c                   N    \ rS rSr " S S\5      rS\S\SS4S jrS\	4S	 jr
S
rg)TrueTypeFonti  c                       \ rS rSrSrg)TrueTypeFont.CMapNotFoundi  rY   NrZ   r[   r\   r]   ra   rY   rJ   rH   CMapNotFoundr    s    rJ   r  rq   r   r5   Nc           
         Xl         X l        0 U l        UR                  S5      U l         [        [        [        [        [        [        4   [        R                  " SUR                  S5      5      5      u  p4pV[        U5       Ha  n[        [        [        [        [        [        4   [        R                  " SUR                  S5      5      5      u  ppX4U R                  U'   Mc     g ! [        R                   a     g f = f)Nr   >HHHHr   z>4sLLLr   )rq   r   tablesr   fonttyper   r   r<   r   r   r@   rS  error)ri   rq   r   ntables_1_2_3r|   
name_bytestsumoffsetlengths               rH   rg   TrueTypeFont.__init__  s    	46
	$(c3S()6=="''!*+M%!W" 7^59%c3./xQS1U626 ,2*:J'	 $ 	 || 	 	s   B>C* *D Dc                    SU R                   ;  a  [        R                  eU R                   S   u  pU R                  nUR	                  U5        [        [        [        [        4   [        R                  " SUR                  S5      5      5      u  pE/ n[        U5       HX  nUR                  [        [        [        [        [        4   [        R                  " SUR                  S5      5      5      5        MZ     0 nU GH  u  pnUR	                  X-   5        [        [        [        [        [        4   [        R                  " SUR                  S5      5      5      u  pnUS:X  aW  UR                  [        [        [        [        S	4   [        R                  " S
UR                  S5      5      5      5      5        M  US:X  Ga  [        [        [        S	4   [        R                  " SUR                  S5      5      5      nS/S-  n[        U5       H  u  nnUUUS-  '   M     [        U5      S-  S-   n/ n[        U5       H}  n[        [        [        [        [        [        4   [        R                  " SUR                  S5      5      5      u  nnnnUR                  UUUUUR!                  5       S-
  U-   45        M     U H  u  nnnnnU(       d  M  UUU   S-  -   nUR	                  U5        [        U5       HU  n[        [        [           [        R                  " SUR                  S5      5      5      S   nU(       a  UU-  nUUUU-   '   MW     M     GMa  US:X  Ga;  [        [        [        [        [        [        4   [        R                  " SUR                  S5      5      5      u  npnUS-  n[        [        [        S	4   [        R                  " SU-  UR                  SU-  5      5      5      nUR                  S5        [        [        [        S	4   [        R                  " SU-  UR                  SU-  5      5      5      n[        [        [        S	4   [        R                  " SU-  UR                  SU-  5      5      5      n UR!                  5       n[        [        [        S	4   [        R                  " SU-  UR                  SU-  5      5      5      n![#        UUU U!5       H  u  n"n#n$n%U%(       au  UR	                  UU%-   5        [        U#U"S-   5       HL  n[        [        [           [        R                  " SUR                  S5      5      5      S   n&U&U$-   S-  UU'   MN     M  [        U#U"S-   5       H  nUU$-   S-  UU'   M     M     GM   [%        SU45      5       e   ['        5       n'UR)                  5        H  u  n(nU'R+                  UU(5        M     U'$ )Ns   cmapz>HHr   z>HHLr   z>HHH   r   .z>256Br   rx   z>256Hi   i    r   z>HHhHr   r  z>%dHz>%dhi  r]  )r  r~  r  r   r<  r   r   r<   r   r   r   r@   r>   updater;   maxr:  zipr_   r   itemsadd_cid2unichr))ri   base_offsetr  r   version
nsubtables	subtablesrE   char2gidr  r  	st_offsetfmttypefmtlenfmtlangsubheaderkeys
firstbytesr  nhdrshdrs	firstcodeentcountdeltar  ru   ru  r   rt  segcountr  ecsscsiddsidrsecsciddidrr   unicode_mapchars)                                            rH   create_unicode_mapTrueTypeFont.create_unicode_map  s   $++%+++ $G 4WW
 $U38_fmmE277ST:6V W02	z"AU3S=)6==+LM # $&#,RYGGK+,)-c3m$fmmFBGGAJ&G*&Wg !|U38_fmmGRWWS\.RS
 A $#s(OV]]7BGGCL%I!  S4Z
'6FQ)*JqAv& 7M*a/!3=?uA;?c3S016=="''RS*3U<8Y% KKIx	APV@V WX	 &
 =A8Q	8UC# %A!);<EGGCL"8_"5:v}}T2771:/NOPQR5LC.1+	 - =A A)-#sC,-v}}Wbggaj/Q*&22 Q#s(OMM&8"3RWWQ\5JK 
#s(OMM&8"3RWWQ\5JK #s(OMM&8"3RWWQ\5JK ggi#s(OMM&8"3RWWQ\5JK +.c3d*C&RS#c	*!&r26!2A $U3ZtRWWQZ1P QRS TA+,s7f*<HQK "3 "'r26!2A+,s7f*<HQK "3 +D :c;"899uI $-L %&#>>+KT3&&sD1 ,rJ   )r  r   rq   r  )rZ   r[   r\   r]   	Exceptionr  r_   r   rg   r   r  ra   rY   rJ   rH   r~  r~    s6    y S h 4 *WN WrJ   r~  c                       \ rS rSrSrg)PDFFontErroriB  rY   Nr  rY   rJ   rH   r  r  B      rJ   r  c                       \ rS rSrSrg)PDFUnicodeNotDefinediF  rY   Nr  rY   rJ   rH   r  r  F  r  rJ   r  StandardEncodingType1Cc            	           \ rS rSr SS\\\4   S\S\\	   SS4S jjr
S\4S jrS\4S	 jrS\4S
 jrS\S\\   4S jrS\	4S jrS\	4S jrS\	4S jrS\	4S jrS\S\	4S jrS\S\\	\\\	   \	4   4   4S jrS\S\	4S jrS\S\4S jrSrg)PDFFontiR  N
descriptorrA   default_widthr5   c                 x   Xl         [        U5      U l        [        UR	                  SS5      5      U l        [        U R
                  [        5      (       a  [        U R
                  5      U l        [        UR	                  SS5      5      U l
        [        UR	                  SS5      5      U l        [        UR	                  SS5      5      U l        [        UR	                  SS5      5      U l        Uc!  [        UR	                  SS5      5      U l        OX0l        [        U R                  5      U l        [        UR	                  S	S5      5      U l        [#        [$        ['        [        UR	                  S
S5      5      5      5      U l        S=U l        U l        U R                  S:  a  U R                  * U l        g )NFontNameunknownFlagsr   AscentDescentItalicAngleMissingWidthLeadingFontBBox)r   r   r   r   gMbP?)r  r$   rA   r#   rc  rS   r9   r*   r,   r    flagsr"   ascentdescentitalic_angler  leadingr   r/   r!   bboxhscalevscale)ri   r  rA   r  s       rH   rg   PDFFont.__init__S  sL    %%0%8 
I!FGdmmY//(7DMz~~gq9:

x ;< 	1!=>%jnn]A&FG !*:>>.!+L!MD!.%d&8&89 	1!=>*[
L)QRS
	 %*)dk <<! LL=DLrJ   c                     g)Nz	<PDFFont>rY   rA  s    rH   rB  PDFFont.__repr__u  s    rJ   c                     gNFrY   rA  s    rH   is_verticalPDFFont.is_verticalx      rJ   c                     gr  rY   rA  s    rH   is_multibytePDFFont.is_multibyte{  r  rJ   rS  c                     [        U5      $ rU   )	bytearrayri   rS  s     rH   decodePDFFont.decode~  s    rJ   c                 4    U R                   U R                  -  $ )z.Ascent above the baseline, in text space units)r  r  rA  s    rH   
get_ascentPDFFont.get_ascent  s    {{T[[((rJ   c                 4    U R                   U R                  -  $ )z@Descent below the baseline, in text space units; always negative)r  r  rA  s    rH   get_descentPDFFont.get_descent  s    ||dkk))rJ   c                     U R                   S   U R                   S   -
  nUS:X  a  U R                  * nXR                  -  $ )Nrx   r   )r  r  r  )ri   rF   s     rH   	get_widthPDFFont.get_width  s=    IIaL499Q<'6###A;;rJ   c                     U R                   S   U R                   S   -
  nUS:X  a  U R                  U R                  -
  nXR                  -  $ )Nr8   r   r   )r  r  r  r  )ri   r  s     rH   
get_heightPDFFont.get_height  sA    IIaL499Q<'6dll*A;;rJ   rp   c                     [        [        [        [        4   U R                  5      U   U R
                  -  $ ! [         a|    [        [        [        [        4   U R                  5      n X R                  U5         U R
                  -  s $ ! [        [        4 a    U R                  U R
                  -  s s $ f = ff = frU   )r   r   r<   r=   rA   r  rm   r_   	to_unichrr  r  )ri   rp   
str_widthss      rH   
char_widthPDFFont.char_width  s    	8S%Z($++6s;dkkII 	8d3:.<J8!.."56DD23 8))DKK778		8s-   69 1B?+B
B?)B;6B?:B;;B?c                     g)DReturns an integer for horizontal fonts, a tuple for vertical fonts.r   rY   ri   rp   s     rH   	char_dispPDFFont.char_disp  s    rJ   r   c                 L   ^  [        U 4S jT R                  U5       5       5      $ )Nc              3   F   >#    U  H  nTR                  U5      v   M     g 7frU   )r  )rM  rp   ri   s     rH   rN  'PDFFont.string_width.<locals>.<genexpr>  s     B>C4??3''>s   !)sumr  )ri   r   s   ` rH   string_widthPDFFont.string_width  s    B4;;q>BBBrJ   c                     [         erU   )NotImplementedErrorr  s     rH   r  PDFFont.to_unichr  s    !!rJ   )r  r  r  r  r  r  rS   r  r  r  r  rA   rU   )rZ   r[   r\   r]   r
   r_   r   FontWidthDictr   r=   rg   rB  boolr  r  rS  r   r<   r  r  r  r  r  r  r   r   r  r  r  ra   rY   rJ   rH   r  r  R  s   
 *.	 CH%     	 
 
 D# T d  E  hsm  )E )*U *5 E 
8c 
8e 
8S U5%8N2O+O%P Ce C C"S "S "rJ   r  c                   T    \ rS rSrS\\\4   S\S\\\4   SS4S jrS\	S\4S	 jr
S
rg)PDFSimpleFonti  r  rA   specr5   Nc                 N   SU;   a  [        US   5      nO[        n[        U[        5      (       aV  [	        UR                  S[        5      5      n[        UR                  S/ 5      5      n[        R                  " XV5      U l	        O$[        R                  " [	        U5      5      U l	        S U l
        SU;   aX  [        US   5      n[        5       U l
        [        U R                  [        UR                  5       5      5      R!                  5         ["        R%                  XU5        g )NEncodingBaseEncodingDifferences	ToUnicode)r#   LITERAL_STANDARD_ENCODINGr9   dictr,   rc  r!   r   rs   cid2unicoder  r%   r   r   r   get_datarunr  rg   )ri   r  rA   r  encodingrq   diffstrms           rH   rg   PDFSimpleFont.__init__  s     Z 01H0Hh%%^=V WXDhll="=>D)66tBD)66|H7MND15$[ 12D-/Dt'')ABFFH62rJ   rp   c                     U R                   (       a   U R                   R                  U5      $  U R                  U   $ ! [         a     Nf = f! [         a    [	        S U5      ef = frU   )r  
get_unichrrm   r  r  r  s     rH   r  PDFSimpleFont.to_unichr  sn    ''22377	2##C((    	2&tS11	2s   > A 
A
AA%)r  r  )rZ   r[   r\   r]   r
   r_   r   r  rg   r<   r  ra   rY   rJ   rH   r  r    sR    CH%  c3h	
 
6	2S 	2S 	2rJ   r  c                   B    \ rS rSrSSS\\\4   SS4S jrS\4S jrS	r	g)
PDFType1Fonti  rsrcmgrr3   r  r5   Nc                 v    [        US   5      U l         [        R                  U R                  5      u  p4[        [        [        [        4   U5      n["        R%                  XXR5        S	U;  a  S
U;   a}  ['        UR                  S
5      5      U l        [        U R(                  S   5      n
U R(                  R+                  5       S U
 n[-        [/        U5      5      nUR1                  5       U l        g ! [         a+    [        R                  (       a  [        S5      eSU l         GNf = f! [         a    [        UR                  S0 5      5      n[        UR                  SS5      5      n[        UR                  SS/S-  5      5      n[!        U5       VV	s0 s H
  u  pX-   U	_M     Os  sn	nf nnn	 GNcf = f)NBaseFontBaseFont is missingr  FontDescriptor	FirstCharr   Widthsr   r  FontFileLength1)r,   basefontrm   r   STRICTr  rQ   rW   r   r   r_   r=   r   rc  r    r!   r;   r  rg   r%   fontfiler  rc   r   rs   r  )ri   r  r  r  
int_widthsrA   	firstchar
width_listrE   rF   length1re   parsers                rH   rg   PDFType1Font.__init__  sz   	&(j)9:DM	L'4'@'@'O$Z$sEz*J7F 	t>T!jJ&>(
)CDDMi 89G==))+HW5D*74=9F%224D/  	&"#899%DM	&  	L#DHH-=r$BCJ!$((;":;I#DHHXsSy$ABJ5>z5JK5J6AamQ&5JKFKF	Ls/   C4 >D, 41D)(D),A-F8F+*
F87F8c                      SU R                   -  $ )Nz<PDFType1Font: basefont=%r>r#  rA  s    rH   rB  PDFType1Font.__repr__  s    ,t}}<<rJ   )r#  r  r%  
rZ   r[   r\   r]   r
   r_   r   rg   rB  ra   rY   rJ   rH   r  r    s3     4 GCH<M RV 8=# =rJ   r  c                   "    \ rS rSrS\4S jrSrg)PDFTrueTypeFonti  r5   c                      SU R                   -  $ )Nz<PDFTrueTypeFont: basefont=%r>r-  rA  s    rH   rB  PDFTrueTypeFont.__repr__  s    /$--??rJ   rY   N)rZ   r[   r\   r]   r_   rB  ra   rY   rJ   rH   r1  r1    s    @# @rJ   r1  c                   B    \ rS rSrSSS\\\4   SS4S jrS\4S jrS	r	g)
PDFType3Fonti  r  r3   r  r5   Nc           
         [        UR                  SS5      5      n[        UR                  SS/S-  5      5      n[        U5       VVs0 s H
  u  pVXS-   U_M     nnnSU;   a  [	        US   5      nO	SSUS   S.n[
        R                  XXr5        [        [        [        [        UR                  S5      5      5      5      U l
        U R                  u  ol        ol        [        U R                  S	5      u  U l        U l        g s  snnf )
Nr  r   r   r   r  r  )r  r  r  
FontMatrix)r   r   )r    rc  r!   r;   r   r  rg   r   r-   tuplematrixr  r  r  r0   r  r  )
ri   r  r  r'  r(  rE   rF   rA   r  r|   s
             rH   rg   PDFType3Font.__init__  s    dhh{A67	A39 =>
1::1FG1Fv!-"1FGt##D)9$:;J$%!jAQRJt>65DHH\4J)K#LM,0II)L![%6t{{F%K"dk Hs   	Dc                     g)Nz<PDFType3Font>rY   rA  s    rH   rB  PDFType3Font.__repr__
  s    rJ   )r  r  r  r9  r  r/  rY   rJ   rH   r5  r5    s3     4 GCH<M RV  #  rJ   r5  c            	       B   \ rS rSr% \\\\\   \4   4   \S'   \	R                  4SSS\\\4   S\SS4S	 jjrS\\\4   S\S\4S
 jr\S\\\4   S\S\4S j5       rS\4S jrS\4S jrS\4S jrS\S\\   4S jrS\S\\\\\   \4   4   4S jrS\S\4S jrSrg)
PDFCIDFonti  default_dispr  r3   r  strictr5   Nc           	      \    [        US   5      U l        [	        UR                  S0 5      5      U l        [        U R                  R                  SS5      5      R                  S5      n[        U R                  R                  SS5      5      R                  S5      nS	R                  XE5      U l
        U R                  X#5      U l         [	        US
   5      nS nSU;   aV  [        UR                  S5      5      U l        [        U R                  [!        U R                  R#                  5       5      5      nS U l        SU;   a  ['        US   [(        5      (       aY  [        US   5      n[+        5       U l        [-        U R$                  [!        UR#                  5       5      5      R/                  5         O[        US   5      n	[        US   5      n
SU;   d  SU	;   d  SU
;   a  [1        5       U l        OnU R                  S;   a  U(       a   UR3                  5       U l        O@O? [6        R8                  " U R                  U R                  R;                  5       5      U l        U R                  R;                  5       U l        U R<                  (       a  [?        [A        UR                  S/ 5      5      5      nURC                  5        VVVVs0 s H  u  nu  nu  pXU4_M     snnnnU l"        [        UR                  SSS/5      5      u  nnS U4U l#        URC                  5        VVVs0 s H  u  nu  noU_M     nnnnWnOD0 U l"        SU l#        [I        [A        UR                  S/ 5      5      5      nUR                  SS5      n[J        RM                  XUUS9  g ! [         a    U(       a  [        S5      eSU l         GNf = f! [         a    U(       a  [        S5      e0 n GNf = f! [        R4                   a     GNf = f! [6        R4                   a     GNf = fs  snnnnf s  snnnf )Nr  r  r  CIDSystemInfoRegistrys   unknownlatin1Orderingz{}-{}r  zFontDescriptor is missing	FontFile2r  r  Identity)zAdobe-Identityz	Adobe-UCSW2DW2ip  ir   r   DWi  )r  )'r,   r#  rm   r  r   rc  cidsysteminfor#   r  rr  	cidcodingget_cmap_from_speccmapr%   r%  r~  r   r  r  r9   r   r   r   r  r   r  r  r   get_unicode_mapr  verticalrO   r!   r  dispsr?  rI   r  rg   )ri   r  r  r@  cid_registrycid_orderingr  ttfr  	cmap_namer  widths2rp   r|   rM   rN   rF   rA   r  s                      rH   rg   PDFCIDFont.__init__  s   	&(j)9:DM
 ("(EF 2 2 6 6z: NOVV
   2 2 6 6z: NOVV
 !C"55dC		#D)9$:;J
 *$()DEDMt}}gdmm6L6L6N.OPC15$${+Y77#D$56#1#3 4++WT]]_-EFJJL(k):;	'Z(89,.!Y.!X-'9';D$^^>>'*'='='?D$ #)#9#9NNDII$9$9$;$  		--/==!*TXXdB-?"@AGDKMMOTO,@S-1hr#Bx-OTDJtxxU|<=GR!%r
D29--/B/#v11f/FBM DJ !D
488C+< =>F HHT40M6OK  	&"#899%DM	&   	"#>??J	6 $00  &&  U CsS   N 
O 
O) ">P 	P
'P'#O OO&%O&)P PPPc                     U R                  X5      n [        R                  " U5      $ ! [        R                   a&  nU(       a  [	        U5      e[        5       s SnA$ SnAff = f)a>  Get cmap from font specification

For certain PDFs, Encoding Type isn't mentioned as an attribute of
Encoding but as an attribute of CMapName, where CMapName is an
attribute of spec['Encoding'].
The horizontal/vertical modes are mentioned with different name
such as 'DLIdent-H/V','OneByteIdentityH/V','Identity-H/V'.
N)_get_cmap_namer   get_cmapr  r  r   )ri   r  r@  rU  rr   s        rH   rM  PDFCIDFont.get_cmap_from_spec`  sR     ''5		??9--"" 	"1o%6M	s   ) A#AA#A#c                    Sn U S   n[        US5      (       a  [        U S   5      nO[        US   5      n [	        U5      [
        L aD  [        [
        U5      nSU;   a  UR                  S5      R                  nOU(       a  [        S5      e[        R                  X"5      $ ! [         a    U(       a  [        S5      e Nf = f)z%Get cmap name from font specificationr  r  rq   CMapNamezEncoding is unspecifiedz!CMapName unspecified for encoding)
hasattrr,   rm   r  typer   r   rc  rq   IDENTITY_ENCODER)r  r@  rU  spec_encodingcmap_name_streams        rH   rY  PDFCIDFont._get_cmap_namer  s     		> ,M}f--(j)9:	(z)BC	
 	?i'*.y)*D--,00<AA	&'JKK##I99  	>"#<== 	>s   $B# B# #CCc                 N    SR                  U R                  U R                  5      $ )Nz+<PDFCIDFont: basefont={!r}, cidcoding={!r}>)rr  r#  rL  rA  s    rH   rB  PDFCIDFont.__repr__  s"    <CCMM4>>
 	
rJ   c                     U R                   $ rU   )rP  rA  s    rH   r  PDFCIDFont.is_vertical  s    }}rJ   c                     g)NTrY   rA  s    rH   r  PDFCIDFont.is_multibyte  s    rJ   rS  c                 8    U R                   R                  U5      $ rU   )rN  r  r  s     rH   r  PDFCIDFont.decode  s    yy&&rJ   rp   c                 L    U R                   R                  XR                  5      $ )r  )rQ  rc  r?  r  s     rH   r  PDFCIDFont.char_disp  s    zz~~c#4#455rJ   c                      U R                   (       d  [        U5      eU R                   R                  U5      $ ! [         a    [        U R                  U5      ef = frU   )r  rm   r  r  rL  r  s     rH   r  PDFCIDFont.to_unichr  sQ    	<##sm###..s33 	<&t~~s;;	<s	   69 !A)	r#  rL  rK  rN  r?  rQ  r%  r  rP  )rZ   r[   r\   r]   r   r=   r   r   __annotations__r   r$  r
   r_   r   r  rg   r   rM  staticmethodrY  rB  r  r  rS  r   r<   r  r  r  ra   rY   rJ   rH   r>  r>    s1   uXe_e%;<<==  	M%M c3hM 	M
 
M^wsCx'8 $ 8 $ :WS#X. : : : :0
# 

T d 'E 'hsm '6S 6U5%8N2O+O%P 6<S <S <rJ   r>  argvc                     SSK Jn  U" S[        5        U SS   H5  n[        US5      n[	        X#5      n[        U5        UR                  5         M7     g )Nr   )warnzThe function main() from pdffont.py will be removed in 2023. It was probably introduced for testing purposes a long time ago, and no longer relevant. Feel free to create a GitHub issue if you disagree.r   rb)warningsrt  DeprecationWarningopenr   printclose)rr  rt  fnamer   fonts        rH   mainr}    sT    	> 		 ab%u!d

	 
 rJ   __main__)Zloggingr   sysior   typingr   r   r   r   r   r	   r
   r   r   r   r   r   r   r   cmapdbr   r   r   r   r   r   r   
encodingdbr   r   fontmetricsr   pdftypesr   r   r   r    r!   r"   r#   r$   r%   psparserr&   r'   r(   r)   r*   r+   r,   utilsr-   r.   r/   r0   r1   r2   	pdfinterpr3   	getLoggerrZ   rn   r`   r<   r=   rI   rO   rQ   rc   r   r`  rS  r   r   r~  r  r  r  LITERAL_TYPE1Cr_   r  r  r  r  r1  r5  r>  r}  rr  rY   rJ   rH   <module>r     s5     
          " &  " $ % "        + "      # "    $  -!HV$ c5j)9 *Xf% $sE%,4G/G*H *& &.M#. .b X
  +% +Dd5+<&=!=> +\xC xCvp pf	< 		< 	   23 X d3:&S%Z(889W" W"t%2G %2P== =B@l @
 =  (U< U<ptCy T $ zN rJ   