ó
î Xc           @   sÝ   d  d l  m Z d  d l  m Z d  d l  m Z d Z d Z d Z d Z d Z d Z	 d Z
 d Z d Z d Z d „  d „  d „  d „  g Z e j Z e j Z e j Z e j Z e j Z d „  Z d e j f d „  ƒ  YZ d S(   iÿÿÿÿ(   t   Image(   t   FontFile(   t   _binaryifcpi   i    i   i   i   i   i   i   i   c         C   s   |  d d ?S(   Ni   i   (    (   t   bits(    (    s3   /usr/lib/python2.7/dist-packages/PIL/PcfFontFile.pyt   <lambda>'   s    c         C   s   |  d d ?d @S(   Ni   i   i   iþÿÿÿ(    (   R   (    (    s3   /usr/lib/python2.7/dist-packages/PIL/PcfFontFile.pyR   (   s    c         C   s   |  d d ?d @S(   Ni   i   iüÿÿÿ(    (   R   (    (    s3   /usr/lib/python2.7/dist-packages/PIL/PcfFontFile.pyR   )   s    c         C   s   |  d d ?d @S(   Ni?   i   i   iøÿÿÿ(    (   R   (    (    s3   /usr/lib/python2.7/dist-packages/PIL/PcfFontFile.pyR   *   s    c         C   s   |  | |  j  d | ƒ !S(   Nt    (   t   index(   t   st   o(    (    s3   /usr/lib/python2.7/dist-packages/PIL/PcfFontFile.pyt   sz4   s    t   PcfFontFilec           B   sD   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   t   namec      	   C   s«  t  | j d ƒ ƒ } | t k r0 t d ƒ ‚ n  t j j |  ƒ t  | j d ƒ ƒ } i  |  _ xl t | ƒ D]^ } t  | j d ƒ ƒ } t  | j d ƒ ƒ t  | j d ƒ ƒ t  | j d ƒ ƒ f |  j | <qk W| |  _ |  j	 ƒ  |  _
 |  j ƒ  } |  j | ƒ } |  j ƒ  } x˜ t d ƒ D]Š }	 | |	 }
 |
 d  k	 r| |
 \ } } } } } } } } | d f | | | | | | f d d | | f | |
 f } | |  j |	 <qqWd  S(   Ni   s   not a PCF filei   i    (   t   l32t   readt	   PCF_MAGICt   SyntaxErrorR   t   __init__t   toct   ranget   fpt   _load_propertiest   infot   _load_metricst   _load_bitmapst   _load_encodingt   Nonet   glyph(   t   selfR   t   magict   countt   it   typet   metricst   bitmapst   encodingt   cht   ixt   xt   yt   lt   rt   wt   at   dt   fR   (    (    s3   /usr/lib/python2.7/dist-packages/PIL/PcfFontFile.pyR   ?   s(    	G	
"<c         C   sx   |  j  | \ } } } |  j } | j | ƒ t | j d ƒ ƒ } | d @r[ t t } } n t t } } | | | | f S(   Ni   (   R   R   t   seekR   R   t   b16t   b32t   l16(   R   t   tagt   formatt   sizet   offsetR   t   i16t   i32(    (    s3   /usr/lib/python2.7/dist-packages/PIL/PcfFontFile.pyt
   _getformat_   s    	
c         C   s(  i  } |  j  t ƒ \ } } } } | | j d ƒ ƒ } g  } xW t | ƒ D]I } | j | | j d ƒ ƒ t | j d ƒ ƒ | | j d ƒ ƒ f ƒ qI W| d @r» | j d | d @d ƒ n  | j | | j d ƒ ƒ ƒ }	 xH | D]@ \ }
 } } t |	 |
 ƒ }
 | rt |	 | ƒ } n  | | |
 <qà W| S(   Ni   i   i   (   R7   t   PCF_PROPERTIESR   R   t   appendt   i8R-   R	   (   R   t
   propertiesR   R2   R5   R6   t   npropst   pR   t   datat   kR   t   v(    (    s3   /usr/lib/python2.7/dist-packages/PIL/PcfFontFile.pyR   o   s    G
c      
   C   sô  g  } |  j  t ƒ \ } } } } | j } | d @d k rx³t | | j d ƒ ƒ ƒ D]¹ } t | j d ƒ ƒ d } t | j d ƒ ƒ d }	 t | j d ƒ ƒ d }
 t | j d ƒ ƒ d } t | j d ƒ ƒ d } |	 | } | | } | | | | |	 |
 | | d f ƒ qV WnÚ x× t | | j d ƒ ƒ ƒ D]º } | | j d ƒ ƒ } | | j d ƒ ƒ }	 | | j d ƒ ƒ }
 | | j d ƒ ƒ } | | j d ƒ ƒ } | | j d ƒ ƒ } |	 | } | | } | | | | |	 |
 | | | f ƒ q2W| S(   Ni ÿ  i   i   i   i€   i    i   (   R7   t   PCF_METRICSR9   R   R   R:   (   R   R    R   R2   R5   R6   R9   R   t   leftt   rightt   widtht   ascentt   descentt   xsizet   ysizet
   attributes(    (    s3   /usr/lib/python2.7/dist-packages/PIL/PcfFontFile.pyR   ‹   s8    	"

"

c      
   C   sº  g  } |  j  t ƒ \ } } } } | | j d ƒ ƒ } | t | ƒ k rW t d ƒ ‚ n  g  } x0 t | ƒ D]" }	 | j | | j d ƒ ƒ ƒ qj Wg  }
 x0 t d ƒ D]" }	 |
 j | | j d ƒ ƒ ƒ q£ W| d @} | d @} | d @} |
 | } | j | ƒ | j | ƒ } t | } d } | r,d } n  x‡ t | ƒ D]y }	 | |	 \ } } } } } } } } | |	 | |	 d } } | j t j	 d | | f | | | !d | | | ƒ ƒ ƒ q9W| S(	   Ni   s   Wrong number of bitmapsi   i   s   1;Rt   1i   t   raw(
   R7   t   PCF_BITMAPSR   t   lent   IOErrorR   R9   t   BYTES_PER_ROWR    t	   frombytes(   R   R    R!   R   R2   R5   R6   t   nbitmapst   offsetsR   t   bitmapSizest	   byteordert   bitordert   padindext
   bitmapsizeR>   t   padt   modeR%   R&   R'   R(   R)   R*   R+   R,   t   bt   e(    (    s3   /usr/lib/python2.7/dist-packages/PIL/PcfFontFile.pyR   ¹   s6      




	"6c         C   s  d  g d } |  j t ƒ \ } } } } | | j d ƒ ƒ | | j d ƒ ƒ } } | | j d ƒ ƒ | | j d ƒ ƒ } }	 | | j d ƒ ƒ }
 | | d |	 | d } x_ t | ƒ D]Q } | | j d ƒ ƒ } | d k rº y | | | | <Wqt k
 rPqXqº qº W| S(   Ni   i   i   iÿÿ  (   R   R7   t   PCF_BDF_ENCODINGSR   R   t
   IndexError(   R   R"   R   R2   R5   R6   t   firstColt   lastColt   firstRowt   lastRowt   defaultt	   nencodingR   t   encodingOffset(    (    s3   /usr/lib/python2.7/dist-packages/PIL/PcfFontFile.pyR   æ   s    ++(	   t   __name__t
   __module__R   R   R7   R   R   R   R   (    (    (    s3   /usr/lib/python2.7/dist-packages/PIL/PcfFontFile.pyR
   ;   s   	 			.	-Ni   i   i   i   i   i    i@   i€   i   (   t   PILR    R   R   R   R8   t   PCF_ACCELERATORSRA   RL   t   PCF_INK_METRICSR\   t   PCF_SWIDTHSt   PCF_GLYPH_NAMESt   PCF_BDF_ACCELERATORSRO   R:   t   i16leR0   t   i32leR   t   i16beR.   t   i32beR/   R	   R
   (    (    (    s3   /usr/lib/python2.7/dist-packages/PIL/PcfFontFile.pyt   <module>   s.   						