+
    bIi{                     2   R t Rt^ RI5 ^ RIHtHt ^ RIHtHtH	t	 ^ RI
HtHt ^ RIHt ^ RIHtHt ^ RIHt ^ R	IHtHt ^ R
IHt ^RIHtHt ^ RIt^ RIt^ RIH t H!t! ^ RI"H#t#H$t$H%t%H&t& R-R lt' ]'! ]PP                  4      t)R t*R t+R t,]PZ                  3R lt.^ RIH/t/  ! R R]/4      t0R t1R t2R t3R-R lt4]5! RRRR7      t6Rt7 ! R R 4      t8^HR!R]PZ                  ]PP                  R"3R# lt9^HR!R]PZ                  ]PP                  R"3R$ lt:^HR!R]PZ                  ]PP                  R"3R% lt;R&^HR!R]PZ                  ]PP                  R"3R' lt<R&^HR!R]PZ                  ]PP                  R"3R( lt=]<t>R.R) lt?]@R*8X  d   ]?! R+R,7       R# R#   ] d    Rt) ELi ; i)/z3.3.0a$  Render drawing objects in common bitmap formats

Usage::

    from reportlab.graphics import renderPM
    renderPM.drawToFile(drawing,filename,fmt='GIF',configPIL={....})

Other functions let you create a PM drawing as string or into a PM buffer.
Execute the script to see some test drawings.)*)getStateDeltarenderScaledDrawing)getFont
unicode2T1stringWidth)	ShapedStrshapeFragWord)bidiShapedText)	isUnicode	asUnicode)ABag)toColorwhite)	rl_config)setFontRenderPMErrorN)BytesIOStringIO)sincospiceilc                    V '       g   \         P                  p V R 8X  d    ^ RIpV# RV P                  4       9   d    ^ RIpV# \        RV  24      h  \         d+   p ^ RIp Rp?T#   \         d    \        R4      hi ; iRp?ii ; i  \         d/   p ^ RIp Rp?T#   \         d    \        RT  R24      hi ; iRp?ii ; i)	_renderPMNzCannot import desired renderPM backend, {backend}.
No module named _rl_renderPM
it may be badly or not installed!
You may need to install development tools
or seek advice at the users list see
https://pairlist2.pair.net/mailman/listinfo/reportlab-userscairoz'cannot import desired renderPM backend z^
Seek advice at the users list see
https://pairlist2.pair.net/mailman/listinfo/reportlab-userszInvalid renderPM backend, )r   renderPMBackend_rl_renderPMImportError	rlPyCairor   lower)backendMerrMsgs   &  ڄC:\Users\petid\OneDrive\Desktop\Maestro\MAESTRO CLAUDE\MAESTRO\maestro-backend\venv\Lib\site-packages\reportlab/graphics/renderPM.py_getPMBackendr%      s    i77G	@$. H 
GMMO	#	@! H 8	BCC+  		@@%( H'  @# %? @ @@		@  	@@( H  @#(OPWy Y< %? @ @@	@sF   A B	 BA''A>>BB	CBB::B==Cc                  @     ^ RI Hp  V #   \         d	    ^ RIp  T # i ; i)    ImageN)PILr)   r   r(   s    r$   	_getImager+   @   s*     L  Ls   
 c                    V '       d   ^\        ^V P                  ,          4      ,          ^,          ^\        ^V P                  ,          4      ,          ^,          ,          ^\        ^V P                  ,          4      ,          ,          # V # )   )intredgreenbluecs   &r$   	Color2Hexr4   G   s_    4CI&2-4CK8H3HQ2NOSWX[\_`a`f`f\fXgSgh
hH    c                $    V e   \        V 4      # T # )zy
c should be None or something convertible to Color
rlPyCairo.GState can handle Color directly in either RGB24 or ARGB32
)r   r2   s   &r$   
CairoColorr7   L   s    
 71:-A-r5   c                    \        4       pVP                  P                  V4       VP                  \	        V 4      WW4R7       R# )z
As it says)showBoundaryN)_PMRenderer__dict__updatedrawr   )drawingcanvasxyr9   kwdsRs   &&&&&, r$   r=   r=   T   s3    AJJdFFw'AFQr5   )Rendererc                   |   a  ] tR t^[t o RtR tR tR tR tR t	R t
R tR	 tR
 tRR ltR tR tR tR tRtV tR# )r:   zThis draws onto a pix map image. It needs to be a class
