ó
ÄCõRc           @  s3  d  Z  d d l m Z d d l Z d d l Z d d l Z y e Wn! e k
 re d d l m	 Z n Xd d l
 Z
 d d l
 m Z d d l
 m Z d d l
 m Z m Z d d l m Z d d l j Z d d	 l m Z d d
 l m Z m Z y d d l Z Wn e k
 rd d l Z n Xe Z e
 j Z i
 d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d e 6Z i	 d d 6d d 6d d  6d! d" 6d# d$ 6d% d& 6d' d( 6d) d* 6d+ d, 6Z i d d- 6d d. 6d! d$ 6d! d/ 6d! d0 6d# d 6d# d1 6d% d2 6d% d3 6d% d4 6d' d5 6d) d6 6d) d7 6d+ d8 6Z  e d9 d: d; d< d= d> d? g ƒ Z! d@ Z" dA dB g Z# dC dD dE dF dG g Z$ dH dI dJ dK g Z% e rñe j& j' dL ƒ Z( e( e k	 rîe j) j* e( dM dN ƒ Z) e% j+ e) ƒ e j) j* e( dO ƒ Z) e$ j+ e) ƒ n  n  dP „  Z, dQ „  Z- dR „  Z. e dS dT „ Z/ e dS dU „ Z0 dS dV „ Z1 e dS dW „ Z2 dX „  Z3 dY e4 f dZ „  ƒ  YZ5 d[ „  Z6 d\ „  Z7 dS d] „ Z8 d^ e4 f d_ „  ƒ  YZ9 d` „  Z: da „  Z; db „  Z< dc f  dd „  ƒ  YZ= i  Z> de „  Z? e a@ e ZA e oóe jB df k r/d d lC ZC dg „  ZD eC jE dh ƒ ZF i  ZG dS di „ ZH n dj e j& k rše ƒ  ZI eI e k	 r—e jJ dk dl k re j) j* eI dm ƒ ZA n e j) j* eI dn ƒ ZA n  n e ZA e a@ do „  ZK eA ryV e< eA ƒ a@ eL t@ dp ƒ pãt@ jM e= jN k rðeK ƒ  n e t@ _O e jP dq eA ƒ Wn eK ƒ  n Xn eK ƒ  dr „  ZH d S(s   sè  
A module for finding, managing, and using fonts across platforms.

This module provides a single :class:`FontManager` instance that can
be shared across backends and platforms.  The :func:`findfont`
function returns the best TrueType (TTF) font file in the local or
system font path that matches the specified :class:`FontProperties`
instance.  The :class:`FontManager` also handles Adobe Font Metrics
(AFM) font files for use by the PostScript backend.

The design is based on the `W3C Cascading Style Sheet, Level 1 (CSS1)
font specification <http://www.w3.org/TR/1998/REC-CSS2-19980512/>`_.
Future versions may implement the Level 2 or 2.1 specifications.

