Skip to content

Commit

Permalink
Refactor and parallelize
Browse files Browse the repository at this point in the history
  • Loading branch information
chase committed Jun 28, 2015
1 parent 7c0f614 commit 7bdbbca
Show file tree
Hide file tree
Showing 342 changed files with 75 additions and 34 deletions.
8 changes: 7 additions & 1 deletion .gitignore
Expand Up @@ -2,7 +2,13 @@
*.py[co]
__pycache__/

# Wercker
# Build byproducts
_release/
node_modules/
woff2/

# OS X file metadata
.DS_Store

# Vim swap
*.swp
25 changes: 14 additions & 11 deletions build.py → Scripts/build.py
@@ -1,18 +1,21 @@
#!/usr/bin/env python2.7
# vim: sts=4 sw=4 ts=4 et

from fontbuilder import *
import sys
if len(sys.argv) < 4:
usage = """Build should be run with 3 arguments:
# Configuration
## Source directory
source = "Source"
First: The total possible number of parallel processes (1+)
Second: The parallel batch number (0+)
Third: The .sfdir for the font
"""
print >> sys.stderr, usage
exit(1)

## Output directory
output = "_release"
from fontbuilder import *

## Fonts to modify
## To be added when the script supports it + the fonts are done 'Monoid-Oblique.sfdir', 'Monoid-Bold.sfdir'
fonts = ['Monoid.sfdir']
# Output directory
output = "_release"

# Options to generate
conflicting(
Expand Down Expand Up @@ -44,5 +47,5 @@
# ss08
option('l', 'Alt l', Swap("l", "l.zstyle"))

for font in fonts:
build(output, source, font)
# Build options in
build_batch(output, sys.argv[3], int(sys.argv[1]), int(sys.argv[2]))
18 changes: 12 additions & 6 deletions fontbuilder.py → Scripts/fontbuilder.py
Expand Up @@ -64,20 +64,19 @@ def permutations():
for opts in _expand_options(bitmap):
yield(int(float(i)/bitmap_max*100), opts)

def build(dstdir, srcdir, font):
def _build(dstdir, font, permutations):
# Ensure that the destination directory exists
try:
mkdir(dstdir)
except OSError:
pass

for prcnt, opts in permutations():
for prcnt, opts in permutations:
# Open the original font
fnt = fontforge.open(join(srcdir, font))
fnt = fontforge.open(font)

# Get the base name for the font
base = fnt.fontname.split('-')[0]
name = join(dstdir, base)
name = join(dstdir, fnt.fontname)

for opt in opts:
# Append this option to the font name
Expand All @@ -93,9 +92,16 @@ def build(dstdir, srcdir, font):
fnt.generate(name)
fnt.close()

# Log progress to prevent Wercker from timing out
# Log progress to prevent timeoout
print(str(prcnt) + '%.. ' + name)

def build(dstdir, font):
_build(dstdir, font, permutations())

def build_batch(dstdir, font, total_nodes, node_number):
# Starting at (i) node_number, build option every (n) total_nodes
_build(dstdir, font, list(permutations())[node_number::total_nodes])

# Operations
## NOTE:
## All operations return a closure with the 1st argument being a fontforge.font
Expand Down
16 changes: 16 additions & 0 deletions Scripts/gh-pages.sh
@@ -0,0 +1,16 @@
#!/bin/bash
git checkout gh-pages

# Ensure release byproducts are not included
git branch -D release
[[ -e _release ]] && git rm -rf _release

# Convert to webfonts
./node_modules/.bin/ttf2eot /tmp/monoid-normal.ttf /tmp/monoid-normal.eot
./node_modules/.bin/ttf2woff /tmp/monoid-normal.ttf /tmp/monoid-normal.woff
./woff/woff2_compress /tmp/monoid_normal.ttf

cp /tmp/monoid-normal.* css/
git add css
git commit -m "Update web fonts for ${CIRCLE_SHA1}"
git push origin gh-pages
4 changes: 4 additions & 0 deletions Scripts/parallel_build.sh
@@ -0,0 +1,4 @@
#!/bin/bash
echo Total Nodes: $CIRCLE_NODE_TOTAL
echo Current Node: $CIRCLE_NODE_INDEX
docker run -v `pwd`:/data colman/py-fontforge ./Scripts/build.py $CIRCLE_NODE_TOTAL $CIRCLE_NODE_INDEX $1
9 changes: 9 additions & 0 deletions Scripts/prepare_release.sh
@@ -0,0 +1,9 @@
#!/bin/bash
shopt -s extglob
git rm -f *.zip
for f in Monoid-Regular*.ttf; do
# Get the built options
options=${f#Monoid-Regular}
# Add all the fonts with those options
zip -j "../Monoid${options%.ttf}.zip" Monoid-+([^-])$options
done
4 changes: 4 additions & 0 deletions Scripts/woff2.sh
@@ -0,0 +1,4 @@
#!/bin/bash
sudo apt-get install g++
git clone https://github.com/google/woff2.git woff2
cd woff2 && git submodule init && git submodule update && make all
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 7bdbbca

Please sign in to comment.