+
     ]ih c                   s\   R t ^ RIt^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RIH	t	 ^ RI
t
^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIt^ RIHtHtHtHtHt ^ R	I H!t! ^ R
I"H#t#H$t$H%t%H&t&H't' ^ RI(H)t) ^ RI*H+t+ ^ RI,H-t-H.t/ ^ RI0H1t1 ^ RI2H3t3H4t4H5t5H6t6H7t7 ^ RI8H9t9H:t: ^ RI;H<t< ^ RI=H>t> ^ RIH?t? ^RI@HAtA ]P                  ! ]C4      tDR>R ltER tFR tGR?R ltHR?R ltIR?R ltJ]KP                  RRRRRR R!R"R#R$/4      tMR% tNR& tO ! R' R(4      tP] ! R) R*4      4       tQ ! R+ R,4      tR ! R- R.]4      tS ! R/ R04      tTR1 tU ! R2 R34      tV ! R4 R5]AP                  4      tX ! R6 R7]&4      tY ! R8 R94      tZ ! R: R;]$4      t[]%t\]#P                   ! R< R=]#4      4       t^R# )@uO   
A PDF Matplotlib backend.

Author: Jouni K Seppänen <jks@iki.fi> and others.
N)timezone)datetime)Enum)total_ordering)BytesIO)Image)_api_text_helpers
_type1fontcbookdviread)Gcf)_BackendFigureCanvasBaseFigureManagerBaseGraphicsContextBaseRendererBase)MixedModeRenderer)Figure)get_fontfontManager)AFM)FT2Font	FaceFlagsKerning	LoadFlags
StyleFlags)Affine2DBboxBase)Path)UTC)_path)_backend_pdf_psc                s:   ^ p^ p. p\        V 4       FT  w  rV\        V4      pW',           V8  d   W'^,           ,          pK.  VP                  RP                  WV 4      4       TpTpKV  	  VP                  RP                  WR 4      4       RP                  V4      # )z
Make one string from sequence of strings, with whitespace in between.

The whitespace is chosen to form lines of at most *linelen* characters,
if possible.
    N   
)	enumeratelenappendjoin)ZstringsZlinelenZcurrposZlastiresultislength   &&      F/usr/lib64/python3.14/site-packages/matplotlib/backends/backend_pdf.py_fillr-   _   s     GEF'"Qg%z!GMM$))G!$456EG # MM$))GFO,-::f    c                sh   \         P                  ! R4      pV'       dF   \        P                  ! \	        V4      \
        P                  4      pVP                  \        R7      pM\        P                  ! 4       pRR\        P                   R2RRV  R\        P                   2R	V/VCpVP                  4        UUu/ uF  w  rVVf   K  WVbK  	  pppR
 pRVn        R pRVn        R p	RV	n        RVRVRVRVRVRVR	VRVRV	/	p
V F  pWZ9  d+   \        P                  ! RV: R\!        V
4      : R24       K3  W,          ! WE,          4      '       d   KO  \        P                  ! RV RWE,          : RW,          P                   R24       K  	  RV9   d   \#        VR,          4      VR&   V# u uppi )a  
Create a PDF infoDict based on user-supplied metadata.

A default ``Creator``, ``Producer``, and ``CreationDate`` are added, though
the user metadata may override it. The date may be the current time, or a
time set by the ``SOURCE_DATE_EPOCH`` environment variable.

Metadata is verified to have the correct keys and their expected types. Any
unknown keys/types will raise a warning.

Parameters
----------
backend : str
    The name of the backend to use in the Producer value.

metadata : dict[str, Union[str, datetime, Name]]
    A dictionary of metadata supplied by the user with information
    following the PDF specification, also defined in
    `~.backend_pdf.PdfPages` below.

    If any value is *None*, then the key will be removed. This can be used
    to remove any pre-defined values.

Returns
-------
dict[str, Union[str, datetime, Name]]
    A validated dictionary of metadata.
ZSOURCE_DATE_EPOCH)ZtzinfoZCreatorzMatplotlib vz, https://matplotlib.orgZProducerzMatplotlib z
 backend vZCreationDatec                 "    \        V \        4      # N)
isinstancestrx   &r,   is_string_likeZ-_create_pdf_info_dict.<locals>.is_string_like   s    !S!!r.   zan instance of strc                 r/   r0   )r1   r   r3   r5   r,   is_dateZ&_create_pdf_info_dict.<locals>.is_date   s    !X&&r.   z an instance of datetime.datetimec                 sV    \        V \        4      '       d   V P                  R9   # V R9   # )   True)r8   s   Falses   Unknown)ZTrueZFalseZUnknownr1   Namenamer3   r5   r,   check_trappedZ,_create_pdf_info_dict.<locals>.check_trapped   s+    a66<<<444r.   z#one of {"True", "False", "Unknown"}ZTitleZAuthorZSubjectZKeywordsZModDateZTrappedzUnknown infodict keyword: z. Must be one of Z.zBad value for infodict keyword z. Got z which is not )osZgetenvr   Zfromtimestampintr    Zutcreplacer   ZtodaymplZ__version__itemsZtext_for_warningr   Zwarn_externalsetr:   )backendmetadataZsource_date_epochZsource_dateinfokvr6   r7   r<   Zkeywordss   &&         r,   _create_pdf_info_dictrH   u   s   @ 		"56,,S1B-CX\\R!)))5nn& 	\#//!22JKk'*S__4EF 	D  $zz|=|VaqDAD|D="&:N#'AG5
 &KM" 	.>N>N7=
H !;A5 A114X0A D ETW%%!@ D&&*g["*+">">!?q B C  DtI/YKO >s   <F.	F.c                s   V P                  R4      pV P                  4       pVe   VP                  pM7\        P                  '       d   \        P
                  pM\        P                  pV^ 8X  d   VR,          pV# V^ 8  d%   VRV) R,          V) R,          3,          ,          pV# VRVR,          VR,          3,          ,          pV# )zL
Convert a datetime to a PDF string representing it.

Used for PDF and PGF.
zD:%Y%m%d%H%M%SZZz+%02d'%02d'i  z-%02d'%02d')ZstrftimeZ	utcoffsetZsecondstimeZdaylightZaltzoner    )drZz   &  r,   _datetime_to_pdfrM      s     	


#$A	A}II===AAAv	S
 H	 
Q	]rdlaR4K888 H 	
]a4iT222Hr.   c                s   \         P                  ! V) 4      p\         P                  ! V4      p\         P                  ! V4      pWV,          ,           pWV,          ,           pWV,          ,           W5,          ,           p	WV,          ,
          W6,          ,           p
WV,          ,           pWV,          ,
          pW3W3W3Wx33# )zJ
Calculate the coordinates of rectangle when rotated by angle around x, y
)mathradianssincos)r4   ywidthheightangleZ	sin_angleZ	cos_angleaZbcrJ   ef   &&&&&        r,   !_calculate_quad_point_coordinatesr[      s    
 LL% EII	YA	YA	I 22A	I 22A	IA	IAFQFQFQF++r.   c                sb   \        WVW44      pV^Z,          '       d   RM^ p\        R V 4       4      V,
          p\        R V 4       4      V,
          p\        R V 4       4      V,           p	\        R V 4       4      V,           p
\        \        P
                  P                  V4      4      WxW33# )z[
Get the coordinates of rotated rectangle and rectangle that covers the
rotated rectangle.
gh㈵>c              3   2   "   T F  q^ ,          x  K  	  R# 5i    N .0rG      & r,   	<genexpr>,_get_coordinates_of_block.<locals>.<genexpr>       'h!h   c              3   2   "   T F  q^,          x  K  	  R# 5i   Nr_   r`   rb   r,   rc   rd     re   rf   c              3   r\   r]   r_   r`   rb   r,   rc   rd     re   rf   c              3   rg   rh   r_   r`   rb   r,   rc   rd     re   rf   )r[   minmaxtuple	itertoolsZchainZfrom_iterable)r4   rR   rS   rT   rU   verticesZpadZmin_xZmin_yZmax_xZmax_ys   &&&&&      r,   _get_coordinates_of_blockro      s     1u17@H RZZ'QC'h''#-E'h''#-E'h''#-E'h''#-E)////9:5(* *r.   c                s    \        WW4V4      w  rgR\        R4      R\        R4      RVR. RORR\        R	4      R	V P                  4       //pV^Z,          '       d   WhR
&   V# )z5
Create a link annotation object for embedding URLs.
TypeAnnotSubtypeZLinkRectZBorderASZURIZ
QuadPointsr^   r^   r^   )ro   r:   get_url)	gcr4   rR   rS   rT   rU   Z
quadpointsZrectZlink_annotations	   &&&&&&   r,   _get_link_annotationry     sm     1ueLJW4<)e2::<
	O rzz(2%r.   Z\z\\Z(z\(Z)z\)Z
z\nZz\rc                s   \        V R4      '       d   V P                  4       # \        V \        \        P
                  34      '       dQ   \        P                  ! V 4      '       g   \        R4      hRV ,          pVP                  R4      P                  R4      # \        V \        4      '       d   RR.V ,          # \        V \        \        P                  34      '       d
   RV ,          # \        V \        4      '       d[   \        V P                  4       '       d   V P                  R	4      4      # \        P                   V P                  R
4      ,           4      # \        V \"        4      '       dB   RV P%                  R4      P'                  \(        4      P                  R4      ,           R,           # \        V \*        4      '       da   \-        R.V P/                  4        UUu. uF5  w  r#\1        V4      P                  4       R,           \        V4      ,           NK7  	  uppORN4      # \        V \2        \4        34      '       d*   \-        R.V  Uu. uF  p\        V4      NK  	  upORN4      # V f   R# \        V \6        4      '       d   \        \9        V 4      4      # \        V \:        4      '       d/   \-        V P<                   Uu. uF  p\        V4      NK  	  up4      # \?        R\A        V 4       R24      hu uppi u upi u upi )z!Map Python objects to PDF syntax.pdfReprz%Can only output finite numbers in PDFs   %.10fs   0s   .s   falses   trues   %dasciizUTF-16BEs   (zlatin-1s   )s   <<r!   s   >>s   [s   ]s   nullz$Don't know a PDF representation for z objects)!Zhasattrrz   r1   floatnpZfloatingisfinite
ValueErrorZrstripboolr>   Zintegerr2   ZisasciiencodecodecsZBOM_UTF16_BEbytesdecode	translate_str_escapesdictr-   rA   r:   listrl   r   rM   r   ZboundsZ	TypeErrortype)objrK   rF   rG   Zvals   &    r,   rz   rz   +  s    sI{{}
 
C%-	.	.{{3DEEsNxx~$$T** 
C		'"3'' 
C#rzz*	+	+s{ 
C		ckkmmszz'* J 	J"//#**Z2HHJ 	J 
C		JJy!++L9@@KL	 
C		
@C		Ld1goo$&33L
 
  	 
C$	'	'dAc:csgclc:ADABB 
 
C	"	"',-- 
C	"	"cjj9jsgclj9:: >tCyk J" " # 	#+ M ; :s    ;K7K=
Lc                sF    V ^8X  d   V^8*  # V ^*8X  d   VR8*  # \        4       h)z
Returns True if the font is able to provide codepoint *glyph* in a PDF.

For a Type 3 font, this method returns True only for single-byte
characters. For Type 42 fonts this method return True if the character is
from the Basic Multilingual Plane.
  )ZNotImplementedError)fonttypeglyph   &&r,   _font_supports_glyphr   t  s/     1}|2~~

r.   c                   s<   a  ] tR tRt o RtR tR tR tR tRt	V t
R# )		Referencei  zJ
PDF reference object.

Use PdfFile.reserveObject() to create References.
c                    Wn         R # r0   idselfr   r   r,   __init__ZReference.__init__  s    r.   c                (    R V P                   ,          # )z<Reference %d>r   r   r5   r,   __repr__ZReference.__repr__  s    $''))r.   c                r   )s   %d 0 Rr   r   r5   r,   rz   ZReference.pdfRepr  s    477""r.   c                s    VP                   pV! R V P                  ,          4       V! \        V4      4       V! R4       R# )	   %d 0 obj
s   
endobj
N)writer   rz   )r   contentsfiler      &&& r,   r   ZReference.write  s1    

mdgg%&gh mr.   r   N)__name__
__module____qualname____firstlineno____doc__r   r   rz   r   __static_attributes____classdictcell____classdict__   @r,   r   r     s#     *# r.   r   c                   s   a ] tR tRt oRtRt0 ]! R4      m0 ]! ]! R4      ]! R4      ^,           4      m,
           U u/ uF  p V RV ,          bK  	  up tR t	R t
R	 tR
 tR tR tR tRtVtR# u up i )r:   i  zPDF name object.   Z!Z~z#%02xc                s   \        V\        4      '       d   VP                  V n        R# \        V\        4      '       d   VP	                  R 4      pVP                  V P                  4      P                  R 4      V n        R# )r{   N)r1   r:   r;   r   r   r   _hexifyr   )r   r;   r   r,   r   ZName.__init__  sT    dD!!		DI$&&{{7+t||4;;GDDIr.   c                r   )z	<Name %s>r;   r   r5   r,   r   ZName.__repr__  s    TYY&&r.   c                sF    R V P                   P                  R4      ,           # )Z/r{   )r;   r   r   r5   r,   __str__ZName.__str__  s    TYY%%g...r.   c                sd    \        V\        4      ;'       d    V P                  VP                  8H  # r0   r9   r   otherr   r,   __eq__ZName.__eq__  s$    %&BB499