rather than a function, as some image-specific state tracking is
needed outside of the state info in the SVG model.c                Z    V P                   P                  4        V P                  4        R # N)_trackerpop
applyStateselfs   &r$   rI   _PMRenderer.pop`   s    r5   c                r    \        V4      pV P                  P                  V4       V P                  4        R # rG   )r   rH   pushrJ   )rL   nodedeltass   && r$   rO   _PMRenderer.pushd   s(    t$6"r5   c                n   V P                   P                  4       pVR ,          V P                  n        VR,          V P                  n        VR,          pVe   W P                  n        V P                  P                  VR,          4       VR,          V P                  n        VR,          V P                  n        VR,          V P                  n	        VR,          pV'       g   RpMV\        V\        \        34      '       g   V3p\        V4      ^8w  g$   \        V^,          \        \        34      '       g   ^ V3pW0P                  n        VR	,          pVe   W P                  n        V P                  P!                  VR
,          4       V P                  P#                  VR,          VR,          4       R# )ctmstrokeWidthstrokeOpacityNstrokeColorstrokeLineCapstrokeLineJoinfillModestrokeDashArrayfillOpacity	fillColorfontNamefontSize)rH   getState_canvasrT   rU   rV   setStrokeColorlineCaplineJoinrZ   
isinstancelisttuplelen	dashArrayr\   setFillColorr   )rL   salphadas   &   r$   rJ   _PMRenderer.applyStatei   sB   MM""$U8#$]#3 /").LL&##Am$45 1 !"2 3 !* !Bb$u..S2wzBqE4,!?!?U!#- ',LL$!!!K.1Qz]AjM:r5   c                    V P                   P                  R,          pV P                  P                  R,          W3,           ;VR&   VR&   V P                   P	                  V4       V P                  4        R# )   :r'      N	transformrT   N)rH   	_combinedra   _baseCTMrO   rJ   )rL   r@   rA   rQ   s   &&& r$   	initState_PMRenderer.initState   s[    ((,.2ll.C.CC.H!.NN{fUm6"r5   c                j    V P                  V4       V P                  V4       V P                  4        R# )z=This is the recursive method called for each node
in the treeN)rO   drawNodeDispatcherrI   )rL   rP   s   &&r$   drawNode_PMRenderer.drawNode   s*    
 			$ 	% 	
r5   c                   V P                   pVP                  VP                  u;8X  d   ^ 8X  dB   M M>VP                  VP                  VP
                  VP                  VP                  4       R# VP                  VP                  VP
                  VP                  VP                  VP                  VP                  4       R# )r'   N)	ra   rxryrectr@   rA   widthheight	roundRect)rL   r   r3   s   && r$   drawRect_PMRenderer.drawRect   sp    LL77dgg""FF466$&&$**dkk:KKtvvtzz4;;Qr5   c                    V P                   P                  VP                  VP                  VP                  VP
                  4       R # rG   )ra   linex1y1x2y2)rL   r   s   &&r$   drawLine_PMRenderer.drawLine   s*    $''$''$''$'':r5   c           
        VP                   p\        V\        4      '       dY   V'       d&   \        P                   P	                  V4      '       g   R # \        4       P                  V4      P                  R4      pM&\        VR4      '       d   VP                  R4      pMR # VP                  w  rEVP                  VP                  rvVf   TpVf   TpV P                  P                  VP                  VP                  YgV P                  P                   R8X  d   TM.\        VR4      '       d   VP"                  MVP$                  ! 4       WE^4       R # )NRGBconvertr   tobytes)pathre   strosisfiler+   openr   hasattrsizer   r   ra   	_aapixbufr@   rA   _backendr   tostring)rL   imager   imsrcWsrcHdstWdstHs   &&      r$   	drawImage_PMRenderer.drawImage   s    zzd3RWW^^D11F!!$'//6BT)$$e$BWW
[[%,,d<<$||,,k9(/9(=(="**2;;NQA		r5   c                    V P                   pVP                  VP                  VP                  VP                  4       VP                  4        R # rG   )ra   circlecxcyrfillstrokepath)rL   r   r3   s   && r$   
drawCircle_PMRenderer.drawCircle   s3    LL	699fhh/	r5   c                   VP                   p\        V4      ^8  g   Q R4       hV P                  pVP                  4        VP	                  V^ ,          V^,          4       \        ^\        V4      ^4       F(  pVP                  W5,          W5^,           ,          4       K*  	  V'       d!   VP                  4        VP                  4        VP                  4        R# )   z#Polyline must have 1 or more pointsN)
pointsrh   ra   	pathBeginmoveTorangelineTo	pathClosepathFill
pathStroke)rL   polyline_doClosePr3   is   &&&   r$   drawPolyLine_PMRenderer.drawPolyLine   s    OO1v{AAA{LL		1qtq#a&!$AHHQT1qS6" %KKMJJL	r5   c                    V P                   pVP                  VP                  VP                  VP                  VP
                  4       VP                  4        R # rG   )ra   ellipser   r   r}   r~   r   )rL   r   r3   s   && r$   drawEllipse_PMRenderer.drawEllipse   s9    
,,			'**gjj'**WZZ@	r5   c                ,    V P                  V^R7       R# )rp   )r   N)r   )rL   polygons   &&r$   drawPolygon_PMRenderer.drawPolygon   s    '1-r5   c           	        V P                   pVP                  p\        VR ^ 4      pVf
   V'       Ed   V P                  P	                  4       pVR,          pVR,          pVR,          pVP
                  p	VP                  p
VP                  pVR
9   gu   \        WV4      pVR8X  d
   W,          p
MXVR8X  d   W^,          ,          p
MAVR8X  d    V
\        WiWWP                  4      ,          p
M\        R\        V4      ,           4      hVP                  pWBn         VP                  WWV3R	7       Wn        R# R#   Yn        i ; i)textRenderModeN
textAnchorr^   r_   endmiddlenumericzbad value for textAnchor )	_fontInfo)start	inherited)ra   r]   getattrrH   r`   textr@   rA   r   numericXShiftencoding
ValueErrorr   r   
drawString)rL   	stringObjcanvfillr   Stext_anchorr^   r_   r   r@   rA   textLenoldTextRenderModes   &&            r$   r   _PMRenderer.drawString   s$   ||~~ +;A>~~&&(AL/K}H}H>>DAA"77%dX>%LA (*NA )+{RdRdeeA$%@[AQ%QRR $ 3 3"08DX3FG&7#/  .. '8#s   D9 9Ec                  aa	a
a V P                   o
S\        J dq   S
P                  R S
P                  '       d@   S
P                  R,          pVP                  p^Vn        V P	                  V4       W2n        R# S
P                  4        R# ^ RIHo	 S
P                  S
P                  S
P                  S
P                  3o\        SRR4      pRV	V
VV3R llpSP                  '       d3   V! 4        S
P                  4        S
P                  P                  S4       S
P                  RJpS
P                   RJp\        SRR4      pVR8X  d   V'       d<   V'       d4   V! RR	7       S
P#                  V4       V! 4        S
P%                  4        R# V'       d   V! RR	7       S
P#                  V4       R# V'       d   V! 4        S
P%                  4        R# R# VR
8X  d?   V! RR	7       V'       d   S
P#                  V4       V'       d   S
P%                  4        R# R# V! 4       '       d   S
P#                  V4       S
P%                  4        R# )rp   N)_renderPath	autoclose c                 :   < SP                  4        S! SSV R 7      # )
forceClose)r   )r   r   r3   	drawFuncsr   s   &r$   rP _PMRenderer.drawPath.<locals>.rP   s    KKMtY:FFr5   rZ   svgTr   pdfrs   )F)ra   EmptyClipPath
_clipPaths
isClipPathdrawPathclipPathClearreportlab.graphics.shapesr   r   r   curveTor   r   clipPathSetappendr]   rW   r   r   )rL   r   r   icpr   r   r   strokerZ   r   r3   r   s   &f       @@@r$   r   _PMRenderer.drawPath   s   LL= R |||LL$ll a "  !9XXqxxAKK@	DR0		G 	G ???DMMOLL%{{$&d*4
2.ed#

