Skip to content

Commit 6c2b12a

Browse files
committed
feat: New documentation images
1 parent 3c86285 commit 6c2b12a

File tree

5 files changed

+177
-22
lines changed

5 files changed

+177
-22
lines changed

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Description of your font goes here. We recommend to start with a very short pres
1717
Don't hesitate to create images!
1818

1919
![Sample Image](documentation/image1.png)
20+
![Sample Image](documentation/image2.png)
2021

2122
## About
2223

@@ -28,9 +29,9 @@ Fonts are built automatically by GitHub Actions - take a look in the "Actions" t
2829

2930
If you want to build fonts manually on your own computer:
3031

31-
* `make build` will produce font files.
32-
* `make test` will run [FontBakery](https://github.com/googlefonts/fontbakery)'s quality assurance tests.
33-
* `make proof` will generate HTML proof files.
32+
- `make build` will produce font files.
33+
- `make test` will run [FontBakery](https://github.com/googlefonts/fontbakery)'s quality assurance tests.
34+
- `make proof` will generate HTML proof files.
3435

3536
The proof files and QA tests are also available automatically via GitHub Actions - look at https://kiwari-kolektiv-studio.github.io/sutasoma.
3637

@@ -65,10 +66,11 @@ Current `1.230`, new `1.231`
6566
## Changelog
6667

6768
When you update your font (new version or new release), please report all notable changes here, with a date.
68-
[Font Versioning](https://github.com/googlefonts/gf-docs/tree/main/Spec#font-versioning) is based on semver.
69+
[Font Versioning](https://github.com/googlefonts/gf-docs/tree/main/Spec#font-versioning) is based on semver.
6970
Changelog example:
7071

7172
**26 May 2021. Version 2.13**
73+
7274
- MAJOR Font turned to a variable font.
7375
- SIGNIFICANT New Stylistic sets added.
7476

@@ -80,4 +82,4 @@ https://scripts.sil.org/OFL
8082

8183
## Repository Layout
8284

83-
This font repository structure is inspired by [Unified Font Repository v0.3](https://github.com/unified-font-repository/Unified-Font-Repository), modified for the Google Fonts workflow.
85+
This font repository structure is inspired by [Unified Font Repository v0.3](https://github.com/unified-font-repository/Unified-Font-Repository), modified for the Google Fonts workflow.

documentation/image1.png

-24.6 KB
Loading

documentation/image1.py

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,18 @@
1515
import argparse
1616

1717
# Constants, these are the main "settings" for the image
18-
WIDTH, HEIGHT, MARGIN, FRAMES = 2048, 1048, 128, 1
19-
FONT_PATH = "fonts/ttf/SutasomaDisplay-BoldItalic.ttf"
18+
WIDTH, HEIGHT, MARGIN, FRAMES = 2048, 1024, 128, 1
19+
FONT_PATH = "fonts/ttf/SutasomaDisplay-Regular.ttf"
2020
FONT_LICENSE = "OFL v1.1"
2121
AUXILIARY_FONT = "Helvetica"
22-
AUXILIARY_FONT_SIZE = 32
23-
BIG_TEXT_FONT_SIZE = 280
24-
BIG_TEXT_SIDE_MARGIN = MARGIN * 2
25-
BIG_TEXT_BOTTOM_MARGIN = MARGIN * 4.35
26-
GRID_VIEW = False # Change this to "True" for a grid overlay
22+
AUXILIARY_FONT_SIZE = 48
23+
24+
BIG_TEXT = "AaBb"
25+
BIG_TEXT_FONT_SIZE = 730
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
2730

2831
# Handel the "--output" flag
2932
# For example: $ python3 documentation/image1.py --output documentation/image1.png
@@ -73,7 +76,7 @@ def remap(value, inputMin, inputMax, outputMin, outputMax):
7376
# Draw the page/frame and a grid if "GRID_VIEW" is set to "True"
7477
def draw_background():
7578
newPage(WIDTH, HEIGHT)
76-
fill(1)
79+
fill(0)
7780
rect(-2, -2, WIDTH + 2, HEIGHT + 2)
7881
if GRID_VIEW:
7982
grid()
@@ -83,24 +86,23 @@ def draw_background():
8386

8487
# Draw main text
8588
def draw_main_text():
86-
fill(0)
89+
fill(1)
8790
stroke(None)
8891
font(FONT_PATH)
8992
fontSize(BIG_TEXT_FONT_SIZE)
9093
# Adjust this line to center main text manually.
9194
# TODO: This should be done automatically when drawbot-skia
9295
# has support for textBox() and FormattedString
9396
# text(BIG_TEXT, ((WIDTH / 2) - MARGIN * 4.75, (HEIGHT / 2) - MARGIN * 2.5))
94-
text("Sutasoma", (MARGIN, (HEIGHT - (MARGIN * 3.5))))
95-
text("Text & Display", (MARGIN, MARGIN * 2.5))
97+
text(BIG_TEXT, (BIG_TEXT_SIDE_MARGIN, BIG_TEXT_BOTTOM_MARGIN))
9698

9799

98100
# Divider lines
99101
def draw_divider_lines():
100-
stroke(0)
101-
strokeWidth(4)
102+
stroke(1)
103+
strokeWidth(5)
102104
lineCap("round")
103-
line((MARGIN, HEIGHT - MARGIN), (WIDTH - MARGIN, HEIGHT - MARGIN))
105+
line((MARGIN, HEIGHT - (MARGIN * 1.5)), (WIDTH - MARGIN, HEIGHT - (MARGIN * 1.5)))
104106
line((MARGIN, MARGIN + (MARGIN / 2)), (WIDTH - MARGIN, MARGIN + (MARGIN / 2)))
105107
stroke(None)
106108

@@ -110,8 +112,8 @@ def draw_auxiliary_text():
110112
# Setup
111113
font(AUXILIARY_FONT)
112114
fontSize(AUXILIARY_FONT_SIZE)
113-
POS_TOP_LEFT = (MARGIN, HEIGHT - MARGIN * 1)
114-
POS_TOP_RIGHT = (WIDTH - MARGIN, HEIGHT - MARGIN * 1)
115+
POS_TOP_LEFT = (MARGIN, HEIGHT - MARGIN * 1.25)
116+
POS_TOP_RIGHT = (WIDTH - MARGIN, HEIGHT - MARGIN * 1.25)
115117
POS_BOTTOM_LEFT = (MARGIN, MARGIN)
116118
POS_BOTTOM_RIGHT = (WIDTH - MARGIN * 0.95, MARGIN)
117119
URL_AND_HASH = MY_URL + "at commit " + MY_HASH
@@ -127,7 +129,7 @@ def draw_auxiliary_text():
127129
if __name__ == "__main__":
128130
draw_background()
129131
draw_main_text()
130-
# draw_divider_lines()
132+
draw_divider_lines()
131133
draw_auxiliary_text()
132134
# Save output, using the "--output" flag location
133135
saveImage(args.output)

documentation/image2.png

215 KB
Loading

documentation/image2.py

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
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/SutasomaDisplay-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 = 160
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(
103+
LINE_THREE,
104+
(BIG_TEXT_SIDE_MARGIN, BIG_TEXT_BOTTOM_MARGIN - (MARGIN * (LEADING * 2))),
105+
)
106+
text(
107+
LINE_FOUR,
108+
(BIG_TEXT_SIDE_MARGIN, BIG_TEXT_BOTTOM_MARGIN - (MARGIN * (LEADING * 3))),
109+
)
110+
111+
112+
# Divider lines
113+
def draw_divider_lines():
114+
stroke(1)
115+
strokeWidth(5)
116+
lineCap("round")
117+
line((MARGIN, HEIGHT - (MARGIN * 1.5)), (WIDTH - MARGIN, HEIGHT - (MARGIN * 1.5)))
118+
line((MARGIN, MARGIN + (MARGIN / 2)), (WIDTH - MARGIN, MARGIN + (MARGIN / 2)))
119+
stroke(None)
120+
121+
122+
# Draw text describing the font and it's git status & repo URL
123+
def draw_auxiliary_text():
124+
# Setup
125+
font(AUXILIARY_FONT)
126+
fontSize(AUXILIARY_FONT_SIZE)
127+
POS_TOP_LEFT = (MARGIN, HEIGHT - MARGIN * 1.25)
128+
POS_TOP_RIGHT = (WIDTH - MARGIN, HEIGHT - MARGIN * 1.25)
129+
POS_BOTTOM_LEFT = (MARGIN, MARGIN)
130+
POS_BOTTOM_RIGHT = (WIDTH - MARGIN * 0.95, MARGIN)
131+
# URL_AND_HASH = "github.com/googlefonts/googlefonts-project-template " + "at commit " + MY_HASH
132+
URL_AND_HASH = MY_URL + "at commit " + MY_HASH
133+
URL_AND_HASH = URL_AND_HASH.replace("\n", " ")
134+
# Draw Text
135+
# text("Your Font Regular", POS_TOP_LEFT, align="left")
136+
text(FONT_NAME, POS_TOP_LEFT, align="left")
137+
text(FONT_VERSION, POS_TOP_RIGHT, align="right")
138+
text(URL_AND_HASH, POS_BOTTOM_LEFT, align="left")
139+
text(FONT_LICENSE, POS_BOTTOM_RIGHT, align="right")
140+
141+
142+
# Build and save the image
143+
if __name__ == "__main__":
144+
draw_background()
145+
draw_main_text()
146+
draw_divider_lines()
147+
draw_auxiliary_text()
148+
# Save output, using the "--output" flag location
149+
saveImage(args.output)
150+
# Print done in the terminal
151+
print("DrawBot: Done")

0 commit comments

Comments
 (0)