+BBr.   c                sd    \        V\        4      ;'       d    V P                  VP                  8  # r0   r9   r   r   r,   __lt__ZName.__lt__  s$    %&AA499uzz+AAr.   c                ,    \        V P                  4      # r0   )hashr;   r   r5   r,   __hash__ZName.__hash__  s    DIIr.   c                s(    R V P                   ,           # )s   /r   r   r5   r,   rz   ZName.pdfRepr  s    diir.   r   N)r   r   r   r   r   	__slots__rangeordr   r   r   r   r   r   r   rz   r   r   )rW   r   s   0@r,   r:   r:     s     I%%*(H%C#c(Q,*G(HHJH1 'A+~HJGE'/CB   5Js   A.r:   c                   s0   a  ] tR tRt o RtR tR tRtV tR# )Verbatimi  zEStore verbatim PDF command content for later inclusion in the stream.c                r   r0   Z_x)r   r4   r   r,   r   ZVerbatim.__init__  s    r.   c                    V P                   # r0   r   r   r5   r,   rz   ZVerbatim.pdfRepr  s    wwr.   r   N)	r   r   r   r   r   r   rz   r   r   r   r   r,   r   r     s     O r.   r   c                   s   a  ] tR tRt o RtRtRtRtRtRt	Rt
R	tR
tRtRtRtRtRtRtRtRtRtRtRtRtRtRtRtRtRtRtRtRt Rt!R t"R!t#R"t$R#t%R$t&R%t'R&t(R't)R( t*]+R) 4       t,R*t-V t.R+# ),Opi  z'PDF operators (not an exhaustive list).s   bs   B   f   hs   ss   S   ns   BTs   ET   cs   re   l   ms   cms   Dos   Gs   gs   RGs   rgs   CSs   css   SCNs   scns   ds   js   Js   gss   qs   Qs   Tds   Tfs   Tms   Tjs   TJs   ws   Ws   shc                r   r0   )valuer   r5   r,   rz   Z
Op.pdfRepr  s    zzr.   c                s    V'       d!   V'       d   V P                   # V P                  # V'       d   V P                  # V P                  # )z
Return the PDF operator to paint a path.

Parameters
----------
fill : bool
    Fill the path with the fill color.
stroke : bool
    Stroke the outline of the path with the line color.
)fill_strokestrokefillendpath)Zclsr   r      &&&r,   
paint_pathZOp.paint_path  s4     &zz!xx{{"r.   r_   N)/r   r   r   r   r   Zclose_fill_stroker   r   	closepathZclose_stroker   r   
begin_textend_textcurveto	rectanglelinetomovetoconcat_matrixuse_xobjectsetgray_strokesetgray_nonstrokesetrgb_strokesetrgb_nonstrokesetcolorspace_strokesetcolorspace_nonstrokeZsetcolor_strokesetcolor_nonstrokesetdashsetlinejoin
setlinecap	setgstategsavegrestoretextpos
selectfont
textmatrixshowshowkernsetlinewidthclipshadingrz   Zclassmethodr   r   r   r   r   r,   r   r     s     1KDILFGJHGIFFMKNM #OGKJIEHGJJDHLDG # #r.   r   c                   sJ   a  ] tR tRt o RtR
tRR ltR tR tR t	R t
R	tV tR# )Streami	  z
PDF stream object.

This has no pdfRepr method. Instead, call begin(), then output the
contents of the stream by calling write(), and finally call end().
Nc                s   Wn         W n        W0n        VP                  V n        RV n        Vf   \        4       V n        MVP                  4       V n        Ve)   V P                  P                  R\        R4      RV/4       V P                  P                  V P                   4       \        P                  R,          '       d9   V'       g1   \        P
                  ! \        P                  R,          4      V n        V P                  f   \        4       V n        R# V P!                  4        V P                  P#                  4       V n        R# )a  
Parameters
----------
id : int
    Object id of the stream.
len : Reference or None
    An unused Reference object for the length of the stream;
    None means to use a memory buffer so the length can be inlined.
file : PdfFile
    The underlying object to write the stream to.
extra : dict from Name to anything, or None
    Extra key-value pairs to include in the stream header.
png : dict or None
    If the data is already png encoded, the decode parameters.
NFilterFlateDecodeZDecodeParmspdf.compression)r   r$   pdfFilefhr   compressobjr   extraZcopyZupdater:   
recordXrefr@   rcParamszlibr   _writeHeadertellpos)r   r   r$   r   r   pngs   &&&&&&r,   r   ZStream.__init__  s      GG	=DJDJ?JJxd=.A,c3 4 	(<<)**3#//./ 1D88	DIyy~~'DHr.   c                s"   V P                   P                  pV! R V P                  ,          4       V P                  pV P                  VR&   \
        P                  R,          '       d   \        R4      VR&   V! \        V4      4       V! R4       R# )r   ZLengthr   r   r   s   
stream
N)	r   r   r   r   r$   r@   r   r:   rz   )r   r   r   rL   r,   r   ZStream._writeHeader9  sh    		mdgg%&zzX<<)**!-0DNgdmmr.   c                s4   V P                  4        V P                  f   V P                  P                  4       p\        V4      V n        V P                  P
                  V n        V P                  4        V P                  P                  V4       V P                  P                  R4       R# V P                  P                  4       V P                  ,
          pV P                  P                  R4       V P                  P                  V P                  V4       R# )zFinalize stream.Ns   
endstream
endobj
)_flushr$   r   getvaluer   r   r   r   r   r   writeObject)r   r   r*   rL   r,   endZ
Stream.endD  s     	88yy))+H8}DHDIIIOOH%IIOO45YY^^%0FIIOO45LL$$TXXv6r.   c                s    V P                   f   V P                  P                  V4       R# V P                   P                  V4      pV P                  P                  V4       R# )zWrite some data on the stream.N)r   r   r   Zcompress)r   data
compressed   && r,   r   ZStream.writeT  sF     #IIOOD!))2248JIIOOJ'r.   c                s    V P                   e?   V P                   P                  4       pV P                  P                  V4       RV n         R# R# )zFlush the compression object.N)r   flushr   r   )r   r   rb   r,   r   ZStream._flush]  sA     '))//1JIIOOJ'#D (r.   )r   r   r   r   r$   r   r   )r   r$   r   r   r   r   r   NN)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r,   r   r   	  s1      PI%(N	7 ($ $r.   r   c                 s.   \        V ^R7      pRVP                  ,          p/ pV EFk  pVP                  V\        P                  4      p\
        P                  ! VP                  ^ .VP                  O4      V,          R,           P                  \        4      pVP                  4       w  rV^@,          P                  \        4      p\
        P                  ! V	^8H  4      w  p
V
R,          p\
        P                  ! \        0 Vm0 V
^,
          m,          0 V
^,           m,          4      \        4      pVW,          W^,
          ,          W^,           ,          ,           ^,          P                  \        4      8H  P                  ^R7      ,          pVP                  V3R9   d   VR;;,          ^,          uu&   W,          R,           P                  \        4      pW^,
          ,          W^,           ,          ,           ^,          P                  \        4      W&   RP!                  \#        \$        V4      4      P'                  R4      R,           \(        P*                  ! \-        W4      R	R	R
R	R. ROR4      ,           R,           WBP/                  V4      &   EKn  	  V# )ri   )Zhinting_factor  g      ?:ri   N   ZaxisZ r{   s    d1
NFTr   ))DejaVuSerif-ItaliciM   )r  i   )NNNr^   )r   r   r.   r   r   )r   units_per_EMZ
load_glyphr   NO_SCALEr}   arrayhoriAdvancebboxastyper>   Zget_pathZnonzerosortedallpostscript_namer&   mapr2   r   r   convert_to_stringr   get_glyph_name)Z	font_path	glyph_idsfontZconvZprocsZglyph_idZgZd1rG   rW   ZquadsZquads_onZquads_mid_onZimplicits   &&            r,   _get_pdf_charprocsr  f  s   Ia0D$###DEOOHi&8&89 hhq216623d:R?GGL}}VOOC  AF#;xx;X;EAI/.UQY.@A3H_1$%*:(;;q@HHMNSaS[   (+ 0
 
 dGqLGX]""3'!|_qA.!3VVC[ 	
 HHSb\"))'2X=%%Q
D$tR-t55
  	!!(+,A N Lr.   c                   s  a a ] tR tRt oRtR6V 3R lltR t. R7O3R ltR tR t	R	 t
R
 tR tR8R ltR tRR/R ltR tR tR tR tR tR tR tR tRtR tR tR tR tR tR t]P@                  ! R4      ! ]!! R  4      4      t"R! t#R" t$R# t%R$ t&R% t'R& t(R6R' lt)R( t*R) t+R* t,R+ t-R, t.]/R9R- l4       t0R:R. lt1R;R/ lt2R0 t3R1 t4R2 t5R3 t6R4 t7R5t8Vt9V ;t:# )<PdfFilei  zPDF file object.Nc                s*  < \         S	V `  4        \        P                  ! ^4      V n        . R O.V n        RV n        RV n        ^ V n        \        P                  ! VRRR7      w  r4V'       g     VP                  4       V n        TpRV n        W0n        RV n        VP!                  R4       VP!                  R4       V P#                  R4      V n        V P#                  R	4      V n        . V n        V P#                  R
4      V n        V P#                  R4      V n        V P#                  R4      V n        V P#                  R4      V n        V P#                  R4      V n        V P#                  R4      V n        R\7        R4      RV P&                  /pV P9                  V P$                  V4       \;        RT;'       g    / 4      V n        / V n        R \        P                  ! ^4       4       V n         / V n!        / V n"        \F        PH                  ! 4       V n%        / V n&        R \        P                  ! ^4       4       V n'        / V n(        R \        P                  ! ^4       4       V n)        . V n*        / V n+        R \        P                  ! ^4       4       V n,        . V n-        / V n.        R \        P                  ! ^4       4       V n/        / V n0        / V n1        . V n2        . V n3        . V n4        RPk                  4        Uu. uF  p\7        V4      NK  	  ppRV P*                  RV P2                  RV P,                  RV P.                  RV P0                  RV/pV P9                  V P4                  V4       R#   \         d    \        4       pYn         EL i ; iu upi )!a{  
Parameters
----------
filename : str or path-like or file-like
    Output target; if a string, a file will be opened for writing.

metadata : dict from strings to strings and dates
    Information dictionary object (see PDF reference section 10.2.1
    'Document Information Dictionary'), e.g.:
    ``{'Creator': 'My software', 'Author': 'Me', 'Title': 'Awesome'}``.

    The standard keys are 'Title', 'Author', 'Subject', 'Keywords',
    'Creator', 'Producer', 'CreationDate', 'ModDate', and
    'Trapped'. Values have been predefined for 'Creator', 'Producer'
    and 'CreationDate'. They can be removed by setting them to `None`.
FNZwbT)Zreturn_openeds	   %PDF-1.4
s   % 
rootZpagesfontszextended graphics statesztiling patternszGouraud triangleszexternal objects	resourcesrp   ZCatalogPagespdfc              3   >   "   T F  p\        R V 24      x  K  	  R# 5i)ZFNr:   ra   r(   rb   r,   rc   #PdfFile.__init__.<locals>.<genexpr>       "M:LQ4!A3==:L   c              3   r  )rt   Nr  r  rb   r,   rc   r    s      K8J1!g8Jr  c              3   r  )ZSMNr  r  rb   r,   rc   r    s     J7I!tbH~~7Ir  c              3   r  )ZHNr  r  rb   r,   rc   r    r  r  c              3   r  )ZINr  r  rb   r,   rc   r    s     E2DQ4!A3==2Dr  PDF Text ImageB ImageC ImageIFontXObject	ExtGStatePatternShadingZProcSet)r^   r   the zero object)6superr   rm   Zcount_object_seq	xrefTablepassed_in_file_objectoriginal_file_like	tell_baser	   Zto_filehandler   ZOSErrorr   r   currentstreamr   reserveObject
rootObjectpagesObjectpageList
fontObject_extGStateObjecthatchObjectgouraudObjectXObjectObjectresourceObjectr:   r   rH   infoDict	fontNames_internal_font_seqdviFontInfotype1Descriptorsr    ZCharacterTracker_character_trackeralphaStates_alpha_state_seq_soft_mask_states_soft_mask_seq_soft_mask_groups_hatch_patterns_hatch_pattern_seqgouraudTriangles_images
_image_seqmarkersmulti_byte_charprocspaths_annotationspageAnnotationssplit)
r   filenamerD   r   Zopenedr  r4   Zprocsetsr  	__class__s
   &&&      r,   r   ZPdfFile.__init__  s   " 	$??1-78%*""&((4tL
2!)
 -1*!
 	(),,V4--g6,,W5 $ 2 23M N--.?@!//0CD!//0BC"00=Y))+$/-eX^^D"M)//!:L"M ""1"B"B"D K	8J K!#Jyq7IJ!#!"M)//!:L"M "E)//!2DE$&!

   " &E%J%J%LM%LDG%LM
 T__ 2 2 $"7"7 0 0 2 2*	 	,,i8W  3Y*2'3@ Ns   .M. :N.NNc                s8   V P                  4        WuV n        V n        V P                  R 4      pV P                  R4      pR\	        R4      RV P
                  RV P                  R^ ^ ^HV,          ^HV,          .RVRV/pV P                  R	4      pV P                  We4       V P                  P                  V4       V P                  P                  W@P                  34       V P                  VP                  V P                  R
