
    ^j              
          d Z ddlZddlZddlZddlmZ ddlZddlmZ ddl	Z	ddl
Z
ddlZddlZddlZddlZddlZddlmZ ddlZddlZddlZddlZddlZddlmZmZmZmZ ddlmZmZm Z m!Z! ddl"m#Z#m$Z$ dd	l%m&Z& dd
l'm(Z( ddl)m*Z* ddl+m,Z, ddl-m.Z. ddl/m0Z0 ddl1m2Z2 ddl3m4Z4  e
jj                  e6      Z7dZ8i dddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=Z9d>d?d@Z:dA Z;dB Z<dC Z=dD Z>dE Z?dF Z@dG ZAdH ZBdI ZC G dJ dKe4j                        ZE G dL dMe      ZF G dN dOe      ZGdP ZHdQ ZIdZdRZJdZdSZKdT ZLdU ZMd[dVZNe ZOg dWZPej                   G dX dYe             ZRy)\zG
A PostScript backend, which can produce both PostScript .ps and .eps.
    N)Enum)StringIO)TemporaryDirectory)_apicbook_path_text_helpers)_BackendFigureCanvasBaseFigureManagerBaseRendererBase)is_writable_file_likefile_requires_unicode)get_font)	LoadFlags)	uni2type1)Path)
