Skip to content

Commit

Permalink
feat: New documentation images
Browse files Browse the repository at this point in the history
  • Loading branch information
ottta committed Feb 1, 2024
1 parent 3c86285 commit 6c2b12a
Show file tree
Hide file tree
Showing 5 changed files with 177 additions and 22 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Description of your font goes here. We recommend to start with a very short pres
Don't hesitate to create images!

![Sample Image](documentation/image1.png)
![Sample Image](documentation/image2.png)

## About

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

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

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

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

Expand Down Expand Up @@ -65,10 +66,11 @@ Current `1.230`, new `1.231`
## Changelog

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

**26 May 2021. Version 2.13**

- MAJOR Font turned to a variable font.
- SIGNIFICANT New Stylistic sets added.

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

## Repository Layout

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.
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.
Binary file modified documentation/image1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 19 additions & 17 deletions documentation/image1.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@
import argparse

# Constants, these are the main "settings" for the image
WIDTH, HEIGHT, MARGIN, FRAMES = 2048, 1048, 128, 1
FONT_PATH = "fonts/ttf/SutasomaDisplay-BoldItalic.ttf"
WIDTH, HEIGHT, MARGIN, FRAMES = 2048, 1024, 128, 1
FONT_PATH = "fonts/ttf/SutasomaDisplay-Regular.ttf"
FONT_LICENSE = "OFL v1.1"
AUXILIARY_FONT = "Helvetica"
AUXILIARY_FONT_SIZE = 32
BIG_TEXT_FONT_SIZE = 280
BIG_TEXT_SIDE_MARGIN = MARGIN * 2
BIG_TEXT_BOTTOM_MARGIN = MARGIN * 4.35
GRID_VIEW = False # Change this to "True" for a grid overlay
AUXILIARY_FONT_SIZE = 48

BIG_TEXT = "AaBb"
BIG_TEXT_FONT_SIZE = 730
BIG_TEXT_SIDE_MARGIN = MARGIN * 1
BIG_TEXT_BOTTOM_MARGIN = MARGIN * 2

GRID_VIEW = False # Toggle this for a grid overlay

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

# Draw main text
def draw_main_text():
fill(0)
fill(1)
stroke(None)
font(FONT_PATH)
fontSize(BIG_TEXT_FONT_SIZE)
# Adjust this line to center main text manually.
# TODO: This should be done automatically when drawbot-skia
# has support for textBox() and FormattedString
# text(BIG_TEXT, ((WIDTH / 2) - MARGIN * 4.75, (HEIGHT / 2) - MARGIN * 2.5))
text("Sutasoma", (MARGIN, (HEIGHT - (MARGIN * 3.5))))
text("Text & Display", (MARGIN, MARGIN * 2.5))
text(BIG_TEXT, (BIG_TEXT_SIDE_MARGIN, BIG_TEXT_BOTTOM_MARGIN))


# Divider lines
def draw_divider_lines():
stroke(0)
strokeWidth(4)
stroke(1)
strokeWidth(5)
lineCap("round")
line((MARGIN, HEIGHT - MARGIN), (WIDTH - MARGIN, HEIGHT - MARGIN))
line((MARGIN, HEIGHT - (MARGIN * 1.5)), (WIDTH - MARGIN, HEIGHT - (MARGIN * 1.5)))
line((MARGIN, MARGIN + (MARGIN / 2)), (WIDTH - MARGIN, MARGIN + (MARGIN / 2)))
stroke(None)