4      4       V P                  \	        R4      \        P                   4       V P                  \	        R4      \        P"                  4       V P                  \$        P&                  R,          \        P(                  4       . V n        R# )zpage contentsannotationsrp   ZPageZParent	ResourcesZMediaBoxContentsZAnnotspagezlength of content stream	DeviceRGBroundN)	endStreamrS   rT   r-  r:   r/  r6  r   r0  r%   rJ  rK  beginStreamr   outputr   r   r   GraphicsContextPdf
joinstylesr   )r   rS   rT   ZcontentObjectannotsObjectZthePageZ
pageObjects   &&&    r,   newPageZPdfFile.newPage   sQ   "'
DK**?;))-84<T-- 3 31b5j"v+>}\ ''/
-Z(  ,0D0D!EF))++,FG	I 	D%r'>'>?D%r'A'AB&11':BNNK  "r.   c                st    R \        R4      R\        R4      RVRV/pV P                  P                  V4       R# )rp   rq   rr   ZTextrQ  rs   N)r:   rK  r%   )r   textpositionRectZtheNoter   r,   newTextnoteZPdfFile.newTextnote  s;    4=d6lt<
 	##G,r.   c                s   a V3R  lo\        \        VP                  4       4      4      \        P                  ^,           ^,          ,          pS! V^4      pVR,          R,           V,           # )c                 s   < W8  d   \         P                  V ,          # S! W,          V4      \         P                  W,          ,          ,           # r0   )stringZascii_uppercase)ZnZbasetoStr   &&r,   r`  Z,PdfFile._get_subsetted_psname.<locals>.toStr'  s>    x--a00 !)T*V-C-CAH-MMr.   :N   NZ+)r   Z	frozensetZkeyssysZmaxsize)r   ps_nameZcharmapZhashedZprefixr`  s   &&&  @r,   _get_subsetted_psnameZPdfFile._get_subsetted_psname&  sS    	 i/0S[[1_4IJvr" bzC'))r.   c                s   V P                  4        V P                  4        V P                  4        V P                  4        V P	                  4        V P                  4        V P                  4        V P                  P                  4        UUUu/ uF  w  rq2VbK
  	  ppppV P                  P                  4        F  pV^,          WE^ ,          &   K  	  V P                  P                  4        F	  w  r&WdV&   K  	  V P                   F  w	  r'rrrpW4V&   K  	  V P                  V P                  V4       V P                  4        V P!                  4        V P#                  4        V P                  V P$                  R\'        R4      RV P(                  R\+        V P(                  4      /4       V P-                  4        V P/                  4        V P1                  4        R# u upppi )z>Write out the various deferred objects and the pdf end matter.rp   r  ZKidsZCountN)rU  _write_annotations
writeFontswriteExtGSTates_write_soft_mask_groupswriteHatcheswriteGouraudTrianglesrE  valuesrG  rH  rA   rI  r   r5  writeImageswriteMarkerswritePathCollectionTemplatesr/  r:   r0  r$   writeInfoDict	writeXrefwriteTrailer)r   imager;   obZxobjectsZtupr   pathtransr&   Zcappaddingfilledstroked   &             r,   finalizeZPdfFile.finalize6  s    	!$$&""$,0LL,?,?,AC,Ab"H,A 	 C<<&&(C"1vHV )44::<KD"TN = :: GD4gwTN ++X6))+)) $w- $--!3t}}#57	8 	 	+Cs   Gc                s8   V P                  4        V P                  '       d   V P                  P                  4        R# V P                  e4   V P                  P                  V P                  P                  4       4       V P                  P                  4        R# )z)Flush all buffers and free all resources.N)rU  r)  r   r   r*  r   r   closer   r5   r,   r|  ZPdfFile.closeW  sa     	%%%GGMMO&&2''--dgg.>.>.@AGGMMOr.   c                s    V P                   f   V P                  P                  V4       R # V P                   P                  V4       R # r0   )r,  r   r   )r   r   r   r,   r   ZPdfFile.writeb  s2    %GGMM$$$T*r.   c           
     s    T P                  \        V Uu. uF  p\        V4      NK  	  up4      4       V P                  R 4       R# u upi )r"   N)r   r-   rz   )r   r   r4      &* r,   rW  ZPdfFile.outputh  s7    

5d3d'!*d345

5 4s   Ac                sJ    V P                   e   Q h\        WWV4      V n         R # r0   )r,  r   )r   r   r$   r   r      &&&&&r,   rV  ZPdfFile.beginStreaml  s%    !!)))#BT#>r.   c                sh    V P                   e$   V P                   P                  4        R V n         R # R # r0   )r,  r   r   r5   r,   rU  ZPdfFile.endStreamp  s-    )""$!%D *r.   r   c               s    V P                  VP                  R V4       V P                  P                  V4       V P	                  4        R # r0   )rV  r   r,  r   rU  )r   Zrefr   r   s   &&&$r,   outputStreamZPdfFile.outputStreamu  s6    u-  &r.   c                sR    V P                    F  w  rV P                  W4       K  	  R # r0   )rJ  r   )r   rZ  rO  rL   r,   rf  ZPdfFile._write_annotationsz  s#    )-):):%L\7 *;r.   c                s   \        V\        4      '       d   V.pM[\        P                  R,          '       d)   \        P
                  ! VR\        P                  R7      pM\        P
                  ! V4      pRpV Fs  pV P                  P                  V4      pV'       g   TpVe   K.  \        V P                  4      pWPP                  V&   \        P                  RWT4       V'       d   Kq  TpKu  	  V# )z
Select a font based on fontprop and return a name suitable for
Op.selectfont. If fontprop is a string, it will be interpreted
as the filename of the font.
pdf.use14corefontsZafm)ZfontextZ	directoryNzAssigning font %s = %r)r1   r2   r@   r   _fontManagerZ_find_fonts_by_propsRendererPdf_afm_font_dirr8  getnextr9  _logdebug)r   ZfontpropZ	filenamesZfirst_FxfnameFx   &&    r,   fontNameZPdfFile.fontName~  s     h$$!
I\\.//$99%;3L3LI %99(CIE##E*Bz$112(*u%

3R?x!H  r.   c           	     s   V P                   P                  VP                  4      pVe   VP                  # \        P
                  ! \        P                  ! R4      4      pW1P                  ,          pVP                  f0   \        RP                  VP                  VP                  4      4      h\        V P                  4      p\        P                  RWQP                  4       \        P                   ! VVVP                  VP                  VP"                  VP$                  R7      V P                   VP                  &   V# )z
Given a dvi font object, return a name suitable for Op.selectfont.
This registers the font information in ``self.dviFontInfo`` if not yet
registered.
z
pdftex.mapzNNo usable font file found for {} (TeX: {}); the font may lack a Type-1 versionzAssigning font %s = %s (dvi))dvifontpdfnamefontfilebasefontencodingfileeffects)r:  r  texnamer  r
   Z
PsfontsMapZfind_tex_filerM  r   formatZpsnamer  r9  r  r  typesZSimpleNamespaceZencodingr  )r   r  Zdvi_infoZtex_font_mapZpsfontr  r  r,   dviFontNameZPdfFile.dviFontName  s     ##''8###))'*?*?*MNoo.??"5w79 9
 t../

17OOL,1,A,A__]]NN-$) r.   c                s   / p\        V P                  P                  4       4       F:  w  r#VP                  p\        P                  R V4       V P                  V4      W&   K<  	  \        V P                  4       F  pV P                  V,          p\        P                  RV4       VP                  R4      '       d+   \        P                  R4       V P                  V4      W&   Km  \        P                  R4       V P                  P                  P                  V4      pV'       g   K  V P                  WV4      W&   K  	  V P                  V P                  V4       R# )z"Embedding Type-1 font %s from dvi.zEmbedding font %s.z.afmzWriting AFM font.zWriting TrueType font.N)r
  r:  rA   r  r  r  _embedTeXFontr8  Zendswith_write_afm_fontr<  Zusedr  embedTTFr   r1  )r   r  ZdvinamerE   r  rM  Zchars   &      r,   rg  ZPdfFile.writeFonts  s	   #D$4$4$:$:$<=MGBJJ;WE**40EI > t~~.H)BJJ+X6  ((

./ 00:	 

34//4488B5 $h >EI / 	%0r.   c           
     s<   \        VR 4      ;_uu_ 4       p\        V4      pRRR4       XP                  4       pR\        R4      R\        R4      R\        V4      R\        R4      /pV P	                  R	4      pV P                  We4       V#   + '       g   i     Lr; i)
ZrbNrp   r   rr   Type1BaseFontEncodingZWinAnsiEncodingfont dictionary)Zopenr   Zget_fontnamer:   r-  r   )r   rM  r   r  fontnamefontdictfontdictObjects   &&     r,   r  ZPdfFile._write_afm_font  s    (D!!Rr7D "$$&DLtG}X%6 79 ++,=>2 "!s   BB	c           
     s   \         P                  R VP                  P                  VP                  4       V P                  R4      pV P                  W!P                  P                  4       V P                  R4      pR\        R4      R\        R4      R^ R\        VP                  P                  4      ^,
          R	V/pVP                  eB   R\        R
4      R^ .\        \        \        P                  ! VP                  4      4      O/VR
&   VP                  fL   \         P                  RVP                   4       \        VP                   4      VR&   V P                  W44       V# \"        P$                  ! VP                  4      pVP&                  '       d   VP)                  VP&                  4      p\        VP*                  R,          4      VR&   VP&                  P-                  RR4      VP&                  P-                  RR4      3pV P.                  P-                  VP                  V34      pVf6   V P1                  WQP                  4      pWpP.                  VP                  V3&   WtR&   V P                  W44       V# )z#Embedding TeX font %s - fontinfo=%sfont widthsr  rp   r   rr   r  	FirstCharLastCharWidthsr  DifferenceszBecause of TeX configuration (pdftex.map, see updmap option pdftexDownloadBase14) the font %s is not embedded. This is deprecated as of PDF 1.5 and it may cause the consumer application to show something that was not intended.r  FontNameZslant        extend      ?FontDescriptor)r  r  r  r  __dict__r-  r   widthsr:   r$   r  r  r
   Z
_parse_encr  Zwarningr  r   Z	Type1Fontr  	transformpropr  r;  createType1Descriptor)r   ZfontinfowidthsObjectr  r  t1fontr  Zfontdescr+   r,   r  ZPdfFile._embedTeXFont  sG   

8##++X->->	@ ))-8'7'7'>'>? ++,=>fgX--4459   ,Z( ND'"4"4X5J5J"KL N$HZ  $LLG !!# $((9(9#:HZ ^6!! %%h&7&78%%h&6&67F#FKK
$;<
 ##''5##''#68((,,h.?.?-IJ11&:K:KLHBJ!!8#4#4g">?%-!"2r.   c                s   V P                  R 4      pV P                  R4      pVP                  R,          pVP                  R,          p^ pV'       d
   V^,          p  T^,          pT'       d
   T^@,          p   \        T4      pR\        R4      R\        TP                  R,          4      RTRTP                  RTR	TP
                  R
TP                  RRRRRTRTP                  R,          R^2/p	T P                  Y94       T P                  TRP                  TP                  R,          4      R\        TP                  ^ ,          4      R\        TP                  ^,          4      R^ /R7       T# )font descriptorz	font fileItalicAngleZisFixedPitchrp   r  r  FlagsFontBBoxAscentDescent	CapHeightr   XHeighti  ZFontFileZ
FontFamilyZ
FamilyNameStemVr.   Nr   NLength1ZLength2ZLength3r   )r-  r  r   r:   r  ascender	descenderr   r  r&   Zpartsr$   )
r   r  r  fontdescObjectfontfileObjectZitalic_angleZfixed_pitchflagsZft2font
descriptors
   &&&       r,   r  ZPdfFile.createType1Descriptor  sk    ++,=>++K8{{=1kk.1VOE VOE
 VOE   8$ 4 014J 7857<<<7++7,,43>6;;|42
" 	4.#((6<<3C*D!*CQ,@!*CQ,@!*A!/ 	 	0
 r.   c                s    V P                  V4      pR P                  VP                  P                  4       \        P
                  P                  \        P
                  P                  V4      4      ^ ,          V.4      # )Z-)r  r&   r;   r   r=   ru  ZsplitextZbasename)r   rM  
glyph_namer  r   r,   _get_xobject_glyph_nameZPdfFile._get_xobject_glyph_nameU  s]    ]]8$xxGGNNGGRWW--h78;  	r.   sO  /CIDInit /ProcSet findresource begin
12 dict begin
begincmap
/CIDSystemInfo
<< /Registry (Adobe)
   /Ordering (UCS)
   /Supplement 0
>> def
/CMapName /Adobe-Identity-UCS def
/CMapType 2 def
1 begincodespacerange
<0000> <ffff>
endcodespacerange
%d beginbfrange
%s
endbfrange
endcmap
CMapName currentdict /CMap defineresource pop
end
endc                s  a aaaa \        S4      p\        P                  R,          oVP                  R3R loVVVV 3R lpVVVVV 3R lpS P	                  VP
                  VP                  4       4      oSP                  RR4      o\        S4      oVP                  R4      ;'       g    R	^ R