TexManager)Affine2D)MixedModeRenderer   )_backend_pdf_psFletter)      !@   legal)r      ledger)r      a0)Gz@@gHzgG@a1)p=
c7@r!   a2)
ףp=0@r#   a3)zGa'@r%   a4)
ףp= @r'   a5)RQ@r)   a6)Q@r+   a7)HzG@r-   a8)ffffff @r/   a9)\(\?r1   a10)gRQ?r3   b0)fffffFD@g)\L@b1))\<@r6   b2)QE4@r8   ))\,@r:   )Q8$@r;   )p=
ף@r<   ))\(@r=   )p=
ף@r>   )Gz@r?   ))\(?r@   )g)\(?rA   )b3b4b5b6b7b8b9b10 )sepc                 2    | j                  d |D              S )Nc              3   `   K   | ]&  }|d j                  d      j                  d       ( yw)1.3f0.N)rstrip).0args     i/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/matplotlib/backends/backend_ps.py	<genexpr>z_nums_to_str.<locals>.<genexpr>H   s*     Jcs4j((-44S9Js   ,.)join)rK   argss     rT   _nums_to_strrX   G   s    88JTJJJ    c                 
   t        |      rFt        |      rt        | d      nt        | d      }|5  t        j                  ||       ddd       yt        j
                  | |t        j                         y# 1 sw Y   yxY w)z
    Move the contents of file at *src* to path-or-filelike *dst*.

    If *dst* is a path, the metadata of *src* are *not* copied.
    latin-1encodingrbN)copy_function)r   r   openshutilcopyfileobjmovecopyfile)srcdstfhs      rT   _move_path_to_path_or_streamrh   K   ss     S!&s+ 3+T? 	  	(r3'	( 	( 	CFOO<	( 	(s   A99Bc                   
 t        |       
dj                  
j                  |d
j                  z  dj	                  t        t        
j                              dj	                  
fd|D              t        |      dz         }d}g }|D ]  }
j                  |t        j                        }
j                         \  }}	|j                  d
j                  |      dj	                  t        t        |j                  dg|j                              d	z  t!        j"                  t%        |d
z  |	      dddddg dd      j'                  d      z   dz           |dj	                  |      z   |z   S )a  
    Subset *glyphs_indices* from the font at *font_path* into a Type 3 font.

    Parameters
    ----------
    font_path : FontPath
        Path to the font to be subsetted.
    subset_index : int
        The subset of the above font being created.
    glyph_indices : set[int]
        The glyphs to include in the subsetted font.

    Returns
    -------
    str
        The string representation of a Type 3 font, which can be included
        verbatim into a PostScript file.
    aV  %!PS-Adobe-3.0 Resource-Font
%%Creator: Converted from TrueType to Type 3 by Matplotlib.
10 dict begin
/FontName /{font_name}-{subset} def
/PaintType 0 def
/FontMatrix [{inv_units_per_em} 0 0 {inv_units_per_em} 0 0] def
/FontBBox [{bbox}] def
/FontType 3 def
/Encoding [{encoding}] def
/CharStrings {num_glyphs} dict dup begin
/.notdef 0 def
r   rJ   c              3   F   K   | ]  }d j                  |         yw)/N)get_glyph_name)rR   glyph_indexfonts     rT   rU   z$_font_to_ps_type3.<locals>.<genexpr>   s,      ?!,  !!4!4[!A BC ?s   !)	font_namesubsetinv_units_per_embboxr]   
num_glyphsz
end readonly def

/BuildGlyph {
 exch begin
 CharStrings exch
 2 copy known not {pop /.notdef} if
 true 3 1 roll get exec
 end
} _d

/BuildChar {
 1 index /Encoding get exch get
 1 index /BuildGlyph get exec
} _d

FontName currentdict end definefont pop
z/%(name)s{%(bbox)s sc
r   )namerr   @   NF)   m   lrY      crY   Tasciizce} _d
)r   formatpostscript_nameunits_per_EMrV   mapstrrr   len
load_glyphr   NO_SCALEget_pathappendrl   horiAdvancer   convert_to_stringr   decode)	font_pathsubset_indexglyph_indicespreamble	postambleentriesrm   gvcrn   s             @rT   _font_to_ps_type3r   [   ss   & ID FT)), 1 11S$)),-HH ?0=? ?-(1,  . $I& G$ 
OOK););<}}1%++K8S1==!*Eaff*E!FG)  %% QVQtUD!
 -d4 5;F7OD 	

( dii((944rY   c                 ~   t         j                  d| ||       	 t        j                  j	                  | j
                  | j                        5 }t        j                  | |      5 }|j                  }t        j                  |      j                         }t         j                  d| |t        j                  |       j                  t        |             |j!                  t#        ||||             ddd       ddd       y# 1 sw Y   xY w# 1 sw Y   yxY w# t$        $ r t         j'                  d|         w xY w)a  
    Subset *glyph_indices* from the font at *font_path* into a Type 42 font at *fh*.

    Parameters
    ----------
    font_path : FontPath
        Path to the font to be subsetted.
    subset_index : int
        The subset of the above font being created.
    glyph_indices : set[int]
        The glyphs to include in the subsetted font.
    fh : file-like
        Where to write the font.
    zSUBSET %s:%d characters: %s)
fontNumberzSUBSET %s:%d %d -> %dNzIThe PostScript backend does not currently support the selected font (%s).)_logdebug	fontToolsttLibTTFontpath
face_indexr   get_glyphs_subsetrn   font_as_filegetvalueosstatst_sizer   write_serialize_type42RuntimeErrorwarning)r   r   r   rg   rn   rp   new_fontfontdatas           rT   _font_to_ps_type42r      s    	JJ,i}Uoo$$Y^^090D0D % F 		PIM//	=I		PMS{{H&33H=FFHHJJ'L	"**CM HH&t\8XNO		P 		P 		P 		P 		P 		P  W	 		sB   5D D&BD2D:D D	DDD D !D<c           
      z   t        | j                  d      |      \  }}| d   }| d   }t        |      }t        |||      }	t	        j
                  dj                  g d|d    d|d    d	| d
   j                  dd|j                  d       d	| d|j                  d       d|j                  d       d|j                  d       d|j                   d|j                  rdnd d|j                   d|j                   dt        t        |         d| d|	 d            S )a  
    Output a PostScript Type-42 format representation of font

    Parameters
    ----------
    font : fontTools.ttLib.ttFont.TTFont
        The original font object
    subset_index : int
        The subset of the above font to be created.
    subset : fontTools.ttLib.ttFont.TTFont
        The subset font object
    fontdata : bytes
        The raw font data in TTF format

    Returns
    -------
    str
        The Type-42 formatted font
    locapostrt    z
        %%!PS-TrueTypeFont-r   rP   r   -headz.7fzi
        10 dict begin
        /FontType 42 def
        /FontMatrix [1 0 0 1 0 0] def
        /FontName /   z; def
        /FontInfo 7 dict dup begin
        /FullName (   z) def
        /FamilyName (z) def
        /Version (   z) def
        /ItalicAngle z def
        /isFixedPitch truefalsez  def
        /UnderlinePosition z! def
        /UnderlineThickness zX def
        end readonly def
        /Encoding StandardEncoding def
        /FontBBox [z=] def
        /PaintType 0 def
        /CIDMap 0 def
        z	
        z9
        FontName currentdict end definefont pop
        )_version_and_breakpointsget_generate_charstrings_generate_sfntstextwrapdedentrV   fontRevisiongetDebugNameitalicAngleisFixedPitchunderlinePositionunderlineThicknessrX   _bounds)
rn   r   rp   r   versionbreakpointsr   rt   charssfntss
             rT   r   r      s   ( 4DHHV4DhOG[<D<D!&)EHfk:E??     #AJ<'()0456:6l6O6OPS5TU
 %%a()
 *+
 ,8.
9 %%a()* ''*+, $$Q'() &&'( "&!2!2v@A !2234 "4456  !'$-01! 2	!& 
'&	'( 
)(	)  rY   c           	         t        j                  d|dd       \  }}}||f}i }t        |      D ]C  }t        j                  d|d|dz  z   d|dz   dz  z          \  }}	}
}	|
||j                  d      <   E | #| j                  dd	 D 
ch c]
  }
|d
   |
z    }}
n
t               }t        h |j                         |t        |            }||fS c c}
w )a  
    Read the version number of the font and determine sfnts breakpoints.

    When a TrueType font file is written as a Type 42 font, it has to be
    broken into substrings of at most 65535 bytes. These substrings must
    begin at font table boundaries or glyph boundaries in the glyf table.
    This function determines all possible breakpoints and it is the caller's
    responsibility to do the splitting.

    Helper function for _font_to_ps_type42.

    Parameters
    ----------
    loca : fontTools.ttLib._l_o_c_a.table__l_o_c_a or None
        The loca table of the font if available
    fontdata : bytes
        The raw data of the font

    Returns
    -------
    version : tuple[int, int]
        A 2-tuple of the major version number and minor version number.
    breakpoints : list[int]
        The breakpoints is a sorted list of offsets into fontdata; if loca is not
        available, just the table boundaries.
    z>3hNr   z>4sIII      r   ry   glyf)	structunpackranger   	locationssetsortedvaluesr   )r   r   v1v2	numTablesr   tablesitag_offsetglyf_breakpointsr   s                rT   r   r     s    6 eXbq\:BI2hGF9 -"MM(HR!B$YrQqSRTH}4UVQ&,szz'"#- BF..QTRTBUVF6NV3VV5M6==?M-=Ms8}MNKK Ws   Cc                     | j                  d      }t        j                  j                  j	                  |      }|j                         D ]  }||   j                  |        |j                  xs dS )as  
    Compute the font bounding box, as if all glyphs were written
    at the same start position.

    Helper function for _font_to_ps_type42.

    Parameters
    ----------
    font : fontTools.ttLib.ttFont.TTFont
        The font

    Returns
    -------
    tuple
        (xMin, yMin, xMax, yMax) of the combined bounding box
        of all the glyphs in the font
    F)r   r   r   r   )getGlyphSetr   pens	boundsPen	BoundsPenkeysdrawbounds)rn   gspenrt   s       rT   r   r   ,  sb    $ 
		%	 B
..
"
"
,
,R
0C	 
4c::%%rY   c                     | j                         }dt        |       d}t        |      D ]  \  }}|d| d| dz  } |dz  }|S )a  
    Transform font glyphs into CharStrings

    Helper function for _font_to_ps_type42.

    Parameters
    ----------
    font : fontTools.ttLib.ttFont.TTFont
        The font

    Returns
    -------
    str
        A definition of the CharStrings dictionary in PostScript
    z/CharStrings z dict dup begin
rk   rJ   z def
zend readonly def)getGlyphOrderr   	enumerate)rn   gosr   rt   s        rT   r   r   E  se      
			B
By 12AR= "4	qas&!!"	AHrY   c           	      :   dd}|t        |       k  rVt        j                  ||dz         }||dz
     }||k  r|d   }d| || j                          dz  |}|t        |       k  rVdz  d	j	                  fd
t        dt              d      D              S )a  
    Transform font data into PostScript sfnts format.

    Helper function for _font_to_ps_type42.

    Parameters
    ----------
    fontdata : bytes
        The raw data of the font
    font : fontTools.ttLib.ttFont.TTFont
        The fontTools font object
    breakpoints : list
        Sorted offsets of possible breakpoints

    Returns
    -------
    str
        The sfnts array for the font definition, consisting
        of hex-encoded strings in PostScript format
    z/sfnts[r   i  r   r   <z00>z]defrz   c              3   .   K   | ]  }||d z      yw)d   N )rR   r   r   s     rT   rU   z"_generate_sfnts.<locals>.<genexpr>}  s     ?AQq3Z?s   r   )r   bisectbisect_lefthexrV   r   )r   rn   r   posr   newposr   s         @rT   r   r   ]  s    * 	A
C
H
{C%K8QqS!S= _F	q#f%))+,C00 H
 KA99?q#a&#)>???rY   c                 B     t        j                          fd       }|S )z}
    Wrap `RendererPS` method *meth* to emit a PS comment with the method name,
    if the global flag `debugPS` is set.
    c                 z    t         r)| j                  j                  dj                   d        | g|i |S )Nz% rz   )debugPS	_pswriterr   __name__)selfrW   kwargsmeths      rT   wrapperz!_log_if_debug_on.<locals>.wrapper  s:    NN  2dmm_B!78D*4*6**rY   )	functoolswraps)r   r   s   ` rT   _log_if_debug_onr     s'    
 __T+ +
 NrY   c                   `    e Zd ZdZ ej
                  d      ZdZd  fd	Zd Z	d!dZ
d!dZed	        Zd!d
Zed        Zd!dZd!dZd!dZd Zd Zd"dZd Zed#d       Zed#d       Ze	 d#d       Zeddd       Zeddd       Zed"d       Zed        Zed        ZddddZ  xZ!S )$
RendererPSz
    The renderer handles all the drawing primitives using a graphics
    context instance that controls the colors/styles.
    z	fonts/afm	ps.useafmc                    t         |   ||       || _        t        j                  d   rd| _        g | _        || _        d | _        d | _	        d | _
        d | _        d | _        d | _        d | _        i | _        |dz  | _        i | _        d| _        t'        j(                  t&        j*                  j-                  t        j                  d   d            | _        t1        j2                  t4        j6                        | _        y )Ntext.usetexr   H   ps.fonttype)super__init__r   mplrcParamstextcntpsfragimagedpicolor	linewidthlinejoinlinecaplinedashfontnamefontsize_hatchesimage_magnification_clip_paths_path_collection_idr   CharacterTracker_FONT_MAX_GLYPHr   _character_trackerr   cacher   r   _logwarn_once)r   widthheightpswriterr  	__class__s        rT   r  zRendererPS.__init__  s     	'!<<&DLDK  
#+b= #$ "1"B"B++//]0KQO#Q&__T\\:rY   c                 l    |yt        |      dk(  r#|d   dk(  ry|d   dk7  r| j                  d       yy)NTr      r   r   zlThe PostScript backend does not support transparency; partially transparent artists will be rendered opaque.F)r   r  )r   rgb_or_rgbas     rT   _is_transparentzRendererPS._is_transparent  sP    "1~"1~"""MN rY   Tc                     |||f| j                   k7  rS| j                  j                  ||cxk(  r|k(  rn nt        |       dnt        |||       d       |r|||f| _         y y y )Nz	 setgray
z setrgbcolor
)r  r   r   rX   )r   rr   bstores        rT   	set_colorzRendererPS.set_color  ss    q!9

"NN  $%KaK %1O#4J!?$0Aq$9#:.!IK AY
 	 #rY   c                     t        |      }|| j                  k7  r2| j                  j                  t	        |       d       |r|| _        y y y )N setlinewidth
)floatr  r   r   rX   )r   r  r'  s      rT   set_linewidthzRendererPS.set_linewidth  sK    )$	&NN  L$;#<O!LM!*  'rY   c                 &    ddddddd|    } | ddS )Nr   r      )miterroundbevelr   r   r.  dz setlinejoin
r   )r  s    rT   _linejoin_cmdzRendererPS._linejoin_cmd  s-     Q1qI1^,,rY   c                     || j                   k7  r5| j                  j                  | j                  |             |r|| _         y y y N)r  r   r   r3  )r   r  r'  s      rT   set_linejoinzRendererPS.set_linejoin  s?    t}}$NN  !3!3H!=> (  %rY   c                 &    ddddddd|    } | ddS )Nr   r   r.  )buttr0  
projectingr   r   r.  r2  z setlinecap
r   )r  s    rT   _linecap_cmdzRendererPS._linecap_cmd  s-     qaA!L!M**rY   c                     || j                   k7  r5| j                  j                  | j                  |             |r|| _         y y y r5  )r  r   r   r:  )r   r  r'  s      rT   set_linecapzRendererPS.set_linecap  s?    dll"NN  !2!27!;<&  #rY   c                 
   | j                   +| j                   \  }}t        j                  ||      r||k(  ry | j                  j	                  |#t        |      rdt        |  dt        |       dnd       |r
||f| _         y y )N[z] z	 setdash
z[] 0 setdash
)r  nparray_equalr   r   r   rX   )r   r   seqr'  oldooldseqs         rT   set_linedashzRendererPS.set_linedash  s    ==$==LD&~~c6*tv~ #CH  !s!3 4B|F7K6LJW-	/ #SMDM rY   c                     ||f| j                   | j                  fk7  r5| j                  j                  d| d|dd       |r|| _         || _        y y y )Nrk   rJ   rN    selectfont
)r  r  r   r   )r   r  r  r'  s       rT   set_fontzRendererPS.set_font  s[    hDMM4==#AANN  1XJam!LM ( (  BrY   c                    d}|| j                   v r| j                   |   S dt        | j                         z  }| j                  dz  }| j                  j	                  d|dd|dd|dd|dd|d	d
| j                  t        j                  |      t               j                  |      d       d|d	d| d       || j                   |<   |S )Nr  zH%dzH  << /PatternType 1
     /PaintType 2
     /TilingType 2
     /BBox[0 0 r2  rJ   z]
     /XStep z
     /YStep z(

     /PaintProc {
        pop
        r   r*  Fsimplifyz]
        gsave
        fill
        grestore
        stroke
     } bind
   >>
   matrix
   0 z translate
   makepattern
   /z
 exch def
)
r  r   r  r   r   _convert_pathr   hatchr   scale)r   rL  r  sidelenrt   
pageheights         rT   create_hatchzRendererPS.create_hatch  s    DMM!==''s4==))[[2%
 " {!GA; 'QK QK 	 
1 DJJu%xz'7'7'@5Q R S ^ 	F + 	.  $erY   c                     | j                   S )z
        Get the factor by which to magnify images passed to draw_image.
        Allows a backend to have images at a different resolution to other
        artists.
        )r  r   s    rT   get_image_magnificationz"RendererPS.get_image_magnification  s     '''rY   Nc           
          |r!dd| j                   dz  | j                  dz  f}nd }t        j                  ||||d dg dd      j	                  d      S )Ng        g      R@r   )rv   rw   rY   rx   s   clTry   )r  r  r   r   r   )r   r   	transformcliprJ  s        rT   rK  zRendererPS._convert_path%  sZ    djj4/t1CDDD&&)T8T-t55;VG_	ErY   c           
         g }|j                         }|3|j                  t        g |j                  |j                    d       |j                         \  }}||t        |      f}| j                  j                  |      }|[dt        | j                        z  }| j                  j                  d| d| j                  ||d       d       || j                  |<   |j                  | d       d	j                  |      S )
N
 rectclip
zc%drk   z {
FrI  z
clip
newpath
} bind def
rz   r   )get_clip_rectangler   rX   p0sizeget_clip_pathidr  r   r   r   r   rK  rV   )r   gcrV  rectr   trfkeycustom_clip_cmds           rT   _get_clip_cmdzRendererPS._get_clip_cmd.  s   $$&KK<==499=>kJK$$&	cC/C"..2237O&"'#d.>.>*?"?$$ * D#. / 0&  )8  %KK?+2./wwt}rY   c                    |j                   d d \  }}d}|d d dd d d df   }	|	j                         j                  dd      }
|!d}|| j                  z  }|| j                  z  }n?dj	                  t        t        |j                         j                                     }d	}d	}| j                  j                  d
| j                  |       d|dd|dd| d|dd|dd|dd|dd|dd|dd|dd|dd| d|
 d       y )Nr.  zfalse 3 colorimager   r!  rz   z1 0 0 1 0 0rJ   g      ?gsave
r   z translate
[z	] concat
z scale
/DataString r2  z string def
z 8 [ z 0 0 -z 0 z5 ]
{
currentfile DataString readhexstring pop
} bind 

grestore
)shapetobytesr   r  rV   r~   r   frozen	to_valuesr   r   rc  )r   r^  xyimrU  hwimagecmddatahexdatamatrixxscaleyscales                 rT   
draw_imagezRendererPS.draw_imageD  sY    xx|1'$B$2A2+,,.$$T3/"F111F111FXXc#y'7'7'9'C'C'EFGFFF "B  1Qqe  

!F1: qE 1Qqe51VAa5Aa5 )	 

 	 
 	rY   c                     |d u xr |j                         d u }|j                  xr |}| j                  ||||      }| j                  |||       y )NrV  rJ  )get_hatch_pathshould_simplifyrK  _draw_ps)r   r^  r   rU  rgbFacerV  rJ  pss           rT   	draw_pathzRendererPS.draw_pathe  sY     $>2#4#4#6$#>''0DidXNb"g&rY   c                    | j                  |      rd n5|d   |d   cxk(  r|d   k(  rn nt        |d          dnt        |d d   d}g d}|j                         }	|j                         st	        |j                               dk(  r|j                         n|j                         d   }
|	dkD  xr |
dkD  }|rp|j                  d|	z         |j                  | j                  |j                                      |j                  | j                  |j                                      |j                  | j                  ||d	
             |r;|r|j                  d       |r|j                  |dg       |r|j                  d       |r|j                  d       |j                  ddg       |j                  |dd| j                  dz  | j                   dz  fd	      D ]2  \  }}t	        |      s|dd  \  }}|j                  |dd|dd       4 dj#                  |      }| j%                  |||d	d	       y )Nr   r   r.  z setgrayr!  z setrgbcolor)z/o {gsavenewpath	translatez%.1f setlinewidthFrI  r  fillgrestorestrokez
} bind defr  ry  r   rJ   z orz   r  r  )r#  rX   get_linewidthget_forced_alphar   get_rgb	get_alphar   r3  get_joinstyler:  get_capstylerK  extenditer_segmentsr  r  rV   r|  )r   r^  marker_pathmarker_transr   transr}  ps_colorps_cmdlwalphar  verticescoderl  rm  r~  s                    rT   draw_markerszRendererPS.draw_markersm  s6    ##G,  qzWQZ571:5 !,-X6 '"1+./|< 	 ;'')S->!-C jjl1o 	 a%EAIMM-23MM$,,R-=-=-?@AMM$++BOO,=>?d((l27 ) 9 	: g&x01j)MM(#z<01"00DJJrM4;;r>: 1   	0NHd 8}}11Qqe2./	0 YYvb"gE%@rY   hatchcolorsc                   |g }t        |      dkD  rt        |d   j                        nd}| j                  |||||      }|d|z  z   dz   |dz   |z  k  }|s$t        j                  | |||||||||	|
||||      S g }t        | j                  |||            D ]`  \  }\  }}d| j                  |fz  }| j                  ||d      }| j                  j                  d| d	| d
       |j                  |       b | j                  |||||||	|
