'Install a Font'

def import_font(self, url):

    if (url == 'unifont'):
        url = 'http://unifoundry.com/pub/unifont-7.0.06/font-builds/unifont-7.0.06.ttf'
        filename = 'unifont.ttf'
        extension = 'ttf'
    else:
        filename = url.split('/')[(-1)]
        (filename, extension) = filename.rsplit('.', 1)
        if (extension not in ('ttf', 'gz', 'zip')):
            current.log.warning(('Unsupported    font    extension:    %s' % extension))
            return
        filename = ('%s.ttf' % filename)
    fontPath = os.path.join(current.request.folder, 'static', 'fonts')
    if os.path.exists(os.path.join(fontPath, filename)):
        current.log.warning(('Using    cached    copy    of    %s' % filename))
        return
    cwd = os.getcwd()
    os.chdir(fontPath)
    try:
        _file = fetch(url)
    except urllib2.URLError as exception:
        current.log.error(exception)
        os.chdir(cwd)
        return
    if (extension == 'gz'):
        import tarfile
        tf = tarfile.open(fileobj=StringIO(_file))
        tf.extractall()
    elif (extension == 'zip'):
        import zipfile
        zf = zipfile.ZipFile(StringIO(_file))
        zf.extractall()
    else:
        f = open(filename, 'wb')
        f.write(_file)
        f.close()
    os.chdir(cwd)
