Skip to content

Commit

Permalink
Merge pull request #32 from simoncozens/sixtyfour-color
Browse files Browse the repository at this point in the history
Add SixtyFour Color
  • Loading branch information
jenskutilek authored Oct 18, 2023
2 parents 95d7e68 + ee097ea commit 9b182d8
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 59 deletions.
Binary file not shown.
15 changes: 14 additions & 1 deletion Sixtyfour/sources/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,17 @@ stat:
- name: Moderate
value: 40
- name: Strong
value: 100
value: 100
recipeProvider: googlefonts
recipe:
../fonts/variable/Sixtyfour-Color[BLED,SCAN,XELA,YELA].ttf:
- source: Sixtyfour.glyphs
- fontmake_args: --filter ... --filter FlattenComponentsFilter --filter DecomposeTransformedComponentsFilter
--keep-overlaps
operation: buildVariable
- fixargs: ''
operation: fix
- operation: paintcompiler
args: --add-axis "XELA:-100:0:100:Horizontal Element Alignment" --add-axis "YELA:-100:0:100:Vertical Element Alignment"
- operation: rename
name: Sixtyfour Color
87 changes: 87 additions & 0 deletions Sixtyfour/sources/paints.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# This is a little Python program which runs inside the font builder.
# We get access to a number of functions, starting in "Paint...",
# which create the paint tables, and the font builder expects us
# to set up a dictionary called `glyphs` which maps glyph names to
# paint definitions.

# To understand what paint tables are available and their parameters,
# you need to read https://github.com/googlefonts/colr-gradients-spec/blob/main/OFF_AMD2_WD.md

# The paint builder will automatically set up the palettes for us;
# we can just call "PaintSolid" and "PaintLinearGradient" etc.
# with colour strings and it'll sort it out. We define constants here
# to make the code tidier.
RED = "#FF141DFF"
ORANGE = "#FB7236FF"
LOW_GREEN = "#14FF1D77"
HIGH_GREEN = "#72FB36AA"
LOW_BLUE = "#141DFF77"
HIGH_BLUE = "#7236FBAA"

# A little wrapper to make defining our three gradients easier
def grad(start, mid):
return PaintLinearGradient(
(512, 0), # Start gradient at middle, baseline
(512, 900), # End gradient at middle, top
(0, 0), # Rotate gradient 90 degrees
ColorLine({0: start, 0.25: mid, 1: start})
# Go from the start colour to the mid colour at 25% and
# back to the start again
)


# And another wrapper encoding our skew constants
def skew(paint):
return PaintVarSkewAroundCenter(
{(('YELA', -100.0),): -2, (('YELA', 0.0),): 0, (('YELA', 100.0),): 2}, # X axis skew
{(('XELA', -100.0),): -2, (('XELA', 0.0),): 0, (('XELA', 100.0),): 2}, # Y axis skew
# "At XELA=-100, skew the Y axis -2 degrees; at XELA=100, skew
# it 2 degrees"
(512, 450), # skew around the center of the glyph
paint, # dispatch to the next paint table
)


# We also have access to the font object, so we can get all the glyph
# names
for gname in font.getGlyphOrder():
# Now we are going to compose three copies of the base glyph
# together using the "screen" composition mode.

# The frontmost copy is the base glyph painted in a
# blue gradient, skewed a few degrees, and then translated
# according to the values of the XELA and YELA axes.
foreground = PaintVarTranslate(
{(('XELA', -100.0),): 100, (('XELA', 0.0),): 0, (('XELA', 100.0),): -100},
{(('YELA', -100.0),): 110, (('YELA', 0.0),): 0, (('YELA', 100.0),): -110},
skew(
PaintGlyph(gname, grad(LOW_BLUE, HIGH_BLUE)),
),
)

# The second copy is the base glyph itself painted in a
# red-orange-red gradient, skewed a few degrees, but
# not translated.
middle = skew(PaintGlyph(gname, grad(RED, ORANGE)))

# And the back layer, the background of our inner
# composition, is the base glyph again painted in a
# green gradient, skewed, and moved in the opposite
# direction on the XELA/YELA axes.
background = PaintVarTranslate(
{(('XELA', -100.0),): -110, (('XELA', 0.0),): 0, (('XELA', 100.0),): 110},
{(('YELA', -100.0),): -100, (('YELA', 0.0),): 0, (('YELA', 100.0),): 100},
skew(
PaintGlyph(gname, grad(LOW_GREEN, HIGH_GREEN)),
),
)

# Now we create the composition. Since we have three layers
# and "PaintComposite" takes a foreground and a background,
# we do two compositing operations and feed the second as
# the background to the first.
glyphs[gname] = PaintComposite(
"screen", foreground, PaintComposite("screen", middle, background)
)

