Skip to content

Commit 78c3f8c

Browse files
committed
updated workflow
1 parent de2069d commit 78c3f8c

23 files changed

Lines changed: 574 additions & 12 deletions

Makefile

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
SOURCES=$(shell python3 scripts/read-config.py --sources )
2+
FAMILY=$(shell python3 scripts/read-config.py --family )
3+
DRAWBOT_SCRIPTS=$(shell ls documentation/*.py)
4+
DRAWBOT_OUTPUT=$(shell ls documentation/*.py | sed 's/\.py/.png/g')
5+
6+
help:
7+
@echo "###"
8+
@echo "# Build targets for $(FAMILY)"
9+
@echo "###"
10+
@echo
11+
@echo " make build: Builds the fonts and places them in the fonts/ directory"
12+
@echo " make test: Tests the fonts with fontspector"
13+
@echo " make proof: Creates HTML proof documents in the proof/ directory"
14+
@echo " make images: Creates PNG specimen images in the documentation/ directory"
15+
@echo
16+
17+
build: build.stamp
18+
19+
venv: venv/touchfile
20+
21+
customize: venv
22+
. venv/bin/activate; python3 scripts/customize.py
23+
24+
build.stamp: venv sources/config.yaml $(SOURCES)
25+
rm -rf fonts
26+
(for config in sources/config*.yaml; do . venv/bin/activate; gftools builder $$config; done) && touch build.stamp
27+
28+
venv/touchfile: requirements.txt
29+
test -d venv || python3 -m venv venv
30+
. venv/bin/activate; pip install -Ur requirements.txt
31+
touch venv/touchfile
32+
33+
test: build.stamp
34+
which fontspector || (echo "fontspector not found. Please install it with 'cargo install fontspector'." && exit 1)
35+
TOCHECK=$$(find fonts/variable -type f 2>/dev/null); if [ -z "$$TOCHECK" ]; then TOCHECK=$$(find fonts/ttf -type f 2>/dev/null); fi ; mkdir -p out/ out/fontspector; fontspector --profile googlefonts -l warn --full-lists --succinct --html out/fontspector/fontspector-report.html --ghmarkdown out/fontspector/fontspector-report.md --badges out/badges $$TOCHECK || echo '::warning file=sources/config.yaml,title=fontspector failures::The fontspector QA check reported errors in your font. Please check the generated report.'
36+
37+
proof: venv build.stamp
38+
TOCHECK=$$(find fonts/variable -type f 2>/dev/null); if [ -z "$$TOCHECK" ]; then TOCHECK=$$(find fonts/ttf -type f 2>/dev/null); fi ; . venv/bin/activate; mkdir -p out/ out/proof; diffenator2 proof $$TOCHECK -o out/proof
39+
40+
images: venv $(DRAWBOT_OUTPUT)
41+
42+
%.png: %.py build.stamp
43+
. venv/bin/activate; python3 $< --output $@
44+
45+
clean:
46+
rm -rf venv
47+
find . -name "*.pyc" -delete
48+
49+
update-project-template:
50+
npx update-template https://github.com/googlefonts/googlefonts-project-template/
51+
52+
update: venv
53+
venv/bin/pip install --upgrade pip-tools
54+
# See https://pip-tools.readthedocs.io/en/latest/#a-note-on-resolvers for
55+
# the `--resolver` flag below.
56+
venv/bin/pip-compile --upgrade --verbose --resolver=backtracking requirements.in
57+
venv/bin/pip-sync requirements.txt
58+
59+
git commit -m "Update requirements" requirements.txt
60+
git push

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
<source media="(prefers-color-scheme: light)" srcset="./documentation/slide1-light.svg">
77
<img alt="Brawler open-source font by Cyreal" src="./documentation/slide1-light.svg">
88
</picture>
9+
<a href="https://cyreal.org/fonts/brawler">Website</a> |
10+
<a href="https://fonts.google.com/specimen/Brawler">Google Fonts</a>
911
</p>
1012

1113
## About

documentation/ARTICLE.en_us.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<p>Brawler is a compact typeface with sharp features and a sturdy character, designed for comfortable reading in small
2+
sizes. It was initially planned as a typeface for newspapers and tabloids. Thus, the design concept was shaped by
3+
the demands of low quality printing media and the aesthetic preferences of periodical publications.</p>
4+
<p>To contribute, see <a href="https://github.com/cyrealtype/Brawler">github.com/cyrealtype/Brawler</a>.</p>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<p>Brawler is a compact typeface with sharp features and a sturdy character, designed for comfortable reading in small
2+
sizes. It was initially planned as a typeface for newspapers and tabloids. Thus, the design concept was shaped by
3+
the demands of low quality printing media and the aesthetic preferences of periodical publications.</p>
4+
<p>To contribute, see <a href="https://github.com/cyrealtype/Brawler">github.com/cyrealtype/Brawler</a>.</p>

documentation/image1.py

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# This script is meant to be run from the root level
2+
# of your font's git repository. For example, from a Unix terminal:
3+
# $ git clone my-font
4+
# $ cd my-font
5+
# $ python3 documentation/image1.py --output documentation/image1.png
6+
7+
# Import moduels from external python packages: https://pypi.org/
8+
from drawbot_skia.drawbot import *
9+
from fontTools.ttLib import TTFont
10+
from fontTools.misc.fixedTools import floatToFixedToStr
11+
12+
# Import moduels from the Python Standard Library: https://docs.python.org/3/library/
13+
import subprocess
14+
import sys
15+
import argparse
16+
17+
# Constants, these are the main "settings" for the image
18+
WIDTH, HEIGHT, MARGIN, FRAMES = 2048, 1024, 128, 1
19+
FONT_PATH = "fonts/ttf/Brawler-Regular.ttf"
20+
FONT_LICENSE = "OFL v1.1"
21+
AUXILIARY_FONT = "Helvetica"
22+
AUXILIARY_FONT_SIZE = 48
23+
24+
BIG_TEXT = "AaBb"
25+
BIG_TEXT_FONT_SIZE = 680
26+
BIG_TEXT_SIDE_MARGIN = MARGIN * 1
27+
BIG_TEXT_BOTTOM_MARGIN = MARGIN * 2
28+
29+
GRID_VIEW = False # Toggle this for a grid overlay
30+
31+
# Handel the "--output" flag
32+
# For example: $ python3 documentation/image1.py --output documentation/image1.png
33+
parser = argparse.ArgumentParser()
34+
parser.add_argument("--output", metavar="PNG", help="where to write the PNG file")
35+
args = parser.parse_args()
36+
37+
# Load the font with the parts of fonttools that are imported with the line:
38+
# from fontTools.ttLib import TTFont
39+
# Docs Link: https://fonttools.readthedocs.io/en/latest/ttLib/ttFont.html
40+
ttFont = TTFont(FONT_PATH)
41+
42+
# Constants that are worked out dynamically
43+
MY_URL = subprocess.check_output("git remote get-url origin", shell=True).decode()
44+
MY_HASH = subprocess.check_output("git rev-parse --short HEAD", shell=True).decode()
45+
FONT_NAME = ttFont["name"].getDebugName(4)
46+
FONT_VERSION = "v%s" % floatToFixedToStr(ttFont["head"].fontRevision, 16)
47+
48+
49+
# Draws a grid
50+
def grid():
51+
stroke(1, 0, 0, 0.75)
52+
strokeWidth(2)
53+
STEP_X, STEP_Y = 0, 0
54+
INCREMENT_X, INCREMENT_Y = MARGIN / 2, MARGIN / 2
55+
rect(MARGIN, MARGIN, WIDTH - (MARGIN * 2), HEIGHT - (MARGIN * 2))
56+
for x in range(29):
57+
polygon((MARGIN + STEP_X, MARGIN), (MARGIN + STEP_X, HEIGHT - MARGIN))
58+
STEP_X += INCREMENT_X
59+
for y in range(29):
60+
polygon((MARGIN, MARGIN + STEP_Y), (WIDTH - MARGIN, MARGIN + STEP_Y))
61+
STEP_Y += INCREMENT_Y
62+
polygon((WIDTH / 2, 0), (WIDTH / 2, HEIGHT))
63+
polygon((0, HEIGHT / 2), (WIDTH, HEIGHT / 2))
64+
65+
66+
# Remap input range to VF axis range
67+
# This is useful for animation
68+
# (E.g. sinewave(-1,1) to wght(100,900))
69+
def remap(value, inputMin, inputMax, outputMin, outputMax):
70+
inputSpan = inputMax - inputMin # FIND INPUT RANGE SPAN
71+
outputSpan = outputMax - outputMin # FIND OUTPUT RANGE SPAN
72+
valueScaled = float(value - inputMin) / float(inputSpan)
73+
return outputMin + (valueScaled * outputSpan)
74+
75+
76+
# Draw the page/frame and a grid if "GRID_VIEW" is set to "True"
77+
def draw_background():
78+
newPage(WIDTH, HEIGHT)
79+
fill(0)
80+
rect(-2, -2, WIDTH + 2, HEIGHT + 2)
81+
if GRID_VIEW:
82+
grid()
83+
else:
84+
pass
85+
86+
87+
# Draw main text
88+
def draw_main_text():
89+
fill(1)
90+
stroke(None)
91+
font(FONT_PATH)
92+
fontSize(BIG_TEXT_FONT_SIZE)
93+
# Adjust this line to center main text manually.
94+
# TODO: This should be done automatically when drawbot-skia
95+
# has support for textBox() and FormattedString
96+
#text(BIG_TEXT, ((WIDTH / 2) - MARGIN * 4.75, (HEIGHT / 2) - MARGIN * 2.5))
97+
text(BIG_TEXT, (BIG_TEXT_SIDE_MARGIN, BIG_TEXT_BOTTOM_MARGIN))
98+
99+
100+
# Divider lines
101+
def draw_divider_lines():
102+
stroke(1)
103+
strokeWidth(5)
104+
lineCap("round")
105+
line((MARGIN, HEIGHT - (MARGIN * 1.5)), (WIDTH - MARGIN, HEIGHT - (MARGIN * 1.5)))
106+
line((MARGIN, MARGIN + (MARGIN / 2)), (WIDTH - MARGIN, MARGIN + (MARGIN / 2)))
107+
stroke(None)
108+
109+
110+
# Draw text describing the font and it's git status & repo URL
111+
def draw_auxiliary_text():
112+
# Setup
113+
font(AUXILIARY_FONT)
114+
fontSize(AUXILIARY_FONT_SIZE)
115+
POS_TOP_LEFT = (MARGIN, HEIGHT - MARGIN * 1.25)
116+
POS_TOP_RIGHT = (WIDTH - MARGIN, HEIGHT - MARGIN * 1.25)
117+
POS_BOTTOM_LEFT = (MARGIN, MARGIN)
118+
POS_BOTTOM_RIGHT = (WIDTH - MARGIN * 0.95, MARGIN)
119+
URL_AND_HASH = MY_URL + "at commit " + MY_HASH
120+
URL_AND_HASH = URL_AND_HASH.replace("\n", " ")
121+
# Draw Text
122+
text(FONT_NAME, POS_TOP_LEFT, align="left")
123+
text(FONT_VERSION, POS_TOP_RIGHT, align="right")
124+
text(URL_AND_HASH, POS_BOTTOM_LEFT, align="left")
125+
text(FONT_LICENSE, POS_BOTTOM_RIGHT, align="right")
126+
127+
128+
# Build and save the image
129+
if __name__ == "__main__":
130+
draw_background()
131+
draw_main_text()
132+
draw_divider_lines()
133+
draw_auxiliary_text()
134+
# Save output, using the "--output" flag location
135+
saveImage(args.output)
136+
# Print done in the terminal
137+
print("DrawBot: Done")

documentation/image2.py

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
# This script is meant to be run from the root level
2+
# of your font's git repository. For example, from a Unix terminal:
3+
# $ git clone my-font
4+
# $ cd my-font
5+
# $ python3 documentation/image1.py --output documentation/image1.png
6+
7+
# Import moduels from external python packages: https://pypi.org/
8+
from drawbot_skia.drawbot import *
9+
from fontTools.ttLib import TTFont
10+
from fontTools.misc.fixedTools import floatToFixedToStr
11+
12+
# Import moduels from the Python Standard Library: https://docs.python.org/3/library/
13+
import subprocess
14+
import sys
15+
import argparse
16+
17+
# Constants, these are the main "settings" for the image
18+
WIDTH, HEIGHT, MARGIN, FRAMES = 2048, 1024, 128, 1
19+
FONT_PATH = "fonts/ttf/Brawler-Regular.ttf"
20+
FONT_LICENSE = "OFL v1.1"
21+
AUXILIARY_FONT = "Helvetica"
22+
AUXILIARY_FONT_SIZE = 48
23+
24+
LINE_ONE = "ABCDEFGHIJKLMNOPQ"
25+
LINE_TWO = "RSTUVWXYZ123456789"
26+
LINE_THREE = "abcdefghijklmnopqrstu"
27+
LINE_FOUR = "vwxyz,.;:!@#$%^&*(){}[]"
28+
BIG_TEXT_FONT_SIZE = 150
29+
BIG_TEXT_SIDE_MARGIN = MARGIN * 1
30+
BIG_TEXT_BOTTOM_MARGIN = MARGIN * 5.45
31+
32+
GRID_VIEW = False # Toggle this for a grid overlay
33+
34+
# Handel the "--output" flag
35+
# For example: $ python3 documentation/image1.py --output documentation/image1.png
36+
parser = argparse.ArgumentParser()
37+
parser.add_argument("--output", metavar="PNG", help="where to write the PNG file")
38+
args = parser.parse_args()
39+
40+
# Load the font with the parts of fonttools that are imported with the line:
41+
# from fontTools.ttLib import TTFont
42+
# Docs Link: https://fonttools.readthedocs.io/en/latest/ttLib/ttFont.html
43+
ttFont = TTFont(FONT_PATH)
44+
45+
# Constants that are worked out dynamically
46+
MY_URL = subprocess.check_output("git remote get-url origin", shell=True).decode()
47+
MY_HASH = subprocess.check_output("git rev-parse --short HEAD", shell=True).decode()
48+
FONT_NAME = ttFont["name"].getDebugName(4)
49+
FONT_VERSION = "v%s" % floatToFixedToStr(ttFont["head"].fontRevision, 16)
50+
51+
52+
# Draws a grid
53+
def grid():
54+
stroke(1, 0, 0, 0.75)
55+
strokeWidth(2)
56+
STEP_X, STEP_Y = 0, 0
57+
INCREMENT_X, INCREMENT_Y = MARGIN / 2, MARGIN / 2
58+
rect(MARGIN, MARGIN, WIDTH - (MARGIN * 2), HEIGHT - (MARGIN * 2))
59+
for x in range(29):
60+
polygon((MARGIN + STEP_X, MARGIN), (MARGIN + STEP_X, HEIGHT - MARGIN))
61+
STEP_X += INCREMENT_X
62+
for y in range(29):
63+
polygon((MARGIN, MARGIN + STEP_Y), (WIDTH - MARGIN, MARGIN + STEP_Y))
64+
STEP_Y += INCREMENT_Y
65+
polygon((WIDTH / 2, 0), (WIDTH / 2, HEIGHT))
66+
polygon((0, HEIGHT / 2), (WIDTH, HEIGHT / 2))
67+
68+
69+
# Remap input range to VF axis range
70+
# This is useful for animation
71+
# (E.g. sinewave(-1,1) to wght(100,900))
72+
def remap(value, inputMin, inputMax, outputMin, outputMax):
73+
inputSpan = inputMax - inputMin # FIND INPUT RANGE SPAN
74+
outputSpan = outputMax - outputMin # FIND OUTPUT RANGE SPAN
75+
valueScaled = float(value - inputMin) / float(inputSpan)
76+
return outputMin + (valueScaled * outputSpan)
77+
78+
79+
# Draw the page/frame and a grid if "GRID_VIEW" is set to "True"
80+
def draw_background():
81+
newPage(WIDTH, HEIGHT)
82+
fill(0)
83+
rect(-2, -2, WIDTH + 2, HEIGHT + 2)
84+
if GRID_VIEW:
85+
grid()
86+
else:
87+
pass
88+
89+
90+
# Draw main text
91+
def draw_main_text():
92+
fill(1)
93+
stroke(None)
94+
font(FONT_PATH)
95+
fontSize(BIG_TEXT_FONT_SIZE)
96+
# Adjust this line to center main text manually.
97+
# TODO: This should be done automatically when drawbot-skia
98+
# has support for textBox() and FormattedString
99+
LEADING = 1.2
100+
text(LINE_ONE, (BIG_TEXT_SIDE_MARGIN, BIG_TEXT_BOTTOM_MARGIN))
101+
text(LINE_TWO, (BIG_TEXT_SIDE_MARGIN, BIG_TEXT_BOTTOM_MARGIN - (MARGIN * LEADING)))
102+
text(LINE_THREE, (BIG_TEXT_SIDE_MARGIN, BIG_TEXT_BOTTOM_MARGIN - (MARGIN * (LEADING * 2))))
103+
text(LINE_FOUR, (BIG_TEXT_SIDE_MARGIN, BIG_TEXT_BOTTOM_MARGIN - (MARGIN * (LEADING * 3))))
104+
105+
106+
# Divider lines
107+
def draw_divider_lines():
108+
stroke(1)
109+
strokeWidth(5)
110+
lineCap("round")
111+
line((MARGIN, HEIGHT - (MARGIN * 1.5)), (WIDTH - MARGIN, HEIGHT - (MARGIN * 1.5)))
112+
line((MARGIN, MARGIN + (MARGIN / 2)), (WIDTH - MARGIN, MARGIN + (MARGIN / 2)))
113+
stroke(None)
114+
115+
116+
# Draw text describing the font and it's git status & repo URL
117+
def draw_auxiliary_text():
118+
# Setup
119+
font(AUXILIARY_FONT)
120+
fontSize(AUXILIARY_FONT_SIZE)
121+
POS_TOP_LEFT = (MARGIN, HEIGHT - MARGIN * 1.25)
122+
POS_TOP_RIGHT = (WIDTH - MARGIN, HEIGHT - MARGIN * 1.25)
123+
POS_BOTTOM_LEFT = (MARGIN, MARGIN)
124+
POS_BOTTOM_RIGHT = (WIDTH - MARGIN * 0.95, MARGIN)
125+
#URL_AND_HASH = "github.com/googlefonts/googlefonts-project-template " + "at commit " + MY_HASH
126+
URL_AND_HASH = MY_URL + "at commit " + MY_HASH
127+
URL_AND_HASH = URL_AND_HASH.replace("\n", " ")
128+
# Draw Text
129+
#text("Your Font Regular", POS_TOP_LEFT, align="left")
130+
text(FONT_NAME, POS_TOP_LEFT, align="left")
131+
text(FONT_VERSION, POS_TOP_RIGHT, align="right")
132+
text(URL_AND_HASH, POS_BOTTOM_LEFT, align="left")
133+
text(FONT_LICENSE, POS_BOTTOM_RIGHT, align="right")
134+
135+
136+
# Build and save the image
137+
if __name__ == "__main__":
138+
draw_background()
139+
draw_main_text()
140+
draw_divider_lines()
141+
draw_auxiliary_text()
142+
# Save output, using the "--output" flag location
143+
saveImage(args.output)
144+
# Print done in the terminal
145+
print("DrawBot: Done")

documentation/images-license.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The images in this repository are licensed under the CC https://creativecommons.org/licenses/by-sa/4.0/

documentation/sample.png

-85.4 KB
Binary file not shown.

documentation/slide1-dark.png

-37 KB
Binary file not shown.

0 commit comments

Comments
 (0)