
    &h<                        S 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	  SSK
Jr  \R                  S:w  a  \R                  S:X  a  SSKrSSKr\" S5      r0 r0 rSqS	 rS
 rS rS rS rS rS rSS jrS rS rS r S r!SS jr"S r#SS jr$g)z5sysfont, used in the font module to find system fonts    N)basenamedirnameexistsjoinsplitext)Font
emscriptennt)z.ttfz.ttcz.otfFc                 2    SR                  S U  5       5      $ )z&create simple version of the font name c              3   n   #    U  H+  oR                  5       (       d  M  UR                  5       v   M-     g 7f)N)isalnumlower).0cs     F/var/www/auris/envauris/lib/python3.13/site-packages/pygame/sysfont.py	<genexpr>_simplename.<locals>.<genexpr>-   s      :diik917799ds   55)r   )names    r   _simplenamer   *   s     77:d:::    c                 &    X;  a  0 X@'   X4U    X4'   g)z0insert a font and style into the font dictionaryN )r   bolditalicfontfontdicts        r   _addfontr   0   s    #'TN4< r   c            	         [        [        R                  R                  SS5      S5      n 0 nSS/n[        R
                  [        R                  4 H  nU H  n [        R                  " X45      n[        [        R                  " U5      S   5       H  n [        R                  " XV5      u  pxn	[        U5      S   R                  5       [        ;  a  MC  [!        U5      (       d  [        X5      nUR#                  S5       H  n[%        XxU5        M     M     M     M     U$ ! [         a     M  f = f! [         a       M  f = f)z&initialize fonts dictionary on WindowsWINDIRz
C:\WindowsFontsz2SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fontsz/SOFTWARE\Microsoft\Windows\CurrentVersion\Fonts   &)r   osenvironget_winregHKEY_LOCAL_MACHINEHKEY_CURRENT_USEROpenKeyFileNotFoundErrorrangeQueryInfoKey	EnumValueOSErrorr   r   OpenType_extensionsr   split_parse_font_entry_win)
fontdirfontsmicrosoft_font_dirsdomainfont_dirkeyir   r   _s
             r   initsysfonts_win32r;   7   s+    2::>>(M:GDGE 	A=
 --w/H/HI+Hoof7 7//4Q78 %,$5$5c$=MD D>!$**,4GGt}}.D !JJsOD)$e< , 9 , J2 L+ %   s$   D"D3"
D0/D03
E	E	c                    SnSnU R                  U5      (       a  U R                  U5      R                  5       n U R                  5       R                  5       n S=pVU H  nXp;   d  M
  U R	                  U5        M     SU ;   a  U R	                  S5        SnSU ;   a  U R	                  S5        SnSR                  U 5      n [        U 5      n [        XXaU5        g)	z
Parse out a simpler name and the font style from the initial file name.

:param name: The font name
:param font: The font file path
:param fonts: The pygame font dictionary
z
(TrueType))demiboldnarrowlightunicodebtmtFr   Tr   r   N)endswithrstripr   r1   remover   r   r   )r   r   r4   true_type_suffixmodsr   r   mods           r   r2   r2   _   s     $AD}}%&&{{+,335::<DD;KK  ~F4H774=DtDTu-r   c                     [        U 5      n SnU H  nX@;   d  M
  U R                  US5      n M     S=pVSU ;   a  U R                  SS5      n SnSU ;   a  U R                  SS5      n Sn[        XXaU5        g)z
Parses a font entry for macOS

:param name: The filepath without extensions or directories
:param filepath: The full path to the font
:param fonts: The pygame font dictionary to add the parsed font data to.
)regularr   Fr   Tr   N)r   replacer   )r   filepathr4   rG   rH   r   r   s          r   _parse_font_entry_darwinrM   |   s     tDD;<<R(D  D~||FB'4||Hb)T51r   c            	         / SQn [         R                  " S5      nU(       a  U R                  SU S35        Sn[        U5      (       a.  U [         R                  " U5       Vs/ s H	  o2 SU 3PM     sn-  n 0 nU  Hc  n[        U5      (       d  M  [         R                  " U5      nU H2  n[        U5      u  pU	[        ;   d  M  [        U[        XW5      U5        M4     Me     U$ s  snf )N)/Library/Fontsz/Network/Library/Fontsz/System/Library/Fontsz"/System/Library/Fonts/SupplementalUSERz/Users/rO   z2/System/Library/Assets/com_apple_MobileAsset_Font3/)	r$   getenvappendr   listdirr   r0   rM   r   )
	locationsusernamestrange_rootlocr4   locationfilesfiler   	extensions
             r   _font_finder_darwinr]      s    I yy H78*N;<GLlL9QR9Q#au-9QRR	Eh

