Skip to content

anthrotype/fontbakery

 
 

Repository files navigation

Latest Version License Python Travis Build Status Coveralls.io Test Coverage Status

Font Bakery

Font Bakery is a set of command-line tools for building and testing font projects, and a web interface for reviewing them. It runs checks on source files in UFO, SFD or TTX formats and builds them into OTF and TTF files (plus the files needed for hosting in Google Fonts.) It runs tests on these files and stores the results in files that can be browsed by the Font Bakery web app.

If you use Github for your font project, you can use FontBakery on Travis so that with each update to your Github repository, your files are built and tested. Travis can then upload the result back to the project's gh-pages branch, so that they are available on the web via Github Pages.

Install

Mac OS X

Install the dependencies with Homebrew, PIP and gem:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" # install homebrew
brew install python giflib libspiro; # fontforge optional dependencies
brew install --HEAD --with-x fontforge; # fontforge
brew install ttfautohint swig; # fontbakery dependencies
easy_install pip # install pip
pip install git+https://github.com/behdad/fontTools.git; # fontbakery dependencies
pip install git+https://github.com/googlefonts/fontcrunch.git; # fontbakery dependencies
sudo gem install travis; # fontbakery dependencies
pip install git+https://github.com/googlefonts/fontbakery.git; # install fontbakery

GNU+Linux

sudo add-apt-repository --yes ppa:fontforge/fontforge;
sudo apt-get update -qq;
sudo apt-get install python-fontforge ttfautohint swig;
pip install git+https://github.com/behdad/fontTools.git;
pip install git+https://github.com/googlefonts/fontcrunch.git;
pip install git+https://github.com/googlefonts/fontbakery.git;

Usage

On Your Computer

All fontbakery commands begin with fontbakery-

You will have a font project directory with your source files. The first step is to add a bakery.yml file that contains settings for Font Bakery to follow. An interactive terminal application will create one in its current directory:

cd ~/src/github.com/davelab6/fontproject/;
fontbakery-setup.py;
fontbakery-build.py --verbose bakery.yaml;

fontbakery-build.py

fontbakery-check.py

fontbakery-build-font2ttf.py fontbakery-build-metadata.py

fontbakery-crawl.py fontbakery-fix-ascii-fontmetadata.py fontbakery-fix-dsig.py fontbakery-fix-fstype.py fontbakery-fix-gasp.py fontbakery-fix-glyph-private-encoding.py fontbakery-fix-nbsp.py fontbakery-fix-opentype-names.py fontbakery-fix-style-names.py fontbakery-fix-vertical-metrics.py fontbakery-report.py fontbakery-setup-orig.py

fontbakery-travis-deploy.py fontbakery-travis-secure.sh

On Travis

Travis-CI.org is a Continuous Integration system that will run Font Bakery on your files each time you update them on Github. After building your fonts, it will publish the build to the gh-pages branch of your repository.

Warning: This will replace the entire contents of the gh-pages branch if any exist. The previous versions will be available in git history, though.

Travis requires a .travis.yml file in the root directory of your repository. Full documentation is available from docs.travis-ci.com but you can use a typical template.

  1. Enable your font repository in your travis profile, travis-ci.org/profile

  2. Create the .travis.yml text file with your favorite text editor as follows:

    language: python
    before_install:
    - sudo add-apt-repository --yes ppa:fontforge/fontforge
    - sudo apt-get update -qq
    - sudo apt-get install python-fontforge ttfautohint swig
    - cp /usr/lib/python2.7/dist-packages/fontforge.* "$HOME/virtualenv/python2.7.8/lib/python2.7/site-packages"
    install:
    - pip install git+https://github.com/behdad/fontTools.git
    - pip install git+https://github.com/googlefonts/fontcrunch.git
    - pip install git+https://github.com/googlefonts/fontbakery.git
    before_script:
    - mkdir -p builds/$TRAVIS_COMMIT
    script: (set -o pipefail; PATH=/home/travis/virtualenv/python2.7.8/bin/:$PATH fontbakery-build.py . 2>&1 | tee -a    builds/$TRAVIS_COMMIT/buildlog.txt)
    after_script:
    - PATH=/home/travis/virtualenv/python2.7.8/bin/:$PATH fontbakery-report.py builds/$TRAVIS_COMMIT
    - rm -rf builds/$TRAVIS_COMMIT/sources
    - rm -rf builds/$TRAVIS_COMMIT/build.state.yaml
    - PATH=/home/travis/virtualenv/python2.7.8/bin/:$PATH fontbakery-travis-deploy.py
    branches:
      only:
      - master
  3. Add the secure section to the file. First fetch a Github secure token for your repository, replacing yourGithubUsername and yourRepoName with your own:

    curl -u yourGithubUsername \
        -d '{"scopes":["public_repo"],"note":"FontBakery for yourRepoName"}' \
        -s "https://api.github.com/authorizations";

If you get the following response, you already have a token for note, and you can find it on your github profile page

{
  "message": "Validation Failed",
  "documentation_url": "https://developer.github.com/v3/oauth_authorizations/#create-a-new-authorization",
  "errors": [
    {
      "resource": "OauthAccess",
      "code": "already_exists",
      "field": "description"
    }
  ]
}

Now add the token using the travis command, replacing yourGithubUserEmail and yourGithubRepoToken with your own:

travis encrypt GIT_NAME="yourGithubUsername" \
  GIT_EMAIL="yourGithubUserEmail" \
  GH_TOKEN="yourGithubRepoToken" \
  --add --no-interactive -x;
  1. Add and commit your .travis.yml file and push it to Github.

    git add .travis.yml;
    git commit .travis.yml -m "Adding .travis.yml";
    git push origin master;
  2. After each build by Travis you can see a report at http://yourGithubUsername.github.io/yourRepo

Tips for working with Github

When working with font projects on Github, it is typical to work with several forks of the same project. To keep things simple, create a folder in your projects director called github.com, inside that make a directory for each username you work with, and clone each user's repo inside their correpsonding folder. This way on your harddisk you have a 'mirror' of the github.com site structure.

There are many good guides for Github around the web, including:

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%