
\c           @  s  d  d l  m Z 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   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 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(   t   print_functionNi   i    c         C  sT   |  d k r t  S|  d k r  t  S|  d k r0 t  S|  d k r@ t  S|  d k rP t  St S(   Ni   i   i   i`   i  (   t   Truet   False(   t   char(    (    sh   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\text\font.pyt   is_zerowidth)   s    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 | _ t | j  s |  j	 j
 | d   } | d  k r t d j |    n  |  j	 | | _	 |  j | | _ n d | _	 d | _ | 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    i   (   t   textsupportt   Glypht   ordt	   charactert   baselinet   ascentt   heightt   line_spacingR   t   widtht   gett   Nonet	   Exceptiont   formatt   advancet   appendt   ranget   lent   kernst   default_kern(   t   selft   st   rvt   ct   gR   t   it   kern(    (    sh   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\text\font.pyt   glyphsM   s*    		(c         C  s   | S(   N(    (   R   R    t   bounds(    (    sh   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\text\font.pyR!   q   s    c	         C  s  | d  k r d  Sx | D] }	 |	 j s, q n  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   R   t   unichrR	   t   offsetst   xt   yR   t   charst   renpyt   configt   recolor_sfontst   WHITEt   BLACKt   displayt   pgrendert   surfacet   get_sizeR   t   modulet   twomapt   blit(   R   t   targett   xot   yot   colorR    t	   underlinet   strikethrought   black_colorR   R   t   cxot   cyoR$   R%   t	   char_surft   new_surf(    (    sh   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\text\font.pyt   drawt   s     	(   t   __name__t
   __module__R    R!   R>   (    (    (    sh   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\text\font.pyR   <   s   	$	t   SFontc           B  s   e  Z d d   Z d   Z RS(   c         C  sM   t  t |   j   | |  _ | |  _ | |  _ | |  _ | |  _ | |  _ d  S(   N(	   t   superRA   t   __init__t   filenamet
   spacewidthR   R   t   charsetR
   (   R   RD   RE   R   R   RF   R
   (    (    sh   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\text\font.pyRC      s    					c         C  s
  i  |  _  i  |  _ i  |  _ i  |  _ t j j j |  j  j	 d t
  } | j   \ } } | } | |  _ |  j d  k r | |  _ n" |  j d k  r | |  j |  _ n  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} qWd } x | | k  r| t |  j  k  r| j | d f  | k r| } | d 7} x9 | | k  rm| j | d f  | k r`Pn  | d 7} q5W|  j | }	 | d 7} | j | d | | | f  }
 t j j j |
  }
 |
 |  j  |	 <| | |  j |	 <| | |  j |	 <d
 |  j |	 <n  | d 7} qWd  S(   Nt   unscaledi    u    u   ​u    i   i   (   i    i    (   i    i    (   i    i    (   R&   R   R   R#   R'   R,   t   imt   ImageRD   t   loadR   R/   R   R
   R   R-   R.   RE   t   get_atR   RF   t
   subsurfacet   scalet   surface_scale(   R   t   surft   swt   shR   R   t   keyt   cit   startR   t   ss(    (    sh   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\text\font.pyRJ      s`    				$	(%	$

N(   R?   R@   R   RC   RJ   (    (    (    sh   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\text\font.pyRA      s   t	   MudgeFontc           B  s   e  Z d    Z d   Z RS(   c         C  sD   t  t |   j   | |  _ | |  _ | |  _ | |  _ | |  _ d  S(   N(   RB   RV   RC   RD   t   xmlRE   R   R   (   R   RD   RW   RE   R   R   (    (    sh   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\text\font.pyRC      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(   NRG   i    R   t   idR$   R%   R   R   u    u    u   ​(   i    i    (   i    i    (   i    i    (   R&   R   R   R#   R'   R,   RH   RI   RD   RJ   R   t   etreet
   fromstringt   loaderRW   t   readt   findallt   intt   attribR"   RL   RM   RN   t   maxR   R
   R-   R.   RE   (   R   RO   t   treeR   t   eR   R   R$   R%   t   wt   hRU   (    (    sh   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\text\font.pyRJ      sN    				$$		(%(   R?   R@   RC   RJ   (    (    (    sh   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\text\font.pyRV      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   (    (    sh   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\text\font.pys	   <genexpr>Q  s    i   i    (   R   R   t   dict(   t   lRc   t   linet   quoteR   t   map(    (    sh   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\text\font.pyt   parse_bmfont_line8  s&    	t   BMFontc           B  s   e  Z d    Z d   Z RS(   c         C  s    t  t |   j   | |  _ d  S(   N(   RB   Rp   RC   RD   (   R   RD   (    (    sh   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\text\font.pyRC   W  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 r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 | d k rX t t | d   } t t | d   } t | d  |  j | | <qX qX W| j   d |  j  k r|  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   fileRG   RX   R   R$   R%   R   R   t   xoffsett   yoffsett   xadvancet   kerningt   firstt   secondt   amountu    u    u   ​(   i    i    (   R&   R   R   R#   R   R   R'   R[   RJ   RD   Ro   R^   R   R
   R,   RH   RI   R   R"   RL   RM   RN   t   closeR-   R.   (   R   t   pagest   fRk   t   kindt   argsR   R$   R%   Rc   Rd   R4   R5   Rx   Rt   RU   Rz   R{   (    (    sh   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\text\font.pyRJ   \  sZ    						6"
((   R?   R@   RC   RJ   (    (    (    sh   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\text\font.pyRp   U  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(    sh   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\text\font.pyRM     s    c           s%   i  |  ] \ } }   |  |  q S(    (    (   Ri   t   kt   v(   RM   (    sh   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\text\font.pys
   <dictcomp>  s   	 c           s%   i  |  ] \ } }   |  |  q S(    (    (   Ri   R   R   (   RM   (    sh   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\text\font.pys
   <dictcomp>  s   	 c           s9   i  |  ]/ \ } }   | d     | d  f |  q S(   i    i   (    (   Ri   R   R   (   RM   (    sh   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\text\font.pys
   <dictcomp>  s   	 c           s%   i  |  ] \ } }   |  |  q S(    (    (   Ri   R   R   (   RM   (    sh   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\text\font.pys
   <dictcomp>  s   	 (   R   R
   R   R   t	   iteritemsR   R#   R   R&   R/   R'   R,   RM   t   smoothscale(	   R   t   parentR   R   R   Rc   Rd   t   nwt   nh(    (   R   RM   sh   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\text\font.pyRC     s    """"	(   R?   R@   t   __doc__RC   (    (    (    sh   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\text\font.pyR     s   i
   u^   !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~c         C  sh   |  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.

    `baseline`
        The distance from the top of the font to the baseline (the invisible
        line letters sit on), an integer in pixels.  If this font is mixed with
        other fonts, their baselines will be aligned.  Negative values indicate
        distance from the bottom of the font instead, and ``None`` means the
        baseline equals the height (i.e., is at the very bottom of the font).

    `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   RA   t   image_fonts(   t   namet   sizet   boldt   italicsR7   RD   RE   R
   R   R   RF   t   sf(    (    sh   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\text\font.pyt   register_sfont  s    9$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   RV   R   (   R   R   R   R   R7   RD   RW   RE   R   R   t   mf(    (    sh   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\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(   Rp   R   (   R   R   R   R   R7   RD   t   bmf(    (    sh   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\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_cacheRh   R^   R   R'   R[   RJ   t   IOErrorR(   t	   developert   allow_sysfontst   stript   lowert   pygamet   sysfontt   initsysfontst   Sysfontst
   itervaluesR   t   endswithRu   R   R   t   ftfontt   FTFace(
   t   fnt   orig_fnt   indext	   font_fileR   t   fontsR   t   _flagst   ffnR   (    (    sh   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\text\font.pyt	   load_faceV  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   hintingRM   t   tRR   R   t   face(    (    sh   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\text\font.pyt   get_font  s.    

	!!.
c           C  s   t  j   t j   d S(   s    
    Clears the font cache.
    N(   R   R   R   (    (    (    sh   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\text\font.pyt   free_memory  s    
c          C  sF   x t  j   D] }  |  j   q Wx t j j D] }  t |   q. Wd  S(   N(   R   R   RJ   R'   R(   t   preload_fontsR   (   R   (    (    sh   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\text\font.pyt
   load_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   i  |  _  d  S(   N(   Rn   (   R   (    (    sh   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\text\font.pyRC     s    c         C  s  | d k r t | t  r] x^ | j j   D]+ \ } } | |  j k r+ | |  j | <q+ q+ Wn d |  j k r| | |  j d <n  |  St | t  s t |  } n  t | t  s t |  } n  | | k  r t d   n  x: t | | d  D]% } | |  j k r | |  j | <q q W|  S(   s  
        :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. If start is None, then the
            font is used as the default.

        `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.i   N(	   R   t
   isinstanceR   Rn   t   itemsR^   R   R   R   (   R   t   fontRT   t   endR   R   R   (    (    sh   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\text\font.pyt   add  s$    c         c  s   d } d } d } x | D] } t |  } |  j j t |  d  } | d k r |  j j d d  } | d k r t d j |    q n  | | k r | r | | | | !f Vn  | } | } n  | d 7} q W| | | 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   Rn   R   R   R   (   R   R   t   markt   post   old_fontR   R   R   (    (    sh   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\text\font.pyt   segment  s"    	(   R?   R@   R   RC   R   R   (    (    (    sh   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\text\font.pyR     s   		1(   i   i   i   i   (   i    i    i    i   ((   t
   __future__R    t   pygame_sdl2R   t   xml.etree.ElementTreeRY   t   ElementTreet   renpy.displayR'   t   renpy.text.ftfontt   textR   t   renpy.text.textsupportR   t   initR*   R+   R   t   objectR   RA   RV   Ro   Rp   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   (    (    (    sh   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\text\font.pyt   <module>   sF   
	T[M	A>5*	4	-			