^ /pVP                  R4      ;'       g    RR/pVP                  pVP                  p	^ p
Rp\        P                  V9   d
   V
^,          p
 T'       d   T
^,          p
M	T
^ ,          p
\        P                  T	9   d
   T
^@,          p
   R\        R4      RSRT
RTP                    Uu. uF  pS! TRR7      NK  	  upRS! TP"                  RR7      RS! TP$                  RR7      RS! TR	,          RR7      RS! TR
,          4      RTR,          ^,          R^ /
pS^8X  d
   T! Y2T4      # S^*8X  d
   T! Y2T4      # R# u upi )z9Embed the TTF font from the named file into the document.pdf.fonttypeTc                s    W,          R,          pV'       d   \        V4      # V^ 8  d   \        P                  ! V4      # \        P                  ! V4      # )z2Convert font coordinates to PDF glyph coordinates.r   )rT  rN   ZfloorZceil)r*   Zupenearestr   r   r,   cvtZPdfFile.embedTTF.<locals>.cvtw  s@    L4'EU|#qyzz%((yy''r.   c                sF  <a a S#P                  R4      pS#P                  R4      pS#P                  R4      pS#P                  R4      p. p^ ^rS P                   U
u. uF  p
S ! V
RR7      NK  	  pp
R\        R4      R	S"R
VRV	RVR\        R4      RVR,          RVR. R"ORVRR\        R4      RV/RV/p^ RIHo VV V 3R lp\
        P                  ! 4       ;_uu_ 4        \
        P                  ! R4       \        W^,           4       Uu. uF  pV! V4      NK  	  ppRRR4       \        X4      VR&   . p. p\        4       pV Fe  pTpS P                  V4      pVP                  V4       S P                  V4      pV^8:  d   VP                  VV34       KT  VP                  V4       Kg  	  VP                  4        R#pV FA  w  ppVV^,           8w  d   VP                  V4       VP                  \        V4      4       TpKC  	  \!        S!V4      p/ p\#        V4       F  pVV,          p/ pVV9   d6   R\        R4      R\        R4      RV/pVVP%                  R4      ^,           R pS#P                  R 4      pS#P'                  VVVR!7       VV9   d$   S#P)                  S!V4      pVS#P*                  V&   K  VVV&   K  	  S#P-                  W\4       S#P-                  WB4       S#P-                  W?4       S#P-                  VV4       V# u up
i u upi   + '       g   i     EL; i)$z5The Type 3-specific part of embedding a Truetype fontr  r  r  zcharacter procsFr  rp   r   r  r  r  r  rr   ZType3r:   r  r  Z
FontMatrixZ	CharProcsr  r  r  )cp1252c                 s   < \        SP                  V ,          4      pSP                  V\        P                  \        P
                  ,          R 7      P                  pS! V4      # )r  )r   Zdecoding_table	load_charr   r  
NO_HINTINGr  )charcoder)   rS   r  r  r  s   &  r,   get_char_widthZ?PdfFile.embedTTF.<locals>.embedTTFType3.<locals>.get_char_width  sT    --h78Y//)2F2FF ' HHS 5z!r.   ZignoreNMaxWidthr!  FormBBox   d1charProcr  )MbP?r^   r^   r  r^   r^   )r-  r  r:   Z	encodingsr  warningsZcatch_warningsZfilterwarningsr   rk   rB   get_char_indexr%   r  Zaddsortr  r
  findr  r  rH  r   )$r  
charactersr  r  r  r  ZcharprocsObjectZdifferencesArrayZ	firstcharZlastcharr4   r  r  r  r  r  r  ZdifferencesZmulti_byte_charsrW   ccodegindr  Zlast_cr;   rawcharprocsZ	charprocscharnamestreamcharprocDictcharprocObjectr  r  rM  rd  r   s$   f&&                            @r,   embedTTFType3Z'PdfFile.embedTTF.<locals>.embedTTFType3  sB   --m<L!//0ABN!//0ABN"001BCO!"#Sx3799=9aC5)9D= VGYH .4=
:.D6_D,!#35 ,H" )"
 ((** ''1*/	A:*FH*Fh )2*F  H + &)[Jz"
 IK"u**51  &!006
C<&&z':;$((4   F&4
?$++A. ''T
3	 ' .h	BLI"<0%h/! //$*DO$-tF|$*D$2L $FKK$6$:$;<F!%!3!3J!?!!.&!M //77(KD6DD--d3*8Ih'3 18 ^6^8\2_i8!!A >@H +**s$   L+LL
L
LL 	c                s
  < S-P                  R4      pS-P                  R4      pS-P                  R4      pS-P                  R4      pS-P                  R4      pS-P                  R4      pS-P                  R4      p	RP                  R	 V 4       4      p
\        P                  R
S*V
4       \        P
                  ! S*V
4      ;_uu_ 4       p\        P                  ! V4      pRRR4       \        P                  RS*\        P                  ! S*4      P                  XP                  4       P                  4       T p\        V4      p R\        R4      R\        R4      RS,RRRRRR^ /RVRVRV/pR\        R4      R\        R4      RS,R\        R4      RV.RV	/pWrR &   S-P                  W|P                  4       R!VP                  4       P                  /R"7       R#.R$,          p. p^ pV F  pTpV P!                  V4      pV P#                  V\$        P&                  \$        P(                  ,          R%7      pVP+                  VS)! VP,                  4      34       VR$8  d   \/        V4      VV&   \1        VV4      pK  	  VP3                  4        VRV^,            pR4p. p^ p. pV F}  w  ppVV^,           8w  d8   VP+                  V4       VP+                  V.4       VP+                  VV.4       M$VR5,          P+                  V4       VVR5,          ^&   \1        VV4      pTpK  	  . pV F]  w  ppVR&8  d   K  \5        R&V4      pVP+                  R'VVR(P                  R) \7        VV^,           4       4       4      3,          4       K_  	  S-P8                  \;        V4      R*P                  V4      3,          p. p V F9  p\=        S+V4      '       d   K  VP!                  V4      pV P+                  V4       K;  	  VP>                   U!u. uF  p!S)! V!R+R,7      NK  	  p"p!\A        S*V 4      p#\C        V#4       F  p$V#V$,          p%R\        R-4      R\        R.4      R/V"/p&V%V%PE                  R04      ^,           R p%S-P                  R14      p'S-P                  V'V%V&R"7       S-PG                  S*V$4      p(V'S-PH                  V(&   K  	  RP                  V4      PK                  R24      pS-P                  VV4       S-P                  V	V4       VVR3&   S-PM                  WN4       S-PM                  W_4       S-PM                  W24       S-PM                  VV4       V#   + '       g   i     ELp; iu up!i )6z6The Type 42-specific part of embedding a Truetype fontr  zCID font dictionaryzType 0 font dictionaryzCIDToGIDMap streamzfont file streamzType 0 widthszToUnicode map c              3   s8   "   T F  p\        V4      x  K  	  R # 5ir0   )chr)ra   rW   rb   r,   rc   ;PdfFile.embedTTF.<locals>.embedTTFType42.<locals>.<genexpr>  s      <AQs   zSUBSET %s characters: %sNzSUBSET %s %d -> %drp   r   rr   ZCIDFontType2r  ZCIDSystemInfoZRegistryZAdobeZOrderingZIdentityZ
Supplementr  ZWZCIDToGIDMapZType0r  z
Identity-HZDescendantFontsZ	ToUnicodeZ	FontFile2r  r  Z i   r  r   s   <%04x> <%04x> [%s]r!   c              3   s4   "   T F  pR V,          x  K  	  R# 5i)s   <%04x>Nr_   )ra   r4   rb   r,   rc   r  M  s     J6Iy1}}6Is   r"   Fr  r!  r  r  r  r  utf-16ber  r  r  )'r-  r&   r  r  r    Zget_glyphs_subsetZfont_as_filer=   ZstatZst_sizeZ	getbufferZnbytesr   r:   r  r   r  r  r   r  r  r%   r  r  rk   r  rj   r   _identityToUnicodeCMapr$   r   r  r  r
  r  r  rH  r   r   ).r  r  r  r  ZcidFontDictObjectZtype0FontDictObjectZcidToGidMapObjectr  ZwObjectZtoUnicodeMapObjectZ
subset_strZsubsetZfontdataZ	full_fontZcidFontDictZtype0FontDictZcid_to_gid_mapr  Z	max_ccoderW   r  r  r   Z
last_ccodewZ	max_widthZunicode_groupsrS   Zunicode_bfrangeZstartr   Zunicode_cmapr  r4   r  r  r  r  r  r  r;   r  rM  r   rd  r   s.   &&&                                      r,   embedTTFType42Z(PdfFile.embedTTF.<locals>.embedTTFType42  sP   !//0ABN $ 2 23H I"&"4"45M"N $ 2 23G H!//0BCN((9G!%!3!3O!D < <<JJJ18ZH 228ZHHF*77? IJJ$h!))8+=+=+?+F+F I
 8$D V4/G
 !"% !.W0K V4=GD.!$5#6/M '5{# 1 1 3 ("4"4"6"="=>  @ #Ve^NFI**51u-6-?-?)BVBV-V ' Xuc%*;*;&<=>5=,/IN5)y1	   KKM+NY];NJAIN &uJN*HHUOHHeW%"))5%.9bELL',1N2&q)	51	"
 !' !O,
s5=%o&&)CYYJeE3q56IJJLLM - !77 0%**_2MNOL I#+He<<$33E:D$$T* $
 4=>>B>aC5)>DB-h	BL"<0%h/ &Y )4< & .  E 2Q 6 78!%!3!3J!?!!.&!M33HhG2@))$/! 1&  WW^4;;JGN/@ 0,?%.Jz" .<0@^8Wa(&&G IHH@ Cs   U>UU	r{   r?   pcltZ	capHeightZxHeightpostZitalicAngleFrp   r  r  r  r  r  r  r  r  r  r  r  N)r^   r^   )r   r@   r   r  re  r  Zget_charmapr   r:   Zget_sfnt_tableZ
face_flagsZstyle_flagsr   ZFIXED_WIDTHr   ZITALICr  r  r  )r   rM  r  r  r  r  r  r  ZffZsfr  Zsymbolicr4   r  r  r   rd  s   ff&           @@@r,   r  ZPdfFile.embedTTFq  s    !<</ --t 		(h	" h	"TO	' O	'f ,,  
 ..)4w-""6*LL{Ay!.L""6*EE}f.E__  B&VOEVOEVOE"VOE D)*U		B	1Q.	Bc$--7s4>>59T+.>s4	?+4.q1Q
 q= :>>^!$J??  Cs   $G7c                s    V P                   P                  VR4      pVe
   V^ ,          # \        V P                  4      pVR\	        R4      RV^ ,          RV^,          /3V P                   V&   V# )z?Return name of an ExtGState that sets alpha to the given value.Nrp   r"  ZCAZca)r=  r  r  r>  r:   )r   alphastater;      &&  r,   
