Exemple #1
0
def win32FontDirectory():
    """
    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.
    """
    try:
        from matplotlib.externals.six.moves import winreg
    except ImportError:
        pass  # Fall through to default
    else:
        try:
            user = winreg.OpenKey(winreg.HKEY_CURRENT_USER, MSFolders)
            try:
                try:
                    return winreg.QueryValueEx(user, 'Fonts')[0]
                except OSError:
                    pass  # Fall through to default
            finally:
                winreg.CloseKey(user)
        except OSError:
            pass  # Fall through to default
    return os.path.join(os.environ['WINDIR'], 'Fonts')
Exemple #2
0
 def _init_from_registry(cls):
     if sys.platform != 'win32' or rcParams[cls.exec_key] != 'convert':
         return
     from matplotlib.externals.six.moves import winreg
     for flag in (0, winreg.KEY_WOW64_32KEY, winreg.KEY_WOW64_64KEY):
         try:
             hkey = winreg.OpenKeyEx(winreg.HKEY_LOCAL_MACHINE,
                                     'Software\\Imagemagick\\Current', 0,
                                     winreg.KEY_QUERY_VALUE | flag)
             binpath = winreg.QueryValueEx(hkey, 'BinPath')[0]
             winreg.CloseKey(hkey)
             binpath += '\\convert.exe'
             break
         except Exception:
             binpath = ''
     rcParams[cls.exec_key] = rcParamsDefault[cls.exec_key] = binpath