
    Q?hUC                        S r SrSSKrSSKrSSKJr  SSKJr  SSKJ	r	  SSK
JrJr  SSKJr  SS	KJr  SS
K7  SSKr/ SQrS rS rSSKJr  \" \5        \" 5         S rS rS rS rS rS rS rS rS r S r!S r"SSK#J$r$  S r%S r&S r'S r(S r)S(S  jr*S)S! jr+S(S" jr,S# r- " S$ S%\R\                  5      r/S& r0\1S':X  a&  \Rd                  " 5       Rg                  \0" 5       5        gg)*z $Id $ zExecute this script to see some test drawings.

This contains a number of routines to generate test drawings
for reportlab/graphics.  For now many of them are contrived,
but we will expand them to try and trip up any parser.
Feel free to add more.
    N)BytesIO)colors)cm)asNativebase64_decodebytes)Canvas)stringWidth)*)Times-RomanVerazTimes-BoldItalicc                  |   SSK Jn Jn  U R                  UR	                  SS5      5        U R                  UR	                  SS5      5        U R                  UR	                  SS5      5        U R                  UR	                  S	S
5      5        / SQn[
        R                  S:X  a  S H  u  p4S H~  n[        R                  R                  USU5      n[        R                  R                  U5      (       d  MJ   UR	                  X65      nU R                  U5        UR                  U5        M     M     U$ !    M  = f)Nr   )
pdfmetricsttfontsr   zVera.ttfVeraBdz
VeraBd.ttfVeraItz
VeraIt.ttfVeraBIz
VeraBI.ttf)r   Courier	Helveticar   r   r   r   win32))zAdventurer Light SFz
Advlit.ttf)ArialMSz	ARIAL.TTF)zArial Unicode MSzARIALUNI.TTF)zBook Antiquaz	BKANT.TTF)zCentury Gothicz
GOTHIC.TTF)zComic Sans MSz	COMIC.TTF)zElementary Heavy SF Boldz	Vwagh.ttf)z
Firenze SFzflot.ttf)GaramondzGARA.TTF)JaggerzRols.ttf)zMonotype CorsivazMTCORSVA.TTF)z
Seabird SFzseag.ttf)Tahomaz
TAHOMA.TTF)	VerdanaMSzVERDANA.TTF)zc:\WINNTz
c:\WindowsFonts)reportlab.pdfbaser   r   registerFontTTFontsysplatformospathjoinisfileappend)r   r   FnamettfDfnfs           O/var/www/html/env/lib/python3.13/site-packages/reportlab/graphics/testshapes.py_setupr-      s    5GNN6:>?GNN8\BCGNN8\BCGNN8\BCRA
||WID 1WW\\!GC077>>"%%#NN44"//2 10 Hs   93D66D;c                  h    [        5        H$  n U [        ;  d  M  [        R                  U 5        M&     g )N)r-   _FONTSr%   )r+   s    r,   
resetFontsr0   A   s!    XF?MM!     )register_resetc           	          [        SS5      n/ SQnUR                  [        US[        -  [        R
                  [        R                  S95        [        SSSU -  SS	9nUR                  U5        U$ )
a  Generate a drawing in case something goes really wrong.

This will create a drawing to be displayed whenever some
other drawing could not be executed, because the generating
function does something terribly wrong! The box contains
an attention triangle, plus some error message.
     )r5         P   i  r8         ?strokeWidthstrokeColor	fillColor(   z"Error in generating function '%s'!middle
textAnchor)DrawingaddPolygonr   r   redyellowString)funcNamer)   pointsss       r,   getFailedDrawingrK   N   sl     	SA&FEE'&!"f$jj"MM+ ,
 	sB3h>"	$A EE!HHr1   c            
         [        SS5      n U R                  [        SSSS[        R                  S95        U R                  [        SSS[        R                  S95        U R                  [        SS	S
[        R                  S95        U $ )zoHello World, on a rectangular background.

The rectangle's fillColor is yellow.
The string's fillColor is red.
r4   r5   2   ,  d   r=      Hello WorldV   s   Special characters ¢©®£αβ)rB   rC   Rectr   rF   rG   rE   r)   s    r,   getDrawing01rV   i   sl     	SAEE$r2sC6==
9:EE&S-6::
>?EE&R_kqkuku
vwHr1   c                      [        SS5      n U R                  [        SSSS[        R                  S[
        -  S95        U R                  [        SSSS[        R                  S[
        -  / SQS	95        U $ )
z{Various Line shapes.

The lines are blue and their strokeWidth is 5 mm.
One line has a strokeDashArray set to [5, 10, 15].
r4   r5   rM   rN   rO   r9   )r<   r;   )   
      )r<   r;   strokeDashArray)rB   rC   Liner   bluer   rU   s    r,   getDrawing02r^   x   sn     	SAEE$r"c#!;;r6  EE$r#s2!;;r6*  Hr1   c                      [        SS5      n [        SSS5       H2  nU R                  [        SUS-  -   SUS-  -   S[        S	   US
95        M4     U R                  [        SSS[        S   SS
95        U $ )zText strings in various sizes and different fonts.

Font size increases from 12 to 36 and from bottom left
to upper right corner.  The first ones should be in
Times-Roman.  Finally, a solitary Courier string at
the top right corner.
r4   r5      $      rY      rR   r   fontNamefontSize      )rB   rangerC   rG   r/   )r)   sizes     r,   getDrawing03rk      s     	SAb"a 	fRQYQY"$Qi"	$ 	% ! EE&c )  Hr1   c            
          [        SS5      n Sn[        R                  [        R                  [        R                  4 H/  nU R                  [        SUS-  -   SUS-  -   SUS95        US-   nM1     U $ )	zdText strings in various colours.

Colours are blue, yellow and red from bottom left
to upper right.
r4   r5   r   rM      rR   rP   rh   )rB   r   r]   rF   rE   rC   rG   )r)   icolors      r,   getDrawing04rp      sn     	SA	A++v}}fjj9	fR"Wb2g"e5 	6E :
 Hr1   c            
         [        SS5      n SnU R                  [        USUS[        R                  S95        SnS H@  nU R                  [        XS	US
95        U R                  [        SX#S-   5      5        US-
  nMB     U $ )zlText strings with various anchors (alignments).

Text alignment conforms to the anchors in the left column.
r4   r5      rY      r<      )startr?   endrR   r@   rM   :rm   )rB   rC   r\   r   grayrG   )r)   lineXyanchors       r,   getDrawing05r}      s}     	SAEEE$uRs
<=A,	fU}@A	fRSL)*F -
 Hr1   c                     [         R                  n [        SS5      nUR                  [	        SSSS5      5        UR                  [        SSSU S95        UR                  [        SSS	U S95        UR                  [        S
SSU S95        UR                  [        SSS	SS	U S95        UR                  [        / SQU S95        UR                  [        / SQU S95        UR                  [        SSS	SU S95        UR                  [        SSSSS[         R                  U S95        UR                  [        SSSSSSU S95        UR                  [        SSS[         R                  SS95        U$ )zThis demonstrates all the basic shapes at once.

There are no groups or references.
Each solid shape should have a green fill.
r4   r5   rY     rs   rO      rP   r>   rN   rm   J  i)x   rY   ru   r   r7   rY   rg   r      rY   r6   r   rQ   rY   rs   r   r5   rY   )
rN   r   i^  r   r   r8   rN   K   r   r>   rM   rg   r   <   r:      zBasic Shapesr   )r=   re   )r   greenrB   rC   r\   CircleWedgePolyLinerD   EllipserT   rF   rG   black)r   r)   s     r,   getDrawing06r      sE    LLESAEE$r"c#
EE&Su
-.EE&Su
-.EE&Su
-.EE%CCe
45EE( 4?DF G EE':e
LMEE'"S"bE
23EE$s32!==  ! EE$sCRR5
9:EE&B&,,
UVHr1   c                  4   [        SS5      n [        [        SSSS5      [        SSSS5      [        SSSS5      [        SSSS5      [        SSSS5      [        SS	SS	5      [        SSSS5      [        SSSS5      [        SSSS5      [        S	SS	S5      [        SSSS5      [        S
SS
S5      [        SSSS5      [        SSSS5      [        SSSS5      [        SSS[        R
                  S95      n[        U5      nUR                  SS5        U R                  U5        [        U5      nUR                  SS5        UR                  S5        U R                  U5        [        U[        [        SS5      [        S5      5      S9nU R                  U5        U $ )zThis tests the ability to translate and rotate groups.  The first set of axes should be
near the bottom left of the drawing.  The second should be rotated counterclockwise
by 15 degrees.  The third should be rotated by 30 degrees.r4   r5   r   rO   rM   rY   r   rm   r>   r   F   r8   Z   #   Axesfillrg   rZ   rN   	transform)
rB   Groupr\   rG   r   r   	translaterC   rotatemmult)r)   AxisfirstAxisGroupsecondAxisGroupthirdAxisGroups        r,   getDrawing07r      s    	SAQqQQq2Qr"RQr"RQr"RQr"RR"RR"RR"RR"RR"RR"RR"RR"RR"Rr2vFLL1!
D& 4[NR#EE.DkOc"%2EE/ 453r1BF2J+OPNEE.Hr1   c                     [        SS5      n [        [        SSSS5      [        SSSS5      [        SSSS5      [        SSSS5      [        SSSS5      [        SS	SS	5      [        SSSS5      [        SSSS5      [        SSSS5      [        S	SS	S5      [        SSSS5      [        S
SS
S5      [        SSSS5      [        SSSS5      [        SSSS5      [        SSS[        R
                  S95      n[        U5      nUR                  SS5        U R                  U5        [        U5      nUR                  SS5        UR                  SS5        U R                  U5        [        U5      nUR                  SS5        UR                  SS5        U R                  U5        [        U5      nUR                  SS5        UR                  SS5        U R                  U5        U $ )aU  This tests the ability to scale coordinates. The bottom left set of axes should be
near the bottom left of the drawing.  The bottom right should be stretched vertically
by a factor of 2.  The top left one should be stretched horizontally by a factor of 2.
The top right should have the vertical axiss leaning over to the right by 30 degrees.r4   r5   r   rO   rM   rY   r   rm   r>   r   r   r8   r   r   r   r   rg   rh   rc   }   rr   )
rB   r   r\   rG   r   r   r   rC   scaleskew)r)   r   r   r   r   fourthAxisGroups         r,   getDrawing08r     s   
 	SAQqQQq2Qr"RQr"RQr"RQr"RR"RR"RR"RR"RR"RR"RR"RR"RR"Rr2vFLL1!
D& 4[NR#EE.DkOc"%!AEE/4[NR$1EE.DkOc#&AEE/ Hr1   c                     [        SS5      n [        S   nSnSn[        X1U5      n[        [	        SSX1US9[        SSUS	-   US	-   S
S95      nU R                  U5        Sn[        X1U5      n[        [	        SSX1US9[        SSUS	-   US	-   S
S95      nUR                  SS5        UR                  S5        U R                  U5        U $ )zThis tests rotated strings

Some renderers will have a separate mechanism for font drawing.  This test
just makes sure strings get transformed the same way as regular graphics.r4   r5   r   r`   z4I should be totally horizontal and enclosed in a boxr   rd      rb   NrP   zGI should slope up by 15 degrees, so my right end is higher than my leftrM   rZ   )	rB   r/   r	   r   rG   rT   rC   r   r   )r)   re   rf   text	textWidthg1g2s          r,   getDrawing09r   J  s    
 	SAayHHADDH5I 
2r4xHRQ1E
B EE"ITDDH5I	2r4xHRQ1E
B LLBIIbMEE"IHr1   c                     [        SS5      n [        S   nSn[        [        SSSS[        R
                  S9[        SSS	XS
95      nU R                  U5        [        U[        SS5      S9nU R                  U5        [        U[        SS5      S9nU R                  U5        [        U[        SS5      S9nU R                  U5        U $ )zThis tests nested groups with multiple levels of coordinate transformation.
Each box should be staggered up and to the right, moving by 25 points each time.r4   r5   r   r`   rO   r   rP   rX   zText in the boxrd      r   )	rB   r/   r   rT   r   rF   rG   rC   r   )r)   re   rf   r   r   g3g4s          r,   getDrawing10r   i  s     	SAayHH	AsB&--81a*XS
B EE"I	ryB/	0BEE"I	ryB/	0BEE"I	ryB/	0BEE"I Hr1   )
SmileyFacec            
         S n [        SS5      n[        SS9nUR                  U " SSS[        R                  5      5        UR                  [        SSS	S[        R                  S
95        UR                  [        SSSS	[        R                  S
95        UR                  U5        [        SS9nUR                  U " SSS[        R                  5      5        UR                  [        SSS	S[        R                  S
95        UR                  [        SSSS	[        R                  S
95        UR                  U5        [        SS9nU$ )ztest of anchoringc                 b    Un[        5       nX5l        X-
  Ul        X-
  Ul        US-  Ul        U$ )z'Make a smiley data item representation.rc   )r   r=   xr{   rj   )r   r{   rj   ro   drJ   s         r,   
makeSmiley getDrawing11.<locals>.makeSmiley  s5    Lcc1r1   r4   r5   )rh   r   r   rh   r   r   r   rO   rY   r   n   rt   )rc   r   r   rc   rO   i)rc   r   r   rc   r   r   )rB   r   rC   r   rE   r\   r   r]   )r   r)   gs      r,   getDrawing11r     s     	SA&AEE*SR


+,EE$r#c#&,,
78EE$s2c#&,,
78EE!H*+AEE*SR
,-EE$r#c#&,,
78EE$s2c#&,,
78EE!H&AHr1   c                      Sn [        SS5      n[        SSS5       H+  nUR                  [        SUS-  -   SUS-  -   S	U US
95        M-     U$ )zText strings in a non-standard font.
All that is required is to place the .afm and .pfb files
on the font path given in rl_config.py,
for example in reportlab/fonts/.
DarkGardenMKr4   r5   r`   ra   rb   rY   rc   rR   rd   )rB   ri   rC   rG   )faceNamer)   rj   s      r,   getDrawing12r     s`     HSAb"a 	fRQYQY"&"	$ 	% ! Hr1   c                  f    SS jn U " [         5      u  pnUS:  d  US:  a  U " [         X5      u    pCU$ )zTest Various TTF Fontsr4   r5   c                 r   [        X5      nSU-  US-  -   nUSU-  -   nUn	Sn
U  H  nX-  n	U[        S5      -   n[        XU5      n[        XS-   5      n
UR	                  [        [        SX-
  US-   U[        R                  S	[        R                  S
9[        SXXS95      5        U	S-  n	M     XU	-
  U-   U4$ )Nrc   g333333?g?r   sl   : I should be totally horizontal and enclosed in a box and end in alphabetagamma ¢©®£ʥЖփאقকαβγr      rb   r9   )r<   r;   r=   rY   rd   rX   )rB   r   r	   maxrC   r   rT   r   rE   	lightgreyrG   )r&   whrf   slackgapr)   thghr{   maxxre   r   r   s                 r,   drawitgetDrawing13.<locals>.drawit  s    ALsUXc\!2h;HGAH  &f  g  gD#DH=ItbL)DEEd1adIM26::[]ioiyiyz2qOQR FA  qSWar1   )r4   r5   r`   rc   rX   )r/   )r   r   maxyr)   _s        r,   getDrawing13r     s7       6NMDCx48VF4%=UQqHr1   c                  b    SSK Jn   [        S5      nU " 5       R                  [	        U5      5      $ )zcreate a small PIL imager   )	_getImages   R0lGODdhCgAHAIMAAP/////29v/d3f+ysv9/f/9VVf9MTP8iIv8ICP8AAAAAAAAAAAAAAAAAAAAA
AAAAACwAAAAACgAHAAAIMwABCBxIsKABAQASFli4MAECAgEAJJhIceKBAQkyasx4YECBjx8TICAQ
AIDJkwYEAFgZEAA7)reportlab.graphics.renderPMr   r   openr   )r   bs     r,   
smallArrowr     s-    5  	A ;GAJ''r1   c            
          SSK Jn   [        SS5      n[        5       nUR	                  U " SSSSUS95        [        5       nUR	                  U " SSS	S
US95        U$ )ztest shapes.Imager   )Imager4   r5   N)r   r{   widthheightr"   i|     r      )reportlab.graphics.shapesr   rB   r   rC   )r   r)   im0im1s       r,   getDrawing14r     sV    /SA
,CEE%!ad$C
89
,CEE%&6"#
>?Hr1   c                     / n[        [        5       R                  5       5      nUR                  5         U H.  nUSS S:X  d  M  U (       d  US:w  d  M  UR	                  U5        M0     U$ )z4Get a list of drawing function names from somewhere.r   rY   
getDrawingr   )listglobalskeyssortr%   )doTTF	funcNamessymbolsrH   s       r,   getAllFunctionDrawingNamesr     s_     I 79>>#$GLLNAb>\).0  * 
 r1   c                     Uc
  [        5       nUc
  [        5       nUR                  XR                  U S 5      5      n U" 5       nUR	                  U[        USS5      U SS  45        g !   [        U 5      n N2= f)Nz.__doc__    )r   localsgetrK   r%   getattr)r'   r)   lr   funcr   s         r,   _evalFuncDrawingr     sr    ygi!yfh!55eeD&'D#F HHaj,d12h78#T"s   A' 'A6c                 @    / n[        U S9 H  n[        X!5        M     U$ )N)r   )r   r   )r   r)   r+   s      r,   getAllTestDrawingsr     s#    
A'e4 5Hr1   c                    [         R                  R                  [        R                  S   5      S   S-   n[        U5      nUR                  [        S   S5        UR                  SSS5        UR                  [        S   S5        SnS	nU  H  u  pVnUS
:  a  UR                  5         SnUS-
  nUR                  [        S   S5        UR                  SUSXt4-  5        UR                  [        S   S5        US-
  nUR                  SU5      nUR                  U5        UR                  U5        UR                  5       nX5R                  -
  nUR                  USU5        US	-   nM     UR!                  5         [#        SU-  5        g)z4Create and save a PDF file containing some drawings.r   z.pdf    r8   i  zReportLab Graphics-Shapes Testr`   i  rh   rN   rm   rc   z%s (#%d)r   z	wrote %s N)r!   r"   splitextr   argvr   setFontr/   
drawStringshowPage	beginText	textLinesdrawTextgetYr   drawOnsaveprint)	drawingspdfPathcr{   rn   drawing	docstringfuncnametextObjs	            r,   writePDFr    sW    ggsxx{+A.7GwAIIfQiLLS:; IIfQiA	A*2&Xs7JJLAF			&)B	RJ(67			&)BF++b!$)$	

7LLNq"a E! +3$ FFH	+
 r1   c                   *    \ rS rSrSrS rS rS rSrg)ShapesTestCasei  z$Test generating all kinds of shapes.c                 0    [        5       U l        / U l        g)z+Prepare some things before the tests start.N)r   r   r  selfs    r,   setUpShapesTestCase.setUp  s     45r1   c                 .    [        U R                  5        g)z0Do what has to be done after the tests are over.N)r  r  r  s    r,   tearDownShapesTestCase.tearDown#  s     	r1   c                 j    U R                    H#  nUSS S:X  d  M  [        XR                  5        M%     g)zMake a list of drawings.r   rY   r   N)r   r   r  )r  r+   s     r,   testAllDrawingsShapesTestCase.testAllDrawings-  s.     A2w,& !==1	  r1   )r  r   N)	__name__
__module____qualname____firstlineno____doc__r  r  r  __static_attributes__ r1   r,   r  r    s    * 2r1   r  c                  d    [         R                  " 5       n U R                  [        S5      5        U $ )z#Make a test suite for unit testing.r  )unittest	TestSuiteaddTestr  )suites    r,   	makeSuiter%  7  s)      E	MM.!234Lr1   __main__)rh   )NN)4__version__r  r!   r   ior   reportlab.libr   reportlab.lib.unitsr   reportlab.lib.utilsr   r   reportlab.pdfgen.canvasr   reportlab.pdfbase.pdfmetricsr	   r   r!  r/   r-   r0   reportlab.rl_configr2   rK   rV   r^   rk   rp   r}   r   r   r   r   r   *reportlab.graphics.widgets.signsandsymbolsr   r   r   r   r   r   r   r   r   r  TestCaser  r%  r  TextTestRunnerrunr  r1   r,   <module>r3     s    	     " < * 4 ' 	3 D / z  
6.0"("H'T.`>4 B6 .(9!D2X&& 2< z!!)+. r1   