||||      D ]'  \  }}}}}|dd|dd| }| j                  |||       ) | xj                  dz  c_        y )Nr   r!  r.  r  zp%d_%dFrI  rk   z {
newpath
translate
z
} bind def
r   rJ   r   )r   r  _iter_collection_uses_per_pathr   draw_path_collectionr   _iter_collection_raw_pathsr  rK  r   r   r   _iter_collectionr|  )r   r^  master_transformpathsall_transformsoffsetsoffset_trans
facecolors
edgecolors
linewidths
linestylesantialiasedsurlsoffset_positionr  len_pathuses_per_pathshould_do_optimization
path_codesr   r   rU  rt   
path_bytesxoyopath_idgc0r}  r~  s                                 rT   r  zRendererPS.draw_path_collection  s   
 K .1Z!^3uQx(();;>7J
D q=((1,1/MM 	%44b*E>z:Jd[	: : 
$-d.M.M %/9 %: 	$ A it77;;D++D)e+LJNN   &   	"  d#	$ .2-B-BJJ
JdO .C .N 	,)BGS' q62a&'+BMM"c7+	, 	  A% rY   )mtextc          
      (   | j                  |j                               ry t        | d      s*| j                  d       | j	                  ||||||d|       y | j                  ||d      \  }}	}
|j                         }d| j                  z  }t        |j                         d d dd	i}d
ddj                  t        j                  d   d   d      }||z  }d|d|}t        j                  |dz         }t        ||
t        j                  |      z  z
  ||