Expand All @@ -110,8 +112,8 @@ def draw_auxiliary_text():
# Setup
font(AUXILIARY_FONT)
fontSize(AUXILIARY_FONT_SIZE)
POS_TOP_LEFT = (MARGIN, HEIGHT - MARGIN * 1)
POS_TOP_RIGHT = (WIDTH - MARGIN, HEIGHT - MARGIN * 1)
POS_TOP_LEFT = (MARGIN, HEIGHT - MARGIN * 1.25)
POS_TOP_RIGHT = (WIDTH - MARGIN, HEIGHT - MARGIN * 1.25)
POS_BOTTOM_LEFT = (MARGIN, MARGIN)
POS_BOTTOM_RIGHT = (WIDTH - MARGIN * 0.95, MARGIN)
URL_AND_HASH = MY_URL + "at commit " + MY_HASH
Expand All @@ -127,7 +129,7 @@ def draw_auxiliary_text():
if __name__ == "__main__":
draw_background()
draw_main_text()
# draw_divider_lines()
draw_divider_lines()
draw_auxiliary_text()
# Save output, using the "--output" flag location
saveImage(args.output)
Expand Down
Binary file added documentation/image2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
151 changes: 151 additions & 0 deletions documentation/image2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
# This script is meant to be run from the root level
# of your font's git repository. For example, from a Unix terminal:
# $ git clone my-font
# $ cd my-font
# $ python3 documentation/image1.py --output documentation/image1.png

# Import moduels from external python packages: https://pypi.org/
from drawbot_skia.drawbot import *
from fontTools.ttLib import TTFont
from fontTools.misc.fixedTools import floatToFixedToStr

# Import moduels from the Python Standard Library: https://docs.python.org/3/library/
import subprocess
import sys
import argparse

# Constants, these are the main "settings" for the image
WIDTH, HEIGHT, MARGIN, FRAMES = 2048, 1024, 128, 1
FONT_PATH = "fonts/ttf/SutasomaDisplay-Regular.ttf"
FONT_LICENSE = "OFL v1.1"
AUXILIARY_FONT = "Helvetica"
AUXILIARY_FONT_SIZE = 48

LINE_ONE = "ABCDEFGHIJKLMNOPQ"
LINE_TWO = "RSTUVWXYZ123456789"
LINE_THREE = "abcdefghijklmnopqrstu"
LINE_FOUR = "vwxyz,.;:!@#$%^&*(){}[]"
BIG_TEXT_FONT_SIZE = 160
BIG_TEXT_SIDE_MARGIN = MARGIN * 1
BIG_TEXT_BOTTOM_MARGIN = MARGIN * 5.45

GRID_VIEW = False # Toggle this for a grid overlay

# Handel the "--output" flag
# For example: $ python3 documentation/image1.py --output documentation/image1.png
parser = argparse.ArgumentParser()
parser.add_argument("--output", metavar="PNG", help="where to write the PNG file")
args = parser.parse_args()

# Load the font with the parts of fonttools that are imported with the line:
# from fontTools.ttLib import TTFont
# Docs Link: https://fonttools.readthedocs.io/en/latest/ttLib/ttFont.html
ttFont = TTFont(FONT_PATH)

# Constants that are worked out dynamically
MY_URL = subprocess.check_output("git remote get-url origin", shell=True).decode()
MY_HASH = subprocess.check_output("git rev-parse --short HEAD", shell=True).decode()
FONT_NAME = ttFont["name"].getDebugName(4)
FONT_VERSION = "v%s" % floatToFixedToStr(ttFont["head"].fontRevision, 16)


# Draws a grid
def grid():
stroke(1, 0, 0, 0.75)
strokeWidth(2)
STEP_X, STEP_Y = 0, 0
INCREMENT_X, INCREMENT_Y = MARGIN / 2, MARGIN / 2
rect(MARGIN, MARGIN, WIDTH - (MARGIN * 2), HEIGHT - (MARGIN * 2))
for x in range(29):
polygon((MARGIN + STEP_X, MARGIN), (MARGIN + STEP_X, HEIGHT - MARGIN))
STEP_X += INCREMENT_X
for y in range(29):
polygon((MARGIN, MARGIN + STEP_Y), (WIDTH - MARGIN, MARGIN + STEP_Y))
STEP_Y += INCREMENT_Y
polygon((WIDTH / 2, 0), (WIDTH / 2, HEIGHT))
polygon((0, HEIGHT / 2), (WIDTH, HEIGHT / 2))