8$d#

8$  $

8$  tt

8$LLNr5    N)r'   )__name__
__module____qualname____firstlineno____doc__rI   rO   rJ   rv   rz   r   r   r   r   r   r   r   r   r   __static_attributes____classdictcell____classdict__s   @r$   r:   r:   [   sV     :
;4R;(

.8:/ /r5   r:   c                 f    \        4       pV P                  R VP                  VP                  R7      # )r   ditherpalette)r+   r   NONEADAPTIVE)r   r)   s   & r$   _convert2pilpr    s&    KE::c%**enn:EEr5   c                 $    V P                  R 4      # )Lr   r   s   &r$   _convert2pilLr  !      ::c?r5   c                 $    V P                  R 4      # )1r  r  s   &r$   _convert2pil1r  $  r  r5   c                    \        V 4      p V P                  w  rE\        P                  YE\	        V R 4      '       d   V P
                  MV P                  ! 4       V P                  P                  4       4      p\	        VR4      '       g   \        \        P                  P                  V4      ^ ,          R,           VP                  4       ,           R4      ;_uu_ 4       pVP                  V4       RRR4       \        P                  R8X  d   ^ RIHp V! VRR7       R# R# VP                  V4       R#   + '       g   i     LL; i)	r   write.wbNmacmarkfilenamePICText)r  r   
_pmBackendpil2pictr   r   r   r   
getpaletter   r   r   splitextr    r  namereportlab.lib.utilsr  )	r   fnfmttransparentcolsrowsrk   fr  s	   &&&&     r$   _saveAsPICTr"  '  s    	r	BJDDWR	5J5JrzzPRP[P['[&^_a_d_d_o_o_qrA2g"''""2&q)#-ciik9$??1GGAJ @77E>8'  	 @?s   D22E	ARGB32RGB24)ARGBRGBAr   gOQ?c                     a  ] tR tRt o R!R lt]R"R l4       tR#R ltR tR#R lt	R$R lt
R	 tR#R
 ltR tR tR%R ltR tR tR tR&R ltR#R ltR'R ltR tR%R ltR tR tR tR tR tR t]tR tR t R t!R(R lt"R t#V t$R# ))PMCanvasi6  Nc                l   VR,          p\        W,          R,           4      p\        W(,          R,           4      pV P                  WWFVR7      V P                  R&   W@P                  R&   V^ ^ V^ ^ 3V P                  R&   . V P                  R&   WPP                  R&   W0P                  R	&   \        V P                  P
                  4      \        \        4      8X  d   R