Experimental support is included for using `fontconfig` on Unix
variant platforms (Linux, OS X, Solaris).  To enable it, set the
constant ``USE_FONTCONFIG`` in this file to ``True``.  Fontconfig has
the advantage that it is the standard way to look up fonts on X11
platforms, so if a font is installed, it is much more likely to be
found.
iÿÿÿÿ(   t   print_functionN(   t   Set(   t   afm(   t   ft2font(   t   rcParamst   get_cachedir(   t   is_string_like(   t
   subprocess(   t   parse_fontconfig_patternt   generate_fontconfig_patterngºI+‡â?s   xx-smallgh‘í|?5æ?s   x-smallg-²�ï§ê?t   smallg      ð?t   mediumg333333ó?t   largeg
×£p=
÷?s   x-largegÙÎ÷Sã¥û?s   xx-larget   largert   smallerid   s   ultra-condensediÈ   s   extra-condensedi,  t	   condensedi�  s   semi-condensediô  t   normaliX  s   semi-expandedi¼  t   expandedi   s   extra-expandedi„  s   ultra-expandedt
   ultralightt   lightt   regulart   bookt   romant   semiboldt   demiboldt   demit   boldt   heavys
   extra boldt   blackt   serifs
   sans-serifs
   sans serift   cursivet   fantasyt	   monospacet   sanss@   Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folderss2   SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fontss/   SOFTWARE\Microsoft\Windows\CurrentVersion\Fontss   /usr/X11R6/lib/X11/fonts/TTF/s   /usr/X11/lib/X11/fontss   /usr/share/fonts/s   /usr/local/share/fonts/s)   /usr/lib/openoffice/share/fonts/truetype/s   /Library/Fonts/s   /Network/Library/Fonts/s   /System/Library/Fonts/s   /opt/local/share/fontst   HOMEt   Libraryt   Fontss   .fontsc         C  s   i d d 6d d 6d d 6|  S(   ss   
    Return a list of file extensions extensions that are synonyms for
    the given file extension *fileext*.
    t   ttft   otfR   (   R%   R&   (   R%   R&   (   s   afm(    (   t   fontext(    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyt   get_fontext_synonymsœ   s    
c         C  sB   d j  g  | D] } d | | j ƒ  f ^ q ƒ } t j |  | ƒ S(   s…   
    Return a list of all fonts matching any of the extensions,
    possibly upper-cased, found recursively under the directory.
    t   ;s	   *.%s;*.%s(   t   joint   uppert   cbookt	   listFiles(   t	   directoryt
   extensionst   extt   pattern(    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyt
   list_fonts¥   s    	)c          C  s¬   y d d l  }  Wn t k
 r# no XyZ |  j |  j t ƒ } z0 y |  j | d ƒ d SWn t k
 rj n XWd |  j | ƒ XWn t k
 r‘ n Xt j	 j
 t j d d ƒ S(   s  
    Return the user-specified font directory for Win32.  This is
    looked up from the registry key::

      \HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Fonts

    If the key is not found, $WINDIR/Fonts will be returned.
    iÿÿÿÿNR$   i    t   WINDIR(   t   _winregt   ImportErrort   OpenKeyt   HKEY_CURRENT_USERt	   MSFolderst   QueryValueExt   OSErrort   CloseKeyt   ost   pathR*   t   environ(   R4   t   user(    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyt   win32FontDirectory®   s    	R%   c   
      C  sµ  d d l  } |  d k r$ t ƒ  }  n  t | ƒ } d i  } } xqt D]i} y | j | j | ƒ } Wn t k
 ry qD n X| s� t |  | ƒ Szxþ t	 | j
 | ƒ d ƒ D]ã } y  | j | | ƒ \ } } }	 t | ƒ sà wª n  t j j | ƒ s
t j j |  | ƒ } n  t j j | ƒ j ƒ  } t j j | ƒ d d | k rOd | | <n  Wqª t k
 rfqª qª t k
 ryqª qª t k
 rŒqª qª Xqª W| j ƒ  SWd | j | ƒ XqD Wd S(   sÔ   
    Search for fonts in the specified font directory, or use the
    system directories if none given.  A list of TrueType font
    filenames are returned by default, or AFM fonts if *fontext* ==
    'afm'.
    iÿÿÿÿNi   (   R4   t   NoneR@   R(   t   MSFontDirectoriesR6   t   HKEY_LOCAL_MACHINER:   R2   t   ranget   QueryInfoKeyt	   EnumValueR   R<   R=   t   dirnameR*   t   abspatht   lowert   splitextt   EnvironmentErrort   WindowsErrort   MemoryErrort   keysR;   (
   R.   R'   R4   t   keyt   itemst   fontdirt   localt   jt   direct   any(    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyt   win32InstalledFontsÉ   s@      c         C  sz   |  d k r t }  n  t | ƒ } g  } xL |  D]D } | d k r\ | j t j | d ƒ ƒ q. | j t | | ƒ ƒ q. W| S(   sJ   
    Get list of font files on OS X - ignores font suffix by default.
    t   *N(   RA   t   OSXFontDirectoriesR(   t   extendR,   R-   R2   (   t   directoriesR'   t   filesR=   (    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyt   OSXInstalledFontsö   s    	c         C  sì   t  |  ƒ }  i  } y5 t j d d d g d t j ƒ} | j ƒ  d } Wn t k
 r] } | SX| j d k rè t | ƒ } xl | j d ƒ D]X } | j d ƒ d } t	 j
 j | ƒ d d |  k r‰ t	 j
 j | ƒ r‰ d | | <q‰ q‰ Wn  | S(	   s  
    Grab a list of all the fonts that are being tracked by fontconfig
    by making a system call to ``fc-list``.  This is an easy way to
    grab all of the fonts the user wants to be made available to
    applications, without needing knowing where all of them reside.
    s   fc-listt    t   filet   stdouti    s   
t   :i   (   R(   R   t   Popent   PIPEt   communicateR:   t
   returncodet   strt   splitR<   R=   RJ   t   exists(   R'   t	   fontfilest   pipet   outputt   IOErrort   linet   fname(    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyt   get_fontconfig_fonts  s    ! c         C  s�  i  } t  | ƒ } |  d k rt j d k r¦ t ƒ  } | g }  xÁ t | ƒ D]S } t j j | ƒ \ } } t	 | ƒ d k rL | d j
 ƒ  | k rL d | | <qL qL Wq't }  t j d k râ x$ t d | ƒ D] } d | | <qË Wn  xB t | ƒ D] } d | | <qï Wn! t |  t t f ƒ r'|  g }  n  xD |  D]< } t | | ƒ }	 x$ |	 D] }
 d | t j j |
 ƒ <qJWq.Wg  | j ƒ  D] }
 t j j |
 ƒ r{|
 ^ q{S(   s4  
    Search for fonts in the specified font paths.  If no paths are
    given, will use a standard set of system paths, as well as the
    list of fonts tracked by fontconfig if fontconfig is installed and
    available.  A list of TrueType fonts are returned by default with
    AFM fonts as an option.
    t   win32i   t   darwinR'   N(   R(   RA   t   syst   platformR@   RV   R<   R=   RJ   t   lenRI   t   X11FontDirectoriesR\   Rn   t
   isinstanceRe   t   unicodeR2   RH   t   iterkeysRg   (   t	   fontpathsR'   Rh   t   fontextsRQ   t   ft   baseR0   R=   R[   Rm   (    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyt   findSystemFonts"  s.    		(c         C  sk   t  |  t ƒ r@ y t |  j ƒ  }  Wqg t k
 r< d }  qg Xn' |  t d d d ƒ k r[ n t d ƒ ‚ |  S(   s   
    Return the weight property as a numeric value.  String values
    are converted to their corresponding numeric value.
    i�  id   iè  s   weight not a valid integer(   Ru   Re   t   weight_dictRI   t   KeyErrorRD   t
   ValueError(   t   weight(    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyt   weight_as_numberK  s    t	   FontEntryc           B  s5   e  Z d  Z d d d d d d d d „ Z d „  Z RS(   sj   
    A class for storing Font properties.  It is used when populating
    the font lookup dictionary.
    R]   R   R   c         C  sp   | |  _  | |  _ | |  _ | |  _ | |  _ | |  _ y t t | ƒ ƒ |  _ Wn t	 k
 rk | |  _ n Xd  S(   N(
   Rm   t   namet   stylet   variantR€   t   stretchRe   t   floatt   sizeR   (   t   selfRm   Rƒ   R„   R…   R€   R†   Rˆ   (    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyt   __init__a  s    							c         C  s8   d |  j  t j j |  j ƒ |  j |  j |  j |  j f S(   Ns   <Font '%s' (%s) %s %s %s %s>(	   Rƒ   R<   R=   t   basenameRm   R„   R…   R€   R†   (   R‰   (    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyt   __repr__u  s    $(   t   __name__t
   __module__t   __doc__RŠ   RŒ   (    (    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyR‚   \  s   c         C  ss  |  j  } |  j ƒ  } | j d ƒ } | j d ƒ } | rQ | j d ƒ j ƒ  } n d } | ru | j d ƒ j ƒ  } n d } | j d ƒ d k r™ d } n[ | j d ƒ d k r· d } n= | j d	 ƒ d k rÕ d
 } n |  j t j @rî d } n d
 } | j ƒ  d k rd } n d
 } d } x3 t
 j ƒ  D]% } | j | ƒ d k r(| } Pq(q(W| sy|  j t j @rpd } qyd } n  t | ƒ } | j d ƒ d k sÄ| j d ƒ d k sÄ| j d ƒ d k rÍd }	 nW | j d ƒ d k rëd }	 n9 | j d ƒ d k s| j d ƒ d k rd }	 n d
 }	 |  j r6d }
 n t t |  j ƒ  ƒ ƒ }
 d } t |  j | | | | |	 |
 ƒ S(   sŸ   
    A function for populating the :class:`FontKey` by extracting
    information from the TrueType font file.

    *font* is a :class:`FT2Font` instance.
    i   i    i   i   t   macromanR]   t   obliquet   italicR   R   t   capitalss
   small-capsi¼  i�  t   narrowR   t   conds	   demi conds   semi-condensedt   wideR   t   scalable(   i   i    i    i   (   i   i    i    i   (   R“   s
   small-capsN(   t   family_namet   get_sfntt   gett   decodeRI   t   findt   style_flagsR   t   ITALICRA   R}   Rw   t   BOLDR�   R—   Re   R‡   t   get_fontsizeR‚   Rm   (   t   fontRƒ   t   sfntt   sfnt2t   sfnt4R„   R…   R€   t   wR†   Rˆ   t   size_adjust(    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyt   ttfFontProperty{  sZ    									*		*	
		c   
      C  s~  | j  ƒ  } | j ƒ  j ƒ  } | j ƒ  d k sK | j ƒ  j d ƒ d k rT d } n* | j ƒ  j d ƒ d k rx d } n d } | j ƒ  d k r™ d } n d } t | j ƒ  j ƒ  ƒ } | j d ƒ d k sö | j d ƒ d k sö | j d	 ƒ d k rÿ d } nW | j d
 ƒ d k rd } n9 | j d ƒ d k sG| j d ƒ d k rPd } n d } d } d }	 t |  | | | | | | ƒ S(   sœ   
    A function for populating a :class:`FontKey` instance by
    extracting information from the AFM font file.

    *font* is a class:`AFM` instance.
    i    R’   R‘   R   R“   s
   small-capsR”   R   R•   s	   demi conds   semi-condensedR–   R   R—   (   s   capitalss
   small-capsN(	   t   get_familynamet   get_fontnameRI   t	   get_angleRœ   R�   t
   get_weightRA   R‚   (
   t   fontpathR¡   Rƒ   t   fontnameR„   R…   R€   R†   Rˆ   R¦   (    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyt   afmFontPropertyÙ  s,    -			*		*	c   	      C  s³  g  } i  } x |  D]˜} t  j d | d ƒ t j j | ƒ d } | | k rU q n
 d | | <| d k ry t | d ƒ } Wn t  j d | ƒ q n Xy% z t j | ƒ } Wd | j ƒ  XWn% t	 k
 rè t  j d | ƒ q n Xy t
 | | ƒ } Wqžt k
 rq qžXnˆ y t j t | ƒ ƒ } WnE t	 k
 rVt  j d | ƒ q n! t k
 rvt  j d	 ƒ q n Xy t | ƒ } Wn t k
 r�q n X| j | ƒ q W| S(
   s›   
    A function to create a font lookup list.  The default is to create
    a list of TrueType fonts.  An AFM font list can optionally be
    created.
    s   createFontDict: %st   debugi   R   t   rbs   Could not open font file %sNs   Could not parse font file %ss   Cannot handle unicode filenames(   t   verboset   reportR<   R=   Rf   t   openR   t   AFMt   closet   RuntimeErrorR®   R~   R   t   FT2FontRe   t   UnicodeErrorR§   t   append(	   Rh   R'   t   fontlistt   seent   fpathRm   t   fhR¡   t   prop(    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyt   createFontList  sN     

t   FontPropertiesc        	   B  s  e  Z d  Z d d d d d d d d d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 e
 Z d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z e Z d „  Z e Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   s 	  
    A class for storing and manipulating font properties.

    The font properties are those described in the `W3C Cascading
    Style Sheet, Level 1
    <http://www.w3.org/TR/1998/REC-CSS2-19980512/>`_ font
    specification.  The six properties are:

      - family: A list of font names in decreasing order of priority.
        The items may include a generic font family name, either
        'serif', 'sans-serif', 'cursive', 'fantasy', or 'monospace'.
        In that case, the actual font to be used will be looked up
        from the associated rcParam in :file:`matplotlibrc`.

      - style: Either 'normal', 'italic' or 'oblique'.

      - variant: Either 'normal' or 'small-caps'.

      - stretch: A numeric value in the range 0-1000 or one of
        'ultra-condensed', 'extra-condensed', 'condensed',
        'semi-condensed', 'normal', 'semi-expanded', 'expanded',
        'extra-expanded' or 'ultra-expanded'

      - weight: A numeric value in the range 0-1000 or one of
        'ultralight', 'light', 'normal', 'regular', 'book', 'medium',
        'roman', 'semibold', 'demibold', 'demi', 'bold', 'heavy',
        'extra bold', 'black'

      - size: Either an relative value of 'xx-small', 'x-small',
        'small', 'medium', 'large', 'x-large', 'xx-large' or an
        absolute font size, e.g., 12

    The default font property for TrueType fonts (as specified in the
    default :file:`matplotlibrc` file) is::

      sans-serif, normal, normal, normal, normal, scalable.

    Alternatively, a font may be specified using an absolute path to a
    .ttf file, by using the *fname* kwarg.

    The preferred usage of font sizes is to use the relative values,
    e.g.,  'large', instead of absolute font sizes, e.g., 12.  This
    approach allows all text sizes to be made larger or smaller based
    on the font manager's default font size.

    This class will also accept a `fontconfig
    <http://www.fontconfig.org/>`_ pattern, if it is the only argument
    provided.  See the documentation on `fontconfig patterns
    <http://www.fontconfig.org/fontconfig-user.html>`_.  This support
    does not require fontconfig to be installed.  We are merely
    borrowing its pattern syntax for use here.

    Note that matplotlib's internal font manager and fontconfig use a
    different algorithm to lookup fonts, so the results of the same pattern
    may be different in matplotlib than in other applications that use
    fontconfig.
    c	   	      C  s)  d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ | d  k	 rb |  j j	 | j ƒ d  St
 | ƒ rÊ | d  k rÊ | d  k rÊ | d  k rÊ | d  k rÊ | d  k rÊ | d  k rÊ |  j | ƒ d  Sn  |  j | ƒ |  j | ƒ |  j | ƒ |  j | ƒ |  j | ƒ |  j | ƒ |  j | ƒ d  S(   N(   RA   t   _familyt   _slantt   _variantt   _weightt   _stretcht   _sizet   _filet   __dict__t   updateR   t   set_fontconfig_patternt
   set_familyt	   set_stylet   set_variantt
   set_weightt   set_stretcht   set_filet   set_size(	   R‰   t   familyR„   R…   R€   R†   Rˆ   Rm   t   _init(    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyRŠ   Š  s4    
							c         C  s
   t  | ƒ S(   N(   R   (   R‰   R1   (    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyt   _parse_fontconfig_patternµ  s    c         C  sU   t  |  j ƒ  ƒ |  j ƒ  |  j ƒ  |  j ƒ  |  j ƒ  |  j ƒ  |  j ƒ  f } t | ƒ S(   N(	   t   tuplet
   get_familyt	   get_slantt   get_variantR«   t   get_stretcht   get_size_in_pointst   get_filet   hash(   R‰   t   l(    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyt   __hash__¸  s    					c         C  s
   |  j  ƒ  S(   N(   t   get_fontconfig_pattern(   R‰   (    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyt   __str__Â  s    c         C  s7   |  j  d k r0 t d } t | ƒ r, | g S| S|  j  S(   sL   
        Return a list of font names that comprise the font family.
        s   font.familyN(   RÁ   RA   R   R   (   R‰   RÒ   (    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyRÖ   Å  s    
c         C  s   t  j t t |  ƒ ƒ ƒ j S(   s\   
        Return the name of the font that best matches the font
        properties.
        (   R   R·   Re   t   findfontR˜   (   R‰   (    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyt   get_nameÐ  s    c         C  s   |  j  d k r t d S|  j  S(   s^   
        Return the font style.  Values are: 'normal', 'italic' or
        'oblique'.
        s
   font.styleN(   RÂ   RA   R   (   R‰   (    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyt	   get_style×  s    c         C  s   |  j  d k r t d S|  j  S(   sY   
        Return the font variant.  Values are: 'normal' or
        'small-caps'.
        s   font.variantN(   RÃ   RA   R   (   R‰   (    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyRØ   á  s    c         C  s   |  j  d k r t d S|  j  S(   sú   
        Set the font weight.  Options are: A numeric value in the
        range 0-1000 or one of 'light', 'normal', 'regular', 'book',
        'medium', 'roman', 'semibold', 'demibold', 'demi', 'bold',
        'heavy', 'extra bold', 'black'
        s   font.weightN(   RÄ   RA   R   (   R‰   (    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyR«   ê  s    c         C  s   |  j  d k r t d S|  j  S(   sá   
        Return the font stretch or width.  Options are: 'ultra-condensed',
        'extra-condensed', 'condensed', 'semi-condensed', 'normal',
        'semi-expanded', 'expanded', 'extra-expanded', 'ultra-expanded'.
        s   font.stretchN(   RÅ   RA   R   (   R‰   (    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyRÙ   õ  s    c         C  s   |  j  d k r t d S|  j  S(   s'   
        Return the font size.
        s	   font.sizeN(   RÆ   RA   R   (   R‰   (    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyt   get_sizeÿ  s    c         C  sW   |  j  d  k	 r7 y t |  j  ƒ SWq7 t k
 r3 q7 Xn  t j ƒ  } | t j |  j  ƒ S(   N(   RÆ   RA   R‡   R   t   FontManagert   get_default_sizet   font_scalingsRš   (   R‰   t   default_size(    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyRÚ     s    c         C  s   |  j  S(   s=   
        Return the filename of the associated font.
        (   RÇ   (   R‰   (    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyRÛ     s    c         C  s
   t  |  ƒ S(   s¨  
        Get a fontconfig pattern suitable for looking up the font as
        specified with fontconfig's ``fc-match`` utility.

        See the documentation on `fontconfig patterns
        <http://www.fontconfig.org/fontconfig-user.html>`_.

        This support does not require fontconfig to be installed or
        support for it to be enabled.  We are merely borrowing its
        pattern syntax for use here.
        (   R	   (   R‰   (    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyRß     s    c         C  s>   | d k r t d } n  t | ƒ r1 | g } n  | |  _ d S(   s7  
        Change the font family.  May be either an alias (generic name
        is CSS parlance), such as: 'serif', 'sans-serif', 'cursive',
        'fantasy', or 'monospace', a real font name or a list of real
        font names.  Real font names are not supported when
        `text.usetex` is `True`.
        s   font.familyN(   RA   R   R   RÁ   (   R‰   RÒ   (    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyRË   $  s
    c         C  sA   | d k r t d } n  | d k r4 t d ƒ ‚ n  | |  _ d S(   s[   
        Set the font style.  Values are: 'normal', 'italic' or
        'oblique'.
        s
   font.styleR   R’   R‘   s'   style must be normal, italic or obliqueN(   s   normals   italics   obliqueN(   RA   R   R   RÂ   (   R‰   R„   (    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyRÌ   3  s
    c         C  sA   | d k r t d } n  | d k r4 t d ƒ ‚ n  | |  _ d S(   sN   
        Set the font variant.  Values are: 'normal' or 'small-caps'.
        s   font.variantR   s
   small-capss$   variant must be normal or small-capsN(   s   normals
   small-capsN(   RA   R   R   RÃ   (   R‰   R…   (    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyRÍ   ?  s
    c         C  s‰   | d k r t d } n  y4 t | ƒ } | d k  s@ | d k rL t ƒ  ‚ n  Wn, t k
 r{ | t k r| t d ƒ ‚ q| n X| |  _ d S(   s	  
        Set the font weight.  May be either a numeric value in the
        range 0-1000 or one of 'ultralight', 'light', 'normal',
        'regular', 'book', 'medium', 'roman', 'semibold', 'demibold',
        'demi', 'bold', 'heavy', 'extra bold', 'black'
        s   font.weighti    iè  s   weight is invalidN(   RA   R   t   intR   R}   RÄ   (   R‰   R€   (    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyRÎ   I  s    c         C  s‰   | d k r t d } n  y4 t | ƒ } | d k  s@ | d k rL t ƒ  ‚ n  Wn, t k
 r{ | t k r| t d ƒ ‚ q| n X| |  _ d S(   s  
        Set the font stretch or width.  Options are: 'ultra-condensed',
        'extra-condensed', 'condensed', 'semi-condensed', 'normal',
        'semi-expanded', 'expanded', 'extra-expanded' or
        'ultra-expanded', or a numeric value in the range 0-1000.
        s   font.stretchi    iè  s   stretch is invalidN(   RA   R   Ré   R   t   stretch_dictRÅ   (   R‰   R†   (    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyRÏ   [  s    c         C  sq   | d k r t d } n  y t | ƒ } Wn8 t k
 rc | d k	 rd | t k rd t d ƒ ‚ qd n X| |  _ d S(   s¾   
        Set the font size.  Either an relative value of 'xx-small',
        'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'
        or an absolute font size, e.g., 12.
        s	   font.sizes   size is invalidN(   RA   R   R‡   R   Rç   RÆ   (   R‰   Rˆ   (    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyRÑ   m  s    c         C  s   | |  _  d S(   sw   
        Set the filename of the fontfile to use.  In this case, all
        other properties will be ignored.
        N(   RÇ   (   R‰   R^   (    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyRÐ   |  s    c         C  sq   xj |  j  | ƒ j ƒ  D]S \ } } t | ƒ t k rR t |  d | ƒ | d ƒ q t |  d | ƒ | ƒ q Wd S(   sg  
        Set the properties by parsing a fontconfig *pattern*.

        See the documentation on `fontconfig patterns
        <http://www.fontconfig.org/fontconfig-user.html>`_.

        This support does not require fontconfig to be installed or
        support for it to be enabled.  We are merely borrowing its
        pattern syntax for use here.
        t   set_i    N(   RÔ   t	   iteritemst   typet   listt   getattr(   R‰   R1   RO   t   val(    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyRÊ   ƒ  s    "c         C  s   t  d |  ƒ S(   s   Return a deep copy of selfRÓ   (   RÀ   (   R‰   (    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyt   copy”  s    N(   R�   RŽ   R�   RA   RŠ   RÔ   RÞ   Rà   RÖ   Râ   Rã   R×   RØ   R«   RÙ   Rä   RÚ   RÛ   Rß   RË   t   set_nameRÌ   t	   set_slantRÍ   RÎ   RÏ   RÑ   RÐ   RÊ   Rñ   (    (    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyRÀ   O  sD   9#		
								
							
	
					c         C  s¡   g  } x” |  j  ƒ  D]† } x} | j  ƒ  D]o } xf | j  ƒ  D]X } xO | j  ƒ  D]A } x8 | j  ƒ  D]* } x! | j  ƒ  D] } | j | ƒ qr Wq_ WqL Wq9 Wq& Wq W| S(   s<   
    flatten a ttfdict to all the filenames it contains
    (   t
   itervaluesR¹   (   t   dt   fnamest   namedt   styledt   variantdt   weightdt   stretchdRm   (    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyt   ttfdict_to_fnames˜  s    %c         C  s,   t  | d ƒ � } t j |  | ƒ Wd QXd S(   su   
    Equivalent to pickle.dump(data, open(filename, 'w'))
    but closes the file to prevent filehandle leakage.
    t   wbN(   R³   t   picklet   dump(   t   datat   filenameR½   (    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyt   pickle_dump¦  s    c         C  s+   t  |  d ƒ � } t j | ƒ } Wd QX| S(   so   
    Equivalent to pickle.load(open(filename, 'r'))
    but closes the file to prevent filehandle leakage.
    R°   N(   R³   Rþ   t   load(   R  R½   R   (    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyt   pickle_load®  s    Rå   c           B  s˜   e  Z d  Z d Z d d d „ Z d „  Z e d „  ƒ Z d „  Z	 d „  Z
 d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d d e e d „ Z RS(   s}  
    On import, the :class:`FontManager` singleton instance creates a
    list of TrueType fonts based on the font properties: name, style,
    variant, weight, stretch, and size.  The :meth:`findfont` method
    does a nearest neighbor search to find the font that most closely
    matches the specification.  If no good enough match is found, a
    default font is returned.
    ie   R   c         C  sX  |  j  |  _ | |  _ | |  _ t j j t d d d ƒ t j j t d d d ƒ t j j t d d d ƒ g } xœ d d g D]Ž } | t j k r| t j | } | j	 d ƒ d	 k rÌ | j
 | j d ƒ ƒ q
| j	 d
 ƒ d	 k rú | j
 | j d
 ƒ ƒ q
| j | ƒ q| q| Wt j d t | ƒ ƒ t | ƒ t ƒ  |  _ i d d 6d d 6|  _ i  |  _ xe |  j D]F } t j d | d ƒ | j ƒ  j	 d ƒ d	 k re| |  j d <PqeqeW|  j d	 |  j d <t |  j ƒ |  _ t | d d ƒt d d ƒ |  _ t |  j d d ƒ|  _ t |  j ƒ r5|  j d	 |  j d <n d  |  j d <i  |  _ i  |  _ d  S(   Nt   datapatht   fontsR%   R   t   pdfcorefontst   TTFPATHt   AFMPATHR)   i    R`   s   font search path %ss   Bitstream Vera Sanst	   Helveticas   trying fontname %sR¯   s   vera.ttfR'   (   t   __version__t   _versiont   _FontManager__default_weightRè   R<   R=   R*   R   R>   Rœ   RY   Rf   R¹   R±   R²   Re   R|   t   ttffilest   defaultFamilyt   defaultFontRI   R¿   t   ttflistt   afmfilest   afmlistRs   RA   t   ttf_lookup_cachet   afm_lookup_cache(   R‰   Rˆ   R€   t   pathst   pathnamet   ttfpathRm   (    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyRŠ   Å  sF    				c         C  s   |  j  S(   s1   
        Return the default font weight.
        (   R  (   R‰   (    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyt   get_default_weightù  s    c           C  s   t  d S(   s/   
        Return the default font size.
        s	   font.size(   R   (    (    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyRæ   ÿ  s    c         C  s   | |  _  d S(   sN   
        Set the default font weight.  The initial value is 'normal'.
        N(   R  (   R‰   R€   (    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyt   set_default_weight  s    c         C  s
   t  ‚ d S(   sd   
        Update the font dictionary with new font files.
        Currently not implemented.
        N(   t   NotImplementedError(   R‰   t	   filenames(    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyt   update_fonts  s    c         C  s  t  | t t f ƒ s! | g } n  | j ƒ  } xê t | ƒ D]Ü \ } } | j ƒ  } | t k rð | d k rs d } n  t d | } g  | D] } | j ƒ  ^ qˆ } | | k r| j | ƒ } d t | ƒ t	 | ƒ t | ƒ t t	 | ƒ ƒ Sq: | | k r: t | ƒ t t	 | ƒ ƒ Sq: Wd S(   s  
        Returns a match score between the list of font families in
        *families* and the font family name *family2*.

        An exact match anywhere in the list returns 0.0.

        A match by generic font name will return 0.1.

        No match will return 1.0.
        R!   s
   sans serifs
   sans-serifs   font.gš™™™™™¹?g      ð?(   R!   s
   sans serif(
   Ru   Rî   RÕ   RI   t	   enumeratet   font_family_aliasesR   t   indexR‡   Rs   (   R‰   t   familiest   family2t   it   family1t   optionst   xt   idx(    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyt   score_family  s"    	c         C  s0   | | k r d S| d k r, | d k r, d Sd S(   sÇ   
        Returns a match score between *style1* and *style2*.

        An exact match returns 0.0.

        A match between 'italic' and 'oblique' returns 0.1.

        No match returns 1.0.
        g        R’   R‘   gš™™™™™¹?g      ð?(   s   italics   oblique(   s   italics   oblique(    (   R‰   t   style1t   style2(    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyt   score_style5  s    
c         C  s   | | k r d Sd Sd S(   s~   
        Returns a match score between *variant1* and *variant2*.

        An exact match returns 0.0, otherwise 1.0.
        g        g      ð?N(    (   R‰   t   variant1t   variant2(    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyt   score_variantF  s    c         C  s~   y t  | ƒ } Wn# t k
 r5 t j | d ƒ } n Xy t  | ƒ } Wn# t k
 rk t j | d ƒ } n Xt | | ƒ d S(   só   
        Returns a match score between *stretch1* and *stretch2*.

        The result is the absolute value of the difference between the
        CSS numeric values of *stretch1* and *stretch2*, normalized
        between 0.0 and 1.0.
        iô  g     @�@(   Ré   R   Rê   Rš   t   abs(   R‰   t   stretch1t   stretch2t   stretchval1t   stretchval2(    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyt   score_stretchQ  s    c         C  s~   y t  | ƒ } Wn# t k
 r5 t j | d ƒ } n Xy t  | ƒ } Wn# t k
 rk t j | d ƒ } n Xt | | ƒ d S(   sï   
        Returns a match score between *weight1* and *weight2*.

        The result is the absolute value of the difference between the
        CSS numeric values of *weight1* and *weight2*, normalized
        between 0.0 and 1.0.
        iô  g     @�@(   Ré   R   R}   Rš   R/  (   R‰   t   weight1t   weight2t
   weightval1t
   weightval2(    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyt   score_weightc  s    c         C  s~   | d k r d Sy t  | ƒ } Wn$ t k
 rF |  j t | ƒ } n Xy t  | ƒ } Wn t k
 rk d SXt | | ƒ d S(   sž  
        Returns a match score between *size1* and *size2*.

        If *size2* (the size specified in the font file) is 'scalable', this
        function always returns 0.0, since any font size can be generated.

        Otherwise, the result is the absolute distance between *size1* and
        *size2*, normalized so that the usual range of font sizes (6pt -
        72pt) will lie between 0.0 and 1.0.
        R—   g        g      ð?g      R@(   R‡   R   Rè   Rç   R/  (   R‰   t   size1t   size2t   sizeval1t   sizeval2(    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyt
   score_sizeu  s    R%   c         C  s  t  | t ƒ s t | ƒ } n  | j ƒ  } | d k	 rN t j d | d ƒ | S| d k ro |  j } |  j } n |  j } |  j	 } | d k r¯ | j
 t | ƒ ƒ }	 |	 r¯ |	 Sn  d }
 d } x| D] } | d k	 rû t j j | j | g ƒ | k rû qÂ n  |  j | j ƒ  | j ƒ d |  j | j ƒ  | j ƒ |  j | j ƒ  | j ƒ |  j | j ƒ  | j ƒ |  j | j ƒ  | j ƒ |  j | j  ƒ  | j! ƒ } | |
 k  r²| }
 | } n  | d k rÂ PqÂ qÂ W| d k sÞ|
 d k ro| r>t" j# d | j ƒ  |  j$ | f ƒ | j% ƒ  } | j& |  j$ | ƒ |  j' | | | t( ƒ St" j# d | |  j) | f t* ƒ |  j) | } n, t j d	 | | j | j |
 f ƒ | j } t j j+ | ƒ sï| ràt j d
 ƒ t, ƒ  t- j' | | | t. t( ƒ St/ d ƒ ‚ n  | d k r| | t | ƒ <n  | S(   s  
        Search the font list for the font that most closely matches
        the :class:`FontProperties` *prop*.

        :meth:`findfont` performs a nearest neighbor search.  Each
        font is given a similarity score to the target font
        properties.  The first font with the highest score is
        returned.  If no matches below a certain threshold are found,
        the default font (usually Vera Sans) is returned.

        `directory`, is specified, will only return fonts from the
        given directory (or subdirectory of that directory).

        The result is cached, so subsequent lookups don't have to
        perform the O(n) nearest neighbor search.

        If `fallback_to_default` is True, will fallback to the default
        font family (usually "Bitstream Vera Sans" or "Helvetica") if
        the first lookup hard-fails.

        See the `W3C Cascading Style Sheet, Level 1
        <http://www.w3.org/TR/1998/REC-CSS2-19980512/>`_ documentation
        for a description of the font finding algorithm.
        s   findfont returning %sR¯   R   gõù?éO8Mg      $@i    s6   findfont: Font family %s not found. Falling back to %ss*   findfont: Could not match %s. Returning %ss1   findfont: Matching %s to %s (%s) with score of %fs7   findfont: Found a missing font file.  Rebuilding cache.s   No valid font could be foundN(0   Ru   RÀ   RÛ   RA   R±   R²   R  R  R  R  Rš   RÜ   R<   R=   t   commonprefixRm   R(  RÖ   Rƒ   R+  Rã   R„   R.  RØ   R…   R9  R«   R€   R4  RÙ   R†   R>  Rä   Rˆ   t   warningst   warnR  Rñ   RË   Rá   t   FalseR  t   UserWarningt   isfilet   _rebuildt   fontManagert   TrueR   (   R‰   R¾   R'   R.   t   fallback_to_defaultt   rebuild_if_missingRm   t
   font_cacheRº   t   cachedt
   best_scoret	   best_fontR¡   t   scoret   default_propt   result(    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyRá   �  sp    			!€		N(   R�   RŽ   R�   R  RA   RŠ   R  t   staticmethodRæ   R  R  R(  R+  R.  R4  R9  R>  RG  Rá   (    (    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyRå   ·  s   4			
						c         C  s…   t  j j |  ƒ d j ƒ  d k r� t j |  ƒ } | d k r} t |  d ƒ � } | j d ƒ } Wd QX| d k } | t |  <n  | St	 S(   sÄ   
    Returns True if the given font is a Postscript Compact Font Format
    Font embedded in an OpenType wrapper.  Used by the PostScript and
    PDF backends that can not subset these fonts.
    i   s   .otfR°   i   Nt   OTTO(
   R<   R=   RJ   RI   t   _is_opentype_cff_font_cacheRš   RA   R³   t   readRB  (   R  RP  t   fdt   tag(    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyt   is_opentype_cff_fontö  s    "Ro   c   	      C  sÚ   t  | ƒ } d | } y5 t j d d |  g d t j ƒ} | j ƒ  d } Wn t k
 ra } d  SX| j d k rÖ xb t j	 | ƒ D]N } | j
 d ƒ } | j t j ƒ  ƒ } t j j | ƒ d d | k r� | Sq� Wn  d  S(   Nt   .s   fc-matchs   -svR_   i    i   (   R(   R   Ra   Rb   Rc   R:   RA   Rd   t   _fc_match_regext   finditert   groupR›   Rq   t   getfilesystemencodingR<   R=   RJ   (	   R1   R'   Ry   R0   Ri   Rj   Rk   t   matchR^   (    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyt   fc_match  s    
! s   \sfile:\s+"([^"]*)"c         C  su   t  |  ƒ s |  j ƒ  }  n  t j |  ƒ } | d  k	 r: | St |  | ƒ } | d  k rg t d | ƒ } n  | t |  <| S(   NR`   (   R   Rß   t   _fc_match_cacheRš   RA   R^  (   R¾   R'   RK  RP  (    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyRá      s    
t   TRAVISi    i   s   fontList.py3k.caches   fontList.cachec           C  s0   t  ƒ  a t r t t t ƒ n  t j d ƒ d  S(   Ns   generated new fontManager(   Rå   RF  t   _fmcacheR  R±   R²   (    (    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyRE  ;  s    	R  s"   Using fontManager instance from %sc         K  s   t  j |  | � } | S(   N(   RF  Rá   (   R¾   t   kwR¡   (    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyRá   P  s    (Q   R�   t
   __future__R    R<   Rq   R@  t   sett	   NameErrort   setsR   t
   matplotlibR   R   R   R   t   matplotlib.cbookR   R,   t   matplotlib.compatR   t   matplotlib.fontconfig_patternR   R	   t   cPickleRþ   R5   RB  t   USE_FONTCONFIGR±   RA   Rç   Rê   R}   R  R8   RB   Rt   RX   R>   Rš   t   homeR=   R*   R¹   R(   R2   R@   RV   R\   Rn   R|   R�   t   objectR‚   R§   R®   R¿   RÀ   Rü   R  R  Rå   RS  RW  RF  Ra  Rr   t   reR^  t   compileRY  R_  Rá   t   cachedirt   version_infoRE  t   hasattrR  R  Rè   R²   (    (    (    sQ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/font_manager.pyt   <module>   s
  $	


								-)		^	C3ÿ J				ÿ ?				
	