t        j                  |      z  z
        }| j                   j#                  d||||dz  |fz         | j$                  j'                  d| d| d       | xj                  dz  c_        y )Nr
  zThe PS backend determines usetex status solely based on rcParams['text.usetex'] and does not support having usetex=True only for some elements; this element will thus be rendered as if usetex=False.FTeX)ismathz
psmarker%dr!  rK   ,z{\sffamily %s}z{\ttfamily %s})z
sans-serif	monospacezfont.familyr   z{\rmfamily %s}z\color[rgb]{z} Z   z/\psfrag{%s}[bl][bl][1][%f]{\fontsize{%f}{%f}%s}g      ?rf  z	 moveto
(z)
show
grestore
r   )r#  r  hasattrr  	draw_textget_text_width_height_descentget_size_in_pointsr	  rX   r   r  r  r?  radianscossinr
  r   r   r   )r   r^  rl  rm  r   propangler  rp  ro  blr  thetextr  fontcmdtexrangler   s                     rT   draw_texzRendererPS.draw_tex  s    

-tX&23
 NN2q!QeUEB55ae5L1b**,-bjjl2A.8C8!2 13363||M2157H4J 	 aK',a0 EBJ'1rBFF6N22ARVVF^8K4KL>(4-B> >	? 	 " 	  	 	rY   c	                 n   | j                  |j                               ry |dk(  r| j                  ||||||      S |r| j                  ||||||      S g }	t        j
                  d   r| j                  |      }
