Skip to content

Commit

Permalink
Merge pull request #18 from theleagueof/docker-tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque authored Jun 21, 2020
2 parents 0cfa310 + e53336e commit 4062c33
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ RUN pacman --needed --noconfirm -Syuq && yes | pacman -Sccq

# Install fontship run-time dependecies
RUN pacman --needed --noconfirm -Syq \
entr font-v gftools git libarchive make python sfnt2woff-zopfli ttfautohint zsh \
python-{brotli,click,defcon,font{make,tools},fs,lxml,ufo{2ft,normalizer},zopfli} \
entr font-v gftools git libarchive make python sfnt2woff-zopfli ttfautohint woff2 zsh \
python-{brotli,click,defcon,font{make,tools},fs,lxml,ufo{2ft,normalizer},unicodedata2,zopfli} \
&& yes | pacman -Sccq

# Setup separate image to build fontship so we don't bloat the final image
Expand Down
16 changes: 11 additions & 5 deletions src/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ SHELL := zsh
.ONESHELL:
.SECONDEXPANSION:

CONTAINERIZED != test -f /.dockerenv && echo true || echo false

# Initial environment setup
FONTSHIPDIR != cd "$(shell dirname $(lastword $(MAKEFILE_LIST)))/" && pwd
GITNAME := $(notdir $(shell git worktree list | head -n1 | awk '{print $$1}'))
Expand All @@ -29,7 +31,11 @@ FONTV ?= font-v
PYTHON ?= python3

# Read font name from metadata file or guess from repository name
FontName ?= $(shell python -c 'print("$(PROJECT)".replace("-", " ").title())')
FamilyName ?= $(shell $(CONTAINERIZED) || python -c 'print("$(PROJECT)".replace("-", " ").title())')

ifeq ($(FamilyName),)
$(error We cannot properly detect the font’s Family Name yet from inside Docker. Please manually specify it by adding FamilyName='Family Name' as an agument to your command invocation)
endif

# Determine font version automatically from repository git tags
FontVersion ?= $(shell git describe --tags --abbrev=6 | sed 's/-.*//g')
Expand All @@ -38,7 +44,7 @@ GitVersion ?= $(shell git describe --tags --abbrev=6 | sed 's/-/-r/')
isTagged := $(if $(subst $(FontVersion),,$(GitVersion)),,true)

# Look for what fonts & styles are in this repository that will need building
FontBase = $(subst $(space),,$(FontName))
FontBase = $(subst $(space),,$(FamilyName))
FontStyles = $(subst $(FontBase)-,,$(basename $(wildcard $(FontBase)-*.ufo)))
FontStyles += $(foreach GLYPHS,$(wildcard $(FontBase).glyphs),$(call glyphWeights,$(GLYPHS)))

Expand All @@ -61,7 +67,7 @@ debug:
echo PROJECTDIR = $(PROJECTDIR)
echo PUBDIR = $(PUBDIR)
echo ----------------------------
echo FontName = $(FontName)
echo FamilyName = $(FamilyName)
echo FontBase: $(FontBase)
echo FontStyles: $(FontStyles)
echo FontVersion: $(FontVersion)
Expand Down Expand Up @@ -168,14 +174,14 @@ variable_ttf/%-VF.ttf: %.glyphs
$(normalizeVersion)

instance_otf/$(FontBase)-%.otf: $(FontBase).glyphs
fontmake --master-dir '{tmp}' -g $< -i "$(FontName) $*" -o otf
fontmake --master-dir '{tmp}' -g $< -i "$(FamilyName) $*" -o otf

%.otf: instance_otf/%.otf .last-commit
cp $< $@
$(normalizeVersion)

instance_ttf/$(FontBase)-%.ttf: $(FontBase).glyphs
fontmake --master-dir '{tmp}' -g $< -i "$(FontName) $*" -o ttf
fontmake --master-dir '{tmp}' -g $< -i "$(FamilyName) $*" -o ttf
gftools fix-dsig --autofix $@

%.ttf: instance_ttf/%.ttf .last-commit
Expand Down

0 comments on commit 4062c33

Please sign in to comment.