
    ^j%#                        d Z ddlmZ ddlZddlZddlZddlmZmZm	Z	 ddl
Z
ddl
mZ ddlmZ erddlmZ d&d
Zd'dZd(dZ	 	 d)d*dZ eed d          s e            Zg Zd+d"Zd,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.
    )annotationsN)TYPE_CHECKINGBinaryIOIterable)gl)UserDefinedFontBase)Fontreturn
type[Font]c                     t           j        dk    r	ddlm}  | }nBt           j        dv r,ddlm} |rt           j        d         s	ddlm} |}nddl	m
} |}ndd	lm} |}|S )
zGet the appropriate class for the system being used.

    Pyglet relies on OS dependent font systems for loading fonts and glyph creation.
    darwinr   )
QuartzFont)win32cygwin)WINDOWS_7_OR_GREATERwin32_gdi_font)Win32DirectWriteFont)GDIPlusFont)FreeTypeFont)pygletcompat_platformpyglet.font.quartzr   pyglet.libs.win32.constantsr   optionspyglet.font.dwriter   pyglet.font.win32r   pyglet.font.freetyper   )r   _font_classr   r   r   r   s         O/home/agentuser/manim-venv/lib/python3.11/site-packages/pyglet/font/__init__.py_get_system_font_classr    !   s    
 ))111111 		#6	6	6DDDDDD 	&7G(H 	&??????.KK555555%KK555555"    fontr   Nonec                   t          | t                    sd}t          |          t          j        j        }t          |d          s&t          j                    |_	        g |_
        i |_        |j	        }|j
        }| j        | j        | j        | j        | j        | j        f}||v rd| d}t          |          t$                              | j                  rd| j         d}t          |          | j        t(          vrt(                              | j                   | ||<   |dd= |                    d	|            dS )
aa  Add a custom font created by the user.

    A strong reference needs to be applied to the font object,
    otherwise pyglet may not find the font later.

    Args:
        font:
            A font class instance defined by user.

    Raises:
        Exception: If font provided is not derived from :py:class:`~pyglet.font.user.UserDefinedFontBase`.
    z2Font must be created from the UserDefinedFontBase.pyglet_font_font_cachezA font with parameters z has already been created.zFont name 'z)' already exists within the system fonts.   Nr   )
isinstancer   	Exceptionr   current_contextobject_spacehasattrweakrefWeakValueDictionaryr%   pyglet_font_font_holdpyglet_font_font_name_matchnamesizeweightitalicstretchdpi_system_font_class	have_font_user_fontsappendinsert)r"   msgshared_object_space
font_cache	font_hold
descriptors         r   add_user_fontr@   9   sS    d/00 Bnn ,9&(@AA =5<5P5R5R2461:<7$;J#9I )TYT[$,PTPXYJZN
NNNnn##DI.. PDIPPPnny##49%%%!Jz 	!""Qr!   r0   strboolc                H    | t           v pt                              |           S )zWCheck if specified font name is available in the system database or user font database.)r8   r6   r7   )r0   s    r   r7   r7   g   s!    ;D"4">">t"D"DDr!   normalFstr | Iterable[str] | Noner1   float | Noner2   r3   
bool | strr4   r5   
int | Noner	   c                   |d}|d}t           j        j        }t          |d          s&t	          j                    |_        g |_        i |_        |j        }|j        }|j        }	t          | t          t          f          rft          | t                    rt          |           } | |	v r	|	|          } n5d}
| D ])}|t          v st                              |          r|}
 n*|
|	| <   |
} | |||||f}||v r||         S t          | |||||          }||_        ||_        ||_        ||_        ||_        |||<   |dd= |                    d|           |S )a!  Load a font for rendering.

    Args:
        name:
            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. The default font
            will be platform dependent.
        size:
            Size of the font, in points.  The returned font may be an exact
            match or the closest available.
        weight:
            If set, a specific weight variant is returned if one exists for the given font
            family and size. The weight is provided as a string. For example: "bold" or "light".
        italic:
            If True, an italic variant is returned, if one exists for the given family and size. For some Font
            renderers, italics may have an "oblique" variation which can be specified as a string.
        stretch:
            If True, a stretch variant is returned, if one exists for the given family and size.  Currently only
            supported by Windows through the ``DirectWrite`` font renderer. For example, "condensed" or "expanded".
        dpi: int
            The assumed resolution of the display device, for the purposes of
            determining the pixel size of the font.  Defaults to 96.
    N   `   r%   )r2   r3   r4   r5   r&   r   )r   r)   r*   r+   r,   r-   r%   r.   r/   r'   tuplelistr8   r6   r7   r1   r2   r3   r4   r5   r:   )r0   r1   r2   r3   r4   r5   r<   r=   r>   font_name_match
found_namenr?   r"   s                 r   loadrQ   l   s   6 |
{ ,9&(@AA =5<5P5R5R2461:<7$;J#9I)EO$&& dD!! 	;;D?"""4(DD J  ##'9'C'CA'F'F#!"JE $ %/OD!D ffgs;JZ*%% dDPW]`aaaD DIDKDKDLDH "Jz 	!""QKr!   is_pyglet_doc_runstr | BinaryIO | bytesc                    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.

    Args:
        font:
            Filename, file-like object, or bytes to load fonts from.

    rbreadN)r'   rA   openr+   rV   r6   add_font_data)r"   s    r   add_filerY      s^    " $  D$tV yy{{$$T*****r!   	directoryc                    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.

    Args:
        directory:
            Directory that contains font files.

    Nz.ttf)oslistdirlowerrY   pathjoin)rZ   files     r   add_directoryrc      sc     
9%% 4 49??&&RW\\)T223334 4r!   )rY   rc   r@   rQ   r7   )r
   r   )r"   r   r
   r#   )r0   rA   r
   rB   )NNrD   FFN)r0   rE   r1   rF   r2   rA   r3   rG   r4   rG   r5   rH   r
   r	   )r"   rS   r
   r#   )rZ   rA   r
   r#   )__doc__
__future__r   r]   sysr,   typingr   r   r   r   r   pyglet.font.userr   pyglet.font.baser	   r    r@   r7   rQ   getattrr6   r8   rY   rc   __all__ r!   r   <module>rm      sn   " # " " " " " 				 



  4 4 4 4 4 4 4 4 4 4        0 0 0 0 0 0 &%%%%%%   0+ + + +\E E E E
 \dTXQ Q Q Q Qh ws'// //11K+ + + +04 4 4 4  Nr!   