alphaStateZPdfFile.alphaState  sy       $$UD18OD))*FD-%(D%(4 5 	 r.   c                s   V P                   P                  VR4      pVe
   V^ ,          # \        V P                  4      pV P	                  R4      pVR\        R4      RRRR\        R4      R	\        R
4      R^.RV//3V P                   V&   V P                  P                  VR\        R4      R\        R4      R^RR	\        R4      R\        R4      /R. RORRR	V//R. RO/\        R	4      \        P                  .34       V# )z
Return an ExtGState that sets the soft mask to the given shading.

Parameters
----------
smask : Reference
    Reference to a shading in DeviceGray color space, whose luminosity
    is to be used as the alpha channel.

Returns
-------
Name
Nz transparency group for soft maskrp   r"  ZAISFSMaskZMaskru   Z
LuminosityZBCZGr!  rr   r  ZFormTypeZGroupZTransparencyZCS
DeviceGrayMatrixrP  r$  r  )ri   r^   r^   ri   r^   r^   )r^   r^   ri   ri   )
r?  r  r  r@  r-  r:   rA  r%   r   r   )r   smaskr  r;   ZgroupOb   &&   r,   _soft_mask_stateZPdfFile._soft_mask_state  s&    &&**5$78OD''($$%GH[)uDLl+1#		)
u% 	%%Y4<An-$|, ,i#u6 #Y

#'
 	  r.   c                s    V P                  V P                  \        . V P                  P	                  4       OV P
                  P	                  4       O4      4       R # r0   )r   r2  r   r=  rl  r?  r   r5   r,   rh  ZPdfFile.writeExtGSTates  sT    !! !!((*''..0 	
r.   c                s    V P                    FC  w  rpV P                  VP                  R V4       V P                  ! V!   V P	                  4        KE  	  R # r0   )rA  rV  r   rW  rU  )r   rt  Z
attributesZcontents   &   r,   ri  ZPdfFile._write_soft_mask_groups  sC    '+'='=#BGRUUD*5KK!NN (>r.   c                s    Vw  r#rEVe   \        V4      pVe   \        V4      pW#WE3pV P                  P                  VR 4      pVe   V# \        V P                  4      pWpP                  V&   V# r0   )rl   rB  r  r  rC  )r   hatch_styleZedgeZfacehatchlwZpatternr;   r+   r,   hatchPatternZPdfFile.hatchPattern  sz     +E;D;D5-&&**;=ND++,,0[)r.   3.10c                s    V P                   P                  4        UUUUUu/ uF  w  pw  r#rEWW43bK  	  uppppp# u upppppi r0   )rB  rA   )r   rF   rX   rY   hZls   &     r,   Z<lambda>ZPdfFile.<lambda>  s?    ,0,@,@,F,F,HC,HLQ1q9,HC Cs   ;c                s6   \        4       pR pV P                  P                  4        EF  w  r4V P                  R4      pWQV&   RRP	                  4        Uu. uF  p\        V4      NK  	  up/pV P                  VP                  RR\        R4      R^R^R	^R
^ ^ W".RVRVRVR^^ ^ ^^ V P                  ^H,          ./	4       Vw  rrV P                  V^ ,          V^,          V^,          \        P                  4       V	eY   V P                  V	^ ,          V	^,          V	^,          \        P                  ^ ^ W"\        P                  \        P                  4
       V P                  V\        P                  4       V P                  ! V P!                  \"        P$                  ! V
4      \'        4       P)                  V4      RR7      !   V P                  \        P*                  4       V P-                  4        EK  	  V P/                  V P0                  V4       R# u upi )      R@zhatch patternZProcsetsr  Nrp   r#  ZPatternTypeZ	PaintTypeZ
TilingTyper  ZXStepZYSteprP  r  Fsimplify)r   rB  rA   r-  rL  r:   rV  r   rT   rW  r   r   r   r   r   r   pathOperationsr   r  r   Zscaler   rU  r   r3  )r   Z	hatchDictZsidelenr  r;   rt  r4   ZresZ
stroke_rgbZfill_rgbr  r  s   &           r,   rj  ZPdfFile.writeHatches  s   F	!%!5!5!;!;!=K##O4B dO%D%J%J%LM%LDG%LMOCti;<!Q1'7GcAq!Q4;;+;<>? /:+J%KK
1z!}jm((*#HQK!hqk//q'BLLGG%
 KKBOO,KK,,

5!
  ) -   ! KK'NNA ">B 	))95; Ns   Hc                s    \        R\        V P                  4      ,          4      pV P                  RV 24      pV P                  P	                  W4W34       W43# )ae  
Add a Gouraud triangle shading.

Parameters
----------
points : np.ndarray
    Triangle vertices, shape (n, 3, 2)
    where n = number of triangles, 3 = vertices, 2 = x, y.
colors : np.ndarray
    Vertex colors, shape (n, 3, 1) or (n, 3, 4)
    as with points, but last dimension is either (gray,)
    or (r, g, b, alpha).

Returns
-------
Name, Reference
zGT%dzGouraud triangle )r:   r$   rD  r-  r%   )r   pointscolorsr;   rt  s   &&&  r,   addGouraudTrianglesZPdfFile.addGouraudTriangles:  sV    $ FS!6!6778"3D6 :;$$d%?@xr.   c                s$   \        4       pV P                   EF  w  r#rEW1V&   VP                  pVP                  V^ ,          V^,          ,          ^34      pVP                  ^,          pVR9   g   Q hVP                  V^ ,          V^,          ,          V34      p	V^8X  d   ^p\        P
                  ! V^ R7      R,
          p
\        P                  ! V^ R7      R,           pRW,
          ,          pT P                  VP                  RR^R^ R^R^R\        V^8X  d   R	MR
4      RRRV
^ ,          V^ ,          V
^,          V^,          .^ ^.V,          ,           /4       \        P                  ! V^ ,          V^,          ,          3RRRRV33.R7      p^ VR&   Wz,
          V,          VR&   V	RRV13,          R,          VR&   V P                  VP                  4       4       V P                  4        EK  	  V P                  V P                  V4       R# )r^   r   l    NZShadingTypeZBitsPerCoordinateBitsPerComponentZBitsPerFlag
ColorSpacerS  r  Z	AntiAliasFZDecoder  u1r  r  Zdtyper  g     o@ri   i   r   )r  r  )r  z>u4)r   )r   rD  shapereshaper}   rj   rk   rV  r   r:   Zemptyr   tobytesrU  r   r4  )r   ZgouraudDictr;   rt  r  r  r	  Zflat_pointsZcolordimZflat_colorsZ
points_minZ
points_maxZfactorZ	streamarrrz  r,   rk  ZPdfFile.writeGouraudTrianglesQ  s   f(,(=(=$Df "LLE ..%(U1X*=q)ABK||AHv%%% ..%(U1X*=x)HIK1}!4?J!4?J:#:;Ft$b#Qt$,M[|  eZ]JqM']JqM; !fx/0 qE!H$&&. $467I
 "#Ig#.#;v"EIh"-a(l";e"CIhJJy((*+NNO )>P 	++[9r.   c                s    V P                   P                  \        V4      R4      pVe
   V^,          # \        V P                  4      pV P                  RV 24      pWV3V P                   \        V4      &   V# )z=Return name of an image XObject representing the given image.Nzimage )rE  r  r   r  rF  r-  )r   rs  Zentryr;   rt  r  r,   imageObjectZPdfFile.imageObject}  sm       ED18ODOO$&0#("3RYr.   c                s`   VRRR1,          pVP                   ^8X  d   VR3# VR,          p\        P                  ! VRR7      pVP                  ^,          ^8X  dQ   VR,          R,          p\        P                  ! V^8H  4      '       d   RpW#3# \        P                  ! VRR7      p W#3# RpW#3# )z
Unpack image array *im* into ``(data, alpha)``, which have shape
``(height, width, 3)`` (RGB) or ``(height, width, 1)`` (grayscale or
alpha), except that alpha is None if the image is fully opaque.
NZC)Zorderr  )r  r  N   Nr  r  r  ).N)ndimr}   r  r	  r  )r   imrgbr  r  r,   _unpackZPdfFile._unpack  s     "X77a<t8OX,C((3c*Cxx{a7I.66%3,'' E
 : HHU#6E : :r.   c                s   \        4       pVP                  VRR7       VP                  ^4       RpR;rE \        P                  ! RVP                  ^4      4      w  rgVR9   da   VP                  V4      p\        V4      V8w  d   \        R	4      hVR8X  d   \        V^,          4      pM4VR8X  d   TpM*VR8X  d	   W8,          pMVR
8X  d   M&VP                  V^4       VP                  ^^4       K  W4V3# )zV
Write the image *img* into the pdf file using png
predictors with Flate compression.
r   )r  r.   Ns   !L4s   IHDR   PLTE   IDATztruncated datas   IEND)r  r  r  )	r   ZsaveZseekstructZunpackZreadr$   RuntimeErrorr>   )	r   imgZbufferpng_data	bit_depthpaletter*   r   r   s	   &&       r,   	_writePngZPdfFile._writePng  s    
 &A""	!==&++a.ALF22{{6*t9&&'7887? #DGIW_"GW_$HFA&KK1G++r.   c                s   VP                   w  rEpR\        R4      R\        R4      RVRVR\        ^R^R	/V,          4      R
^/pV'       d   W7R&   \        P                  R,          '       Ed   VP                   R,          ^8X  d   VP	                  RR7      pR^
RVRV/p\
        P                  ! V4      p	V	P                  RR7      p
V^8X  Ed   V
Ee   \        V
4      p\        P                  ! V
 UUUu. uF  w  rV F  qNK  	  K  	  uppp\        P                  R7      pVR,          P                  \        P                  4      ^,          VR,          P                  \        P                  4      ^,          ,          VR,          ,          pVR,          P                  \        P                  4      ^,          VR ,          P                  \        P                  4      ^,          ,          VR!,          ,          p\        P                  ! V4      P                  \        P                  4      pV\        P                  ! VVVR7      ,          p\
        P                  ! V4      P!                  R4      p	V	P#                  V4       V P%                  V	4      w  pppVe   Vf   \'        R4      hVRV^,           p\        R4      \        R	4      V^,
          V.VR&   VVR
&   ^VR&   VVR
&   MV P%                  V	4      w  p pMRpV P)                  VV P+                  R4      VVR7       V'       d   V P,                  P/                  X4       M)V P,                  P/                  VP1                  4       4       V P3                  4        R# u upppi )"z
Write the image *data*, of shape ``(height, width, 1)`` (grayscale) or
``(height, width, 3)`` (RGB), as pdf object *id* and with the soft mask
(alpha channel) *smask*, which should be either None or a ``(height,
width, 1)`` array.
rp   r!  rr   r   ZWidthZHeightr  r  rS  r  r  r   r   Z	PredictorZColorsZColumnsr   )Z	maxcolorsNr  :r^   Nr  :ri   Nr  :r   Nr  )ZsorterZPzinvalid PNG headerZIndexedzlength of image stream)r   r  )r  r  r^   )r  r  ri   )r  r  r   )r	  r:   r@   r   Zsqueezer   Z	fromarrayZ	getcolorsr$   r}   r  Zuint8r	  Zuint32ZargsortZsearchsortedZconvertZ
putpaletter  r  rV  r-  r,  r   r  rU  )r   r   r   r  rT   rS   Zcolor_channelsr   r   r  Z
img_colorsZ
num_colors_ZcolorZcompr  Z	palette24Zrgb24ZindicesZrgb8r  r  s   &&&&                  r,   	_writeImgZPdfFile._writeImg  s    )-

%~tI$w-T1lA{"CN"ST!1&  L<<)**zz"~"|||,HniOC//$'C5J"z'= !_
((#VXQPUDPUD#V)+3%dm22299=C%dm22299=BD$T]+	 w-..ryy9R?w-..ryy9Q>@g' **Y/66rxx@ry%PQood+33C8w'/3~~c/B,)W$&';<<!/:>2%))_d;6G%/!^W%>L!*3&' !H*3&'!%!4!QC78	 	 	 $$X.$$T\\^4G $Ws   6Nc                s   V P                   P                  4        Fh  w  rpV P                  V4      w  rEVe.   V P                  R4      pV P	                  WVP
                  4       MR pV P	                  WCP
                  V4       Kj  	  R # )Nr  )rE  rl  r  r-  r  r   )r   r  r;   rt  r   ZadataZsmaskObjectr  r,   rm  ZPdfFile.writeImages  sj    !\\002MCr,,s+KD "009unn5"NN44 3r.   c                s   V P                  WRR7      p\        V4      \        V4      \        V4      Wg3p	V P                  P	                  V	4      p
V
fu   \        R\        V P                  4      ,          4      pV P                  R\        V P                  4      ,          4      pVP                  V4      pWW.V P                  V	&   V# V
R,          V8  d   WZR&   V
^ ,          pV# )z<Return name of a marker XObject representing the given path.Fr  zM%dz	marker %dr  )	r   rl   r   rG  r  r:   r$   r-  get_extents)r   ru  rv  r   r   r  	joinstylecapstylepathopskeyr'   r;   rt  r  s   &&&&&&&&      r,   markerObjectZPdfFile.markerObject  s     %%dE%BW~tDz4<M!!#&>DLL 112D##K#dll2C$CDB##E*D!%4 4DLL
  bzBr
!9Dr.   c                s|   V P                   P                  4        EF  w  w  rr4pw  rgrVP                  V	^,          4      pV P                  VP                  RR\        R4      R\        R4      R\        VP                  4      /4       V P                  \        P                  V,          \        P                  4       V P                  \        P                  V,          \        P                  4       V P                  ! V!   V P                  \        P                  W#4      4       V P!                  4        EK  	  R# )   Nrp   r!  rr   r  r  )rG  rA   paddedrV  r   r:   r   extentsrW  rX  rY  r   r   	capstylesr   r   rU  )
r   r#  r   r   r!  r"  r;   rt  r  r  s
   &         r,   rn  ZPdfFile.writeMarkers#  s    &*ll&8&8&:#9gV!d ;;rAv&Dti)T&\dll+-. KK*55i@(KK*44X>NKK!KKd34NN% ';r.   c                s    \        R \        V P                  4      ,          4      pV P                  R\        V P                  4      ,          4      pV P                  P	                  WrW8VP                  4       VP                  4       WEV3	4       V# )zP%dzpath %d)r:   r$   rI  r-  r%   get_joinstyleget_capstyle)	r   rx   ru  rv  rw  rx  ry  r;   rt  s	   &&&&&&&  r,   pathCollectionObjectZPdfFile.pathCollectionObject9  sr    EC

O+,	C

O ;<

B$4$4$68Ig'	( r.   c                s   V P                    EFv  w	  rr4rVrxp	V P                  W#R R7      p
VP                  V4      p\        P                  ! \        P
                  ! VP                  4      4      '       g   . ROpM&VP                  V4      p\        VP                  4      pV P                  VP                  RR\        R4      R\        R4      RV/4       V P                  \        P                  V,          \        P                   4       V P                  \        P"                  V,          \        P$                  4       V P                  ! V
!   V P                  \        P'                  W4      4       V P)                  4        EKy  	  R# )	Fr  Nrp   r!  rr   r  r  r^   r^   r^   r^   )rI  r   r   r}   r  r~   r(  r'  r   rV  r   r:   rW  rX  rY  r   r   r)  r   r   rU  )r   r;   ru  rv  rt  r!  r"  rw  rx  ry  r#  r  r(  s   &            r,   ro  Z$PdfFile.writePathCollectionTemplatesA  s   TI))$)FG##E*D66"++dll344&{{7+t||,ti)T&\"# KK*55i@(KK*44X>NKK!KKf67NN# $r.   c                s   \        \        P                  ! WW#V^\        P                  P
                  \        P                  P
                  R\        P                  P
                  \        P                  P
                  .R4      4      .# )rb  r.   T)	r   r   r  r   r   r   r   r   r   )ru  r  r   r  sketchr~  r,   r   ZPdfFile.pathOperationsV  sc    00TVYY__biioosBJJ4D4D\\!   	r.   c                s    V'       d6   R R V P                   ^H,          V P                  ^H,          3pVP                  pMRpRpV P                  WW5VR7      pV P                  ! V!   R# )r  NF)r  r.  )rS   rT   Zshould_simplifyr   rW  )r   ru  r  r   r.  r  cmdss   &&&&&  r,   	writePathZPdfFile.writePath_  sa    djj2ot{{R/?@D++HDH""4D*0 # 2Tr.   c                s~    \        V P                  4      pV P                  P                  R^ V.4       \	        V4      # )z
Reserve an ID for an indirect object.

The name is used for debugging in case we forget to print out
the object with writeObject.
N)r  r'  r(  r%   r   )r   r;   r   r   r,   r-  ZPdfFile.reserveObjectj  s6     $""#tQo.}r.   c                s    V P                   P                  4       V P                  ,
          V P                  V,          ^ &   R# r]   )r   r   r+  r(  r   r   r,   r   ZPdfFile.recordXrefu  s(     $ ?r1r.   c                s^    V P                  VP                  4       VP                  W 4       R # r0   )r   r   r   )r   Zobjectr   r   r,   r   ZPdfFile.writeObjectx  s    		"X$r.   c                s|   V P                   P                  4       V P                  ,
          V n        V P	                  R\        V P                  4      ,          4       \        V P                  4       FG  w  pw  r#pVf   \        RW3,          4      hVR8X  d   RMRpRW#V3,          pV P	                  V4       KI  	  R# )zWrite out the xref table.s
   xref
