
    \
jZ                        d Z ddlZddlZddlZddlZddlmZ  eedd          sWej        dk    r	ddlm	Z	 e	Z
nCej        dv r2dd	lmZ er!ej        d
         du r	ddlmZ eZ
nddlmZ eZ
nddlmZ eZ
nddlmZ eZ
d ZddZd Zd ZdZdS )aY  Load fonts.

pyglet will automatically load any system-installed fonts.  You can add additional fonts
(for example, from your program resources) using :meth:`add_file` or
:meth:`add_directory`. These fonts are then available in the same way as system-installed fonts::

    from pyglet import font
    font.add_file('action_man.ttf')
    action_man = font.load('Action Man', 16)
    # or
    from pyglet import resource
    resource.add_font('action_man.ttf')
    action_man = font.load('Action Man')

See the :mod:`pyglet.font.base` module for documentation on the base classes used
by this package.
    N)glis_pyglet_doc_runFdarwin)
QuartzFont)win32cygwin)WINDOWS_7_OR_GREATERadvanced_font_featuresT)Win32DirectWriteFont)GDIPlusFont)FreeTypeFontc                 6    t                               |           S )z1Check if specified system font name is available.)_font_class	have_font)names    N/DATA/AppData/hermes/venv/lib/python3.11/site-packages/pyglet/font/__init__.pyr   r   T   s      &&&    c                    |d}|d}t          |           t          t          fv r%| D ] }t                              |          r|}  n!d} t
          j        j        }t          |d          st          j
                    |_        g |_        |j        }|j        }	| |||||f}
|
|v r||
         S t          | |||||          }||_        ||_        ||_        ||_        ||_        |||
<   |	dd= |	                    d|           |S )a	  Load a font for rendering.

    :Parameters:
        `name` : str, or list of str
            Font family, for example, "Times New Roman".  If a list of names
            is provided, the first one matching a known font is used.  If no
            font can be matched to the name(s), a default font is used.  In
            pyglet 1.1, the name may be omitted.
        `size` : float
            Size of the font, in points.  The returned font may be an exact
            match or the closest available.  In pyglet 1.1, the size may be
            omitted, and defaults to 12pt.
        `bold` : bool
            If True, a bold variant is returned, if one exists for the given
            family and size.
        `italic` : bool
            If True, an italic variant is returned, if one exists for the given
            family and size.
        `dpi` : float
            The assumed resolution of the display device, for the purposes of
            determining the pixel size of the font.  Defaults to 96.

    :rtype: `Font`
    N   `   pyglet_font_font_cache)bolditalicstretchdpi   r   )typetuplelistr   r   r   current_contextobject_spacehasattrweakrefWeakValueDictionaryr   pyglet_font_font_holdsizer   r   r   r   insert)r   r&   r   r   r   r   nshared_object_space
font_cache	font_hold
descriptorfonts               r   loadr.   Y   sW   4 |
{ DzzeT]"" 	 	A$$Q''  D ,9&(@AA 75<5P5R5R2461$;J#9I dFGS9JZ*%% tTVWRUVVVD DIDIDKDLDH "Jz 	!""QKr   c                     t          | t                    rt          | d          } t          | d          r|                                 } t
                              |            dS )a  Add a font to pyglet's search path.

    In order to load a font that is not installed on the system, you must
    call this method to tell pyglet that it exists.  You can supply
    either a filename or any file-like object.

    The font format is platform-dependent, but is typically a TrueType font
    file containing a single font face. Note that to use a font added with this method,
    you should pass the face name (not the file name) to :meth::py:func:`pyglet.font.load` or any
    other place where you normally specify a font.

    :Parameters:
        `font` : str or file-like object
            Filename or file-like object to load fonts from.

    rbreadN)
isinstancestropenr"   r1   r   add_font_data)r-   s    r   add_filer6      s^    " $  D$tV yy{{d#####r   c                     t          j        |           D ]O}|dd                                         dk    r-t          t           j                            | |                     PdS )a/  Add a directory of fonts to pyglet's search path.

    This function simply calls :meth:`pyglet.font.add_file` for each file with a ``.ttf``
    extension in the given directory. Subdirectories are not searched.

    :Parameters:
        `dir` : str
            Directory that contains font files.

    Nz.ttf)oslistdirlowerr6   pathjoin)	directoryfiles     r   add_directoryr@      sc     
9%% 4 49??&&RW\\)T223334 4r   )r6   r@   r.   r   )NNFFFN)__doc__r9   sysr#   pygletr   getattrcompat_platformpyglet.font.quartzr   r   pyglet.libs.win32.constantsr	   optionspyglet.font.directwriter   pyglet.font.win32r   pyglet.font.freetyper   r   r.   r6   r@   __all__ r   r   <module>rN      sw  H $ 
			 



        ws'// #))111111 		#6	6	6DDDDDD 		&~674??HHHHHH2999999)555555%KK 	655555"' ' '
I I I IX$ $ $04 4 4  =r   