|
j                  j                  dd      j                  d      }d|j                         z  }d}d}|D ]y  }t        j                  t        |      dt        |      d	      }	 |
j                  |      }|
j#                  ||      }|}|||z  z  }|	j%                  ||d|f       |||z  z  }{ n|!|j'                         }|j)                         }nd x}}| j+                  |      }
t-        j.                  ||
||      D ]  }| j0                  j3                  |j4                  |j6                  |j8                        \  }}|j4                  j                  j                  dd      j                  d      }|j4                  j;                  |j8                        }|	j%                  | d| |j<                  |j>                  |f         | j@                  |j                           tC        jD                  |	d       D ]{  \  }}| jG                  ||j                         d       djI                  d |D              }| jJ                  jM                  d| jO                  |       d|dd|dd|dd| d       } y # t        $ r  d
}|
j!                  t        d            }Y 4w xY w)Nr  r   ry   replacegMbP?r   r   uni04Xquestion?)featureslanguager   c                     | d   S )Nr   r   )entrys    rT   <lambda>z&RendererPS.draw_text.<locals>.<lambda>1  s
    eAh rY   Frz   c              3   B   K   | ]  \  }}}}|d d|d d|dd  yw)r   rJ   z m /r   z
 glyphshowNr   )rR   r   rl  rm  rt   s        rT   rU   z'RendererPS.draw_text.<locals>.<genexpr>3  s9       <$1Aq!T $%Q%q1T$q D  <s   rf  r   rJ    translate
 rotate
rg  )(r#  r  r  draw_mathtextr  r  _get_font_afmr|   encoder   r  r   r   ordget_width_from_char_nameKeyErrorget_width_charget_kern_dist_from_namer   get_fontfeaturesget_language_get_font_ttfr	   layoutr  track_glyph	ft_objectcharrm   rl   rl  rm  r(  	itertoolsgroupbyrG  rV   r   r   rc  )r   r^  rl  rm  r   r  r  r  r  streamrn   ps_namerM  thisx	last_namer   rt   r  kernr  r  itemrp   r   
glyph_namegroupr  s                              rT   r  zRendererPS.draw_text  s8    

-U?==Q1dE::%%b!Q4??<<$%%d+D**11'9ELLWUGD3355EEI ' }}SVs3q6#,-?@: 99$?E 33ItD 	%wq$78&'   113 --/&**8%%d+D%,,Qx6>@ 
S
 !33??NNDIIt/?/?A	>>99"F7I6vvg !^^::4;K;KL
'!F84dffdffjQR
S 	

%'//8NO 	NGUMM'4#:#:#<eDii  <5: < <GNN   &B  1Qqe q	 
	 
" 		;   :%D //C9E:s   .L%L43L4c                    | j                   j                  j                  |d|      \  }}}	}
} | j                  |j	                           | j
                  j                  d|dd|dd|dd       d}|
D ]  \  }}}}}}| j                  j                  |||      \  }}|j                  ||f|k7  r>|j                  ||f}| j
                  j                  d|j                   d	| d| d
       |j                  |      }| j
                  j                  |dd|dd| d        |D ].  \  }}}}| j
                  j                  | d| d| d| d       0 | j
                  j                  d       y)z-Draw the math text using matplotlib.mathtext.r  rf  r   rJ   r  r  Nrk   r   rF  z	 moveto
/z glyphshow
z
 rectfill
	grestore
)
_text2pathmathtext_parserparser(  r  r   r   r  r  r|   rl   )r   r^  rl  rm  r   r  r  r  r  descentglyphsrectslastfontrn   r  ccoderm   oxoyrp   r   r  rp  ro  s                           rT   r  zRendererPS.draw_mathtext>  s    OO++11!R> 	.vw

%e1QqEQiy"	# :@ 	.6D(E;B //;;e[*IFA$$fh78C//A$$,,-QvhazOQ,,[9JNN  a&"Q  <|-.	. " 	BLBAqNN  B4qAaS!K!@A	B\*rY   c                    t        |      t        |      k(  sJ t        |      dk(  ry |j                  dk(  sJ |j                  d   dk(  sJ |j                  d   dk(  sJ |j                  dk(  sJ |j                  d   dk(  sJ |j                  d   dk(  sJ |j                  }|j                  |d   |d   z  df      }|j	                  |      }|j                  |d   |d   z  df      }t        j                  |d      dz
  }t        j                  |d      dz   }	t        j                  d|	|z
  z        }
|\  }}|	\  }}t        j                  |d   |d   z  g d	
      }d|d<   ||z
  |
z  |d<   |d d d df   dz  |d<   |j                         j                  dd      }| j                  j                  d|dd|dd|dd|dd| d       y )Nr   r!  r   r.  r   )axisi   l    ))flagsu1)pointsz2>u4)colors3u1)dtyper  r  g     o@r  rz   re  zgsave
<< /ShadingType 4
   /ColorSpace [/DeviceRGB]
   /BitsPerCoordinate 32
   /BitsPerComponent 8
   /BitsPerFlag 8
   /AntiAlias true
   /Decode [ r   rJ   z  0 1 0 1 0 1 ]
   /DataSource <
z
>
>>
shfill
grestore
)r   ndimrh  reshaperU  r?  minmaxceilemptyri  r   r   r   )r   r^  r  r  r  rh  flat_pointsflat_colors
points_min
points_maxfactorxminyminxmaxymaxrr  rs  s                    rT   draw_gouraud_trianglesz!RendererPS.draw_gouraud_triangles[  s   6{c&k)))v;!{{a||A!###||A!###{{a||A!###||A!###nneAhq&91%=>ook2nneAhq&91%=>VVKa0G<
VVKa0G<
+*z*ABC
d
dxx!HuQxJL W%
2f<X$QU+e3X,,.$$T3/ " 1XQtAhaQxqa 1	 
 	rY   r  c                   | j                   j                  }|j                         dkD  xr  | j                  |j	                                }|sd}| j                  |      rd}|j                         }|rz| j                  |j                                | j                  |j                                | j                  |j                                 | j                  |j                           |s|r  | j                  |j	                         dd    |d        || j                  |              ||j                                 |d       |r5|s|r |d        | j                  |dd ddi  |d       |s|r |d	       |rS| j!                  ||j#                               }	 |d        |t%        |j'                         dd          |d
