GithubHelp home page GithubHelp logo

fontsquirrel_dl's Introduction

fontsquirrel_dl

This is a Python 3.x library which provides an easy access to FontSquirrel API.

Some cache is stored to get data faster.

##Documentation This library allows to:

  1. Download all fonts freely available on Font Squirrel
  2. Download a family (using url_name)
  3. Return data from Font Squirrel on a similar way on Google Fonts

#1: Download all familes on FontSquirrel

Font Squirrel's API allows access to free and open fonts. All fonts which needs to go to another site are not available here. The function is contained on FontSquirrel class. It takes one argument: the folder where you want to download and extract the fonts.

import FontSquirrel
FontSquirrel.get_family("raleway",'font/')

#2: Download one family from FontSquirrel

Once you know the url_name for the font you want, you can use the get_family() function. Takes one argument: the folder where you have to download.

import FontSquirrel
FontSquirrel.get_all_families("Fonts/")

#3: Get Json data like Google Font's API

You can get the data from FontSquirrel on a similar way that Google provides with his Web Fonts API. It does not have the same atributes: some of them are not available.

{ 'kind': 'fontsquirrel',
  'family': #family_name
  'family_url': #family_urlname
  'category': #Classification
  "variants" : [ "regular" .. "thin" ]
  "files" : {
     "regular" : "Family-variant.otf",
     "thin" : "Family-variant2.otf",
  }

The files are placed into the zip associated to the family.

##API

Download one family from FontSquirrel

Once you know the url_name for the font you want, you can use the get_family() function. Takes one argument: the folder where you have to download.

import FontSquirrel
FontSquirrel.get_family("raleway",'font/')

fontsquirrel_dl's People

Contributors

vfrico avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

jolg42

fontsquirrel_dl's Issues

ImportError: No module named request

Python 2.7.15rc1 (default, Apr 15 2018, 21:51:34) 
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import fontsquirrel
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "fontsquirrel.py", line 30, in <module>
    import urllib.request
ImportError: No module named request

fs.get_all_families should continue if errors are occuring

I am trying to use fs.get_all_families(target_directory). It stops after a few downloaded fonts:

Python 3.7.3 (default, May 25 2019, 04:51:33) 
[GCC 7.3.0] on haiku1

fs = fontsquirrel.FontSquirrel()
fs.get_all_families("fontsdir/")

(...)
INFO:root:Downloading zip from http://www.fontsquirrel.com/fonts/download/After-Shok
INFO:root:Downloading zip from http://www.fontsquirrel.com/fonts/download/agane
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/boot/home/fontsquirrel_dl-master/fontsquirrel.py", line 198, in get_all_families
    zip_file.extract(filename, path=dest+url_name)
  File "/packages/python3-3.7.3-2/.self/lib/python3.7/zipfile.py", line 1599, in extract
    return self._extract_member(member, path, pwd)
  File "/packages/python3-3.7.3-2/.self/lib/python3.7/zipfile.py", line 1638, in _extract_member
    member = self.getinfo(member)
  File "/packages/python3-3.7.3-2/.self/lib/python3.7/zipfile.py", line 1395, in getinfo
    'There is no item named %r in the archive' % name)
KeyError: "There is no item named 'Aganè 45 (light).ttf' in the archive"

It should should continue if errors are occuring.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.