
j$Zc           @   s  d  d l  Z  d  d l Z d  d l m Z m Z m Z m Z d  d l j j	 Z	 d  d l
 j j Z d  d l j j Z d  d l j j Z d  d l m Z m Z m Z m Z d e f d     YZ d   Z d e f d     YZ d	 e f d
     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d Z i  a i  a  i  a! i  a" d   Z# d   Z$ e j% j& j' d d  d d  Z( e j% j& j' d d d  d  Z) d e j% j* j+ f d     YZ, e	 j- Z- e j. Z. d S(   iN(   t   TAGt   TEXTt	   PARAGRAPHt   DISPLAYABLE(   t   log2vist   WRTLt   RTLt   ONt   Blitc           B   s/   e  Z d  Z d e e e e d  Z d   Z RS(   s   
    Represents a blit command, which can be used to render a texture to a
    render. This is a rectangle with an associated alpha.
    g      ?c
   
      C   sU   | |  _  | |  _ | |  _ | |  _ | |  _ | |  _ | |  _ | |  _ |	 |  _ d  S(   N(	   t   xt   yt   wt   ht   alphat   leftt   rightt   topt   bottom(
   t   selfR	   R
   R   R   R   R   R   R   R   (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyt   __init__)   s    								c         C   s(   d j  |  j |  j |  j |  j |  j  S(   Ns   <Blit ({0}, {1}, {2}, {3}) {4}>(   t   formatR	   R
   R   R   R   (   R   (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyt   __repr__8   s    (   t   __name__t
   __module__t   __doc__t   FalseR   R   (    (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyR   #   s   c         C   s7  |  j  d d    d } d } d } d } g  } x |  D] } | j } | j | j | d }	 | j }
 | j | j | d } | d 8} | |
 k r |
 } | } d } n  | }
 | | k r | } n  | | k r | } n  |	 } | j t | |
 |	 | | |
 | j d | j d | j	 d | j
 d	 | j  q8 W| S(
   s  
    Given a list of blits, adjusts it for the given outline size. That means
    adding borders on the left and right of each line of blits. Returns a second
    list of blit objects.

    We assume that there are a discrete set of vertical areas that divide the
    original blits, and that no blit covers two vertical areas. So something
    like:

     _____________________________________
    |_____________________________________|
    |___________|_________________|_______|
    |_____________________|_______________|

    is fine, but:

     _____________________________________
     |              |_____________________|
     |______________|_____________________|

    is forbidden. That's an invariant that the blit_<method> functions are
    required to enforce.
    t   keyc         S   s   |  j  |  j f S(   N(   R
   R	   (   t   b(    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyt   <lambda>V   s    i    i   i   R   R   R   R   (   t   sortR	   R   R
   R   t   appendR   R   R   R   R   R   (   t   blitst   outlinet   line_yt   top_yt   bottom_yt   max_xt   rvR   t   x0t   x1t   y0t   y1(    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyt   outline_blits<   s0    		
			Rt   DrawInfoc           B   s   e  Z d  Z RS(   s  
    This object is supplied as a parameter to the draw method of the various
    segments. It has the following fields:

    `surface`
        The surface to draw to.

    `override_color`
        If not None, a color that's used for this outline/shadow.

    `outline`
        The amount to outline the text by.

    `displayable_blits`
        If not none, this is a list of (displayable, xo, yo) tuples. The draw
        method adds displayable blits to this list when this is not None.
    (   R   R   R   (    (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyR+      s   t   TextSegmentc           B   sY   e  Z d  Z d	 d  Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z RS(
   sb   
    This represents a segment of text that has a single set of properties
    applied to it.
    c         C   s   | d k	 r | j |  _ | j |  _ | j |  _ | j |  _ | j |  _ | j |  _ | j |  _ | j |  _ | j	 |  _	 | j
 |  _
 | j |  _ | j |  _ | j |  _ | j |  _ | j |  _ | j |  _ n$ d |  _ d |  _ t |  _ t |  _ d S(   s   
        Creates a new segment of text. If `source` is given, this starts off
        a copy of that source segment. Otherwise, it's up to the code that
        creates it to initialize it with defaults.
        i    N(   t   Nonet	   antialiast   verticalt   fontt   sizet   boldt   italict	   underlinet   strikethrought   colort   black_colort	   hyperlinkt   kerningt   cpst   ruby_topt   ruby_bottomt   hintingR   (   R   t   source(    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyR      s*    			c         C   s   d j  |  j   S(   Ns   <TextSegment font={font}, size={size}, bold={bold}, italic={italic}, underline={underline}, color={color}, black_color={black_color}, hyperlink={hyperlink}, vertical={vertical}>(   R   t   __dict__(   R   (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyR      s    c         C   s%  | j  |  _  | j |  _ | j |  _ | j |  _ | j |  _ | j |  _ | j |  _ | j } t | t	  r | j
 |  |  _ n | j r d |  _ n	 d |  _ | j
 | j  |  _ | j |  _ | j |  _ d |  _ | j | j  |  _ | j t k rt j j j |  _ n  |  j | j |  _ d S(   sS   
        Takes the style of this text segment from the named style object.
        i   i    N(   R.   R/   R0   R1   R2   R3   R=   R4   t
   isinstancet   intt	   scale_intR5   R6   R7   R-   R8   t   scaleR9   t   slow_cpst   Truet   renpyt   gamet   preferencest   text_cpsR:   t   slow_cps_multiplier(   R   t   stylet   layoutR4   (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyt
   take_style   s*    				c      
   C   s   t  j |  j  |  j |  j |  j d |  j |  j |  j | j 	 } | j	 |  } |  j
 rm t j
 | |  j
  n  |  j r x | D] } |  j | _ q} Wn  |  j r t j |  n |  j r t j |  n  | S(   sN   
        Return the list of glyphs corresponding to unicode string s.
        i    (   R0   t   get_fontR1   R2   R3   R.   R/   R=   t
   oversamplet   glyphsR9   t   textsupportR8   R<   t   mark_ruby_bottomR;   t   mark_ruby_top(   R   t   sRL   t   foR%   t   g(    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyRP      s    ?				c   	   
   C   s   | j  r | j  } d } n |  j } |  j } t j |  j |  j |  j |  j | j	 |  j
 |  j |  j | j 	 } | j | j | | | | |  j |  j |  d S(   s+   
        Draws the glyphs to surf.
        N(   t   override_colorR-   R6   R7   R0   RN   R1   R2   R3   R    R.   R/   R=   RO   t   drawt   surfaceR4   R5   (	   R   RP   t   dit   xot   yoRL   R6   R7   RU   (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyRX      s    					Bc         C   s   t  j | |  j |  S(   s   
        Assigns times to the glyphs. `gt` is the starting time of the first
        glyph, and it returns the starting time of the first glyph in the next
        segment.
        (   RQ   t   assign_timesR:   (   R   t   gtRP   (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyR]     s    c         c   s   t  |  j t j  s$ |  | f Vd Si  } xk |  j j |  D]W \ } } | j | d  } | d k r t |   } | | _ | | | <n  | | f Vq= Wd S(   s/  
        This is called to break the current text segment up into multiple
        text segments. It yields one or more(TextSegement, string) tuples
        for each sub-segment it creates.

        This is used by the FontGroup code to create new text segments based
        on the font group.
        N(   R@   R0   t	   FontGroupt   segmentt   getR-   R,   (   R   RT   t   segst   ft   sst   seg(    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyt
   subsegment  s    
	c      
   C   sO   t  j |  j  |  j |  j |  j d |  j |  j |  j | j 	 } | j	 | |  S(   s7  
        Given an x, y, w, h bounding box, returns the union of the given
        bounding box and the bounding box the glyphs will actually be drawn
        into, not including any offsets or expansions.

        This is used to deal with glyphs that are on the wrong side of the
        origin point.
        i    (
   R0   RN   R1   R2   R3   R.   R/   R=   RO   t   bounds(   R   RP   Rg   RL   RU   (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyRg   2  s    
?N(   R   R   R   R-   R   R   RM   RP   RX   R]   Rf   Rg   (    (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyR,      s   		#					t   SpaceSegmentc           B   sA   e  Z d  Z d d d  Z d   Z d   Z d   Z d   Z RS(   sL   
    A segment that's used to render horizontal or vertical whitespace.
    i    c         C   sh   t  j   |  _ } d | _ d | _ | | _ | | _ | | _ | j rX | j | _ n  | j	 |  _	 d S(   sS   
        `ts`
            The text segment that this SpaceSegment follows.
        i    N(
   RQ   t   Glypht   glypht	   charactert   ascentt   line_spacingt   advancet   widthR8   R:   (   R   t   tsRo   t   heightRj   (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyR   E  s    						c         C   s
   |  j  g S(   N(   Rj   (   R   RT   RL   (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyRP   X  s    c         C   s   | S(   N(    (   R   RP   Rg   RL   (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyRg   [  s    c         C   s   d  S(   N(    (   R   RP   RZ   R[   R\   RL   (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyRX   ^  s    c         C   s3   |  j  d k r# | d |  j  7} n  | |  j _ | S(   Ni    g      ?(   R:   Rj   t   time(   R   R^   RP   (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyR]   b  s    (   R   R   R   R   RP   Rg   RX   R]   (    (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyRh   @  s   			t   DisplayableSegmentc           B   s;   e  Z d  Z d   Z d   Z d   Z d   Z d   Z RS(   sL   
    A segment that's used to render horizontal or vertical whitespace.
    c         C   sG   | |  _  | | } | j   \ |  _ |  _ | j |  _ | j |  _ d S(   sS   
        `ts`
            The text segment that this SpaceSegment follows.
        N(   t   dt   get_sizeRo   Rq   R8   R:   (   R   Rp   Rt   t   renderst   rend(    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyR   o  s
    	
c         C   s|   t  j   } | j |  j  } | j |  j  } d | _ d | _ | | _ | | _ | | _ |  j	 ru |  j	 | _	 n  | g S(   Ni    (
   RQ   Ri   RB   Ro   Rq   Rk   Rl   Rm   Rn   R8   (   R   RT   RL   Rj   R   R   (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyRP   }  s    						c         C   s   | d } | j  d  k	 r t j j j | j | j | j | j |  j	 j
    \ } } | j  j |  j	 | j | | j | | j f  n  d  S(   Ni    (   t   displayable_blitsR-   RF   t   displayt   coret   placeRo   Rl   Rm   Rt   t   get_placementR   R	   R
   Rr   (   R   RP   RZ   R[   R\   RL   Rj   (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyRX     s    
c         C   s4   |  j  d k r# | d |  j  7} n  | | d _ | S(   Ni    g      ?(   R:   Rr   (   R   R^   RP   (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyR]     s    c         C   s   | S(   N(    (   R   RP   Rg   RL   (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyRg     s    (   R   R   R   R   RP   RX   R]   Rg   (    (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyRs   j  s   				t   FlagSegmentc           B   s2   e  Z d  Z d   Z d   Z d   Z d   Z RS(   sf   
    A do-nothing segment that just exists so we can flag the start and end
    of a run of text.
    c         C   s   g  S(   N(    (   R   RT   RL   (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyRP     s    c         C   s   d  S(   N(    (   R   RP   RZ   R[   R\   RL   (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyRX     s    c         C   s   | S(   N(    (   R   R^   RP   (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyR]     s    c         C   s   | S(   N(    (   R   RP   Rg   RL   (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyRg     s    (   R   R   R   RP   RX   R]   Rg   (    (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyR}     s
   			t   Layoutc           B   sq   e  Z d  Z e e e d  Z d   Z d   Z d   Z	 d   Z
 d   Z d   Z d   Z d	   Z d
   Z RS(   s(   
    Represents the layout of text.
    c   8      C   s
  | rK t  j j rK t  j j j |  _ t  j j j |  _ t  j j j	 |  _
 n- d |  _ t  j j j |  _ t  j j j |  _
 | j } |  j | j  |  _ t |  _ t |  _ d |  _ d |  _ g  |  _ |  j |  } |  j |  } | |  _ | |  _ |  j |  \ }	 }
 } } } |	 |  _ |
 |  _ | |  _ | |  _ | |  _ | |  j 8} | |  j 8} d } d } g  } g  } g  } d } t } |  j | j  | | |  |  _! |  j | j"  } |  j | j#  } xt$ |  j!  D]\ } } t  j j% r|  j& |  \ } } n t } g  } g  } xf | D]^ \ } } | j' | |   } | | f } | j( |  | j( |  | j) |  | j) |  qW| r| j   x! | D] \ } } | j   qWn  |  j j( t* |   | rt+ j, | j | |  n| j- }  |  d k s
|  d k r t+ j. | t d  n |  d k rBt+ j. | t/ d  n |  d k r^t+ j0 |  n{ |  d k rt+ j. | t d	  nY |  d
 k rt+ j. | t d  n7 |  d k rt+ j. | t d  n t1 d j2 |     | j3 }! |! d k rt4 j5 | | | | | t  n |! d k s'|! d k rHt4 j5 | | | | | t/  n[ |! d k rrt+ j6 | | | | |  n1 |! d k rt+ j7 |  n t1 d j2 |!    x | D] \ } } |  j d k	 r|  j | k rd |  _ qqn  | |  j k rt/ } n  | rt+ j8 | d |  q| j8 | |  } qW| rHt+ j9 |  } n  t+ j: | d | |  }" |" | k ru|" } n  t+ j; | | |  j | j<  |  j | j=   \ }# } | j) |#  | j> s| } qqW|  j | j<  }$ | j< d k  r9t  j j? r| |$ t@ |  7} n | |$ 7} | | d jA | d _ n  |  j | jB  }% |% | |  j k rn|% |  j } n  tC jD |  } t+ jE | | | jF | jG  | r| j jH r|  j | jI d | j  }& |  j | jI d	 | j  }' t+ jJ | | |& | |' | | |  |& } |' } n  | |  j | |  j f \ }( }) }* |* |  _I | rOd S|  j rt+ jK | |  j | jL j  |( |)  n  d d | | f }+ x) | D]! \ } } | jM | |+ |   }+ qWtN |+ d d  |  _O tN |+ d	 d  |  _P tN |+ d | d  |  _Q tN |+ d | d  |  _R |( |  jO |  jQ 7}( |) |  jP |  jR 7}) i  |  _S tT   }, x*|  j D]\ }- }. }/ }0 |- |. f }1 |1 |  jS k rqdn  t  j jU jV |( |- |) |- f t/  }2 |2 |, _V |. |, _W |- |, _X |. d k rg  |  _Y |  jY |, _Y n	 d |, _Y xF | D]> \ } } | |  j k r+	Pn  | j | |, |  jO |  jP |   q	Wt  j j jZ |2  t  j j j[ |2  }3 |3 |  jS |1 <qdWt+ j\ |  |  _] | |  _^ |  j r	t+ j_ |  |  _` n	 g  |  _` t  j ja r{
|  jI \ }4 }5 |4 | k s	|5 | k r{
t  jb jc   \ }6 }7 t  j jd je d  t  j jd je d |6 |7  t  j jd je d | | |( |)  t  j jd je d | jf  q{
n  d S(   s^  
        `text`
            The text object this layout is associated with.

        `width`, `height`
            The height of the laid-out text.

        `renders`
            A map from displayable to its render.

        `size_only`
            If true, layout will stop once the size field is filled
            out. The object will only be suitable for sizing, as it
            will be missing the textures required to render it.

        `splits_from`
            If true, line-split information will be copied from this
            Layout (which must be another Layout of the same text).
        g      ?i    g        t   unicodet	   eastasians   korean-with-spacest   westerns   japanese-loosei   s   japanese-normali   s   japanese-stricti   s   Unknown language: {0}t   text   subtitles   tex-subtitlet   greedyt   nobreaks   Unknown layout: {0}iNt    s"   File "%s", line %d, text overflow:s+        Available: (%d, %d) Laid-out: (%d, %d)s        Text: %r(g   RF   t   configt   drawable_resolution_textRy   RX   t   draw_per_virtRO   t   draw_to_virtt   reverset   virt_to_drawt   forwardt   rendert   IDENTITYRK   RB   t   line_overlap_splitR   t   has_hyperlinkst   has_rubyR-   t   start_segmentt   end_segmentt   paragraph_glyphsRo   Rq   t   figure_outlinest   outlinest   xbordert   ybordert   xoffsett   yoffsetR`   t   tokenst
   paragraphst   first_indentt   rest_indentt	   enumeratet   rtlt   rtl_paragraphRP   R   t   extendt   listRQ   t   copy_splitst   languaget   annotate_unicodeRE   t   annotate_westernt	   ExceptionR   RL   t   texwrapt   linebreak_text   linebreak_greedyt   linebreak_nobreakR]   t   reverse_linest   place_horizontalt   place_verticalRm   t   line_leadingt   newline_indentt   broken_line_spacingt   lenR
   t	   min_widtht   matht   ceilt   align_and_justifyt
   text_alignt   justifyt   adjust_spacingR1   t   tweak_glyph_spacingt
   place_rubyt
   ruby_styleRg   t   maxt   add_leftt   add_topt	   add_rightt
   add_bottomt   texturesR+   t   pgrenderRY   RW   R    Rx   t   mutated_surfacet   load_texturet	   max_timest   max_timet   linest   hyperlink_areast
   hyperlinkst   debug_text_overflowt   exportst   get_filename_linet   to_logt   writet   text(8   R   R   Ro   Rq   Rv   t	   size_onlyt   splits_fromt   drawable_resRK   R   R   R   R   R   t   maxxR
   t
   all_glyphst   par_seg_glyphsR   R^   t   endedR   R   t   p_numt   pR   t
   par_glyphst
   seg_glyphsRp   RT   RP   t   tR   RL   R   t   lRm   R   t   target_xt   target_yt   swt   shR1   Rg   RZ   t   oR6   t   _xot   _yoR   t   surfR   t   owt   oht   filenamet   line(    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyR     sJ   														
		!!		6	$	$		(		&					#			c         C   s   | d  k r | S| |  j S(   N(   R-   RO   (   R   t   n(    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyRC     s    c         C   s'   | d  k r | St t | |  j   S(   N(   R-   RA   t   roundRO   (   R   R   (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyRB     s    c         C   sV   | d  k r | St | t j j j  r2 t |  S|  j d k  rE | S| t |  j  S(   Ni   (   R-   R@   RF   Ry   Rz   t   absoluteRA   RO   (   R   R   (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyt   scale_outline  s    
c         C   s   | |  j  | |  j  f S(   N(   RO   (   R   R	   R
   (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyt   unscale_pair'  s    c            s~  i  |  _  g  } g    t d+  } | j | _ | j d+ k sK | j t k r` t j j j	 | _ n  | j
 | |   | g   f d   }    f d   } x| D]\ }	 }
 |	 t k r |   | j    g    q na |	 t k r  j  d j |
   q n5 |	 t k r:  j t  d |
 |  d f  q n  |
 j d  \ } } } | r| d d k r j    sbt d |
   qbq | d	 k rt   }   j | d
 f  | |  _ q | d k rt   }   j | d
 f  | |  _ q | d k r|   | j    g    q | d k rf|  j t |   }   j t  d d | d f  q | d k r|  j t |   }   r| j    n  t  d d | d f g   | j    g    q | d k rq | d k rq | d k rq | d k rt |  _ | j d } | r6| |  } n | } | j } t |  j   d } | |  j  | <t j j  j!   | k rt j j  j" | k r| j# d  n | j# d  |   } | j$ } | j
 | |   | | _$ | | _% | j# |  q | d k rt |   _& q | d k r)t |   _' q | d k rq| rY|  j t |   |   _( qb|  j d  |   _( q | d k rt |   _) q | d k r|   } t* | _& t* | _' t* | _( t* | _) q | d
 k rt+ t j, j- |  } |   j
 | |   q | d k r| |   _. q | d k rf| d d k rQ|   j/ t |  7_/ qbt |  |   _/ q | d  k rt j0 j1 |  |   _1 q | d! k r|   } | d d k r| j1 j2 t3 |  } n9 | d d" k r| j1 j2 t3 | d  } n t3 |  } | j1 j4 |  | _1 q | d# k rF|  j5 t3 |   |   _6 q | d$ k r|   } | j$ } | j
 | j7 |   | | _$ t | _8 t |  _9 q | d% k rt |   _: q | d& k r|   } | d d" k r| j t3 | d  9_ qbt3 |  | _ q | d' k rt |   _$ q | d( k r?|   } t* | _$ q | d d) k rRq t d* |
   q W|   | j    | S(,   s   
        Breaks the text up into segments. This creates a list of paragraphs,
        which each paragraph being represented as a list of TextSegment, glyph
        list tuples.
        c             s!   t    d  }    j |   |  S(   s   
            Creates a new text segment, and pushes it onto the text segement
            stack. Returns the new text segment.
            i(   R,   R   (   Rp   (   t   tss(    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyt   pushC  s    c             sO   x.   D]& }  t  |  d t t t f  r d  Sq W  j  d j d   d  S(   Ni    iu    (   R@   R,   Rh   Rs   R   Rf   (   t   i(   R   R   (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyt   fill_empty_lineN  s    iu    t   =i    t   /s%   %r closes a text tag that isn't open.t   _startR   t   _endR   t   spaceRo   t   vspaceRq   R   t   fastt   nwt   ai   t   hover_t   idle_R   R   t   uRT   t   plainR0   R1   s   +-R6   R   t   *t   kt   rtt   rbR:   t   vertt   horizt   #s   Unknown text tag %rN(;   t   hyperlink_targetsR,   R-   RD   R:   RE   RF   RG   RH   RI   RM   R   R   R   R   Rf   R   Rs   t	   partitiont   popR   R}   R   R   RB   RA   Rh   R   t   hyperlink_functionst   prefixR   Ry   t   focust   get_focusedt   argumentt
   set_prefixR/   R8   R2   R3   R4   R5   R   t   getattrt   storeRK   R0   R1   t   easyR6   R   t   floatt   replace_opacityRC   R9   R   R;   R   R<   (   R   R   RK   Rv   t   text_displayableR   Rp   R   R   t   typeR   t   tagt   _t   valuet   fsRo   Rq   t   hyperlink_stylert   hlst
   old_prefixt   linkt
   vert_style(    (   R   R   s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyR`   *  s   			#
			&			-															c         C   sm   t  } g  } x< | D]4 \ } } t | |  \ } } | j | | f  q W| t k p` | t k } | | f S(   s  
        Given a paragraph (a list of segment, text tuples) handles
        RTL and ligaturization. This returns the reversed RTL paragraph,
        which differers from the LTR one. It also returns a flag that is
        True if this is an rtl paragraph.
        (   R   R   R   R   R   (   R   R   t	   directionR   Rp   RT   R   (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyR     s    c         C   s  | j  } | j } | r6 | r6 d g d d d d f Sg  } | r t | t  s] | g } n  xE | D]: \ } } | j d | j |  j |  |  j |  f  qd Wn  xN | D]F \ } } }	 }
 | j |  j |  | |  j |	  |  j |
  f  q Wd } d } d } d } x | D] \ } } } } | | } | | } | | } | | } | | k  rd| } n  | | k ry| } n  | | k  r| } n  | | k r| } qqW| j d  | | | | | | | f S(   s4  
        Return a list containing the outlines, including an outline
        representing the drop shadow, if we have one, also including
        an entry for the main text, with color None. Also returns the
        space reserved for outlines - to be deducted from the width
        and the height.
        i    N(   i    Ni    i    (   i    Ni    i    (   R   t   drop_shadowR-   R@   R   R   t   drop_shadow_colorR   (   R   RK   t   style_outlinest   dslistR   t   dsxt   dsyR1   R6   R[   R\   R   R   R   R   R   t   _cR	   R
   R   t   rR   R   (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyR   -  s>    			58



			c         C   s  |  j  \ } } g  } |  j s" | Sd } t } xJ |  j D]9 } | j | k rQ Pn  t | j | j |  j |  } q8 Wd } | r | j	 t
 d d | | d | d t d t d | d k  t } n  | d k r | S| } d }	 t }
 t } x | j D] } | j | k rq n  | | j d k r-t }
 n  | | j d k rIt } n  | j | j |	 k rr| j | j }	 n  | j | k  r | j } q q Wt | j | j |  j |  } | |	 k  r	| j	 t
 | | |	 | | | d |
 d | d | d | |  j d k  n  | S(   s   
        Given a st and an outline, returns a list of blit objects that
        can be used to blit those objects.

        This also sets the extreme points when creating a Blit.

        i    R   R   R   R   iN(   R1   R   RE   R   t   minR
   Rq   R   R-   R   R   R   RP   Rr   R	   Rn   (   R   t   stRo   t
   max_heightR%   t   max_yR   R   t   min_xR$   R   R   RV   t   ly(    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyt   blits_typewritere  sF    		$:			 Lc         C   s>   x7 |  j  D]( } | j s q
 n  | j | k r
 Pq
 q
 Wd Sd S(   sS   
        Return the time of the first glyph that should be shown after st.
        i    N(   R   RP   R   R-   (   R   R,  R   (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyt   redraw_typewriter  s    	(   R   R   R   R   R-   RE   R   RC   RB   R   R   R`   R   R   R1  R2  (    (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyR~     s    P							8	Di2   c           C   s   i  a  i  a i  a i  a d S(   s/   
    Clears the old and new layout caches.
    N(   t   layout_cache_oldt   layout_cache_newt   virtual_layout_cache_oldt   virtual_layout_cache_new(    (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyt   layout_cache_clear  s    c           C   s   t  a i  a  t  a i  a d S(   sN   
    Called once per interaction, to merge the old and new layout caches.
    N(   R4  R3  R5  R6  (    (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyt   layout_cache_tick  s    i    i   t   Textc           B   s:  e  Z d  Z d Z e Z e Z e Z d   Z	 d d d d d d  Z d   Z d   Z d   Z e d  Z d e e d  Z d	   Z d
   Z d   Z d   Z e Z d   Z d   Z d   Z e d  Z d   Z e d  Z d   Z d   Z d d d d d  Z d   Z d   Z  d   Z! d   Z" d   Z# RS(   sl  
    :doc: text
    :args: (text, slow=None, scope=None, substitute=None, slow_done=None, **properties)

    A displayable that displays text on the screen.

    `text`
        The text to display on the screen. This may be a string, or a list of
        strings and displayables.

    `slow`
        Determines if the text is displayed slowly, being typed out one character at the time.
        If None, slow text mode is determined by the :propref:`slow_cps` style property. Otherwise,
        the truth value of this parameter determines if slow text mode is used.

    `scope`
        If not None, this should be a dictionary that provides an additional scope for text
        interpolation to occur in.

    `substitute`
        If true, text interpolation occurs. If false, it will not occur. If
        None, they are controlled by :var:`config.new_substitutions`.
    i   c         C   s|   | d k  r d  |  _ n  | d k  rx t |  j t  sH |  j g |  _ n  d  |  _ t |  _ d  |  _ d  |  _	 t
 |  _ n  d  S(   Ni   i   (   R-   t   ctcR@   R   R   t   scopeR   t
   substitutet   startt   endRE   t   dirty(   R   t   version(    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyt   after_upgrade  s    				c   	      K   st  t  t |   j |   t | t  s1 | g } n  x] | D]U } t | t t j j j	 f  s8 t j
 j r t d j |    q d g } Pq8 q8 W| |  _ t |  _ d  |  _ |  j | | |  t j j s t j j j r t } n  | |  _ d  |  _ d  |  _ d  |  _ d  |  _ | d  k	 r[| j |  _ | j |  _ | j |  _ | j |  _ | j |  _ n  d  |  _ |  j |  _ d  S(   Ns   Cannot display {0!r} as text.R   (    t   superR9  R   R@   R   t
   basestringRF   Ry   Rz   t   DisplayableR   t	   developerR   R   R<  RE   R?  R-   R   t   set_textRG   t   less_updatesRH   t   self_voicingR   t   slowt	   slow_doneR:  R=  R>  t   displayablest   _duplicatable(	   R   R   RI  R;  R<  RJ  t   replacest
   propertiesR   (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyR     s8    											c         C   s*   |  j  r& |  j |  } | j   | S|  S(   N(   RL  t   _copyt   unique(   R   t   argsR%   (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyt
   _duplicateO  s
    	
c         C   sf   |  j  s |  S|  j   } | j d  k	 rP g  | j D] } | j   ^ q2 | _ n  d  | _ t | _ | S(   N(   t   _uses_scopeRO  RK  R-   t   _in_current_storeRJ  RE   t   locked(   R   R%   R   (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyRT  X  s    	(		c         C   s   d } xQ |  j  D]F } t | t  r2 | | 7} n  t |  d k r | d  d } Pq q W| j d d  j d d  j d	 d
  } d j |  S(   NR   i   i   u   …s   \s   \\s   "s   \"s   
s   \nu	   Text "{}"(   R   R@   RC  R   t   replaceR   (   R   RT   R   (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyt   __unicode__f  s    *c         C   s)   |  j  r t S|  j |  j | |  j |  S(   s=   
        Called to update the scope, when necessary.
        (   RU  R   RF  t   text_parameterR<  (   R   R;  t   update(    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyt   _scopet  s    	c   
      C   sH  |  j  r d  S|  j } t | t  s1 | g } n  | |  _ g  } t } x | D] } t | t  r | t k	 r t j j	 | | |  \ } }	 | p |	 } n  t | t
  r t | d d  } q t |  } n  | j |  qM W| |  _ | | k r t S| rD| |  _ |  j sDt |  _ | d  k	 rAt j j j |  d  qAqDn  t S(   Ns   utf-8RV  i    (   RU  R   R@   R   RX  R   RC  RF   t   substitutionsR<  t   strR   R   RS  R?  RE   R-   Ry   R   t   redraw(
   R   R   R;  R<  RY  t   old_textt   new_textt
   uses_scopeR   t   did_sub(    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyRF  ~  s6    							c         C   s   | |  _  t |  _ d  S(   N(   R:  RE   R?  (   R   R:  (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyt   set_ctc  s    	c         C   s  t  |  _ |  j   |  j } |  j d k	 r| d |  j  } | d |  j |  j !} | d |  j } | rw | d } n  | r d | } n  g  } | r | j |  n  | j |  |  j d k	 r | j |  j  n  | r | j |  n  | j	 | d  | } n" |  j d k	 r'| j |  j  n  |  j
 |  } t j j sTt j j d k	 rf|  j |  } n  |  j |  \ |  _ |  _ d S(   sy   
        This needs to be called after text has been updated, but before
        any layout objects are created.
        i    s   {_start}s   {_end}i   N(   R   R?  t   kill_layoutR   R=  R-   R>  R   R:  R   t   tokenizeRF   R   t   custom_text_tagst   replace_textt   apply_custom_tagst   get_displayablesR   RK  (   R   R   t   start_stringt
   mid_stringt
   end_stringt
   text_splitR   (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyRY    s6    	
		c         C   s2   |  j  s |  j d  k r% |  j   n  t |  j  S(   N(   R?  RK  R-   RY  R   (   R   (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyt   visit  s    c         C   s   g  } x3 |  j  D]( } t | t  s+ q n  | j |  q Wd j |  } | j d  \ } } } t j j j	 |  } |  j
 j } | d  k	 r t j j | d i | d 6d } n  | S(   NR   s   {fast}R;  R   i    (   R   R@   RC  R   t   joint
   rpartitionRF   t   translationt   dialoguet   notags_filterRK   t   altR-   R[  R<  (   R   R%   R   R  Rs  (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyt   _tts  s    &c         C   sP   t  |   } t j | d  t j | d  t j | d  t j | d  d S(   s]   
        Kills the layout of this Text. Used when the text or style
        changes.
        N(   t   idR3  R  R-   R4  R5  R6  (   R   R   (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyRc    s
    c         C   sC   t  |   } t j | d  } | d k r? t j | d  } n  | S(   s>   
        Gets the layout of this text, if one exists.
        N(   Ru  R4  Ra   R-   R3  (   R   R   R%   (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyt
   get_layout  s
    c         C   sC   t  |   } t j | d  } | d k r? t j | d  } n  | S(   s>   
        Gets the layout of this text, if one exists.
        N(   Ru  R6  Ra   R-   R5  (   R   R   R%   (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyt   get_virtual_layout*  s
    c         C   s~   |  j    } |  j   t j j j |  d  | d k r< d S|  j j d } | j	 j
 t j j j d  } | rz | |  Sd S(   s6   
        Called when a hyperlink gains focus.
        i    Ni   (   Rv  Rc  RF   Ry   R   R]  R-   RK   R  R	  Ra   R  R  (   R   t   defaultRL   t   hyperlink_focust   target(    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyR  8  s    
c         C   s<   | |  j  j k r |  j   n  t t |   j | |  d  S(   N(   RK   R  Rc  RB  R9  t   set_style_prefix(   R   R  t   root(    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyR{  K  s    c         C   sD   |  j    t j j j |  d  |  j j d } | r@ | d  Sd S(   sV   
        Called when a hyperlink loses focus, or isn't focused to begin with.
        i    i   N(   Rc  RF   Ry   R   R]  RK   R  R-   (   R   Rx  Ry  (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyt   unfocusQ  s
    
c         C   s,   t  |  _ |  j r( |  j   d |  _ n  d S(   s/   
        Called when slow is finished.
        N(   R   RI  RJ  R-   (   R   R,  (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyt   call_slow_done^  s    		
c         C   sT  |  j  r[ t j j j | d  r[ |  j j rF |  j |  t |  _  n  t j j	 j
    n  |  j   } | d k rw d Sx[ | j D]P \ } } } }	 | j | | | | j | | | j |  }
 |
 d k	 r |
 Sq W|  j   rPt j j j | d  rP|  j j d } | d k	 rP| j j t j j j d  } |  j j d |  }
 |
 Sn  d S(   sD   
        Space, Enter, or Click ends slow, if it's enabled.
        t   dismissNt   button_selecti   (   RI  RF   Ry   t   behaviort	   map_eventRK   t   slow_abortableR~  R   Rz   t   IgnoreEventRv  R-   Rx   t   eventR   R   t
   is_focusedR  R	  Ra   R  R  (   R   t   evR	   R
   R,  RL   Rt   R[   R\   R  R%   t   clickedRz  (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyR  i  s&    !.i   i    c         C   s   |  j  s |  j d k r% |  j   n  i  } x< |  j D]1 } t j j j | | |  j j | |  | | <q5 Wt	 |  | | | d t
 } | j | j   S(   s   
        Attempts to figure out the size of the text. The parameters are
        as for render.

        This does not rotate vertical text.
        R   N(   R?  RK  R-   RY  RF   Ry   R   RK   R1   R~   RE   R   (   R   Ro   Rq   R,  t   atRv   R   RL   (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyR1     s    /c         C   s#   |  j    } | d k r d S| j S(   sd   
        Returns the amount of time, in seconds, it will take to display this
        text.
        g        N(   Rv  R-   R   (   R   RL   (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyt   get_time  s    c   )      C   s  |  j  j r | | } } n  |  j d  k rO |  j  j rC t |  _ qO t |  _ n  |  j sg |  j d  k rt |  j	   n  i  } x< |  j D]1 } t
 j j j | | |  j  j | |  | | <q W|  j   } | d  k s | j | k s | j | k rBt |  | | | d t d t } t t  t k r/t j   n  | t t |   <n  |  j   } | d  k sx| j | k sx| j | k rt |  | | | d | } t t  t k rt j   n  | t t |   <n  | j \ }	 }
 | j \ } } |  j s3t d d | | j | | j d t d t d t d t g } d  } n | j |  } | j |  } t
 j j j |	 |
  } t
 j j  rt
 j j j |	 |
  } | j! d  | j" | _# | j# | _" | j$ | d  n  x| j% D] \ } } } } | j& | | f } | rt' | |  } n | } x| D]} | j( } | j) } | j* } | j+ } | d k  re| | j( 7} d } n  | d k  r| | 7} d } n  | | | k r| | } n  | | | k r| | } n  | d k s| d k rqn  | j, r| | j- 7} | | 7} n  | j. r"| | j/ 7} | | 7} n  | j0 r;| | j1 7} n | | j1 7} | j2 ra| | j3 7} n | | j3 7} | j4 | j5 | | | | f  | j6 | | | j7 | | j1 | | | j8 | | j3   qWqW| j9 rt
 j j j | |  } | j" | _# | j# | _" x` | j9 D]U \ } } } } |  j rC| | k rCqn  | j4 | | | | j7 | | j8 f  qW| j$ | d  n  xz | j: D]o \ } }  }! }" }# | j6 |  | j7 |! | j8  \ }$ }% | j6 |" |#  \ }& }' | j; |  | |$ |% |& |'  qW|  j r=| d  k	 r-t
 j j j< |  |  q=|  j= |  n  | j# | _# | j" | _" |  j  j rt
 j j j | j | j  }( t> |( _# t? |( _" |( j$ | | j d f  |( } n  | S(   NR   R   R   i    R   R   R   R   i   i    (   i   i    i    i    (   i    i    (   i    i    (@   RK   R/   RI  R-   RD   RE   R   R?  RK  RY  RF   Ry   R   R1   Rw  Ro   Rq   R~   R   R6  t   LAYOUT_CACHE_SIZEt   clearRu  Rv  R4  R   R   R   R1  R2  t   RenderR   t   draw_virtual_text_boxt   fillR   R   t   blitR   R   R*   R	   R
   R   R   R   R   R   R   R   R   R   R   t   absolute_blitt
   subsurfaceR   R   R   Rx   R   t	   add_focusR]  R~  t   VERT_FORWARDt   VERT_REVERSE()   R   Ro   Rq   R,  R  Rv   R   t   virtual_layoutRL   t   vwt   vhR   R   R   R]  R%   R  R   R6   R[   R\   R   t   oblitsR   t   b_xt   b_yt   b_wt   b_ht   drendRt   R   R8   t   hxt   hyt   hwt   hht   h_xt   h_yt   h_wt   h_ht   vrv(    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyR     s    /*!*	>						
					(	,& 				c         C   s   g  } x | D] } t  | t  r; | j t j |   q t  | t  ri | j t j t |    q t  | t j j j	  r | j
 t | f  q t d j |    q W| S(   s9   
        Convert the text into a list of tokens.
        s   Can't display {0!r} as Text.(   R@   R   R   RQ   Rd  R\  RF   Ry   Rz   RD  R   R   R   R   (   R   R   R   R   (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyRd  V  s    c         C   s  g  } x| r| j  d  } | \ } } | t k rj t j j rj | j t t t j j |   f  q	 | t k r | j |  q	 | j d  \ } } } t j j	 j
 | d  }	 |	 d k r | j |  q	 n  g  }
 d | } d } x | r| j  d  } | \ } } | t k rr| j d  \ } } } | | k rL| d 7} qr| | k rr| d 8} | soPqoqrn  |
 j |  q W| rt d j |    n  |	 | | |
  } g  } xE | D]= \ } } t | t  rt |  } n  | j | | f  qW| j |  | } q	 W| S(   s3   
        Apply new-style custom text tags.
        i    R   R   i   s2   Text ended while the '{}' text tag was still open.N(   R  R   RF   R   Rf  R   R   R    R
  Re  Ra   R-   R   R   R@   R\  R   (   R   R   R%   R   t   kindR   R  R  R  t   funct   contentst   closet   countt   t2t   kind2t   text2t   tag2t   new_contentst
   new_tokens(    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyRg  m  sN    	(
	


c         C   s   t    } g  } x | D] } | \ } } | t k rT | j |  | j |  q n  | t k r | j d  \ } } }	 | d k r t j j |	  }
 | j |
  | j t |
 f  q q n  | j |  q W| | f S(   s   
        Goes through the list of tokens. Returns the set of displayables that
        we know about, and an updated list of tokens with all image tags turned
        into displayables.
        R   t   image(	   t   setR   t   addR   R    R
  RF   R  t   displayable(   R   R   RK  R  R   R  R   R  R  R  Rt   (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyRh    s"    		N($   R   R   R   t   __version__RE   RS  R   RL  RU  RA  R-   R   RR  RT  RW  RZ  RF  Rb  RY  Rm  Rt  t   _tts_allRc  Rv  Rw  R  R{  R}  R~  R  R1   R  R   Rd  Rg  Rh  (    (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyR9    s>   	:				
/		=												J(/   R   t   renpy.displayRF   t   renpy.text.textsupportR    R   R   R   R   RQ   t   renpy.text.texwrapR   t   renpy.text.fontR0   t   renpy.text.extrast   extrast
   _renpybidiR   R   R   R   t   objectR   R*   R+   R,   Rh   Rs   R}   R~   R  R3  R4  R5  R6  R7  R8  Ry   R   t   Matrix2DR  R  Rz   RD  R9  t   language_tailort   ParameterizedText(    (    (    s7   E:\Version 1-0-7\Games\DDLC-1.1.1-pc\renpy\text\text.pyt   <module>   s@   ""	J*>   		  	