Skip to content

Commit

Permalink
Unify build.py
Browse files Browse the repository at this point in the history
There is no need for two different Python versions – fontforge can support Python 3 just fine.

Successfully built with:

| Python | fontforge | fonttools |
|--------|-----------|-----------|
| 2.7.17 | 20190413  | 3.42.0    |
| 3.5.9  | 20190413  | 3.42.0    |
| 3.7.5  | 20190413  | 3.42.0    |
| 3.7.5  | 20190413  | 4.0.2     |
  • Loading branch information
jtojnar committed Dec 25, 2019
1 parent 9224c34 commit 821ccb5
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 32 deletions.
21 changes: 12 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
language: python
python: 3.8
sudo: required
install:
- sudo add-apt-repository ppa:fontforge/fontforge -y
- sudo apt-get update -qq
- sudo apt-get install fontforge
- pip install -r requirements.txt
- pip install https://github.com/behdad/fonttools/zipball/master
dist: bionic
addons:
apt:
sources:
# for some reason python3-fontforge is only available in focal
- sourceline: 'deb http://us.archive.ubuntu.com/ubuntu/ focal main restricted'
- sourceline: 'deb http://us.archive.ubuntu.com/ubuntu/ focal universe'
packages:
- python3
- python3-fontforge
- python3-jinja2
- python3-fonttools
script:
- make
deploy:
Expand Down
26 changes: 9 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,16 @@ $(BOLD_DISCORD): $(BOLD_DISCORD_UNLINK) ligatures.fea
ligatures.fea: ligatures.fea.jinja2 data.json build-feature.py
python build-feature.py

$(REGULAR_UNLINK): build-py2.py RictyDiminished/RictyDiminished-Regular.ttf FiraCode/distr/otf/FiraCode-Regular.otf
fontforge -lang=py -script "$<" "$(word 2, $^)" "$(word 3, $^)" "$@" Regular false
$(REGULAR_UNLINK): RictyDiminished/RictyDiminished-Regular.ttf FiraCode/distr/otf/FiraCode-Regular.otf
python build.py "$(word 1, $^)" "$(word 2, $^)" "$@" Regular false

$(BOLD_UNLINK): build-py2.py RictyDiminished/RictyDiminished-Bold.ttf FiraCode/distr/otf/FiraCode-Bold.otf
fontforge -lang=py -script "$<" "$(word 2, $^)" "$(word 3, $^)" "$@" Bold false
$(BOLD_UNLINK): RictyDiminished/RictyDiminished-Bold.ttf FiraCode/distr/otf/FiraCode-Bold.otf
python build.py "$(word 1, $^)" "$(word 2, $^)" "$@" Bold false

$(REGULAR_DISCORD_UNLINK): build-py2.py RictyDiminished/RictyDiminishedDiscord-Regular.ttf FiraCode/distr/otf/FiraCode-Regular.otf
fontforge -lang=py -script "$<" "$(word 2, $^)" "$(word 3, $^)" "$@" Regular true
$(REGULAR_DISCORD_UNLINK): RictyDiminished/RictyDiminishedDiscord-Regular.ttf FiraCode/distr/otf/FiraCode-Regular.otf
python build.py "$(word 1, $^)" "$(word 2, $^)" "$@" Regular true

$(BOLD_DISCORD_UNLINK): build-py2.py RictyDiminished/RictyDiminishedDiscord-Bold.ttf FiraCode/distr/otf/FiraCode-Bold.otf
fontforge -lang=py -script "$<" "$(word 2, $^)" "$(word 3, $^)" "$@" Bold true
$(BOLD_DISCORD_UNLINK): RictyDiminished/RictyDiminishedDiscord-Bold.ttf FiraCode/distr/otf/FiraCode-Bold.otf
python build.py "$(word 1, $^)" "$(word 2, $^)" "$@" Bold true

build-py2.py: build-py3.py ligatures.csv
3to2 "$<" -w -x str
mv -f "$<" "$@"
mv -f "$<.bak" "$<"

clean:
-rm -f build-py2.py

.PHONY: all clean
.PHONY: all
6 changes: 3 additions & 3 deletions build-py3.py → build.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
firacode = fontforge.open(options.firacode)

# Load ligatures data and create data to generate feature file
with open('ligatures.csv', 'rb') as file:
with open('ligatures.csv', 'r') as file:
ligatures_reader = csv.reader(file, delimiter=' ')

ligatures = []
Expand All @@ -57,10 +57,10 @@

# Dump data
with open('data.json', 'w') as file:
file.write(unicode(json.dumps({
file.write(json.dumps({
'ligatures': ligatures,
'nullable_glyphs': nullable_glyphs,
})))
}))

# Copy needed glyphs from Fira Code font to Ricty
for (source_type, name) in glyphs:
Expand Down
3 changes: 0 additions & 3 deletions requirements.txt

This file was deleted.

0 comments on commit 821ccb5

Please sign in to comment.