MRV P                  R&   WpP                  R&   V P                  R8X  d   \        M\        V P                  R&   V P                  V n        R# )z-configPIL dict is passed to image save methodg      R@g      ?r  _gs_bgru   r   	configPIL_dpir   r   r   _backendfmt_colorConverterN)r.   
_getGStater;   typer+  r   powr   r7   r4   ru   rT   )	rL   whdpibgr-  r!   
backendFmtscales	   &&&&&&&& r$   __init__PMCanvas.__init__7  s     D#q2*Me!e%*1QuQq$9j!&(l#%.k" #f378J8J3KTRUY3VK\gj!'1m$9=9S:Yb'(==r5   c                   \        V4      pVf   \        P                  pVR8X  d    VP                  WVR7      # RVP                  4       9   d:   VP                  4       p\        P                  WD4      p VP                  WW$R7      # \        RV: 24      h  \         d      TP                  YY$R7      u #      L5; ii ; i  \         d    TP                  YTR7      u # i ; i)Nr   r7  r*  r   z.Cannot obtain PM graphics state using backend )r%   r   r   gstate	TypeErrorGStater    upper_pycairoFmtsMapgetAttributeErrorRuntimeError)r4  r5  r7  r!   r  mods   &&&&& r$   r1  PMCanvas._getGStateI  s    G$?//GKzz!z,, '))+C!%%c.C-zz!bz11 KG;WXX  ::a":55	 " -zz!z,,-s;   B 6C C$B96C9B>;C>CC&%C&c                   Vf   V P                   pWuV P                  n        V P                  n        RR RR RR RR RR RR RR /pV P                  pVP
                  VP                  rvVP                  4        F  p\        WX4      WH&   K  	  ?V =\        P                  WVR7      ;qPP                  R	&   VP                  4        F  p\        WWH,          4       K  	  VP                  Wg4       R # )
