
    h87                        S SK JrJr  S SKrS SKrS SKrS SKJr  S SKJ	r	  S SK
r
S SKrS SKrS SKrS SKrS SKrS SKJrJrJrJrJrJrJrJrJrJrJrJr  S SKJrJ r J!r"J#r#J$r%  S SK&J'r'J(r(  \
RR                  " S5      SLr*S	 r+S
 r,S r-S r.\R^                  Ra                  \Rb                  S:H  =(       d    \*(       + SS9S 5       r2\R^                  Rg                  S/ SQ5      S 5       r4S r5S r6S r7S r8\R^                  Ra                  \Rb                  S:g  =(       d    \*(       + SS9S 5       r9S r:\R^                  Ra                  \Rb                  S:g  SS9S 5       r;S r<\R^                  Ra                  \=" \S5      (       + S S9S! 5       r>S" r?S# r@S$ rAS% rBS& rCS' rD\R^                  Ra                  \Rb                  S:H  S(S9S) 5       rES* rFS+ rGg),    )BytesIOStringION)Path)Image)findfontfindSystemFonts	FontEntryFontPropertiesfontManager	json_dump	json_loadget_fontis_opentype_cff_fontMSUserFontDirectories_get_fontconfig_fontsttfFontProperty)cbookft2fontpyplot
rc_contextfigure)subprocess_run_helpersubprocess_run_for_testingzfc-listc                     [        SSS/0S9   [        [        S/S95      n S S S 5        [        W 5      R                  S:X  d   e[        U 5      nUR                  5       n[        U5      S:X  d   eUS	   S
:X  d   eg ! , (       d  f       Na= f)Nfont.sans-serifcmmi10Bitstream Vera Sans)rc
sans-seriffamilyz
cmmi10.ttf   i"     )r   r   r
   r   namer   get_charmaplen)fontfilefontcmaps      T/var/www/html/env/lib/python3.13/site-packages/matplotlib/tests/test_font_manager.pytest_font_priorityr+      s    	,-/ 
0 N<.AB
0 >,... HDDt9:
0 
0s   A==
Bc                     S[         R                  " SS5      :X  d   eS[         R                  " SS5      :X  d   eS[         R                  " SS5      s=:  a  [         R                  " SS5      :  d   e   eS[         R                  " SS5      s=:  a  [         R                  " SS5      :  d   e   e[         R                  " SS5      [         R                  " SS5      :X  d   eg )Nr   regularboldi  normal)r   score_weight     r*   test_score_weightr3   (   s    ((I>>>>((8888((c2 7$$Xv67 8 7 8 7((9= 7$$Xv67 8 7 8 7$$Xy9$$S#./ 0 /r2   c                 `   [        [        U S-  5        [        U S-  5      n[        R                  " 5          [        R
                  " SS5        SS0SSS.SS	04 H7  n[        S0 UD6n[        R                  " US
S9UR                  US
S9:X  a  M7   e   S S S 5        g ! , (       d  f       g = f)Nzfontlist.jsonignorez findfont: Font family.*not foundr!   STIXGeneralr   i  )r!   weightzno such font familyF)rebuild_if_missingr1   )r   r   r   warningscatch_warningsfilterwarningsr
   r   )tmp_pathcopypropfps       r*   test_json_serializationr@   3   s     k8o56X/0D		 	 	"*LM. 5E 568D  '$'B((FMM"M?@ A @	8 
#	"	"s   ABB
B-c                  x   Sn [        U 5      R                  5       (       a  [        U 5      (       d   e[        R                   Hc  nSUR
                  ;   d  M  [        UR
                  S5       nUR                  S5      S:H  nS S S 5        W[        UR
                  5      :X  a  Mc   e   g ! , (       d  f       N.= f)Nz//usr/share/fonts/opentype/freefont/FreeMono.otfotfrb   s   OTTO)r   existsr   r   ttflistfnameopenread)rG   ffdress       r*   test_otfrM   B   s    =EE{#E****  AGGaggt$ggajG+ %.qww7777	 !$$s   .B++
B9	win32zno fontconfig installed)reasonc                  6    [        [        5       5      S:  d   eg )N   )r&   r   r1   r2   r*   test_get_fontconfig_fontsrR   M   s     $&'!+++r2   factor)   rD         c                    [        [        S/S95      n[        USS9nUR                  5         UR	                  SS5        UR                  S5        UR                  5       n[        XS9nUR                  5         UR	                  SS5        UR                  S5        [        R                  R                  UR                  5       USS	9  g )
Nr   r    rQ   )hinting_factor   d   abcg?)rtol)
r   r
   r   clearset_sizeset_textget_width_heightnptestingassert_allclose)rS   r(   font1expectedhinted_fonts        r*   test_hinting_factorrg   S   s    N<.9:DT!,E	KKM	NN2s	NN5%%'H47KS!JJ{;;=x$'  )r2   c                       [        S [        R                   5       5      n U R                  S:X  d   eg ! [         a    [
        R                  " S5         g f = f)Nc              3   p   #    U  H,  n[        UR                  5      R                  S :X  d  M(  Uv   M.     g7f)zseguisbi.ttfN)r   rG   r$   ).0entrys     r*   	<genexpr>#test_utf16m_sfnt.<locals>.<genexpr>i   s1      B(;uU[[)...@ U(;s   '6	6iX  z0Couldn't find seguisbi.ttf font to test against.)nextr   rF   r7   StopIterationpytestskip)rk   s    r*   test_utf16m_sfntrr   f   sZ    	# B(;(; B B ||s"""  HFGHs    5  AAc                     [        S/S9n [        [        U 5      5      R                  S:w  a  [        R
                  " S5        [        R                  " 5       u  pUR                  SSSU S9  S H  nUR                  [        5       US	9  M     g )
NzWenQuanYi Zen Heir    zwqy-zenhei.ttcz"Font wqy-zenhei.ttc may be missing      ?u   ⿓fontpropertiesrawsvgpdfpsformatr
   r   r   r$   rp   rq   pltsubplotstextsavefigr   )r?   figaxfmts       r*   test_find_ttcr   s   ss    	 34	5BHRL"2289llnGCGGB/GC*GIc* +r2   c                  *   [        SS/S9n [        [        U 5      5      R                  nUS;  a  [        R
                  " SU S35        [        R                  " 5       u  p#UR                  SSSU S	9  S
 H  nUR                  [        5       US9  M     g )NzNoto Sans CJK SCzNoto Sans CJK JPr    )zNotoSansCJKsc-Regular.otfzNotoSansCJK-Regular.ttcz,Noto Sans CJK SC font may be missing (found )rt   u   Hello, 你好ru   rw   r|   r~   )r?   r$   r   r   r   s        r*   test_find_notor   }   s    	 24FG	HB""DKKB4&JKllnGCGGCobG9*GIc* +r2   c                 F   [         R                  " [        5         [        U S-  5        S S S 5        [         R                  " [        5         [        [	        U S-  5      5        S S S 5        [         R                  " [        5         [        [        U S-  5      5        S S S 5        SSKJn  [         R                  " [        SS9   U" [        5       5        S S S 5        g ! , (       d  f       N= f! , (       d  f       N= f! , (       d  f       Ni= f! , (       d  f       g = f)Nznon-existent-font-name.ttfr   )FT2Fontzfont file or a binary-mode file)match)
rp   raisesFileNotFoundErrorr   strbytesmatplotlib.ft2fontr   	TypeErrorr   )r<   r   s     r*   test_find_invalidr      s    	(	)889 
* 
(	)X <<=> 
* 
(	)x">>?@ 
* +	y(I	J
 
K	J 
*	) 
*	) 
*	)
 
K	Js/   CC0DD
C-0
C>
D
D linuxz$only Linux with fontconfig installedc                 p  ^ Sm[        5       n[        U4S jU 5       5      (       a  [        R                  " T S35        U R	                  S5      nUR                  SS9  [        R                  " [        [        5      R                  T-  UR	                  T5      5        UR                  5        nUR                  S[        U 5      5        [        R                  " 5         [        5       n[        U4S jU 5       5      (       d   e S S S 5        [        R                  " 5         g ! , (       d  f       N$= f)	Nmpltest.ttfc              3   .   >#    U  H
  nTU;   v   M     g 7fNr1   rj   r(   font_test_files     r*   rl   (test_user_fonts_linux.<locals>.<genexpr>        
4ed>T!e    already exists in system fontsfontsT)dirXDG_DATA_HOMEc              3   .   >#    U  H
  nTU;   v   M     g 7fr   r1   r   s     r*   rl   r      s     <ed>T)er   )r   anyrp   rq   joinensureshutilcopyfiler   __file__parentcontextsetenvr   r   cache_clear)tmpdirmonkeypatchr   user_fonts_dirmr   s        @r*   test_user_fonts_linuxr      s     #N E

4e
444~&&EFG [[)Nd#
OODN))N:"''79 
			!	#f+.))+!<e<<<<< 
 %%' 
	s   1AD''
D5c                    ^ Sm[        [        5      R                  T-  n  [        R                  " U 5        U4S j[        R
                   5       u  n[        R
                  R                  U5        [        R
                   Vs/ s H'  nUR                  R                  T5      (       d  M%  UPM)     nnU H"  n[        R
                  R                  U5        M$     gs  snf ! [        R
                   Vs/ s H'  nUR                  R                  T5      (       d  M%  UPM)     Os  snf nnU H"  n[        R
                  R                  U5        M$     f = f)z/Smoke test that addfont() accepts pathlib.Path.r   c              3   l   >#    U  H)  nUR                   R                  T5      (       d  M%  Uv   M+     g 7fr   )rG   endswithr   s     r*   rl   'test_addfont_as_path.<locals>.<genexpr>   s,      :#64ZZ((8 $#6s   $4	4N)	r   r   r   r   addfontrF   removerG   r   )pathaddedr(   	to_remover   s       @r*   test_addfont_as_pathr      s
   "N>  >1D	-D!:;#6#6 :""5)&1&9&9 =&9d

++N; &9	 =D&&t, =k&9&9 =&9d

++N; &9 =	 =D&&t, s*   AC" $C,C"E5$D$D$#1EzWindows onlyc                  X  ^ [         R                  R                  S5      (       d:  [         R                  R                  S5      (       d  [        R                  " S5        [        R                  " S5        Sm[        5       n [        U4S jU  5       5      (       a  [        R                  " T S35        [        S   n[         R                  " U5        [        R                  " [        [        5      R                  T-  U5        [        5       n [        U4S	 jU  5       5      (       d   eg )
NAPPVEYORTF_BUILDznThis test should only run on CI (appveyor or azure) as the developer's font directory should remain unchanged.z4We need to update the registry for this test to workr   c              3   .   >#    U  H
  nTU;   v   M     g 7fr   r1   r   s     r*   rl   (test_user_fonts_win32.<locals>.<genexpr>   r   r   r   r   c              3   .   >#    U  H
  nTU;   v   M     g 7fr   r1   r   s     r*   rl   r      s     8%$~%%r   )osenvirongetrp   xfailr   r   rq   r   makedirsr   r=   r   r   r   )r   r   r   s     @r*   test_user_fonts_win32r      s    JJNN:&&"**..*D*D " 	# LLGH"N E

4e
444~&&EFG*1-N KK KKX%%6G E8%88888r2   c                     [         R                  " 5       u  pUR                  [        5       SS9  [         R                  " 5         g )Nrz   r|   )r   r   r   r   close)_r   r   s      r*   _model_handlerr      s*    llnGCKK	%K(IIKr2   register_at_forkz Cannot register at_fork handlersc                      [        S5        [        R                  " S5      n U R                  SS9 nUR	                  [         [        S5      5        S S S 5        g ! , (       d  f       g = f)Nr   forkrT   )	processes)r   multiprocessingget_contextPoolmaprange)ctxpools     r*   	test_forkr      sJ     1

%
%f
-C	A	$q* 
		s    A
A(c                    S/[         R                  S'   U R                  S5         [        S5        S S S 5        U R                   Vs/ s H  oR                  5       PM     snSS/:X  d   eg ! , (       d  f       NA= fs  snf )Nzthis-font-does-not-existr   WARNINGsanszFfindfont: Font family ['sans'] not found. Falling back to DejaVu Sans.zufindfont: Generic family 'sans' not found because none of the following families were found: this-font-does-not-exist)r   rcParamsat_levelr   records
getMessage)caplogrecs     r*   test_missing_familyr      sr    'A&BCLL"#		# 
$(.7NN7	'	B<    
$	#7s   A-A>-
A;c            	      z  ^^^	 SS K n SSKJm  SS KJm	  S nXl        SnU R                  U5      mUUU	4S jn[        U5       Vs/ s H  nU R                  USU 3U4S9PM     nnU H  nUR                  5         M     U H2  nUR                  SS	9  UR                  5       (       d  M)  [        S
5      e   g s  snf )Nr   )	LoadFlagsc                     [        S5      e)Nzerror in thread!)RuntimeError)argss    r*   loud_excepthook(_test_threading.<locals>.loud_excepthook  s    -..r2   
   c                    > TR                  SS9  [        S5       HG  nTR                  TR                  S5      5      nUR	                  [        U 5      STR                  S9  MI     g )N   timeoutrZ   zDejaVu Sansg        )flags)waitr   r   r   r_   r   
NO_HINTING)njr(   r   bfms      r*   bad_idea!_test_threading.<locals>.bad_idea	  sR    	qsA;;r{{=9:DMM#a&#Y-A-AMB r2   bad_thread_)targetr$   r   	   r   zthread failed to join)	threadingr   r   matplotlib.font_managerfont_manager
excepthookBarrierr   Threadstartr   is_aliver   )
r   r   Nr   r   threadstr   r   r   s
          @@@r*   _test_threadingr     s    ,(/ +
A!AC qA 	QC/@tL  
 		  	q::<<677 s   B8c                  L    [         R                  " S5        [        [        SS9  g )Nr   r   r   )rp   importorskipr   r  r1   r2   r*   test_fontcache_thread_safer    s    
$/26r2   c                 v    [        [        R                  SS/0 [        R                  ES[        U 5      0ESS9ng )Nz-czlimport matplotlib;import os;p = matplotlib.get_cachedir();os.chmod(p, 0o555);import matplotlib.font_manager;MPLCONFIGDIRT)envcheck)r   sys
executabler   r   r   )r<   procs     r*   test_lockfilefailurer  #  s>     &NN.	
 :rzz9>3x=9Dr2   c                     [        SS9n U R                  5       n[        R                  " [	        U5      5      nUR
                  S:  d   eUR                  S:  d   eU R                  5       nUR                  S5      (       d   eg )N	font-name)r$   r   z<img src="data:image/png;base64)	r	   
_repr_png_r   rH   r   widthheight_repr_html_
startswith)fontentpngimghtmls       r*   test_fontentry_dataclassr  9  sp    [)G



C
**WS\
"C99q==::>> D??=>>>>r2   c                      [         R                  " [        5         [        SSS9n U R	                  5         S S S 5        g ! , (       d  f       g = f)Nz/randomr  )rG   r$   )rp   r   r   r	   r  )r  s    r*   %test_fontentry_dataclass_invalid_pathr  E  s3    	(	))+> 
*	)	)s	   ?
AzLinux or OS onlyc                  $   S V s/ s H  n [         R                  " SU 5      PM     nn [        USS9n[        SS9n/ nX#-    H@  n [        R                  " U5      n[        U5      nUR                  UR                  5        MB     [        [        [        U5      5      5      n[        [        R                  " 5       5      n	[        U5      [        U	5      :X  d   e[        U5      [        U	5      :X  d   eX:X  d   eg s  sn f ! [         a     M  f = f)N)ttfr   r   )fontext)r   _get_data_pathr   r   r   r   appendr$   	Exceptionsortedlistsetr   get_font_namesr&   )
subdir	paths_mpl	fonts_mplfonts_system	ttf_fontsr   r(   r>   available_fontsmpl_font_namess
             r*   test_get_font_namesr0  K  s    ELMW6%%gv6WIM	59I"51LI(	??4(D"4(DTYY'	 ) T#i.12OK6689N3~#66663~#6666,,, N  		s   !C<<D
DDc                     ^  " S S5      mU4S jn U " 5         [         R                  " 5        H,  n[        UT5      (       d  M  [        R                  " S5        M.     g )Nc                       \ rS rSrSrg)/test_donot_cache_tracebacks.<locals>.SomeObjectia  r1   N)__name__
__module____qualname____firstlineno____static_attributes__r1   r2   r*   
SomeObjectr3  a  s    r2   r9  c                  t  > T" 5       n [         R                  " 5       nUR                  5       nUR                  SSSSS9  [	        5        n[
        R                  " 5          [
        R                  " S5        UR                  USS9  S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)Nrt   aardvarkdoesnotexistr    r5   rx   r|   )	mfigureFigurer   r   r   r9   r:   r;   r   )xr   r   outr9  s       r*   inner*test_donot_cache_tracebacks.<locals>.innerd  s    Lnn\\^RN;Y#((*''1C. + Y** Ys$   
B) 'BB)
B&	"B))
B7z#object from inner stack still alive)gcget_objects
isinstancerp   fail)rA  objr9  s     @r*   test_donot_cache_tracebacksrH  _  sD     / 
G~~c:&&KK=>  r2   c                      [         R                  " [        R                  5         [	        SS5        SSS5        [         R                  " [        R                  5         [	        SSS9  SSS5        [         R                  " [        R                  5         [	        S/5        SSS5        [	        SSS9  [	        SS9  [	        S5        [	        S5        [	        SS9  g! , (       d  f       N= f! , (       d  f       N= f! , (       d  f       Nc= f)	a;  
Test the deprecated API of FontProperties.__init__.

The deprecation does not change behavior, it only adds a deprecation warning
via a decorator. Therefore, the purpose of this test is limited to check
which calls do and do not issue deprecation warnings. Behavior is still
tested via the existing regular tests.
TimesitalicNr   )size)r!   styler    z"serif-24:style=oblique:weight=bold)rp   warnsmplMatplotlibDeprecationWarningr
   r1   r2   r*   $test_fontproperties_init_deprecationrQ  u  s     
c66	7w) 
8 
c66	7wR( 
8 
c66	7y! 
8
 '2'"778 >?7 
8	7 
8	7 
8	7s#   CC.C?
C+.
C<?
D)Hior   r   rC  r   r   pathlibr   PILr   r   r  r9   numpyra   rp   
matplotlibrO  r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r=  matplotlib.testingr   r   which
has_fclistr+   r3   r@   rM   markskipifplatformrR   parametrizerg   rr   r   r   r   r   r   r   r   hasattrr   r   r  r  r  r  r  r0  rH  rQ  r1   r2   r*   <module>r_     s     	  	    
    C C C C T S P \\)$D0
0A8 CLLG+=:~4  6,6, <0) 1)$
#+	+" CLLG+=:~A  C(C(2-  CLLG+NC9 D96 $677=  ?+?+	8B7,	? CLLG+4FG- H-&?,$@r2   