0 %d
NzNo offset for object %d (%s)r%  r   r   s   %010d %05d %b 
)	r   r   r+  	startxrefr   r$   r(  r#   ZAssertionError)r   r(   offsetZ
generationr;   r$  r\  r  r,   rq  ZPdfFile.writeXref|  s    $..8

?S%889-6t~~-F)A)D~$2aY>@ @ #&77dT*f#-FF

4  .Gr.   c                s~    V P                  R4      V n        V P                  V P                  V P                  4       R# )z8Write out the info dictionary, checking it for good formrE   N)r-  
infoObjectr   r7  r   r5   r,   rp  ZPdfFile.writeInfoDict  s.     ,,V4$--8r.   c           
     s    V P                  R4       V P                  \        R\        V P                  4      RV P                  RV P
                  /4      4       V P                  RV P                  ,          4       R# )zWrite out the PDF trailer.s   trailer
ZSizeZRootZInfos   
startxref
%d
%%%%EOF
N)r   rz   r$   r(  r.  r3  r1  r   r5   r,   rr  ZPdfFile.writeTrailer  s`     	

< 

7S(T__T__&' 	(
 	

04>>ABr.   ))r5  r>  rJ  r<  r2  rC  rB  rF  rE  r9  r'  rA  r@  r?  r=  r,  r:  r   r8  r1  r4  rD  r3  rT   r7  r3  rG  rH  r*  rK  r0  r/  r)  rI  r6  r.  r1  r+  r;  rS   r(  r0   r5  r^   r^   r   )NNNFN)r  );r   r   r   r   r   r   r[  r^  re  r{  r|  r   rW  rV  rU  r  rf  r  r  rg  r  r  r  r  r  r  r  r  rh  ri  r  r   Z
deprecatedZpropertyZhatchPatternsrj  r  rk  r  r  r  r  rm  r%  rn  r,  ro  Zstaticmethodr   r0  r-  r   r   rq  rp  rr  r   r   __classcell__rN  r      @@r,   r  r    sB    g9R": .@ -* B	+?&
t 
8><1*
8t=~*|@|	2h
" OOF+H 6 - M$6L.*:X
.,:=~5:,*  		@%!9	C 	Cr.   r  c                   s   a a ] tR tRt o]P
                  ! R4      tRtV 3R ltR t	RR lt
R tRR	 ltRR
 ltR tRR ltR tRR ltR tRR/R ltR tRR ltR tR tRtVtV ;t# )r  i  zfonts/pdfcorefontsr  c                sh   < \         SV `  WC4       Wn        V P                  4       V n        W n        R # r0   )r&  r   r   new_gcrx   	image_dpi)r   r   r;  rT   rS   rN  s   &&&&&r,   r   ZRendererPdf.__init__  s'    '	++-"r.   c                sj    V P                   P                  ! V P                  P                  4       !   R # r0   )r   rW  rx   r{  r   r5   r,   r{  ZRendererPdf.finalize  s!    		$''**,-r.   Nc                s"   \        VR R4      pW!n        \        VRR4      pVP                  4       f   VP                  RRR7       VP                  '       d   VP
                  VP
                  3Vn        MPVe   \        V4      ^8  d   VP                  ^,          R3Vn        M!VP                  ^,          V^,          3Vn        V P                  P                  V4      pV'       d   V P                  P                  ! V!   W1n        WAn        R# )	
_fillcolor_effective_alphasr  NT)ZisRGBAr  r  r  r  r  r-  )getattrr<  Zget_rgbZset_foreground_forced_alpha_alphar=  r$   _rgbrx   deltar   rW  )r   rx   	fillcolorZ	orig_fillZorig_alphasrD     &&&   r,   check_gcZRendererPdf.check_gc  s    Bl;	!b"5zB::< l48$&IIryy#9B #i.1"4$&GGAJ#4B $&GGAJ	!#=B b!IIe$ "*r.   c                s(    V P                   R ,          # )r  )r;  r   r5   r,   get_image_magnificationZ#RendererPdf.get_image_magnification  s    ~~d""r.   c                s   VP                   R ,          w  rgV^ 8X  g   V^ 8X  d   R# Vf   VP                  R4       V P                  V4       RV,          V P                  ,          pRV,          V P                  ,          pV P                  P                  V4      pVf_   V P                  P                  \        P                  V^ ^ WbV\        P                  V\        P                  \        P                  4       R# VP                  4       P                  4       w  rrrV P                  P                  \        P                  ^^ ^ ^W#\        P                  WWW\        P                  V\        P                  \        P                  4       R# )r  Nr  r  )r	  	set_alpharG  r;  r   r  rW  r   r   r   r   r   ZfrozenZ	to_values)r   rx   r4   rR   r  r  r  r  ZimobZtr1Ztr2Ztr3Ztr4Ztr5Ztr6s   &&&&&&         r,   
draw_imageZRendererPdf.draw_image  s$    xx|6Q!VLLb1Ht~~%1Ht~~%yy$$R(IIRXX1aAr/?/?!2>>2;;@ ,5+;+;+=+G+G+I(CcIIRXX1ar/?/? s2;K;K!2>>2;;@r.   c                s   V P                  W4       V P                  P                  Y#VR J ;'       d    VP                  4       R J VP	                  4       4       V P                  P                  V P                  P                  4       4       R # r0   )rG  r   r0  Zget_hatch_pathZget_sketch_paramsrW  rx   paint)r   rx   ru  r  rgbFacer~  r,   	draw_pathZRendererPdf.draw_path  sj    b"		tO;; 1 1 3t ;  "	$ 			)r.   c                s   R p\         P                  ! V4      p\         P                  ! V4      p\        V4      '       g   RpVP                  4       '       * pM<\         P                  ! VR,          VR,          8H  4      '       d   VR,          R8g  pMRp\        V4      '       g   RpMr\         P                  ! \         P                  ! V	4      R8H  4      '       d   RpM<\         P                  ! VR,          VR,          8H  4      '       d   VR,          R8g  pMRp\        V4      ^ 8  d   \        V^ ,          P
                  4      M^ pV P                  W4WWV4      pVV,           ^,           VV,          8  pV'       d	   V'       g   \        P                  ! WW#VWVWxWWV4      # \         P                  ! V	4      p. p\        V P                  W#V4      4       F:  w  pw  ppV P                  P                  VVVVXX4      pVP                  V4       K<  	  V P                  P                  pV! V P                   P#                  4       !   ^ ^ ppV P%                  VVWVWxWWV4       F]  w  pppp p!V P'                  V V!4       VV,
          VV,
          p#p"V! ^^ ^ ^V"V#\(        P*                  V\(        P,                  4	       TTppK_  	  V! V P                   P/                  4       !   R# )TFr  N)r  r  )r^   r  )r}   asarrayr$   Z	get_hatchr  rn   Z_iter_collection_uses_per_pathr   draw_path_collectionrk   r#   Z_iter_collection_raw_pathsr   r,  r%   rW  rx   pushZ_iter_collectionrG  r   r   r   pop)$r   rx   Zmaster_transformrI  Zall_transformsZoffsetsZoffset_transZ
facecolorsZ
edgecolorsZ
linewidthsZ
linestylesZantialiasedsZurlsZoffset_positionZcan_do_optimizationrx  ry  Zlen_pathZuses_per_pathZshould_do_optimizationrw  Z
path_codesr(   ru  r  r;   rW  lastxlastyZxoZyoZpath_idZgc0rL  dxdys$   &&&&&&&&&&&&&&                      r,   rO  Z RendererPdf.draw_path_collection  s    #ZZ
+
ZZ
+
:F&(lln"4vvj&*T*::;;#D)S0&+#:Gvvbjj,344
4(Jt,<<==$T*c1&+# .1Z!^3uQx(();;7
D }$q(8m+CC 	 $-C44*>z	! ! &&$
$-d.M.M /9 %: A i9911D)Wfg?Dd#	%: !!!u-1-B-BJ
O.5)BGS'
 MM#w'%ZeB1aAr2r'7'7>>#r5E5.5 	r.   c                sF   \        V4      p\        V4      pWx,          Wx,           ^,           8  d   \        P                  ! WW#WEV4       R# V P                  W4       VP	                  V4      p	VP                  4       p
V P                  P                  pV P                  P                  W#WV P                  P                  VP                  4       VP                  4       4      pV! \        P                  4       ^ ^ rVP                  V^ ^ V P                  P                   ^H,          V P                  P"                  ^H,          3RR7       F  w  pp\        V4      '       g   K  VRR w  pp^ Tu;8:  d#   V P                  P                   ^H,          8:  d0   M M,^ Tu;8:  d#   V P                  P"                  ^H,          8:  g   M K|  VV,
          VV,
          ppV! ^^ ^ ^VV\        P$                  V\        P&                  4	       TTrK  	  V! \        P(                  4       R# )r&  NF)r   r  r  )r$   r   draw_markersrG  r   r   r   rW  r%  rx   
_linewidthr*  r+  r   r   Ziter_segmentsrS   rT   r   r   r   )r   rx   Zmarker_pathZmarker_transru  rv  rL  Zlen_marker_pathZusesr   r   rW  ZmarkerrR  rS  rn   Zcoder4   rR   rT  rU  s   &&&&&&&              r,   rV  ZRendererPdf.draw_markers4  s   
 k*4y!O$:Q$>>%%d&*7<b"www!!''tTWW5G5G 13 	rxx!u"00DIIOOB.		0@0@0CD 1  NHd 8}}}1Q6$))//B"66;dii&6&6&;;UAIBq!Q2r2+;+;r~~/ !u  	r{{r.   c                s   \        V4      \        V4      8X  g   Q h\        V4      ^ 8X  d   R# VP                  ^8X  g   Q hVP                  ^,          ^8X  g   Q hVP                  ^,          ^8X  g   Q hVP                  ^8X  g   Q hVP                  ^,          ^8X  g   Q hVP                  ^,          R9   g   Q hVP                  pVP                  V^ ,          V^,          ,          ^34      pVP	                  V4      pVP                  V4      pV P
                  P                  Wc4      w  rxV P
                  P                  p	VP                  ^,          ^8X  d<   VP                  R4       V P                  V4       V	! V\        P                  4       R# VR,          p
\        P                  ! WR,          4      '       d<   VP                  V
4       V P                  V4       V	! V\        P                  4       R# VR,          R,          p
V P
                  P                  Wj4      w  rV P
                  P                  V4      pV	! \        P                  V\        P                   V\        P                  \        P"                  4       R# )r^   Nr  r  )r^   r^   r  r  )r  r  N)r$   r  r	  r
  r  r   r  rW  rI  rG  r   r   r}   Zallcloser  r   r   r   )r   rx   r  r  rv  r	  Ztpointsr;   r  rW  r  Zsmask_obZgstaterZ   r,   draw_gouraud_trianglesZ"RendererPdf.draw_gouraud_trianglesZ  s   6{c&k)))v;!{{a||A!###||A!###{{a||A!###||A&(((qE!H!4a 89//&)//%())//@!!<<?aLLMM"4$w;;uWo..LLMM"4$ 7OJ/E))77GKAYY//9F288VR\\;; r.   c           	     s   Y6u;8X  d   ^ 8X  d=   M M9V P                   P                  W,
          W%,
          \        P                  4       R# \        P
                  ! V4      pV P                   P                  \        P                  ! V4      \        P                  ! V4      \        P                  ! V4      ) \        P                  ! V4      W\        P                  4       V P                   P                  ^ ^ \        P                  4       R# r]   )	r   rW  r   r   rN   rO   rQ   rP   r   )r   r4   rR   rU   oldxoldyZoldangles   &&&&&&&r,   _setup_textposZRendererPdf._setup_textpos  s    !!IIQXqx<LL'EIITXXe_dhhuo"hhuo-txx2==2 IIQ2::.r.   c                sH   V P                   P                  P                  V^HV4      w  rxrpVP                  4       e?   V P                  P
                  R,          ^,          P                  \        WW7W4      4       \        P                  R,          p\        P                  ! V4      pV P                  P                  \        P                  4       V P                  P                  \        P                  ! V4      \        P                   ! V4      \        P                   ! V4      ) \        P                  ! V4      W#\        P"                  4       V P%                  WP&                  4       Rp^ ^ pp. pV P                  P                  \        P(                  4       V
 EF  w  pppppV P                  P*                  P-                  VV4       VP.                  p\1        VV4      '       g   VP                  VVVVV34       Kf  V P3                  VV^ VV4       TTppVV3V8w  dI   V P                  P                  V P                  P5                  V4      V\        P6                  4       VV3pV P                  P                  V P9                  \;        V4      V4      \        P<                  4       EK  	  V P                  P                  \        P>                  4       V F-  w  pppppV PA                  VVVPC                  V4      VV4       K/  	  V F`  w  pprxV P                  P                  \        P                  VVWx\        PD                  \        PF                  \        PH                  4       Kb  	  V P                  P                  \        PH                  4       R# )H   Nr  r  r   )%Z