# Remap input range to VF axis range
# This is useful for animation
# (E.g. sinewave(-1,1) to wght(100,900))
def remap(value, inputMin, inputMax, outputMin, outputMax):
inputSpan = inputMax - inputMin # FIND INPUT RANGE SPAN
outputSpan = outputMax - outputMin # FIND OUTPUT RANGE SPAN
valueScaled = float(value - inputMin) / float(inputSpan)
return outputMin + (valueScaled * outputSpan)


# Draw the page/frame and a grid if "GRID_VIEW" is set to "True"
def draw_background():
newPage(WIDTH, HEIGHT)
fill(0)
rect(-2, -2, WIDTH + 2, HEIGHT + 2)
if GRID_VIEW:
grid()
else:
pass


# Draw main text
def draw_main_text():
fill(1)
stroke(None)
font(FONT_PATH)
fontSize(BIG_TEXT_FONT_SIZE)
# Adjust this line to center main text manually.
# TODO: This should be done automatically when drawbot-skia
# has support for textBox() and FormattedString
LEADING = 1.2
text(LINE_ONE, (BIG_TEXT_SIDE_MARGIN, BIG_TEXT_BOTTOM_MARGIN))
text(LINE_TWO, (BIG_TEXT_SIDE_MARGIN, BIG_TEXT_BOTTOM_MARGIN - (MARGIN * LEADING)))
text(
LINE_THREE,
(BIG_TEXT_SIDE_MARGIN, BIG_TEXT_BOTTOM_MARGIN - (MARGIN * (LEADING * 2))),
)
text(
LINE_FOUR,
(BIG_TEXT_SIDE_MARGIN, BIG_TEXT_BOTTOM_MARGIN - (MARGIN * (LEADING * 3))),
)


# Divider lines
def draw_divider_lines():
stroke(1)
strokeWidth(5)
lineCap("round")
line((MARGIN, HEIGHT - (MARGIN * 1.5)), (WIDTH - MARGIN, HEIGHT - (MARGIN * 1.5)))
line((MARGIN, MARGIN + (MARGIN / 2)), (WIDTH - MARGIN, MARGIN + (MARGIN / 2)))
stroke(None)


# Draw text describing the font and it's git status & repo URL
def draw_auxiliary_text():
# Setup
font(AUXILIARY_FONT)
fontSize(AUXILIARY_FONT_SIZE)
POS_TOP_LEFT = (MARGIN, HEIGHT - MARGIN * 1.25)
POS_TOP_RIGHT = (WIDTH - MARGIN, HEIGHT - MARGIN * 1.25)
POS_BOTTOM_LEFT = (MARGIN, MARGIN)
POS_BOTTOM_RIGHT = (WIDTH - MARGIN * 0.95, MARGIN)
# URL_AND_HASH = "github.com/googlefonts/googlefonts-project-template " + "at commit " + MY_HASH
URL_AND_HASH = MY_URL + "at commit " + MY_HASH
URL_AND_HASH = URL_AND_HASH.replace("\n", " ")
# Draw Text
# text("Your Font Regular", POS_TOP_LEFT, align="left")
text(FONT_NAME, POS_TOP_LEFT, align="left")
text(FONT_VERSION, POS_TOP_RIGHT, align="right")
text(URL_AND_HASH, POS_BOTTOM_LEFT, align="left")
text(FONT_LICENSE, POS_BOTTOM_RIGHT, align="right")


# Build and save the image
if __name__ == "__main__":
draw_background()
draw_main_text()
draw_divider_lines()
draw_auxiliary_text()
# Save output, using the "--output" flag location
saveImage(args.output)
# Print done in the terminal
print("DrawBot: Done")

0 comments on commit 6c2b12a

Please sign in to comment.