8$D&tnOD//(tH/CUK   L Ss   "C$c                      0 n SS/nU H   n[        U5      (       d  M  [        U5      n   O   [        U 5      S:X  a
  [        5       n U $ )z"Read the fonts on MacOS, and OS X.z/usr/X11/bin/fc-listz/usr/X11R6/bin/fc-listr   )r   initsysfonts_unixlenr]   )r4   fclist_locationsbin_locations      r   initsysfonts_darwinrc      sW     E 	  ),%l3E )
 5zQ#%Lr   c           	         0 n[         R                  S:X  a  U$  [        R                  " U SSSS/[        R                  [        R                  SSS9nUR
                  R                  S	S
5      R                  5        H  n [        X15        M     U$ ! [         a     M"  f = f! [         a    [        R                  " SU  S35         U$ [        R                   a    [        R                  " SU  S35         U$ [        R                   a>  n[        R                  " SU  SUR                   SUR                    35         SnAU$ SnAff = f)z6use the fc-list from fontconfig to get a list of fontsr	   :r[   familystyleTr"   )stdoutstderrchecktimeoutasciiignore'z<' is missing, system fonts cannot be loaded on your platformzProcess running 'z;' timed-out! System fonts cannot be loaded on your platformz' failed with error code z@! System fonts cannot be loaded on your platform. Error log is:
N)sysplatform
subprocessrunPIPErh   decode
splitlines_parse_font_entry_unix
ValueErrorr+   warningswarnTimeoutExpiredCalledProcessError
returncoderi   )pathr4   procentryes        r   r_   r_      sO   E
|||# ~~3'2????
4 [['':EEGE&u4 H L	  +  
vQR	
0 L) $$ 
v & 	
& L (( 
v.q||n =778xxjB	
 	
 L
s5   9B# B
B B #$E
-E:E3EEc                 `   U R                  SS5      u  p#n[        U5      S   R                  5       [        ;   au  SU;   nSU;   nSU;   nUR	                  5       R                  S5       H  nU(       d  M    O   [        [        U5      5      S   n[        [        U5      XV=(       d    UX!5        g	g	)
z
Parses an entry in the unix font data to add to the pygame font
dictionary.

:param entry: A entry from the unix font list.
:param fonts: The pygame font dictionary to add the parsed font data to.

re      r"   BoldItalicOblique,r   N)r1   r   r   r0   stripr   r   r   )	r   r4   filenamerf   rg   r   r   obliquer   s	            r   rv   rv      s     $kk#q1He!""$(;;U"u$LLN((-Dt . HX./2DT"D*;GXM <r   c                      Sn U  HA  nU H  nU[         ;   d  M  [         U   n  O   M#  U H  nU[         ;  d  M  U[        U'   M     MC     g)zcMap common fonts that are absent from the system to similar fonts
that are installed in the system
))	monospacez
misc-fixedcourier
couriernewconsolefixedmonofreemonobitstreamverasansmonoverasansmonomonotypelucidaconsoleconsolasdejavusansmonoliberationmono)sansarial	helveticaswissfreesansbitstreamverasansverasansverdanatahomacalibrigillsanssegoeuitrebuchetmsubuntu
dejavusansliberationsans)seriftimes	freeserifbitstreamveraserifroman
timesromantimesnewromandutch	veraserifgeorgiacambria
constantiadejavuserifliberationserif)	wingdingswingbats)comicsansms	comicsansN)SysfontsSysalias)alias_groups	alias_setr   founds       r   create_aliasesr     sT    6Ln "	Dx  
 D8#!&  "r   c                      [         (       a  g[        R                  S:X  a  [        5       n O)[        R                  S:X  a  [	        5       n O
[        5       n [        R                  U 5        [        5         Sq g)z
Initialise the sysfont module, called once. Locates the installed fonts
and creates some aliases for common font categories.

Has different initialisation functions for different platforms.
Nwin32darwinT)	is_initro   rp   r;   rc   r_   r   updater   )r4   s    r   initsysfontsr   V  sS     w
||w"$		!#%!#OOEGr   c                 |    [        X5      nU(       a  UR                  S5        U(       a  UR                  S5        U$ )z
pygame.font specific declarations

:param fontpath: path to a font.
:param size: size of a font.
:param bold: bold style, True or False.
:param italic: italic style, True or False.

:return: A font.Font object.
T)r   set_bold
set_italic)fontpathsizer   r   r   s        r   font_constructorr   n  s1     DdKr   c                 &   Uc  [         n[        5         S=pVSnU (       GaF  [        U [        [        45      (       a(  U R                  [        U [        5      (       a  SOS5      n U  H  n[        U[        5      (       a  UR                  5       n[        U5      n[        R                  U5      n	U	(       d  [        R                  U5      n	U	(       a  U	R                  S5      n
U	R                  X#45      nU(       dL  U
(       dE  [        U	R                  5       5      S   u  pU(       a  US   (       a  SnU(       a  US   (       a  SnOU(       d  U
nO	X:w  a  UnUnU(       d  M    O   S=pU(       a	  U(       d  SnU(       a	  U(       d  SnU" XqX5      $ )	a  pygame.font.SysFont(name, size, bold=False, italic=False, constructor=None) -> Font
Create a pygame Font from system font resources.

This will search the system fonts for the given font
name. You can also enable bold or italic styles, and
the appropriate system font will be selected if available.

This will always return a valid Font object, and will
fallback on the builtin pygame font if the given font
is not found.

Name can also be an iterable of font names, a string of
comma-separated font names, or a bytes of comma-separated
font names, in which case the set of names will be searched
in order. Pygame uses a small set of common font aliases. If the
specific font you ask for is not available, a reasonable
alternative may be used.

If optional constructor is provided, it must be a function with
signature constructor(fontpath, size, bold, italic) which returns
a Font instance. If None, a pygame.font.Font object is created.
NF   ,r   FFr   Tr"   )r   r   
isinstancestrbytesr1   rt   r   r   r&   r   listitems)r   r   r   r   constructorgotbold	gotitalicfontnamesingle_namestyles	plainnamerg   r   r   s                 r   SysFontr     sI   . &NGHdS%L))::ju&=&=d3GDK+u--)002%k2K\\+.F!k2"JJ~6	!::tn5 I )-V\\^(<Q(?%U a"&%($(	!(H*"G &Ix;  > "!HGi
xx<<r   c                  4    [        5         [        [        5      $ )zpygame.font.get_fonts() -> list
get a list of system font names

Returns the list of all found system fonts. Note that
the names of the fonts will be all lowercase with spaces
removed. This is how pygame internally stores the font
names for matching.
)r   r   r   r   r   r   	get_fontsr     s     N>r   c                 L   [        5         Sn[        U [        [        45      (       a(  U R	                  [        U [        5      (       a  SOS5      n U  H  n[        U[        5      (       a  UR                  5       n[        U5      n[        R                  U5      nU(       d  [        R                  U5      nU(       aY  U(       dR  UR                  X45      nU(       a  SnO-U(       a  SnO#U(       d  [        UR                  5       5      S   nU(       d  MR  U(       d  M    U$    U$ )av  pygame.font.match_font(name, bold=0, italic=0) -> name
find the filename for the named system font

This performs the same font search as the SysFont()
function, only it returns the path to the TTF file
that would be loaded. The font name can also be an
iterable of font names or a string/bytes of comma-separated
font names to try.

If no match is found, None is returned.
Nr   r   r   )r   r   r   r   r1   rt   r   r   r&   r   r   values)r   r   r   r   r   r   s         r   
match_fontr     s     NH$e%%zz*T5"9"9$sCk5))%,,.K!+.k*\\+.F!::tn5FD!#FMMO4Q7H h 8O+ * Or   )zfc-list)FFNr   )%__doc__r$   ro   rx   os.pathr   r   r   r   r   pygame.fontr   rp   r   winregr'   rq   	frozensetr0   r   r   r   r   r   r;   r2   rM   r]   rc   r_   rv   r   r   r   r   r   r   r   r   r   <module>r      s   ( < 	 
  = = <<<	ww$    89 
;(%P.:28>*)XN.D'N00F=R
'r   