_text2pathZmathtext_parserZparserw   r   rJ  r%   ry   r@   r   rN   rO   rW  r   r   rQ   rP   r   rG  rC  r   r<  Ztrack_glyphr  r   r[  r  r   encode_stringr  r   r   _draw_xobject_glyphr  r   r   r   )r   rx   r4   rR   r)   r  rU   rS   rT   ZdescentZglyphsZrectsr   rV   	prev_fontrY  rZ  Zunsupported_charsr  fontsizeZnumZoxZoyr  s   &&&&&&&                 r,   draw_mathtextZRendererPdf.draw_mathtext  s    OO++11!R> 	.w ::<#II""2&q)001Eq20 1 <</ LL		"		!dhhqk((1+txx{r//	1 	b''"	d		'+1'D(CRII((44T3?zzH'#66 "(($"b#)FG##BAtT:dh'94II$$TYY%7%7%A8%']]4 (( 2I		  !3!3CHh!G!#* ,2  			%+<'D(BC$$h 3 3C 8"bB ,=
 &+!BEIIRXXr2u\\277BKKA &+
 			%r.   mtextc          
     s
   V P                  4       pVP                  4       p	VP                  WI4      p
\        P                  ! V
^H4      ;_uu_ 4       pVw  pRRR4       VP                  4       eU   V P                  P                  R,          ^,          P                  \        WVXP                  VP                  V4      4       R. rXP                   Fe  w  pppppVV8w  d5   V P                  P                  V4      pVRVVP                  ..,          pTpVRVV\        V.4      .VV,           ..,          pKg  	  ^ ^ Rp	ppV\!        V4      ^,
          8  Ed1   VVV^,            w  ppV^ ,          R8X  d   V^,          p	MV^ ,          V^ ,          u;8X  d   R8X  d   M MV^,          V^,          8X  d   V^,          V^,          ,
          p\#        V4      R8  dV   V^,          R;;,          V^,          ^ ,          ,          uu&   V^;;,          V^,          V^,          ,
          ,          uu&   M?V^;;,          VR,          V	,          V^,          ^ ,          .,          uu&   V^,          V^&   VV^,            EK<  V^,          pEKH  \%        4       P'                  V4      P)                  W#4      pV P+                  WP,                  4       V P                  P/                  \0        P2                  4       Rw  ppppV EF  pV^ ,          R8X  d<   V P                  P/                  V^,          V^,          \0        P4                  4       KM  V^ ,          R8X  d   VP7                  V^,          V^,          34      w  ppV P9                  VVVVV4       TTpp\!        V^,          4      ^8X  d;   V P                  P/                  V^,          ^ ,          \0        P:                  4       K  V P                  P/                  V^,          \0        P<                  4       EK  Q h	  V P                  P/                  \0        P>                  4       V PA                  4       pVPC                  V4       VPE                  ^ 4       \F        PH                  \F        PJ                  \F        PJ                  \F        PJ                  \F        PL                  .pVPN                   F]  w  ppp p!\G        VV.VV!,           V.VV!,           VV ,           .VVV ,           .^ ^ ..V4      p"V PQ                  VV"VVP,                  4       K_  	  R#   + '       g   i     EL; i)r\  Nr  r\  g?g     @@r  r-  ))Zget_texmanagerget_size_in_pointsZmake_dvir
   ZDvirw   r   rJ  r%   ry   rS   rT   r\  r  Zsizer   r$   Zabsr   Z
rotate_degr   rG  rC  rW  r   r   r   r  r[  r   r   r   r:  copy_propertiesZset_linewidthr   ZMOVETOZLINETOZ	CLOSEPOLYZboxesrM  )#r   rx   r4   rR   r)   r  rU   rb  Z
texmanagerr`  ZdvifileZdvirR  ZoldfontZseqZx1Zy1r  r   rS   r  r(   ZcurxZeltZnxtr2  ZmytransZcuryrY  rZ  Zboxgcr#  r  r  ru  s#   &&&&&&&$                           r,   draw_texZRendererPdf.draw_tex  s'   ((*
**,%%a2[["%%ED & ::<#II""2&q)001Eq$**dkk52: ; R-1YY)BGUE'!))//8',,788!VReUGn%5r%x@AAC .7 q$4#c(1*n1QqSzHC1vq6Q3q6+V+A#a&0@Q#a&v;$F2J#a&)+JFc!fSVm+FFvf}X5s1vayAAF VCF!HFA *''.88> 	b''"		'!+dD$C1v		  QQ?Q6!$..AA/?@
d##D$tTB!4ds1v;!#II$$SVAY8II$$SVR[[9u  			% b!A;;T[[$++>># JJLBAq"bBqD":1bd|b"Q$ZQ!")+DNN5$9 'S &%%s   T77U	c                sX    VR9   d   VP                  RR4      # VP                  RR4      # )ri   r  r?   r  )ri   r  )r   )r   r)   r   r   r,   r]  ZRendererPdf.encode_string	  s,    v88Hi00xx
I..r.   c	                sr   V P                  WP                  4       V'       d   V P                  WW4WV4      # VP                  4       p	\        P
                  R ,          '       d   V P                  V4      p
^pMMV P                  V4      p
V P                  P                  P                  W4       \        P
                  R,          pVP                  4       eq   V
P                  V4       V
P                  4       w  rV P                  P                  R,          ^,          P                  \!        WW<^@,          V^@,          V4      4       VR9  d   V P                  P#                  \$        P&                  V P                  P)                  V4      V	\$        P*                  4       V P-                  W#V4       V P                  P#                  V P/                  WK4      \$        P0                  \$        P2                  4       R# . p. pRpT
p\4        P6                  ! WJ\8        P:                  R7       EF  p\=        V\?        VP@                  4      4      '       d   V'       g   VPB                  V8w  d5   VP                  VPB                  VPD                  . 34       VPB                  pVPF                  '       d*   VR,          ^,          P                  VPF                  4       VR,          ^,          P                  VP@                  4       RpK  VP                  VPB                  VPD                  VPH                  34       RpEK  	  V P                  P#                  \$        PJ                  4       \L        PN                  ! V4      pV P                  P#                  \L        PP                  ! V4      \L        PR                  ! V4      \L        PR                  ! V4      ) \L        PP                  ! V4      W#\$        PT                  4       V P                  P#                  \$        P&                  4       ^ pV EF  w  pppV P                  P)                  VPV                  4      pV P                  P#                  VV	\$        P*                  4       V P-                  V^ ^ V^ ^ 4       V P                  P#                  \X        PZ                  ! V\\        4       UUu. uFK  w  ppV\^        8X  d   R	\a        V4      ,          V	,          M V P/                  RPc                  V4      V4      NKM  	  upp\$        Pd                  4       TpEK  	  V P                  P#                  \$        P2                  4       V F  w  pppV Pg                  VV	VV^ 4       K  	  V P                  P#                  \$        Ph                  4       R# u uppi )
r  r  NT)Z	kern_modeFr  r  )r  i*   i)5rG  rC  ra  rc  r@   r   Z_get_font_afmZ_get_font_ttfr   r<  Ztrackrw   Zset_textZget_width_heightrJ  r%   ry   rW  r   r   r  r   r[  r]  r   r   r   Zlayoutr   ZUNFITTEDr   r   Zchar	ft_objectr4   Z	prev_kern	glyph_idxr   rN   rO   rQ   rP   r   r  rm   Zgroupbyr   r|   r  r&   r   r^  r   )r   rx   r4   rR   r)   r  rU   Zismathrb  r`  r  r   rS   rT   Zsinglebyte_chunksZmultibyte_glyphsZprev_was_multibyter_  ZitemrV   Zprev_start_xrf  Zstart_xZkerns_or_charsZft_nameZtpZgrouprg  s   &&&&&&&&&                   r,   	draw_textZRendererPdf.draw_text	  s.   
 	b''"%%bQ4??**,<<,--%%d+DH%%d+DII((..t7||N3H::<#MM! 113MEII""2&q)001Eq"*frk52: ;
 7"IIR]]!YY//5xPe,IIT//<WWbkk3$ !#!!%I%,,Q@P@PQQ'#dii.AA)T^^y-H)00$..$&&"1MN$(NN	~~~)"-a077G%b)!,33DII>).&$++T^^TVVT^^,TU)-& R IIRXX&U#AIITXXa[$((1+"hhqk\488A;2#3#35
 IIR]]+L6G2	7N)),,Y__=		  (BMMB##GQ<AF		  
 '0&7&7&MO&MU 8:U{UT%[(83,,RWWU^XFG&MO KK!  ' 7H IIR[[)1A-	7I((xGQ 2B IIR[[)Os   AV3c                sZ   VP                  V4      pV P                  P                  VP                  V4      pV P                  P	                  \
        P                  RV,          ^ ^ RV,          WE\
        P                  \        V4      \
        P                  \
        P                  4       R# )z<Draw a multibyte character from a Type 3 font as an XObject.r  N)r  r   r  r  rW  r   r   r   r:   r   r   )r   r  r`  rg  r4   rR   r  r;   s   &&&&&&  r,   r^  ZRendererPdf._draw_xobject_glyph{	  sv    ((3
yy00ZH		HHHaEH$4aB<L<LJKK		
r.   c                r   r0   )rX  r   r   r5   r,   r:  ZRendererPdf.new_gc	  s    !$)),,r.   )r   rx   r;  r0   rv   r6  )r   r   r   r   r	   Z_get_data_pathr  Z_use_afm_rc_namer   r{  rG  rH  rJ  rM  rO  rV  rX  r[  ra  re  r]  rh  r^  r:  r   r   r7  r8  r9  r,   r  r    s     (()=>M+#.+6#@<*DL$L& P/4&lQ:$ Q:f/
_*B	
- -r.   r  c            
       s   a a ] tR tRt oV 3R ltR tR tR tR tR^ R^R	^/t	R
^ R^R^/t
R tR tR tR tR tR tR tR tR tR tR tR]3R]3R]3R]3R]3R ]3R!]3R"]3R#]33	tR tV 3R ltR tRtVtV ;t# )$rX  i	  c                sZ   < \         SV `  4        RV n        RV n        Wn        RV n        R# )r  Nr>  r?  )r&  r   r<  r=  r   parent)r   r   rN  ra  r,   r   ZGraphicsContextPdf.__init__	  s)    )!+	r.   c                sN    \        V P                  4      pVR  VR \        V4      # )r   ri  )r   r  Zrepr)r   rJ   rb   r,   r   ZGraphicsContextPdf.__repr__	  s'    fIhKAwr.   c                s    V P                   ^ 8  ;'       dN    V P                  ^ 8  ;'       d7    \        V P                  4      ^8*  ;'       g    V P                  ^,          R8g  # )z
Predicate: does the path need to be stroked (its outline drawn)?
This tests for the various conditions that disable stroking
the path, in which case it would presumably be filled.
r  )rW  rB  r$   rC  r   r5   r,   r   ZGraphicsContextPdf.stroke	  sX     !# = =a = =TYY1$;;		!(;	>r.   c                s    \        V4      '       d   V^ ,          pMV P                  pV P                  ;'       g/    VRJ;'       d#    \        V4      ^8*  ;'       g    V^,          R8g  # )z
Predicate: does the path need to be filled?