NrT   rU   rW   rc   rd   ri   r]   r=  r+  )r,  _drawingr   r   r+  r^   r_   keysr   r  r>  r;   setattrr   )	rL   r4  r5  r7  AgsfNfSks	   &&&&     r$   _drawTimeResizePMCanvas._drawTimeResize_  s    :DHHr451T]]14t]44Q[\`bmnrt  AE  FXXR[[2A2=AD $.$5$5aR$5$@@]]5!AD14  


2r5   c                "   \        4       P                  V P                  R 8X  d   \        V R4      R8X  d   RMRV P                  P
                  V P                  P                  3R7      pVP                  V P                  P                  4       V# )r   _fmtr#  r&  r   )r   )	r+   newr   r   r+  r   r   	frombytespixBuf)rL   r   s   & r$   toPILPMCanvas.toPILm  s    [__t}}k'AgdSYFZ\dFdVjow{ww  xF  xF  HL  HP  HP  HW  HW  wX_  Y
TXX__%	r5   c           
        V P                  4       pVfx   \        V\        4      '       g   \        R\	        V4      ,          4      h\
        P                  P                  V4      ^,          pVP                  R4      '       d
   VR,          pV P                  ;'       g    / pVP                  RR 4       VP                  R4      pV'       d	   V! V4      pVP                  4       pVR9   d   \        V4      pMVR9   dl   VP                  R4      '       d   \        V4      pMEVP                  R4      '       d   \        V4      pM"VP                  R4      '       d   \!        V4      pRpMHVR9   d   \#        W1W$P%                  R	R 4      R
7      # VR9   d   MVR9   d   RpM\'        RV,          4      hVR8X  d   VP%                  R	R 4      pV'       d   ^ RIHpHp R^ .,          p	\/        RVP1                  4       4       F  w  r^WV,           &   K  	  VP3                  RVP5                  4       VP7                  VP9                  V	4      P;                  R4      P9                  ^^ .,          ^.,           4      4      3,           4      pRV P<                  3R3 F  w  rVP%                  W4      WL&   K  	  VP                  R^ 4       VP                  R4      '       d   ^ RIHp VP7                  V4      pVP                  RR 4       VP                  R4      pV'       d	   V! V4      pVP>                  ! W3/ VB  \A        VR4      '       g)   \
        PB                  R8X  d   ^ RI"H#p V! WR7       R # R # R # )Nz*Invalid value '%s' for fn when fmt is Noner  rp   NNpreConvertCBTIFFr   r  r
  r  )r  JPEGzUnknown image kind %s)
ImageChopsr)   i   r&  
resolutionchops_invert)r_  	preSaveCBr  r  r  r  GIF)r]  TIFFPTIFFLTIFTIFF1)PCTr  )PNGBMPPPM)JPGr^  )r'      i   )zresolution unitinch)$rX  re   r   r   asciir   r   r  
startswithr-  
setdefaultrI   rA  r  endswithr  r  r"  rC  r   r*   r_  r)   zip
bitmap_rgbmergesplitinvertpointr   r.  saver   r  r  r  )rL   r  r  r   r-  r\  tcr_  r)   Tor3   adrb  r  s   &&&             r$   
saveToFilePMCanvas.saveToFiler  s   ZZ\;b%% !MPUVXPY!YZZ''""2&q)C~~c""#b'CNN((b	^D1]]>2b!Biik(?r"B::||C  "2&c"""2&c"""2&CN"rS]]=QU5VWW((N"C 7# =>>;}T2B1GR]]_=DA AcF > [[Z5F5FrxxPQ{GZGZ[^G_GeGefikljmfmornsfsGt5u4w)wx$TYY/0JJ(}}Q1	 K^A.==((&""2&B[.--,	2B
##r'""rww~8$ (6"r5   c                Z    \        4       pV P                  W!R 7       VP                  4       # )r*  )r   r  getvalue)rL   r  rk   s   && r$   saveToStringPMCanvas.saveToString  s#    I"zz|r5   c                   ^ RI pV P                  pV P                  R8X  d-   VP                  R8X  d   RVn        VP                  pRVn        MVP                  pVP
                  VP                  reVP                  VP                  RR\        V4      ^6,           ^ ^6^(WV^^4
      4       V^,          p\        \        V4      ^ V) 4       F  pVP                  WHV,
          V 4       K  	  VP                  R4       R# )z
Niki Spahiev, <niki@vintech.bg>, asserts that this is a respectable way to get BMP without PIL
f is a file like object to which the BMP is written
Nr   r#  r$  z=2sLLLLLLhh24xBMz              )structr+  r   rT  rW  r   r   r  packrh   r   )	rL   r!  r  rM  pixr   r   rowbr}  s	   &&       r$   
_saveToBMPPMCanvas._saveToBMP  s    
 	XX==+%"''8*;BG))CBG))C"))v	,T#c(2+a2eSTUWXYqys3x4%(AGGC$qM" )	r5   c                2    \        V P                  W4       R # rG   )_setFontr+  )rL   r^   r_   leadings   &&&&r$   r   PMCanvas.setFont  s    (,r5   c                2    \        V P                  W4       R # rG   )rK  r+  )rL   r  values   &&&r$   __setattr__PMCanvas.__setattr__  s    $r5   c                .    \        V P                  V4      # rG   )r   r+  )rL   r  s   &&r$   __getattr__PMCanvas.__getattr__  s    txx%%r5   c                j    V'       d   V P                  4        V'       d   V P                  4        R # R # rG   )r   r   )rL   r   r   s   &&&r$   r   PMCanvas.fillstrokepath  s    4??$6r5   c                
   \        We,
          4      ^Z8:  g   Q h\        \        V,          R,          4      p\        \        V,          R,          4      pWV,          ,           p	W$V,          ,           p
\        \        V,          R,          4      p\        \        V,          R,          4      pWV,          ,           pW$V,          ,           pV) V,          pWG,          p\        We,
          ,          R,          p\        RR\        V4      ,
          ,          \        V4      ,          4      pWV,          ,           pV
VV,          ,           pV) V,          pWK,          pVVV,          ,
          pVVV,          ,
          pW3VV3VV3W333# )a  compute the control points for a bezier arc with theta1-theta0 <= 90.
Points are computed for an arc with angle theta increasing in the
counter-clockwise (CCW) direction.  returns a tuple with starting point
and 3 control points of a cubic bezier curve for the curvto opertatorg     f@g      ?g     v@gUUUUUU?)absr   r   r   )rL   r   r   r}   r~   theta0theta1cos0sin0x0y0cos1sin1x3y3dx1dy1halfAngrP  r   r   dx2dy2r   r   s   &&&&&&&                  r$   _bezierArcSegmentCCWPMCanvas._bezierArcSegmentCCW  s5    6?#r)))2f9U?#2f9U?#T'\T'\2f9U?#2f9U?#T'\T'\cDji fm$k2	S3w</1CLAC'\#'\cDji#'\#'\2b'Br7RG466r5   c           	        We,
          p\        V4      R8:  d   WV3.pMs\        \        \        V4      R,          4      4      p	\        V4      V	,          p
. p\	        V	4       F,  pW[V
,          ,           pW,           pVP                  W34       K.  	  . pV Fc  w  rV'       g-   V P                  WW4W4      w  w  pppVP                  V4       K9  V P                  WW4W4      w  w  pppVP                  V4       Ke  	  XX3V3# )zreturn a set of control points for Bezier approximation to an arc
with angle increasing counter clockwise. No requirement on (theta1-theta0) <= 90
However, it must be true that theta1-theta0 > 0.g     V@)r  r.   r   floatr   r   r  )rL   r   r   r}   r~   r  r  angularExtent	angleListNfrag	fragAngleiir~  bctrlptsr  r  ptstmpxtmpys   &&&&&&&             r$   bezierArcCCWPMCanvas.bezierArcCCW  s     }% )Is=1#568Em,e3IIEl)^+M  !' #
 EQ!%!:!:2"!M"R#s#%)%>%>rbQ%Q"$tcs#  B!!r5   c           	         V P                  WW4WV4      w  w  rxp	V P                  Wx4       V	 F   w  w  rw  rw  rV P                  WWW4       K"  	  R# )zadds an ellisesoidal arc segment to a path, with an ellipse centered
on cx,cy and with radii (major & minor axes) rx and ry.  The arc is
drawn in the CCW direction.  Requires: (ang2-ang1) > 0N)r  r   r   )rL   r   r   r}   r~   ang1ang2r  r  r  r   r   r   r   r  r  s   &&&&&&&         r$   addEllipsoidalArcPMCanvas.addEllipsoidalArc  sR    
 "..rbDF"'B*1&WbgrgrLLrR+ +2r5   c           	     .    V P                  WW4WVR 7       R# ))r   	directionshapingNr   )rL   r@   rA   r   r   r  r  s   &&&&&&&r$   drawCentredStringPMCanvas.drawCentredString  s    DI_r5   c                0    V P                  WVR VR7       R# )r   )r   r  Nr  )rL   r   r@   rA   r  s   &&&&&r$   drawRightStringPMCanvas.drawRightString  s    qUYGr5   c                "   V P                   pVP                  p	VP                  p
V'       d   WIV
38w  d   Vw  r\        WV4       MT
pT	p\	        W6WVR 7      w  r= VR9   dO   \        W;V4      pVR8X  d
   W,          pM2VR8X  d   WR,          ,          pMVR8X  d   V\        WSWV4      ,          pV P                  R8X  d   VP                  WV4       EM\        V4      pVP                  '       d   VP                  WV4       MTp\        V4      '       g    VP                  R4      p\        W>.VP                   ,           4      p\#        V4      pV^,
          p\%        V4       F|  pVV,          w  ppVV8w  d   \        VVP                  V4       TpVP                  WV4       VV8w  g   KJ  VVP                  VP                  VP&                  4      V4      ,          pK~  	  VP)                  W4       R#   \         du   pTP                  R,          w  pp\        TP                  R,          TP                  ^,          : R	TT^
,
          T : R
TTT : RTTT^
,            : 23,           !  hRp?ii ; i  TP)                  Y4       i ; i))r^   r_   r  r   r   g       @r   r   utf8:r   rq   N:Nrq   N
z-->z<--N)r   r   r   )r+  r_   r^   r  r
   r   r   r   r   r   _dynamicFontr   decodeUnicodeDecodeErrorargsr   substitutionFontsrh   r   encNamer   )rL   r@   rA   r   r   r   r  r  rM  gs_fontSizegs_fontNamer^   r_   r   fontfcer   jFTnnm1r!  ts   &&&&&&&&                r$   r   PMCanvas.drawString"  sl   XXkkkk$==!*HR*"H"H&txbij%	055%dX>%LA (*OA )+{RRA}}k)a$'x($$$MM!d+B$T??L#';;v#6D
 $D0F0F)FGBBAA#C"1X!!u1b5$R

8<!"Ba!,c6qxx		/B8!LLA & JJ{/!  2 L"#&&+CAa"4qvvbzYZY_Y_`aYbYbcghijlhlmncoptuvwxpyz~  @A  BC  DF  BF  {G  DH  CJ  8J  #L  LL  JJ{/s9   B=I; G9 *BI; 06I; 9I8A/I33I88I; ;Jc                    V P                   eE   V P                  4        V P                  W4       V P                  W44       V P	                  4        R # R # rG   )rW   r   r   r   r   )rL   r   r   r   r   s   &&&&&r$   r   PMCanvas.lineV  s?    'NNKKKKOO	 (r5   c                (   V P                  4        V P                  W4       V P                  W,           V4       V P                  W,           W$,           4       V P                  WV,           4       V P                  4        V P	                  WVR 7       R# ))r   r   N)r   r   r   r   r   )rL   r@   rA   r   r   r   r   s   &&&&&&&r$   r   PMCanvas.rect]  se    AAGQAGQZ(A6z"64r5   c                   V^ 8X  d   TpV^ 8X  d   TpW,           pW$,           pV P                  4        V P                  W,           V4       V P                  Wu,
          W&,           WVRR4       V P                  Wu,
          W,
          WV^ ^Z4       V P                  W,           W,
          WV^Z^4       V P                  W,           W&,           WV^R4       V P                  4        V P	                  4        R# )zrect(self, x, y, width, height, rx,ry):
Draw a rectangle if rx or rx and ry are specified the corners are
rounded with ellipsoidal arcs determined by rx and ry
(drawn in the counter-clockwise direction)i  ih  N)r   r   r  r   r   )	rL   r@   rA   r   r   r}   r~   r   r   s	   &&&&&&&  r$   r   PMCanvas.roundRectf  s    
 q5r"q5r"YZADruadBC>rubeRQ;qtRUBB<qtQT23=r5   c                *    V P                  WW34       R# )zRadd closed path circle with center cx,cy and axes r: counter-clockwise orientationN)r   )rL   r   r   r   s   &&&&r$   r   PMCanvas.circlex  s    R1r5   c                   V P                  4        W,           pTpTpW$,
          pW,           p	W$\        ,          ,
          p