|	 d       |r |d        |d	       y)at  
        Emit the PostScript snippet *ps* with all the attributes from *gc*
        applied.  *ps* must consist of PostScript commands to construct a path.

        The *fill* and/or *stroke* kwargs can be set to False if the *ps*
        string already includes filling and/or stroking, in which case
        `_draw_ps` is just supplying properties and clipping.
        r   FNr!  rf  rz   r'  zfill
r  rJ   z setpattern fill grestore
zstroke
)r   r   r  r#  r  	get_hatchr,  r6  r  r<  r  rD  
get_dashesr(  rc  striprP  get_hatch_linewidthrX   get_hatch_color)
r   r~  r^  r}  r  r  r   mightstrokerL  
hatch_names
             rT   r|  zRendererPS._draw_ps  s    $$'')A- B#33BJJLAA 	F(Dr//12b..01R__./Dr}}/%DNNBJJL!,-id  $%bhhjdi DNNGBQK5u5(Ol#**5"2H2H2JKJ), 2 2 4Ra 89:Aj\!<=>*lrY   )r  )T)FNr5  )"r   
__module____qualname____doc__r   _get_data_path_afm_font_dir_use_afm_rc_namer  r#  r(  r,  staticmethodr3  r6  r:  r<  rD  rG  rP  rS  rK  rc  r   rw  r  r  r  r  r  r  r  r|  __classcell__r  s   @rT   r   r     sO   
 )E((5M";8'+ - -) + +'
*)@(E,  @ ' ' FJ2A 2Ah  >B,& ,&\ :> ' 'R @ @D + +8 - -^ 15T 1 1rY   r   c                   (    e Zd Z ed      \  ZZd Zy)_Orientationr.  c                 4    | j                   dk(  r|d d d   S |S )N	landscaper   )rt   )r   rh  s     rT   swap_if_landscapez_Orientation.swap_if_landscape  s     "ii;6uTrT{AEArY   N)r   r   r!  r   portraitr,  r-  r   rY   rT   r*  r*    s    (HiBrY   r*  c                        e Zd ZdZdddZd Zdddddd	Zdd
dZdd
dZ e	j                  ed      Z e	j                  ed      Z fdZ xZS )FigureCanvasPSr  
PostscriptzEncapsulated Postscript)r~  epsc                      y)Nr~  r   rR  s    rT   get_default_filetypez#FigureCanvasPS.get_default_filetype  s    rY   Nr.  )metadata	papertypeorientationbbox_inches_restorec          	         | j                   j                  }d| j                   _        i }	t        |t        t        j
                  f      rCt        j                  |      j                  }
|
j                  dd      j                  d      |	d<   |xs i j                  ddt        j                   d      |	d<   t	        j                  d      }|rPt        j                  j!                  t#        |      t        j$                  j&                        j)                  d	      nt+        j,                         |	d
<   dj/                  d |	j1                         D              }	|t        j2                  d   }|j5                         }t7        j8                  dgt:        |       t7        j<                  t>        |j5                               }t        j2                  d   r| j@                  n| jB                  } |||f||	|||d| y )Nr  ry   r  TitleCreatorzMatplotlib vz, https://matplotlib.org/SOURCE_DATE_EPOCHz%a %b %d %H:%M:%S %YCreationDaterz   c              3   2   K   | ]  \  }}d | d|   yw)z%%z: Nr   )rR   kr   s      rT   rU   z+FigureCanvasPS._print_ps.<locals>.<genexpr>  s%      !<"ab2aSM!<s   zps.papersizefigure)r6  )r7  r  )dpidsc_commentsr7  r6  r8  )"r@  rA  
isinstancer   r   PathLikepathlibr   rt   r  r   r   r  __version__getenvdatetimefromtimestampinttimezoneutcstrftimetimectimerV   itemsr  lowerr   check_in_list	papersizegetitem_checkedr*  _print_figure_tex_print_figure)r   fmtoutfiler5  r6  r7  r8  r   rA  rB  filenamesource_date_epochprinters                rT   	_print_pszFigureCanvasPS._print_ps  s   
 kkoogR[[12||G,11H3::7C !#+>r"6"63??++DE#GY II&9:
 ! ++%&!!%%''/x0F'G 	^$ yy !<&2&8&8&:!< < ^4IOO%	H1y1YG**k&7&7&9; ll=1 ))%% 	 	W 	C#L'9$7	C;A	CrY   r8  c                    |dk(  t        |t        t        j                  f      st	        |      st        d       j                  j                         \  sdk(  r}	}nj                  t                 \  }}	d|z
  z  d|	z
  z  }
}|
 j                  j                  j                  z   }| j                  j                  j                  z   }dt        j                  u r||
||f\  }
}}}d|	z  z
  cd|
