o
    OZh	                     @   s   d Z g dZddlmZmZmZ ddlmZmZm	Z
 ddlmZ ddlmZmZmZ ddlmZ G dd	 d	eZeZd
d Z	dddZ[[[dS )zDpygame module for loading and rendering fonts (freetype alternative))Fontinitquitget_default_fontget_initSysFont
match_font	get_fonts    )r   r   get_default_resolution)r   r   r   )_internal_mod_init)r   r   r   )encode_file_pathc                       s   e Zd ZdZeeZeeZee	 Z
dZdZd" fdd	Zd# fdd		Zd
d Zdd ZeeeZdd Zdd ZeeeZdd Zdd Zdd Zdd Zdd Zdd Zdd Zd d! Z  ZS )$r   a  Font(filename, size) -> Font
    Font(object, size) -> Font
    create a new Font object from a file (freetype alternative)

    This Font type differs from font.Font in that it can render glyphs
    for Unicode code points in the supplementary planes (> 0xFFFF).
         Nc                    s   t |d}t|trz| |t}W n ty   d}Y nw |}t|tr,|| jkr,d }|d u r?t|  d }|dkr>d}nd}t	 j
|||d d| _d| _d| _d| _d| _d	| _d S )
N    g      ?r	   )size
resolutiongUUUUUU?FTg      ?)max
isinstancestr_Font__encode_file_path
ValueErrorbytes_Font__default_fontint_Font__get_default_resolutionsuper__init__ZstrengthZkerningoriginpaducs4Zunderline_adjustment)selffiler   Zbfiler   	__class__ </var/www/auris/lib/python3.10/site-packages/pygame/ftfont.pyr   %   s.   


zFont.__init__c                    s~   |du rd}t |tr| j|v rtdt |tr"| j|v r"td| j}t|| _zt 	|||\}}|W || _S || _w )z]render(text, antialias, color, background=None) -> Surface
        draw text on a new SurfaceNr   z&A null character was found in the text)
r   r   _Font__unullr   r   _Font__bnullZantialiasedboolr   render)r"   textZ	antialiascolor
backgroundZsave_antialiaseds_r$   r&   r'   r+   >   s   
zFont.renderc                 C      t || _dS )zAset_bold(bool) -> None
        enable fake rendering of bold textN)r*   wider"   valuer&   r&   r'   set_boldR      zFont.set_boldc                 C      | j S )z>get_bold() -> bool
        check if text will be rendered bold)r2   r"   r&   r&   r'   get_boldX      zFont.get_boldc                 C   r1   )zEset_italic(bool) -> None
        enable fake rendering of italic textN)r*   obliquer3   r&   r&   r'   
set_italic`   r6   zFont.set_italicc                 C   r7   )zFget_italic() -> bool
        check if the text will be rendered italic)r;   r8   r&   r&   r'   
get_italicf   r:   zFont.get_italicc                 C   r1   )zQset_underline(bool) -> None
        control if text is rendered with an underlineN)r*   	underliner3   r&   r&   r'   set_underlinen   r6   zFont.set_underlinec                 C   r7   )zTget_underline() -> bool
        check if the text will be rendered with an underline)r>   r8   r&   r&   r'   get_underlinet   r:   zFont.get_underlinec                 C   s
   |  |S )zWmetrics(text) -> list
        Gets the metrics for each character in the passed string.)Zget_metricsr"   r,   r&   r&   r'   metricsz   s   
zFont.metricsc                 C      |   S )z6get_ascent() -> int
        get the ascent of the font)get_sized_ascenderr8   r&   r&   r'   
get_ascent      zFont.get_ascentc                 C   rC   )z8get_descent() -> int
        get the descent of the font)get_sized_descenderr8   r&   r&   r'   get_descent   rF   zFont.get_descentc                 C   s   |   |   d S )z6get_height() -> int
        get the height of the fontr   )rD   rG   r8   r&   r&   r'   
get_height   s   zFont.get_heightc                 C   rC   )zAget_linesize() -> int
        get the line space of the font text)Zget_sized_heightr8   r&   r&   r'   get_linesize   rF   zFont.get_linesizec                 C   s   |  |jS )zYsize(text) -> (width, height)
        determine the amount of space needed to render text)Zget_rectr   rA   r&   r&   r'   r      s   z	Font.size)Nr   N)__name__
__module____qualname____doc__staticmethodr   r   r
   r   r   r   r(   r)   r   r+   r5   r9   propertyboldr<   r=   italicr?   r@   rB   rE   rH   rI   rJ   r   __classcell__r&   r&   r$   r'   r      s.    


r   c                   C   s   t  S )z=get_init() -> bool
    true if the font module is initialized)	_get_initr&   r&   r&   r'   r      r:   r   Nc                 C   s    |du rdd }t | ||||S )a  pygame.ftfont.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.ftfont.Font object is created.
    Nc                 S   s"   t | |}|| || |S rK   )r   r5   r<   )Zfontpathr   rR   rS   Zfontr&   r&   r'   constructor   s   


zSysFont.<locals>.constructor)_SysFont)namer   rR   rS   rV   r&   r&   r'   r      s   r   )r	   r	   N)rO   __all__Zpygame._freetyper   r   Z_Fontr
   r   r   r   rU   r   Zpygame.sysfontr   r   r   rW   Zpygamer   ZFontTyper&   r&   r&   r'   <module>   s     

"