Ws\        ,          ,           pTpV P                  WV4       V P                  WWWx4       TpTpW,
          pTpW\        ,          ,
          p	W$,
          p
TpW$\        ,          ,
          pV P                  WWWx4       TpTpTpW$,           pW,
          p	W$\        ,          ,           p
W\        ,          ,
          pW$,           pV P                  WWWx4       TpTpW,           pTpW\        ,          ,           p	W$,           p
W,           pW$\        ,          ,           pV P                  WWWx4       V P	                  4        R# )z}add closed path ellipse with center cx,cy and axes rx,ry: counter-clockwise orientation
(remember y-axis increases downward) N)r   BEZIER_ARC_MAGICr   r   r   )rL   r   r   r}   r~   r  r  r  r  r   r   r   r   s   &&&&&        r$   r   PMCanvas.ellipse|  sb    	WUU###%%%BR2'U###U$$$R2'UU###$$$UR2'U###UU###R2'r5   c                    R# )zdo nothing for compatibilityNr   rK   s   &r$   	saveStatePMCanvas.saveState  s    r5   c                d    V P                  V4      V n        \        VR R4      pVe	   W n        R# R# rl   N)r0  r]   r   r\   rL   aColorrl   s   && r$   rj   PMCanvas.setFillColor  s3    --f5wt,$ r5   c                d    V P                  V4      V n        \        VR R4      pVe	   W n        R# R# r  )r0  rW   r   rV   r  s   && r$   rb   PMCanvas.setStrokeColor  s4    //7wt,!& r5   c                    Wn         R # rG   )rc   )rL   caps   &&r$   
setLineCapPMCanvas.setLineCap  s    r5   c                    Wn         R # rG   )rd   )rL   joins   &&r$   setLineJoinPMCanvas.setLineJoin  s    r5   c                    Wn         R # rG   )rU   )rL   r   s   &&r$   setLineWidthPMCanvas.setLineWidth  s     r5   c                    \        Y;'       g    V P                  P                  Ve   V4      # V P                  P                  4      # rG   )r   r+  r^   r_   )rL   r   r^   r_   s   &&&&r$   r   PMCanvas.stringWidth  sF    4!>!>TXX->->-5-A[ 	[GKxxGXGX[ 	[r5   )rT   r]   r\   rc   rd   rW   rV   rU   )H    NNr   )Nr$  rG   rc  )rp   rp   )r   NF)NleftNF)NN)%r   r   r   r   r:  staticmethodr1  rQ  rX  r  r  r  r   r  r  r   r  r  r  r  r  r   r   r   r   r   r   r  rj   rb   restoreStater  r  r  r   r   r   r   s   @r$   r(  r(  6  s     !$ Y Y*
6%p
(-%&%!7F"<	,`H20h5$ 9v%' L![ [r5   r(  r  r   c           
          \        V 4      p \        V P                  V P                  WW5VR 7      p\	        W^ ^ 3RV/VB  V# ))r6  r7  r-  r!   r8  r9   )r   r(  r   r   r=   )	r  r6  r7  r-  r9   r!   r8  rB   r3   s	   &&&&&&&, r$   drawToPMCanvasr    sB    AA!((idnoAq!6,66Hr5   c                 N    \        V 3R VRVRVRVRVRV/VB P                  4       # )r6  r7  r-  r9   r!   r8  )r  rX  )r  r6  r7  r-  r9   r!   r8  rB   s   &&&&&&&,r$   	drawToPILr    sh    !  L  L  Ly  L|  Lel  L  yC  L  GK  L  R  R  T  Tr5   c                     \        4       p\        V 3R VRVRVRVRVRV/VB p	V	P                  RVP                  VP                  R7      # )r6  r7  r-  r9   r!   r8  r   r   )r+   r  r   r   r  )
r  r6  r7  r-  r9   r!   r8  rB   r)   r   s
   &&&&&&&,  r$   