|||ft                _        t#         j                   |      t%         j                  ||	      } j                  j'                  |        fd
}t(        j*                  d   rt-               5 }t        j.                  j1                  |d      }t3        |dd      5 } ||       ddd       t(        j*                  d   dk(  rt5        t6        |       n*t(        j*                  d   dk(  rt5        t8        |       t;        ||       ddd       yt=        j>                  |dd      5 }tA        |      s tC        jD                  d      |      } ||       ddd       y# 1 sw Y   xY w# 1 sw Y   yxY w# 1 sw Y   yxY w)a'  
        Render the figure to a filesystem path or a file-like object.

        Parameters are as for `.print_figure`, except that *dsc_comments* is a
        string containing Document Structuring Convention comments,
        generated from the *metadata* parameter to `.print_figure`.
        r2  z,outfile must be a path or a file-like objectr@  g      B@r   r  r  r  r]  c           
      x   
rt        d|        n/t        d|        dk7  rt        d |        t        d|        t        d dj                   d	t               d
d|        t        t              }t        d|        t
        j                  d   s>|t        t        t        j                  j                  j                                     z  }t        d|z  |        t        d|        t        d	j                  t              |        t
        j                  d   sj                  j                  j                         D ]  \  }}t        |      D ]w  \  }}|s	t
        j                  d   }| j                          |dk(  r+| j!                  t#        |||j                                      \t%        |||j                         |        y  t        d|        t        d|        
st        d|        t        d|        t        dt'              z  |        rt        dz  |        t        dt'        dz  	dz         d|        t        j(                  j+                         |        t        d|        t        d|        
st        d|        | j                          y )Nz%!PS-Adobe-3.0 EPSF-3.0)filez%!PS-Adobe-3.0r@  z%%DocumentPaperSizes: z
%%Pages: 1z%%LanguageLevel: 3
z
%%Orientation: rz   z
%%EndComments
r   )endra  z%%BeginPrologr   z/mpldict %d dict defzmpldict beginr  r!  rb  z%%EndPrologz%%Page: 1 1z%s translatez	%d rotatez0 0 r  z	 rectclipshowpagez%%EOF)printrt   _get_bbox_headerr   _psDefsr  r  sumr~   r  usedr   rV   rP  r   flushr   r   r   rX   r   r   )rg   Ndictrn   subsetsrp   charmapfonttyperr   rB  r  is_epsr7  r6  ps_rendererrotationr   r  r  r  s          rT   print_figure_implz7FigureCanvasPS._print_figure.<locals>.print_figure_impl)  s[   /b9&R0(29+>RHl,(!N #$$/$4$4#5R%d+, -$%
 r# LE/+<<,Sk&D&D&I&I&P&P&RSTT(50r:/+$))G$2.<<,%0%C%C%H%H%N%N%P 	SMD'+4W+= S&$#&<<#>
#q=HH%6tVW^^EU%VW.tVW^^=MrRS	S %b!-b)m"-/+.<B#77bAkH,26DeBhr	:;9EBO $..))+"5 %b!*2&gB'HHJrY   ps.usedistillertmp.psrp  r[   r\   Nghostscript)ptyperr   xpdf)#rC  r   r   rD  r   
ValueErrorr@  get_size_inchesr-  rS  rr   r  r  r*  r,  r   r   r   r   r   r  r  r   r   rV   r`   _try_distill
gs_distillxpdf_distillrh   r   open_file_cmr   codecs	getwriter)r   rW  rX  rA  rB  r7  r6  r8  paper_widthpaper_heightllxllyurxuryrendererrq  tmpdirtmpfilerg   ra  rr   r  rn  ro  rp  r  r  r  s   `   ```             @@@@@@@@rT   rV  zFigureCanvasPS._print_figure  s    7S"++$67(1KLL 335vY(*(-vK(3(E(E)$)&%K u,-./DKK$$***DKK$$+++,000!$c3!3Cc3,&+RFBHS#s#! !M$KK[ 35 	"6	 6	p <<)* $% 
?'',,vx8'3; *r%b)*<< 12mC !(&	N\\"34> !(&	N,Wg>
? 
? ##GS9E (,T266++I6t<D!$'( (* *
? 
?( (s1   #/J)	JA)J)%/J5J&	"J))J25J>c                   |dk(  }| j                   j                         \  }	}
d}d}|}|}|| j                   j                  j                  z   }|| j                   j                  j                  z   }||||f}t               | _        t        |	|
| j                  |      }t        | j                   |	|
|||      }| j                   j                  |       t               5 }t        j                  |d      }|j                  d| dt        |       dt        t                d	d
j#                  t                dt%        ||       dt%        |	dz  |
dz         d| j                  j'                          dd       |t(        j*                  u r
|
|	}
}	||||f}|s|dk(  r-|j-                  | j                   j                               \  }}nt.        |   \  }}t1        ||j2                  |||j4                        }t6        j8                  d   dk(  st6        j8                  d   rt;        t<        |||||       n+t6        j8                  d   dk(  rt;        t>        |||||       tA        ||       ddd       y# 1 sw Y   yxY w)a(  
        If :rc:`text.usetex` is True, a temporary pair of tex/eps files
        are created to allow tex to manage the text layout via the PSFrags
        package. These files are processed to yield the final ps or eps file.

        The rest of the behavior is as for `._print_figure`.
        r2  r   r_  r]  rs  z+%!PS-Adobe-3.0 EPSF-3.0
%%LanguageLevel: 3
rz   z&
%%EndComments
%%BeginProlog
/mpldict z dict def
mpldict begin
r   z
end
%%EndProlog
mpldict begin
z translate
0 0 r  rX  z
end
showpage
r[   r\   r@  rr  rt  r  )ru  rr   rotatedrv  N)!r@  rx  rr   r  r  r   r   r   r   r   r   rE  r   
write_textre  r   rf  rV   rX   r   r*  r,  r-  rS  _convert_psfragsr
  rt   r  r  ry  rz  r{  rh   )r   rW  rX  rA  rB  r7  r6  r8  rn  r  r  r  r  r  r  r  r  rr   ro  r  r  tmppathr  r  psfrag_rotateds                            rT   rU  z FigureCanvasPS._print_figure_texv  s    335vDKK$$***DKK$$+++S#s#! !M$T[[%*FC9LN 	"  ! 3	;Vll684G  $  
 g,    b"  %(F2I&' (  & #)  $, l444 &vS#s+
 h.,7,I,IKK//1-3)\ -6i,@)\-++[,  "N ./=@||M2Z$fID%35 /0F:\$fID%35 )':g3	; 3	; 3	;s   FI88Jr~  r2  c                 T    | j                   j                          t        |          S r5  )r@  draw_without_renderingr  r   )r   r  s    rT   r   zFigureCanvasPS.draw  s    **,w|~rY   )r   r   r!  	fixed_dpi	filetypesr4  r\  rV  rU  r   partialmethodprint_ps	print_epsr   r'  r(  s   @rT   r0  r0    sy    I#13I
 Tz $(CZ !%|(B !%U;n 'y&&y$7H'	''	59I rY   r0  c           	      L   t        j                  dt         j                  d   t         j                  j	                  d      z   t         j                  j	                  d      z   t         j                  j	                  d      z   d||dz  z   i      5  t               j                  ddj                  |      |d	k(  rd
nd| j                         j                         dz  d      }ddd       t               5 }t        j                  j                  |d      }t        j                  dddd|gt               t!        j"                  ||        ddd       t%        |       5 }d|j'                  d      v }	ddd       |	S # 1 sw Y   xY w# 1 sw Y   >xY w# 1 sw Y   	S xY w)aj  
    When we want to use the LaTeX backend with postscript, we write PSFrag tags
    to a temporary postscript file, each one marking a position for LaTeX to
    render some text. convert_psfrags generates a LaTeX document containing the
    commands to convert those tags to text. LaTeX/dvips produces the postscript
    file that includes the actual text.
    ztext.latex.preambler  graphicxr
  z:\geometry{papersize={%(width)sin,%(height)sin},margin=0in})r  r  zt
\begin{figure}
  \centering\leavevmode
  %(psfrags)s
  \includegraphics*[angle=%(angle)s]{%(epsfile)s}
\end{figure}rz   r,  r  r   )psfragsr  epsfile
   )r  Nrs  dvipsz-qz-R1z-o	Landscapei  )r  
rc_contextr  
texmanager_usepackage_if_not_loadedr   make_dvirV   resolveas_posixr   r   r   r   _check_and_log_subprocessr   ra   rc   r`   read)
r  r  r  r  r7  dvifiler  psfilerg   r  s
             rT   r  r    s    
!LL./NN44W=>NN44Z@A NN44X>? J#|<=	= 
  ,''  99W-*k9q"??,557
  ( . 
	 %fh/''dE494	AFG$% 
g 6"$56O .% %6s&   AF9AF#FF
FF#c                     	  | t        |      g|i | y # t        j                  $ r }t        j	                  d|       Y d }~y d }~ww xY w)Nz%s.  Distillation step skipped.)r   r  ExecutableNotFoundErrorr   r   )funcr  rW   r   excs        rT   ry  ry    sE    =S\+D+F+&& =6<<=s    AAAc                    |rdg}n|dk(  rd|d    d|d    g}nd| g}| dz   }t         j                  d	   }t        j                  t        j                  d
      j
                  dddd|z  dg|d| | t               t        j                  |        t        j                  ||        |rt        | ||       yy)z
    Use ghostscript's pswrite or epswrite device to distill a file.
    This yields smaller files without illegal encapsulated postscript
    operators. The output is low-level, converting text to outlines.
    	-dEPSCropr@  z-dDEVICEWIDTHPOINTS=r.  z-dDEVICEHEIGHTPOINTS=r!  z-sPAPERSIZE=z.pszps.distiller.resr   z-dBATCHz	-dNOPAUSE-dSAFERz-r%dz-sDEVICE=ps2writez-sOutputFile=)r  N)r  r  r   r  _get_executable_info