An optional argument can be used to specify an alternative
_fillcolor, as needed by RendererPdf.draw_markers.
Nr  )r$   r<  _hatch)r   Zargsr<  r}  r,   r   ZGraphicsContextPdf.fill	  si     t99aJJ A A4' @ @j/Q&>>*Q-3*>	Br.   c                sf    \         P                  V P                  4       V P                  4       4      # )zW
Return the appropriate pdf operator to cause the path to be
stroked, filled, or both.
)r   r   r   r   r   r5   r,   rK  ZGraphicsContextPdf.paint	  s!    
 }}TYY[$++-88r.   ZbuttrT  Z
projectingZmiterZbevelc                H    V P                   V,          \        P                  .# r0   )r)  r   r   r   Zstyler   r,   capstyle_cmdZGraphicsContextPdf.capstyle_cmd	  s    u%r}}55r.   c                rk  r0   )rY  r   r   rl  r   r,   joinstyle_cmdZ GraphicsContextPdf.joinstyle_cmd	  s    &77r.   c                s&    V\         P                  .# r0   )r   r   )r   rS   r   r,   linewidth_cmdZ GraphicsContextPdf.linewidth_cmd	  s    r''r.   c                sR    Vw  r#Vf   . p^ p\        V4      V\        P                  .# r0   )r   r   r   )r   Zdashesr2  Zdashr  r,   dash_cmdZGraphicsContextPdf.dash_cmd	  s-    <DFT
FBJJ//r.   c                s\    V P                   P                  V4      pV\        P                  .# r0   )r   r  r   r   )r   r  Zforcedeffective_alphasr;   s   &&&& r,   	alpha_cmdZGraphicsContextPdf.alpha_cmd	  s&    yy##$45bll##r.   c                sB   V'       gE   V P                   e   V P                  V P                   4      # \        R4      \        P                  .# W P                   W3pV P
                  P                  V4      p\        R4      \        P                  V\        P                  .# )NrS  r#  )r<  fillcolor_cmdr:   r   r   r   r  r   )r   r  Zhatch_colorZhatch_linewidthr  r;   s   &&&&  r,   	hatch_cmdZGraphicsContextPdf.hatch_cmd	  s    *))$//::[)2+E+EFF&PK99))+6DOR%?%?"//1 1r.   c                s    \         P                  R ,          '       d   . # V^ ,          V^,          u;8X  d   V^,          8X  d   M MV^ ,          \        P                  .# . VR,          O\        P                  N# )pdf.inheritcolorr  )r@   r   r   r   r   r   r  r   r,   rgb_cmdZGraphicsContextPdf.rgb_cmd	  s_    <<*++Iq6SV%s1v%FB--../SW/b..//r.   c                s    Ve   \         P                  R,          '       d   . # V^ ,          V^,          u;8X  d   V^,          8X  d   M MV^ ,          \        P                  .# . VR,          O\        P                  N# )Nru  r  )r@   r   r   r   r   rv  r   r,   rs  Z GraphicsContextPdf.fillcolor_cmd	  sc    ;#,,'9::IVs1v'Q'FB00112SW2b1122r.   c                s    \        V P                  4      pVP                  V 4       V P                  Vn        Wn        \        P
                  .# r0   )rX  r   rd  ri  r   r   )r   ri  rb   r,   rP  ZGraphicsContextPdf.push	  s:    #DII.t$zr.   c                s    V P                   f   Q hV P                  V P                   4       V P                   P                   V n         \        P                  .# r0   )ri  rd  r   r   r   r5   r,   rQ  ZGraphicsContextPdf.pop	  sA    {{&&&T[[)kk((}r.   c                s   . pV P                   V P                  3W38w  d0   V P                  e"   VP                  V P	                  4       4       KM  V P                   V P                  3W38w  g   V P                  f   VP                  V P                  4       4       V P                   V8w  d@   VP                  V\        P                  \        P                  \        P                  .4       V P                  V8w  d^   VP                  4       w  rEVP                  \        P                  WERR7      \        P                  \        P                  .,           4       V# )z1Set clip rectangle. Calls `.pop()` and `.push()`.Fr  )	_cliprect	_clippathri  r  rQ  rP  r   r   r   r   Zget_transformed_path_and_affiner  r   )r   ZcliprectZclippathr/  ru  ZaffinerF  r,   clip_cmdZGraphicsContextPdf.clip_cmd	  s    /H3GGKK+KK
#^^T^^,0DD#KK		$~~)Xr||RWWbjjIJ~~)'GGI**4%*HWWbjj)*+ r.   c           
     s   . pRpV P                    F  w  rERpV F>  p\        W4      p\        W4      p	 Ve   V	f   WJpM\        W8g  4      p V'       g   K>   M	  VP                  R8X  d   V'       d   RpV'       g   Kp  VP                  R8X  d   RpV Uu. uF  p\        W4      NK  	  p	pVP                  V! V .V	O5!  4       V F  p\        W\        W4      4       K  	  K  	  V#   \         dj    \        P
                  ! T4      p\        P
                  ! T	4      p	TP                  T	P                  8g  ;'       g    \        P                  ! Y8g  4      p ELi ; iu upi )ze
Copy properties of other into self and return PDF commands
needed to transform *self* into *other*.
Frt  Trs  )commandsr@  r   r   r}   rN  r	  Zanyr   r  Zsetattr)
r   r   r/  Zfill_performedZparamsZcmdZ	differentZpZoursZtheirss
   &&        r,   rD  ZGraphicsContextPdf.delta
  sE   
 ==KFIt' *	9|v~$($6	$($8	 9 " ||{*~ 	y<<?2%)N5;<V'%+V<C.v./ADWU%67  7 ): ' " 9::d+DZZ/F!%v||!; "8 "8!#!7 9 =s$   C+ C+E"+AEEEc                s   < \         SV `  V4       \        VRV P                  4      p\        VRV P                  4      pW n        W0n        R# )z%
Copy properties of other into self.
r<  r=  N)r&  rd  r@  r<  r=  )r   r   rE  rq  rN  s   &&  r,   rd  Z"GraphicsContextPdf.copy_propertiesC
  sH     	&E<A	"5*=#'#9#9;#!1r.   c                sh    . pV P                   e"   VP                  V P                  4       4       K/  V# )z2
Make sure every pushed graphics state is popped.
)ri  r  rQ  )r   r/  rb   r,   r{  ZGraphicsContextPdf.finalizeN
  s*     kk%KK
#r.   )r=  r<  r   ri  )rx  ry  )rB  rA  r=  )Z	_capstyle)r<  )Z
_joinstyle)rW  )Z_dashes)rC  )rj  Z_hatch_colorZ_hatch_linewidth)r   r   r   r   r   r   r   r   rK  r)  rY  rm  rn  ro  rp  rr  rt  rw  rs  rP  rQ  rz  r{  rD  rd  r{  r   r   r7  r8  r9  r,   rX  rX  	  s     	>B9 GQa8I1gq'15J68(0$
103, 
$X.	99E	&	-(	-(	-(	x 	G	7CH$L	2 r.   rX  c                   s   a  ] tR tRt o Rt]P                  ! RRRR7      RR l4       tR	 tR
 t	R t
R tR tRR ltR t. RO3R ltRtV tR# )PdfPagesiX
  a  
A multi-page PDF file.

Examples
--------
>>> import matplotlib.pyplot as plt
>>> # Initialize:
>>> with PdfPages('foo.pdf') as pdf:
...     # As many times as you like, create a figure fig and save it:
...     fig = plt.figure()
...     pdf.savefig(fig)
...     # When no figure is specified the current figure is saved
...     pdf.savefig()

Notes
-----
In reality `PdfPages` is a thin wrapper around `PdfFile`, in order to avoid
confusion when using `~.pyplot.savefig` and forgetting the format argument.
r  
keep_emptyzThis parameter does nothing.)ZaddendumNc                s,    Wn         W0n        RV n        R# )a  
Create a new PdfPages object.

Parameters
----------
filename : str or path-like or file-like
    Plots using `PdfPages.savefig` will be written to a file at this location.
    The file is opened when a figure is saved for the first time (overwriting
    any older file with the same name).

metadata : dict, optional
    Information dictionary object (see PDF reference section 10.2.1
    'Document Information Dictionary'), e.g.:
    ``{'Creator': 'My software', 'Author': 'Me', 'Title': 'Awesome'}``.

    The standard keys are 'Title', 'Author', 'Subject', 'Keywords',
    'Creator', 'Producer', 'CreationDate', 'ModDate', and
    'Trapped'. Values have been predefined for 'Creator', 'Producer'
    and 'CreationDate'. They can be removed by setting them to `None`.
N)	_filename	_metadata_file)r   rM  r}  rD      &&&&r,   r   ZPdfPages.__init__m
  s    . "!
r.   c                s    V # r0   r_   r   r5   r,   	__enter__ZPdfPages.__enter__
  s    r.   c                s&    V P                  4        R # r0   )r|  )r   Zexc_typeZexc_valZexc_tbr  r,   __exit__ZPdfPages.__exit__
  s    

r.   c                s    V P                   f'   \        V P                  V P                  R7      V n         V P                   # )NrD   )r  r  r~  r  r   r5   r,   _ensure_fileZPdfPages._ensure_file
  s,    :: $..IDJzzr.   c                s    V P                   e>   V P                   P                  4        V P                   P                  4        RV n         R# R# )zG
Finalize this object, making the underlying file a complete
PDF file.
N)r  r{  r|  r   r5   r,   r|  ZPdfPages.close
  s:    
 ::!JJ!JJDJ "r.   c                s6    V P                  4       P                  # )zy
Return a modifiable information dictionary object
(see PDF reference section 10.2.1 'Document Information
Dictionary').
)r  r7  r   r5   r,   infodictZPdfPages.infodict
  s       "+++r.   c                s   \        V\        4      '       gY   Vf   \        P                  ! 4       pM\        P                  ! V4      pVf   \        RV 24      hVP                  P                  pVP                  ! V 3RRRR/VB  R# )z
Save a `.Figure` to this file as a new page.

Any other keyword arguments are passed to `~.Figure.savefig`.

Parameters
----------
figure : `.Figure` or int, default: the active figure
    The figure, or index of the figure, that is saved to the file.
Nz
No figure r  r  rC   )	r1   r   r   Z
get_activeZget_fig_managerr   Zcanvasfiguresavefig)r   r  ZkwargsZmanagers   &&, r,   r  ZPdfPages.savefig
  ss     &&))~..*--f5 :fX!677^^**FtCEC5CFCr.   c                sH    \        V P                  4       P                  4      # )z=Return the current number of pages in the multipage pdf file.)r$   r  r0  r   r5   r,   get_pagecountZPdfPages.get_pagecount
  s    4$$&//00r.   c                sD    V P                  4       P                  W4       R# )z
Add a new text note to the page to be saved next. The optional
positionRect specifies the position of the new note on the
page. It is outside the page per default to make sure it is
invisible on printouts.
N)r  r^  )r   r\  r]  r   r,   attach_noteZPdfPages.attach_note
  s     	'';r.   )r  r~  r  r   r0   r4  )r   r   r   r   r   r   Zdelete_parameterr   r  r  r  r|  r  r  r  r  r   r   r   r   r,   r|  r|  X
  sf     ( 
6<$BDD2
,D,1 .@ < <r.   r|  c                   sV   a a ] tR tRt o^HtRR/tR tRRRR/R ltV 3R	 ltR
t	Vt
V ;t# )FigureCanvasPdfi
  r  zPortable Document Formatc                s    R # )r  r_   r   r5   r,   get_default_filetypeZ$FigureCanvasPdf.get_default_filetype
  s    r.   bbox_inches_restoreNrD   c               s   V P                   P                  p^HV P                   n        V P                   P                  4       w  rV\        V\        4      '       d   VP                  4       pM\        WR7      p VP                  WV4       \        V P                   WVV\        WtWe4      VR7      pV P                   P                  V4       VP                  4        \        V\        4      '       g   VP                  4        \        V\        4      '       d   VP                  4        R# VP                  4        R#   \        T\        4      '       d   TP                  4        i TP                  4        i ; i)r\  r  )r  N)r  dpiZget_size_inchesr1   r|  r  r  r[  r   r  drawr{  rU  r|  )	r   rM  r  rD   r  rS   rT   r   Zrenderers	   &&$$     r,   	print_pdfZFigureCanvasPdf.print_pdf
  s    kkoo335h))((*D87D	LL'(UCDv5$79H KKX&h11(H-- 

 (H-- 

s   8BD8 89E1c                sT   < V P                   P                  4        \        SV `  4       # r0   )r  Zdraw_without_renderingr&  r  )r   rN  s   &r,   r  ZFigureCanvasPdf.draw
  s    **,w|~r.   r_   )r   r   r   r   Z	fixed_dpiZ	filetypesr  r  r  r   r   r7  r8  r9  r,   r  r  
  s;      I23I&*594 r.   r  c                   s    ] tR tRt]tRtR# )_BackendPdfi
  r_   N)r   r   r   r   r  ZFigureCanvasr   r_   r.   r,   r  r  
  s    "Lr.   r  )iK   )r^   )_r   r   r   r    Zenumr   Z	functoolsr   Zior   rm   ZloggingrN   r=   r_  r  rc  rI   r  r  r   Znumpyr}   ZPILr   Z
matplotlibr@   r   r   r   r	   r
   Zmatplotlib._pylab_helpersr   Zmatplotlib.backend_basesr   r   r   r   r   Z!matplotlib.backends.backend_mixedr   Zmatplotlib.figurer   Zmatplotlib.font_managerr   r   r  Zmatplotlib._afmr   Zmatplotlib.ft2fontr   r   r   r   r   Zmatplotlib.transformsr   r   Zmatplotlib.pathr   Zmatplotlib.datesr   r   r  r    Z	getLoggerr   r  r-   rH   rM   r[   ro   ry   r2   Z	maketransr   rz   r   r   r:   r   r   r   r  r  ZRendererPDFPSBaser  rX  r|  r  ZFigureManagerPdfZexportr  r_   r.   r,   <module>r     s       $     	   
        F F )  @ $ I  Q Q 4      "d,Tn0,"*04 }}&#uc5$tUD EF#R  .      B A# A#HZ$ Z$z+\DC DCN(m-/33 m-`J, JZn< n<b%& %P %  
#( # #r.   