drawToPILPr
    sr    KE	1  
D#  
D"  
D	  
D  
D]d  
Dpz  
D  C  
DB::c%**enn:EEr5   rd  c	                X    \        V 3RVRVRVRVRVRV/V	B p
V
P                  W4       R# )zkcreate a pixmap and draw drawing, d to it then save as a file
configPIL dict is passed to image save methodr6  r7  r-  r9   r!   r8  N)r  r  )r  r  r  r6  r7  r-  r9   r!   r8  rB   r3   s   &&&&&&&&&, r$   
drawToFiler    s\     	q  	Hc  	Hb  	HI  	HL  	Hah  	Ht~  	H  CG  	HALLr5   c                 f    \        4       p	\        W	3R VRVRVRVRVRV/VB  V	P                  4       # )r  r6  r7  r-  r!   r8  )r   r  r  )
r  r  r6  r7  r-  r9   r!   r8  rB   rk   s
   &&&&&&&&, r$   drawToStringr    sB    	Aqnsnnninn[enimn::<r5   c           	      |	  aaaaa R  p^ RI p^ RIHp ^ RIHo VP
                  p. pVP                  P                  V 4      '       g   VP                  ! V 4       RpRpV.p	/ p
\        P                  R,          pV Uu. uF  qP                  R4      '       g   K  VNK  	  ppV'       g   . R,OpMPV F  pVP                  V4       K  	  RP                  V Uu. uF  qR,          NK  	  up4      P                  R4      p. o^ RIo^ RIHo VVVVV3R lpV! \%        \&        R4      R7       EFV  w  pppV
P)                  V^ 4      ^,           ;pV
V&   V^8  d   VRV^,
          ,          ,          pV'       d
   VV9  d   KU  Tp\+        VP,                  4      p\+        VP.                  4      pV	P1                  RV: RV: R24       V EFe  pVR-9   d'   V	P1                  RVP3                  4       ,          4        V: RV! V4      : 2pVP                  P                  V V4      pVP                  P5                  V4      '       d   VP                  ! V4       VR8X  d   \7        VVVR\8        /R7       M,VR.9   d   VP;                  R	R