font["fvar"].instances = []
97 changes: 39 additions & 58 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,122 +1,103 @@
absl-py==1.4.0
absl-py==2.0.0
appdirs==1.4.4
async-generator==1.10
attrs==23.1.0
axisregistry==0.4.3
babelfont==3.0.1
beautifulsoup4==4.12.2
beziers==0.5.0
blackrenderer==0.6.0
booleanOperations==0.9.0
Brotli==1.0.9
Brotli==1.1.0
bump2version==1.0.1
bumpfontversion==0.4.1
cattrs==23.1.2
certifi==2023.7.22
cffi==1.15.1
cffi==1.16.0
cffsubr==0.2.9.post1
charset-normalizer==3.2.0
click==8.1.6
cmarkgfm==2022.10.27
collidoscope==0.6.5
charset-normalizer==3.3.0
click==8.1.7
colorlog==6.7.0
commandlines==0.4.1
compreffor==0.5.4
compreffor==0.5.5
cryptography==41.0.4
cu2qu==1.6.7.post2
defcon==0.10.2
dehinter==4.0.0
defcon==0.10.3
Deprecated==1.2.14
diffenator2==0.2.4
diffenator2==0.2.13
drawbot-skia==0.5.0
exceptiongroup==1.1.1
font-v==2.1.0
fontbakery==0.8.13
fontFeatures==1.8.0
fontmake==3.6.1
fontmake==3.7.1
fontMath==0.9.3
fonttools==4.42.0
fonttools==4.43.1
freetype-py==2.4.0
fs==2.4.16
gflanguages==0.5.4
gftools==0.9.33
gflanguages==0.5.7
gftools @ git+https://github.com/googlefonts/gftools@1b710e84eb2f4e8bc860b323b568c0e8418a8eb2
gitdb==4.0.10
GitPython==3.1.37
glyphsets==0.6.2
glyphsLib==6.3.0
glyphtools==0.8.0
GitPython==3.1.38
glyphsets==0.6.4
glyphsLib==6.4.1
h11==0.14.0
hyperglot==0.4.5
idna==3.4
Jinja2==3.1.2
kurbopy==0.9.0
lxml==4.9.3
markdown-it-py==3.0.0
MarkupSafe==2.1.3
mdurl==0.1.2
munkres==1.1.4
nanoemoji==0.15.1
ninja==1.11.1
numpy==1.25.0
openstep-plist==0.3.0.post1
networkx==3.1
ninja==1.11.1.1
numpy==1.26.1
openstep-plist==0.3.1
opentype-sanitizer==9.1.0
opentypespec==1.9.1
orjson==3.9.2
orjson==3.9.9
outcome==1.2.0
packaging==23.1
paintcompiler==0.2.0
picosvg==0.22.1
Pillow==10.0.1
Pillow==10.1.0
pip-api==0.0.30
pngquant-cli==2.17.0.post5
protobuf==3.20.3
pyahocorasick==2.0.0
pybind11==2.10.4
pyclipper==1.3.0.post4
pybind11==2.11.1
pyclipper==1.3.0.post5
pycparser==2.21
pygit2==1.12.2
PyGithub==1.59.1
Pygments==2.15.1
pygit2==1.13.1
PyGithub==2.1.1
PyJWT==2.8.0
PyNaCl==1.5.0
pyparsing==3.1.1
PySocks==1.7.1
python-bidi==0.4.2
python-dateutil==2.8.2
PyYAML==6.0.1
regex==2023.6.3
regex==2023.10.3
requests==2.31.0
resvg-cli==0.22.0.post3
rich==13.4.2
rstr==3.2.1
selenium==4.10.0
sh==2.0.4
selenium==4.14.0
sh==2.0.6
six==1.16.0
skia-pathops==0.8.0
skia-pathops==0.8.0.post1
skia-python==87.5
smmap==5.0.0
smmap==5.0.1
sniffio==1.3.0
sortedcontainers==2.4.0
soupsieve==2.4.1
sre-yield==1.2
statmake==0.6.0
strictyaml==1.7.3
stringbrewer==0.0.1
tabulate==0.9.0
toml==0.10.2
tqdm==4.65.0
trio==0.22.0
trio-websocket==0.10.3
tqdm==4.66.1
trio==0.22.2
trio-websocket==0.11.1
ttfautohint-py==0.5.1
typing_extensions==4.8.0
ufo2ft==2.33.4
ufoLib2==0.16.0
ufolint==1.2.0
uharfbuzz==0.37.2
unicodedata2==15.0.0
Unidecode==1.3.6
uharfbuzz==0.37.3
unicodedata2==15.1.0
Unidecode==1.3.7
urllib3==2.0.7
vharfbuzz==0.2.0
vttLib==0.12.0
wrapt==1.15.0
wsproto==1.2.0
youseedee==0.3.0
zopfli==0.2.2
zopfli==0.2.3

0 comments on commit 9b182d8

Please sign in to comment.