ó
6…6ic           @   s®  d  d l  Z y d  d l j j Z Wn n Xd  d l Z d  d l j j	 Z	 d  d l
 j j Z e	 j ƒ  d Z d Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d	 „  ƒ  YZ d
 „  Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d d e e e d d d i  d d „
 Z d d e e e d d d d i  d „
 Z d d e e e d d „ Z i  Z d „  Z i  Z i  Z i  Z d a  d „  Z! d „  Z" d „  Z# d e f d „  ƒ  YZ$ d S(   iÿÿÿÿNiÿ   i    t	   ImageFontc           B   s#   e  Z d  „  Z d „  Z d „  Z RS(   c         C   s  g  } | s | Sx§ | D]Ÿ } t  j ƒ  } t | ƒ | _ |  j | _ |  j | _ |  j j | d  ƒ } | d  k r‰ t
 d j | ƒ ƒ ‚ n  |  j | | _ |  j | | _ | j | ƒ q WxY t t | ƒ d ƒ D]A } |  j j | | | | d |  j ƒ } | | j | 7_ qÑ W| S(   Ns.   Character {0!r} not found in image-based font.i   (   t   textsupportt   Glypht   ordt	   charactert   heightt   ascentt   line_spacingt   widtht   gett   Nonet	   Exceptiont   formatt   advancet   appendt   ranget   lent   kernst   default_kern(   t   selft   st   rvt   ct   gR   t   it   kern(    (    s^   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\text\font.pyt   glyphs8   s$    (c         C   s   | S(   N(    (   R   R   t   bounds(    (    s^   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\text\font.pyR   V   s    c	         C   sý   | d  k r d  Sxæ | D]Þ }	 t |	 j ƒ }
 |  j |
 \ } } |	 j | | } |	 j | | |	 j } |  j |
 } t j	 j
 rß | t k s™ | t k rß t j j j | j ƒ  t ƒ } t j j j | | | | ƒ | } qß n  | j | | | f ƒ q Wd  S(   N(   R
   t   unichrR   t   offsetst   xt   yR   t   charst   renpyt   configt   recolor_sfontst   WHITEt   BLACKt   displayt   pgrendert   surfacet   get_sizet   Truet   modulet   twomapt   blit(   R   t   targett   xot   yot   colorR   t	   underlinet   strikethrought   black_colorR   R   t   cxot   cyoR   R   t	   char_surft   new_surf(    (    s^   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\text\font.pyt   drawY   s    (   t   __name__t
   __module__R   R   R9   (    (    (    s^   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\text\font.pyR    '   s   		t   SFontc           B   s   e  Z d  „  Z d „  Z RS(   c         C   sD   t  t |  ƒ j ƒ  | |  _ | |  _ | |  _ | |  _ | |  _ d  S(   N(   t   superR<   t   __init__t   filenamet
   spacewidthR   R   t   charset(   R   R?   R@   R   R   RA   (    (    s^   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\text\font.pyR>   s   s    				c         C   sÖ  i  |  _  i  |  _ i  |  _ i  |  _ t j j j |  j ƒ j	 d t
 ƒ } | j ƒ  \ } } | } | |  _ | |  _ t j j j |  j | f t
 ƒ |  j  d <|  j |  j d <|  j |  j d <d |  j d <t j j j d | f t
 ƒ |  j  d <d |  j d <d |  j d <d	 |  j d <|  j  d |  j  d <|  j d |  j d <|  j d |  j d <|  j d |  j d <d } x= t
 r¨| j | d f ƒ } | d d k r›Pn  | d 7} qlWd } x | | k  rÑ| t |  j ƒ k  rÑ| j | d f ƒ | k rÄ| } | d 7} x9 | | k  r9| j | d f ƒ | k r,Pn  | d 7} qW|  j | }	 | d 7} | j | d | | | f ƒ }
 t j j j |
 ƒ }
 |
 |  j  |	 <| | |  j |	 <| | |  j |	 <d
 |  j |	 <n  | d 7} q²Wd  S(   Nt   unscaledu    i    u   â€‹u   Â i   i   (   i    i    (   i    i    (   i    i    (   R    R   R   R   R!   R&   t   imt   ImageR?   t   loadR*   R)   R   t   baselineR'   R(   R@   t   get_atR   RA   t
   subsurfacet   scalet   surface_scale(   R   t   surft   swt   shR   R   t   keyt   cit   startR   t   ss(    (    s^   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\text\font.pyRE   ‚   sZ    				$		(%	$

(   R:   R;   R>   RE   (    (    (    s^   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\text\font.pyR<   q   s   	t	   MudgeFontc           B   s   e  Z d  „  Z d „  Z RS(   c         C   sD   t  t |  ƒ j ƒ  | |  _ | |  _ | |  _ | |  _ | |  _ d  S(   N(   R=   RR   R>   R?   t   xmlR@   R   R   (   R   R?   RS   R@   R   R   (    (    s^   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\text\font.pyR>   È   s    				c         C   s§  i  |  _  i  |  _ i  |  _ i  |  _ t j j j |  j ƒ j	 d t
 ƒ } t j t j j	 |  j ƒ j ƒ  ƒ } d } x| j d ƒ D]ö } t | j d ƒ } | d k  r­ q‚ n  t | ƒ } t | j d ƒ } t | j d ƒ } t | j d ƒ }	 t | j d ƒ }
 | j | | |	 |
 f ƒ } t j j j | ƒ } | |  j  | <|	 |  j | <|	 |  j | <d |  j | <t | |
 ƒ } q‚ W| |  _ | |  _ d	 |  j  k rõt j j j |  j | f t
 ƒ |  j  d	 <|  j |  j d	 <|  j |  j d	 <d |  j d	 <n  d
 |  j  k rW|  j  d	 |  j  d
 <|  j d	 |  j d
 <|  j d	 |  j d
 <|  j d	 |  j d
 <n  t j j j d | f t
 ƒ |  j  d <d |  j d <d |  j d <d |  j d <d  S(   NRB   i    t   chart   idR   R   R   R   u    u   Â u   â€‹(   i    i    (   i    i    (   i    i    (   R    R   R   R   R!   R&   RC   RD   R?   RE   R*   t   etreet
   fromstringt   loaderRS   t   readt   findallt   intt   attribR   RH   RI   RJ   t   maxR   RF   R'   R(   R@   (   R   RK   t   treeR   t   eRT   R   R   R   t   wt   hRQ   (    (    s^   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\text\font.pyRE   ×   sN    				$$		(%(   R:   R;   R>   RE   (    (    (    s^   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\text\font.pyRR   Æ   s   	c         C   s×   d } g  } t  } x„ |  D]| } | d k s | d k r= q n  | d k rr | rr | r | j | ƒ d } q q n  | d k r‹ | } q n  | | 7} q W| r¯ | j | ƒ n  t d „  | d Dƒ ƒ } | d | f S(	   Nt    s   s   
t    s   "c         s   s!   |  ] } | j  d  d ƒ Vq d S(   t   =i   N(   t   split(   t   .0R   (    (    s^   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\text\font.pys	   <genexpr>,  s    i   i    (   t   FalseR   t   dict(   t   lR`   t   linet   quoteR   t   map(    (    s^   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\text\font.pyt   parse_bmfont_line  s&    	t   BMFontc           B   s   e  Z d  „  Z d „  Z RS(   c         C   s    t  t |  ƒ j ƒ  | |  _ d  S(   N(   R=   Rn   R>   R?   (   R   R?   (    (    s^   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\text\font.pyR>   2  s    c         C   sÁ  i  |  _  i  |  _ i  |  _ i  |  _ i  |  _ d |  _ i  } t j j |  j	 ƒ } x®| D]¦} t
 | ƒ \ } } | d k r¥ t | d ƒ |  _ t | d ƒ |  _ qX | d k rç t j j j | d ƒ j d t ƒ | t | d ƒ <qX | d	 k rX t t | d ƒ ƒ } t | d
 ƒ } t | d ƒ } t | d ƒ }	 t | d ƒ }
 t | d ƒ } t | d ƒ } t | d ƒ } t | d ƒ } | | j | | |	 |
 f ƒ } t j j j | ƒ } | |  j  | <|	 | |  j | <| |  j | <| | f |  j | <qX qX W| j ƒ  d |  j  k rn|  j  d |  j  d <|  j d |  j d <|  j d |  j d <|  j d |  j d <n  t j j j d |  j f t ƒ |  j  d <d |  j d <d |  j d <d |  j d <d  S(   Ni    t   commont
   lineHeightt   baset   paget   fileRB   RU   RT   R   R   R   R   t   xoffsett   yoffsett   xadvanceu   Â u    u   â€‹(   i    i    (   R    R   R   R   R   R   R!   RX   RE   R?   Rm   R[   R   RF   R&   RC   RD   R*   R   RH   RI   RJ   t   closeR'   R(   (   R   t   pagest   fRi   t   kindt   argsR   R   R   R`   Ra   R/   R0   Rv   Rr   RQ   (    (    s^   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\text\font.pyRE   7  sR    						6
((   R:   R;   R>   RE   (    (    (    s^   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\text\font.pyRn   0  s   	t   ScaledImageFontc           B   s   e  Z d  Z d „  Z RS(   s;   
    Represents an imagefont scaled by a given factor.
    c   	         sI  ‡  f d †  ‰ ˆ | j  ƒ |  _  ˆ | j ƒ |  _ ˆ | j ƒ |  _ ‡ f d †  | j j ƒ  Dƒ |  _ ‡ f d †  | j j ƒ  Dƒ |  _ ‡ f d †  | j j ƒ  Dƒ |  _ ‡ f d †  | j j ƒ  Dƒ |  _ i  |  _ xl | j j ƒ  D][ \ } } | j	 ƒ  \ } } ˆ | ƒ } ˆ | ƒ } t
 j j j | | | f ƒ |  j | <qæ Wd  S(   Nc            s   t  t |  ˆ  ƒ ƒ S(   N(   R[   t   round(   t   n(   t   factor(    s^   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\text\font.pyRI   t  s    c            s%   i  |  ] \ } } ˆ  | ƒ | “ q S(    (    (   Rf   t   kt   v(   RI   (    s^   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\text\font.pys
   <dictcomp>{  s   	 c            s%   i  |  ] \ } } ˆ  | ƒ | “ q S(    (    (   Rf   R€   R   (   RI   (    s^   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\text\font.pys
   <dictcomp>|  s   	 c            s9   i  |  ]/ \ } } ˆ  | d  ƒ ˆ  | d ƒ f | “ q S(   i    i   (    (   Rf   R€   R   (   RI   (    s^   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\text\font.pys
   <dictcomp>}  s   	 c            s%   i  |  ] \ } } ˆ  | ƒ | “ q S(    (    (   Rf   R€   R   (   RI   (    s^   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\text\font.pys
   <dictcomp>~  s   	 (   R   RF   R   R   t	   iteritemsR   R   R   R    R)   R!   R&   RI   t   smoothscale(	   R   t   parentR   R€   R   R`   Ra   t   nwt   nh(    (   R   RI   s^   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\text\font.pyR>   r  s    """"	(   R:   R;   t   __doc__R>   (    (    (    s^   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\text\font.pyR|   m  s   i
   u^   !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~c
         C   se   |  d k s$ | d k s$ | d k r3 t d ƒ ‚ n  t | | | | |	 ƒ }
 |
 t |  | | | f <d S(   s~  
    :doc: image_fonts

    This registers an SFont with the given details. Please note that size, bold,
    italic, and underline are all advisory (used for matching), and do not
    change the appearance of the font.

    `More information about SFont. <http://www.linux-games.com/sfont/>`_

    `name`
        The name of the font being registered, a string.

    `size`
        The size of the font being registered, an integer.

    `bold`
        The boldness of the font being registered, a boolean.

    `italics`
        The italicness of the font being registered, a boolean.

    `underline`
        An ignored parameter.

    `filename`
        The file containing the sfont image, a string.

    `spacewidth`
        The width of a space character, an integer in pixels.

    `default_kern`
        The default kern spacing between characters, in pixels.

    `kerns`
        A map from two-character strings to the kern that should be used between
        those characters.

    `charset` - The character set of the font. A string containing characters in
        the order in which they are found in the image. The default character
        set for a SFont is::

            ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ?
            @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _
            ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~
    sO   When registering an SFont, the font name, font size, and filename are required.N(   R
   R   R<   t   image_fonts(   t   namet   sizet   boldt   italicsR2   R?   R@   R   R   RA   t   sf(    (    s^   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\text\font.pyt   register_sfont‰  s    1$c
         C   sq   |  d k s0 | d k s0 | d k s0 | d k r? t d ƒ ‚ n  t | | | | |	 ƒ }
 |
 t |  | | | f <d S(   ss  
    :doc: image_fonts

    This registers a MudgeFont with the given details. Please note that size,
    bold, italic, and underline are all advisory (used for matching), and do not
    change the appearance of the font.

    Please see the `MudgeFont home page <http://www.larryhastings.com/programming/mudgefont/>`_
    for the tool that creates MudgeFonts. Ren'Py assumes that character codes
    found in the MudgeFont xml file are unicode character numbers, and ignores
    negative character codes.

    `name`
        The name of the font being registered, a string.

    `size`
        The size of the font being registered, an integer.

    `bold`
        The boldness of the font being registered, a boolean.

    `italics`
        The italicness of the font being registered, a boolean.

    `underline`
        An ignored parameter.

    `filename`
        The file containing the MudgeFont image, a string. The image is usually
        a TGA file, but could be a PNG or other format that Ren'Py supports.

    `xml`
        The xml file containing information generated by the MudgeFont tool.

    `spacewidth`
        The width of a space character, an integer in pixels.

    `default_kern`
        The default kern spacing between characters, in pixels.

    `kerns`
        A map from two-character strings to the kern that should be used between
        those characters.
    sa   When registering a Mudge Font, the font name, font size, filename, and xml filename are required.N(   R
   R   RR   Rˆ   (   R‰   RŠ   R‹   RŒ   R2   R?   RS   R@   R   R   t   mf(    (    s^   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\text\font.pyt   register_mudgefontÁ  s    /0c         C   s&   t  | ƒ } | t |  | | | f <d S(   sÑ  
    :doc: image_fonts

    This registers a BMFont with the given details. Please note that size, bold,
    italic, and underline are all advisory (used for matching), and do not
    change the appearance of the font.

    Please see the `BMFont home page <http://www.angelcode.com/products/bmfont/>`_
    for the tool that creates BMFonts. Ren'Py expects that the filename
    parameter will be to a file in the BMFont text format, that describes a
    32-bit font. The Alpha channel should contain the font information, while
    the Red, Green, and Blue channels should be set to one. The image files,
    kerning, and other control information is read out of the BMFont file.

    We recommend including Latin and General Punctuation as part of your BMFont,
    to ensure all of the Ren'Py interface can render.

    `name`
        The name of the font being registered, a string.

    `size`
        The size of the font being registered, an integer.

    `bold`
        The boldness of the font being registered, a boolean.

    `italics`
        The italicness of the font being registered, a boolean.

    `underline`
        An ignored parameter.

    `filename`
        The file containing BMFont control information.
    N(   Rn   Rˆ   (   R‰   RŠ   R‹   RŒ   R2   R?   t   bmf(    (    s^   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\text\font.pyt   register_bmfont÷  s    &c   
      C   s´  |  t  k r t  |  S|  } d } d |  k rS |  j d d ƒ \ } }  t | ƒ } n  d  } y t j j |  ƒ } Wnþ t k
 rot j j	 s˜ t j j
 rpg  |  j d ƒ D] } | j ƒ  j ƒ  ^ q¨ } t j j ƒ  x– t j j j ƒ  D] } | d  k	 r[x` | j ƒ  D]O \ } } x6 | D]. } | j ƒ  j | ƒ rt | d ƒ } PqqW| rPqqWn  | ræ Pqæ qæ Wqpn X| d  k r”t d j | ƒ ƒ ‚ n  t j | | ƒ }	 |	 t  | <|	 S(   Ni    t   @i   t   ,t   rbs   Could not find font {0!r}.(   t
   face_cacheRe   R[   R
   R!   RX   RE   t   IOErrorR"   t	   developert   allow_sysfontst   stript   lowert   pygamet   sysfontt   initsysfontst   Sysfontst
   itervaluesR‚   t   endswithRs   R   R   t   ftfontt   FTFace(
   t   fnt   orig_fnt   indext	   font_fileR   t   fontsR   t   _flagst   ffnR   (    (    s^   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\text\font.pyt	   load_face$  s<    .
g      ð?c	      	   C   se  | d k r5 | t  k r5 t j ƒ  t j ƒ  | a  n  |  | | f }	 t j j j |	 |	 ƒ \ }  } } |  | | | f }
 t j |
 d  ƒ } | d  k	 rÚ | d k rÖ |
 t k rº t |
 } qÖ t
 | | ƒ } | t |
 <n  | S|  | | | | | | | | f	 }
 t j |
 d  ƒ } | d  k	 r| St |  ƒ } t j | t | | ƒ | | | | | | ƒ } | t |
 <| S(   Ng      ð?(   t
   last_scalet   scaled_image_fontst   cleart
   font_cacheR!   R"   t   font_replacement_mapR	   Rˆ   R
   R|   R«   R¢   t   FTFontR[   (   R¤   RŠ   R‹   RŒ   t   outlinet	   antialiast   verticalt   hintingRI   t   tRN   R   t   face(    (    s^   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\text\font.pyt   get_fontc  s.    

	!!.
c           C   s"   t  j ƒ  t j ƒ  t j ƒ  d S(   s    
    Clears the font cache.
    N(   R­   R®   R¯   R–   (    (    (    s^   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\text\font.pyt   free_memory  s    

c          C   s%   x t  j ƒ  D] }  |  j ƒ  q Wd  S(   N(   Rˆ   R    RE   (   R   (    (    s^   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\text\font.pyt   load_image_fontsš  s    t	   FontGroupc           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   sa   
    :doc: font_group
    :args: ()

    A group of fonts that can be used as a single font.
    c         C   s   g  |  _  i  |  _ g  |  _ d  S(   N(   R¨   t   cachet   patterns(   R   (    (    s^   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\text\font.pyR>   §  s    		c         C   s¨   t  | t ƒ s t | ƒ } n  t  | t ƒ s< t | ƒ } n  | | k  rW t d ƒ ‚ n  | |  j k ry |  j j | ƒ n  |  j j | ƒ } |  j j | | | f ƒ |  S(   sM  
        :doc: font_group

        Associates a range of characters with a `font`.

        `start`
            The start of the range. This may be a single-character string, or
            an integer giving a unicode code point.

        `end`
            The end of the range. This may be a single-character string, or an
            integer giving a unicode code point.

        When multiple .add() calls include the same character, the first call
        takes precedence.

        This returns the FontGroup, so that multiple calls to .add() can be
        chained together.
        sU   In FontGroup.add, the start of a character range must be before the end of the range.(   t
   isinstanceR[   R   R   R¨   R   R¦   R½   (   R   t   fontRP   t   endR¦   (    (    s^   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\text\font.pyt   add²  s    c         c   s  d } d } d } |  j  } xÞ | D]Ö } | j | d ƒ } | d k r± t | ƒ } xO |  j D]/ \ } }	 }
 |	 | k o‚ |
 k n r\ Pq\ q\ Wt d j | ƒ ƒ ‚ | | | <n  | | k rî | rß |  j | | | | !f Vn  | } | } n  | d 7} q" W|  j | | | f Vd S(   sK   
        Segments `s` into fonts. Generates (font, string) tuples.
        i    s*   Character U+{0:04x} not found in FontGroupi   N(   R¼   R	   R
   R   R½   R   R   R¨   (   R   R   t   markt   post	   old_indexR¼   R   R¦   R~   RP   RÀ   (    (    s^   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\text\font.pyt   segmentÙ  s(    		(   R:   R;   R‡   R>   RÁ   RÅ   (    (    (    s^   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\text\font.pyR»   Ÿ  s   		'(   iÿ   iÿ   iÿ   iÿ   (   i    i    i    iÿ   (%   t   pygame_sdl2Rœ   t   xml.etree.ElementTreeRV   t   ElementTreet   renpy.displayR!   t   renpy.text.ftfontt   textR¢   t   renpy.text.textsupportR   t   initR$   R%   t   objectR    R<   RR   Rm   Rn   R|   R
   Rg   RŽ   R   R’   R–   R«   Rˆ   R­   R¯   R¬   R¸   R¹   Rº   R»   (    (    (    s^   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\text\font.pyt   <module>   sB   
JUM	=65)	3	-	
	