.V VR7       M\7        VVVR7       VR/9   d   V	P1                  RV,          4       M?VR	8X  d   V	P1                  RV,          4       MVR
8X  d   V	P1                  RV,          4       S'       g   S^8  d   \=        R\?        V4      ,          4       EKe  EKh  	  VPB                  PE                  RR 4      R!8X  d   ^ VPF                  R"&   R0 F  p VP;                  V.V VR7       K  	  EKY  	  S'       d?   V	^ ,          PI                  R#R$4      V	^ &   V	P1                  R%4       V	PK                  S4       V	P1                  V4       VP                  P                  V R&4      p\M        VR'4      ;_uu_ 4       pVPO                  V	4       RRR4       \        PP                  R(8X  d   ^ R)I)H*p V! VR*R+7       S'       g   S^8  d   \=        RV,          4       R# R# u upi u upi   \@         d    T! TT4        EK  i ; i   T! TT4        EKB  ; i  + '       g   i     L; i)1c                     V R 8X  d   Rp V # )tifftifr   )r@   s   &r$   r  test.<locals>.ext  s    f9ar5   N)
testshapes)verbosezq<html><head><title>renderPM output results</title></head>
    <body>
    <h1>renderPM results of output</h1>
    z</body>
    </html>
    r[  z--ext=pctpyr   ,:   NN)escapec                   < R V : RV: R2pS'       g   S^8  d   \        V4       SP                  RV,          4       \        4       pSP                  VR7       SP                  RS! VP	                  4       4      ,          4       R# )zProblem drawing z fmt=z filez"<br/><h2 style="color:red">%s</h2>)filez<pre>%s</pre>N)printr   r   	print_excr  )	r  r  msgbuferrsr  shout	tracebackr  s	   &&  r$   handleErrortest.<locals>.handleError  sb    04S9GAIuSz83>?j%OfS\\^&<<=r5   ft_get_face)doTTFz.%02dz<hr><h2>Drawing z</h2>
<pre>z</pre>z<p>%s format</p>
r  r  )r  r-  )formatsoutDirfnRootr*  z<img src="%s" border="1"><br>
z#<a href="%s">python source</a><br>
z<a href="%s">SVG</a><br>
zwrote %sRL_NOEPSPREVIEW0r
  previewz</h1>z7 <a href="#errors" style="color: red">(errors)</a></h1>z<a name="errors"/>zpm-index.htmlr4  r  r  HTMLr  )gifr  pngjpgr  r  r   )r/  r0  r1  r  )r  r   )r/  r0  r1  )epsr   )+r   reportlab.graphicsr  reportlab.rl_configr  getAllTestDrawingsr   isdirmkdirsysargvrq  remover  rw  r#  xml.sax.saxutilsr  r   r  rr  r.   r   r   r   rA  r   r  r   rz  r  rp  rD  environrC  r;   replaceextendr   
writelinesplatformr  r  ) r)  r"  r  r   r  r5  drawingshtmlTop
htmlBottomhtmlnamesr9  r~  Er$  r>   	docstringr  r   r*  r4  r5  rP  filenamefullpathhtmlFileNamer!  r  r!  r  r#  r  s    &f                          @@@@r$   testrK    s   
 -+#66H77==  
GJ 9DE88B<D3DqLL2DA3<AKKN XXa(auua()005D'> > '9wzR_?`&a&a")T**42144E$KQ31Q3'D$hiPQA--01779<=$&,c!f577<<977>>(++IIh'e8wxAu@UV,&LL$uV6LRwxA6++KK AH LMWKK F QRXKK <x GHGAIuZh-G'HI) . ::>>+C0#5UVw7G7G	7RA$aSfE  C 'bN q'//'*cdQ()DKK
77<<8L	lC	 	 A	T 
!
||U4\f-	5l!:;	M 	4 )X " $D##$$D## 
!	 sJ   >Q3Q3Q8<AQ=CQ=
"Q=*RR+=RRR(+R;	__main__T)r"  rG   )pmoutF)A__version__r   r   reportlab.graphics.renderbaser   r   reportlab.pdfbase.pdfmetricsr   r   r   reportlab.pdfbase.ttfontsr   r	   reportlab.pdfgen.textobjectr
   r  r   r   reportlab.lib.abagr   reportlab.lib.colorsr   r   	reportlabr   utilsr   r  r   r   r8  ior   r   mathr   r   r   r   r%   r   r  r+   r4   r7   _unset_r=   rD   r:   r  r  r  r"  dictrB  r  r(  r  r  r
  r  r  rz  rK  r   r   r5   r$   <module>r[     s   	1 ( L I I > 6 4 # /  5    # #:y889J
. .7->-> R 3@( @DF H(w? _[ _[@ T	HYHYbkb{b{  HM  H9CTCT]f]v]v  CH T XIDUDU^g^w^w  DI F
 2(dQZQbQbkt  lE  lE  QV  "TPYPaPajs  kD  kD  PU 
 ]<~ Zt g  Js   0F	 		FF