executabler   r   removera   rc   pstoeps)r  r2  ru  rr   r  paper_optionr  rA  s           rT   rz  rz    s     #}	(	 /tAwi8/Qy9; 'ug./u_F
,,)
*C	##		!	!$	'	2	2	KFSL:M	;
	;'x0	;29	; 		 IIg
KK   	w/ rY   c           
         t        j                  d       t        j                  d       |rdg}n|dk(  rd|d    d|d    g}nd	| g}t               5 }t        j                  |d
      }t        j                  |d      }t        j                  dddddddg|| |t               t        j                  dddd||gt               t        j                  ||        ddd       |rt        |        yy# 1 sw Y   xY w)a
  
    Use ghostscript's ps2pdf and xpdf's/poppler's pdftops to distill a file.
    This yields smaller files without illegal encapsulated postscript
    operators. This distiller is preferred, generating high-level postscript
    output that treats text as text.
    r   pdftopsr  r@  z-dDEVICEWIDTHPOINTS#r.  z-dDEVICEHEIGHTPOINTS#r!  z-sPAPERSIZE#ztmp.pdfrs  ps2pdfr  z-dAutoFilterColorImages#falsez-dAutoFilterGrayImages#falsez-sAutoRotatePages#Nonez-sGrayImageFilter#FlateEncodez-sColorImageFilter#FlateEncodez-papermatchz-level3N)r  r  r   rE  r   r   r  r   ra   rc   r  )	r  r2  ru  rr   r  r  r  tmppdftmppss	            rT   r{  r{  5  s5    T"Y'
#}	(	 /tAwi8/Qy9; 'ug./		 $fi0VX. 	'',+%,-     $		% 	'''9feDd	LE7##$$  %$ $s   B
C88Dc                     | \  }}}}dt        |       dt        |       dt        j                  |       dt        j                  |       d|dd|dd|dd|dS )zGReturn a PostScript header string for bounding box *lbrt*=(l, b, r, t).z%%BoundingBox: rJ   z
%%HiResBoundingBox: z.6f)rJ  mathr  lbrtlr&  r%  ts        rT   re  re  _  sq    JAq!Qc!fXQs1vha		!~Qtyy|n M##$S'1S'1S'1S'C DrY   c                 *    | \  }}}}||z   dddddS )uO   Return a PostScript 90° rotation command for bounding box *lbrt*=(l, b, r, t).z.2frJ   r   z translate
90 rotater   r  s        rT   _get_rotate_commandr  f  s+    JAq!Qc#Ya#w344rY   c                    | dz   }t        |d      5 }t        | d      5 }|j                  }|D ]  }|j                  d      r/ |d       |s |t        |      j	                  d      dz          C|j                  d      r7 ||        |d	       |r# |t        |      j	                  d      dz           n|r|j                  d
      r ||        |D ]6  }|j                  d      r	 |d       |j                  d      r/ ||       8 	 ddd       ddd       t        j                  |        t        j                  ||        y# 1 sw Y   =xY w# 1 sw Y   AxY w)z
    Convert the postscript to encapsulated postscript.  The bbox of
    the eps file will be replaced with the given *bbox* argument. If
    None, original bbox will be used.
    z.epswbr^   s   %!PSs   %!PS-Adobe-3.0 EPSF-3.0
ry      
s   %%EndCommentssp   %%BeginProlog
save
countdictstack
mark
newpath
/showpage {} def
/setpagedevice {pop} def
%%EndProlog
%%Page 1 1
)s   %%Bounds   %%HiResBounds   %%DocumentMedias   %%Pagess   %%EOFsJ   cleartomark
countdictstack
exch sub { end } repeat
restore
showpage
%%EOF
s   %%PageBoundingBoxN)
r`   r   
startswithre  r  r  r   r  ra   rc   )r  rr   r  r  epshtmphr   lines           rT   r  r  l  sd    G	gt	 )d7D&9 )T

 	Dw'23*4077@5HI!12d & ' -d3::7CeKL$// +K Ld/	6  	Dx( ! " !56d	=) )V IIg
KK!Y) ) ) )s)   E-ECEEE	EE$)z/_d { bind def } bind defz/m { moveto } _dz/l { lineto } _dz/r { rlineto } _dz/c { curveto } _dz/cl { closepath } _dz/ce { closepath eofill } _dz/sc { setcachedevice } _dc                       e Zd ZdZeZy)
_BackendPSzLevel IIN)r   r   r!  backend_versionr0  FigureCanvasr   rY   rT   r  r    s     O!LrY   r  )Fr   NF)NF)Sr"  r   r}  rH  enumr   r   ior   r  loggingr  r   rE  ra   r   tempfiler   r   rN  r   numpyr?  
matplotlibr  r   r   r   r	   matplotlib.backend_basesr
   r   r   r   matplotlib.cbookr   r   matplotlib.font_managerr   matplotlib.ft2fontr   matplotlib._mathtext_datar   matplotlib.pathr   matplotlib.texmanagerr   matplotlib.transformsr   !matplotlib.backends.backend_mixedr   r   r   	getLoggerr   r   r   rS  rX   rh   r   r   r   r   r   r   r   r   RendererPDFPSBaser   r*  r0  r  ry  rz  r{  re  r  r  FigureManagerPSrf  exportr  r   rY   rT   <module>r     s=            	    '      8 8A A I , ( /   , * ?  w"
"Xy "i"x" >" >	"
 >" >" =" <" <" <" <" <" L" >" >"  >!"" "!  1"	6   K= O5dD/d( V&20 @Fn22 nbB4 BL% L^/d=$0N'TD54"n $. 
" " "rY   