14
0
mirror of https://github.com/belluzj/fantasque-sans.git synced 2024-12-22 15:31:31 +01:00

Update the build system to bake in the non-looped k

This commit is contained in:
Jany Belluz 2017-07-10 18:47:01 +02:00
parent d6b7f3fbff
commit b6abec986f
13 changed files with 514 additions and 166 deletions

9
.gitignore vendored
View File

@ -4,13 +4,8 @@ TeX
*.deb *.deb
*.rpm *.rpm
*~ *~
Webfonts/*.woff
Webfonts/*.woff2
Webfonts/*.svg
Webfonts/*.eot
Webfonts/*.css
OTF/*.otf
TTF/*.ttf
Specimen/*.svg Specimen/*.svg
Sources/*.sfd-* Sources/*.sfd-*
Variants
*.pyc

111
CHANGELOG.md Normal file
View File

@ -0,0 +1,111 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
## Unreleased
### Changed
- Upgrade the build system to have a proper version of the font with
a built-in stylistic set `ss01` (no-loop `k`)
Thanks to the [Monoid](https://github.com/larsenwork/monoid) project
for open-sourcing their build scripts.
## 1.7.1
- **Add a stylistic set to replace the looped lowercase `k` with
a straight version.**
- Adjust curly quotes so they behave better as apostrophes.
- Also, since nobody complained about the new Cyrillic characters,
I declare this is their official release! (I did not change
anything since 1.7.0 though).
## 1.7.0
Beta version for the 1.7 series.
- **Add Cyrillic alphabet to the four fonts.**
- Add some real sub/supscript numbers and fractions.
- Revamp straight and curly quotes.
- Fix some Windows rendering issues.
- Move accents around (why do I do that every time?)
- Add `fontdiff` script which generates font diffs.
## 1.6.5
- Make italics visible on Windows.
## 1.6.4
- Fix line height on Mac.
- Move all the italic glyphs to the left.
- Adjust some accents.
## 1.6.3
- Add block characters.
- Make the underscore visible on Windows.
- Generate better CSS.
## 1.6.2
- Make `+` symmetrical, align dots in `:` and `;`.
## 1.6.1
- Simplify @ to make it look sharp at all sizes.
- Various fixes.
## 1.6
- Add bold italic version.
## 1.5
- Add regular italic version.
- Some small changes (Q, w, y, n).
## 1.4.1
- Drop Reserved Font Name. **You can now subset, compress, hint and
whatnot without worrying about renaming**.
- Many small improvements (8, s , t, a, e, {, }, W, i, l, g...).
## 1.4
- Rename font to **Fantasque Sans**, because *fantasque is the new cosmic*.
- Make W look symmetrical at big size.
## 1.3.2
- Various fixes: playing again with bold m, moving accents again, taking
care again of Powerline symbols, clean 8 and R.
- Add a few box drawing characters (for use with vim-indentline).
- Generate webfonts (goal: this font used for code samples on all cool
languages' websites).
- Add a WIP medium version of the proportional font.
## 1.3.1
- Various fixes: still cleaning m and w, reworked all ogoneks, changed a
bit the dollar, moved some accents, eliminated glitches around
Powerline symbols.
- TTF fonts are now hinted using Freetype's `ttfautohint`, which should
give much better results on Windows (and maybe in Java apps and others
contexts). In case this is a problem, please let me know and I will
provide also an unhinted version.
**Windows users should use the TTF (TrueType) files.**
## 1.3
- Very slight change of metrics to add space between characters and lines.
- Various small changes : curlier curly brackets, more difference between
- various quotes, cleaner W, w, m, and rounder @.
- Windows compatibility.
- More latin accents.
- Greek letters.
- Powerline characters.
## 1.2.1
- Minor adjustments.
## 1.2
- Add the bold version.
- Various minor adjustments, new paragraph symbol, slanted dollar.
## 1.1.1
- Make slashes longer, ensure parenthesis and brackets are rendered at
the same height, and some other minor adjustments.
## 1.1
First release.

View File

@ -1,34 +1,21 @@
SOURCES=$(wildcard Sources/*.sfdir) SOURCES=$(wildcard Sources/FantasqueSansMono*.sfdir)
BASENAMES=$(patsubst Sources/%.sfdir,%,$(SOURCES)) BASENAMES=$(patsubst Sources/%.sfdir,%,$(SOURCES))
TTF_FILES=$(patsubst %,TTF/%.ttf,$(BASENAMES)) TTF_FILES=$(patsubst %,Variants/Normal/TTF/%.ttf,$(BASENAMES))
OTF_FILES=$(patsubst %,OTF/%.otf,$(BASENAMES)) ZIP_FILE=Variants/Normal/FantasqueSansMono.zip
SVG_FILES=$(patsubst %,Webfonts/%.svg,$(BASENAMES))
WOFF_FILES=$(patsubst %,Webfonts/%.woff,$(BASENAMES))
WOFF2_FILES=$(patsubst %,Webfonts/%.woff2,$(BASENAMES))
EOT_FILES=$(patsubst %,Webfonts/%.eot,$(BASENAMES))
CSS_FRAGMENTS=$(patsubst %,Webfonts/%-decl.css,$(BASENAMES))
CSS_FILE=Webfonts/stylesheet.css
INSTALLED_TTF_FILES=$(patsubst %,~/.fonts/%.ttf,$(BASENAMES)) INSTALLED_TTF_FILES=$(patsubst %,~/.fonts/%.ttf,$(BASENAMES))
all: $(TTF_FILES) all: $(ZIP_FILE)
OTF/%.otf TTF/%.ttf Webfonts/%.svg Webfonts/%.eot Webfonts/%.woff Webfonts/%.woff2 Webfonts/%-decl.css: Sources/%.sfdir $(ZIP_FILE): $(TTF_FILES)
mkdir -p OTF TTF Webfonts Scripts/zip-all-variants Variants
./validate-generate "$*"
# TODO determine perfect parameters
ttfautohint "TTF/$*.ttf" "TTF/$*.hinted.ttf"
mv "TTF/$*.hinted.ttf" "TTF/$*.ttf"
sfnt2woff "OTF/$*.otf"
mv "OTF/$*.woff" Webfonts
woff2_compress "TTF/$*.ttf"
mv "TTF/$*.woff2" Webfonts
ttf2eot "TTF/$*.ttf" > "Webfonts/$*.eot"
$(CSS_FILE): $(CSS_FRAGMENTS) Variants/Normal/TTF/%.ttf: Sources/%.sfdir
cat $(foreach v,$(CSS_FRAGMENTS),$(if $(findstring Mono,$v),$v)) > $(CSS_FILE) mkdir -p Variants
Scripts/validate-font "$<"
Scripts/generate-font-variants "$<" Variants
.PHONY: install clean zips zip-mono zip-prop .PHONY: install clean
install: $(INSTALLED_TTF_FILES) install: $(INSTALLED_TTF_FILES)
$(INSTALLED_TTF_FILES): $(TTF_FILES) $(INSTALLED_TTF_FILES): $(TTF_FILES)
@ -36,19 +23,5 @@ $(INSTALLED_TTF_FILES): $(TTF_FILES)
cp $^ ~/.fonts/ cp $^ ~/.fonts/
fc-cache -f fc-cache -f
zips: zip-mono zip-prop
zip-mono: $(TTF_FILES) $(OTF_FILES) $(SVG_FILES) $(EOT_FILES) $(WOFF_FILES) $(WOFF2_FILES) $(SOURCES) $(CSS_FILE)
zip FantasqueSansMono.zip LICENSE.txt README.md Webfonts/README.md $(CSS_FILE) $(foreach v,$^,$(if $(findstring Mono,$v),$v))
tar czvf FantasqueSansMono.tar.gz LICENSE.txt README.md Webfonts/README.md $(CSS_FILE) $(foreach v,$^,$(if $(findstring Mono,$v),$v))
zip-prop: $(TTF_FILES) $(OTF_FILES) $(SVG_FILES) $(EOT_FILES) $(WOFF_FILES) $(WOFF2_FILES) $(SOURCES)
zip FantasqueSans.zip LICENSE.txt README.md Webfonts/README.md $(foreach v,$^,$(if $(findstring Mono,$v),,$v))
tar czvf FantasqueSans.tar.gz LICENSE.txt README.md Webfonts/README.md $(foreach v,$^,$(if $(findstring Mono,$v),,$v))
clean: clean:
rm -f TTF/*.ttf *.zip OTF/* Webfonts/*.eot Webfonts/*.woff Webfonts/*.woff2 Webfonts/*.svg Webfonts/*.css rm -rf Variants
test: $(INSTALLED_TTF_FILES)
gvim -f ~/Developpement/Système/kernel-base/shared/printf.c

View File

@ -47,7 +47,7 @@ Stylistic set(s)
### `ss01`: nondescript `k` ### `ss01`: nondescript `k`
No ~~distractive~~ lovely loop. No ~~distractive~~ lovely loop.
[Get the pre-activated version here](https://github.com/belluzj/fantasque-sans/releases/download/v1.7.1/FantasqueSansMono_ss01.zip) [Get the pre-activated version here](https://github.com/belluzj/fantasque-sans/releases/download/v1.7.2-alpha/FantasqueSansMono_NoLoopK.zip)
or see the [issue #67](https://github.com/belluzj/fantasque-sans/issues/67) or see the [issue #67](https://github.com/belluzj/fantasque-sans/issues/67)
for techniques to activate the stylistic set. for techniques to activate the stylistic set.
@ -95,81 +95,19 @@ and update the font cache. It comes in handy while modifying the font.
[![](Specimen/Specimen.png)](Specimen/Specimen.pdf) [![](Specimen/Specimen.png)](Specimen/Specimen.pdf)
Webfonts
--------
Each variant has a `Webfonts/` folder which contains various font formats for
use on the web, along with the matching CSS font declarations. To use them,
you must combine in the same folder:
* a custom `.css` file that you can assemble from the `*-decl.css` fragments
(you can only pick the styles that you need, e.g. normal and bold)
* the matching `.svg`, `.woff`, `.woff2`, `.eot` files from `Webfonts/`
* the matching `.ttf` files from the `TTF/` folder
* the matching `.otf` files from the `OTF/` folder.
Versions Versions
-------- --------
1.1 - First release. [Check out the changelog](CHANGELOG.md).
1.1.1 - Make slashes longer, ensure parenthesis and brackets are rendered at
the same height, and some other minor adjustments.
1.2 - Add the bold version.
Various minor adjustments, new paragraph symbol, slanted dollar.
1.2.1 - Minor adjustments.
1.3 - Very slight change of metrics to add space between characters and lines.
Various small changes : curlier curly brackets, more difference between
various quotes, cleaner W, w, m, and rounder @.
Windows compatibility.
More latin accents.
Greek letters.
Powerline characters.
1.3.1 - Various fixes: still cleaning m and w, reworked all ogoneks, changed a
bit the dollar, moved some accents, eliminated glitches around
Powerline symbols.
TTF fonts are now hinted using Freetype's `ttfautohint`, which should
give much better results on Windows (and maybe in Java apps and others
contexts). In case this is a problem, please let me know and I will
provide also an unhinted version.
**Windows users should use the TTF (TrueType) files.**
1.3.2 - Various fixes: playing again with bold m, moving accents again, taking
care again of Powerline symbols, clean 8 and R.
Add a few box drawing characters (for use with vim-indentline).
Generate webfonts (goal: this font used for code samples on all cool
languages' websites).
Add a WIP medium version of the proportional font.
1.4 - Rename font to **Fantasque Sans**, because *fantasque is the new cosmic*.
Make W look symetrical at big size.
1.4.1 - Drop Reserved Font Name. **You can now subset, compress, hint and
whatnot without worrying about renaming**.
Many small improvements (8, s , t, a, e, {, }, W, i, l, g...).
1.5 - Add regular italic version.
Some small changes (Q, w, y, n).
1.6 - Add bold italic version.
1.6.1 - Simplify @ to make it look sharp at all sizes.
Various fixes.
1.6.2 - Make `+` symmetrical, align dots in `:` and `;`.
1.6.3 - Add block characters.
Make the underscore visible on Windows.
Generate better CSS.
1.6.4 - Fix line height on Mac.
Move all the italic glyphs to the left.
Adjust some accents.
1.6.5 - Make italics visible on Windows.
1.7.0 - Beta version for the 1.7 series.
**Add Cyrillic alphabet to the four fonts.**
Add some real sub/supscript numbers and fractions.
Revamp straight and curly quotes.
Fix some Windows rendering issues.
Move accents around (why do I do that every time?)
Add `fontdiff` script which generates font diffs.
1.7.1 - **Add a stylistic set to replace the looped lowercase `k` with
a straight version.**
Adjust curly quotes so they behave better as apostrophes.
Also, since nobody complained about the new Cyrillic characters,
I declare this is their official release! (I did not change
anything since 1.7.0 though).

55
Scripts/build.py Executable file
View File

@ -0,0 +1,55 @@
#!/usr/bin/env python2.7
# Adapted from https://github.com/larsenwork/monoid
# Copyright (c) 2015, Andreas Larsen and contributors.
# vim: sts=4 sw=4 ts=4 et
import sys
if len(sys.argv) < 5:
usage = """Build should be run with 4 arguments:
First: The total possible number of parallel processes (1+)
Second: The parallel batch number (0+)
Third: The .sfdir for the font
Fourth: The output directory
"""
print >> sys.stderr, usage
exit(1)
from fontbuilder import *
# Output directory
output = sys.argv[4]
# # Options to generate
# conflicting(
# style('Loose', Bearing(right=128)),
# style('HalfLoose', Bearing(right=64)),
# # style('normal', Bearing(left=0)),
# style('HalfTight', Bearing(left=-64)),
# style('Tight', Bearing(left=-128))
# )
# conflicting(
# option('XtraSmall', '13px', Line(1536, 256)),
# option('Small', '14px', Line(1536, 384)),
# # option('medium', 15px', Line(1664, 384)),
# option('Large', '16px', Line(1664, 512)),
# option('XtraLarge', '17px', Line(1792, 512))
# )
# ss01
option('NoLoopK', 'No loop k', SwapLookup('ss01'))
# option('Dollar', 'Alt $', Swap("dollar", "dollar.empty"))
# # ss03
# option('0', 'Alt 0', Swap("zero", "zero.dot"))
# # ss05
# option('1', 'Alt 1', Swap("one", "one.base"))
# # ss08
# option('l', 'Alt l', Swap("l", "l.zstyle"))
# # ss14
# # option('Squeeze', 'Squeezed capitals with diacritics', SwapLookup("ss14"))
# # no calt
# option('NoCalt', 'Turn off contextual alternates', DropCAltAndLiga())
# Build options in
build_batch(output, sys.argv[3], int(sys.argv[1]), int(sys.argv[2]))

223
Scripts/fontbuilder.py Normal file
View File

@ -0,0 +1,223 @@
# Adapted from https://github.com/larsenwork/monoid
# Copyright 2015 Chase Colman (chase@colman.io)
# LICENSE: MIT
# vim: sts=4 sw=4 ts=4 et
import fontforge
from itertools import compress
import os
from os.path import basename, splitext, join
import subprocess
SCRIPTS = os.path.dirname(os.path.realpath(__file__))
def mkdir_p(path):
normalized = os.path.normpath(path)
try:
os.makedirs(normalized)
except OSError:
pass
# Builder
def style(name, does):
if not isinstance(does, list):
does = [does]
option(name, name, [Variation(name)] + does)
return name
def option(abrv, name, does):
if not isinstance(does, list):
does = [does]
option.operations[abrv] = does
option.abrvs.append(abrv)
option.names[abrv] = name
return abrv
# Initialize the operations map, abbreviation list, and name map
option.operations = {}
option.abrvs = []
option.names = {}
def conflicting(*abrvs):
"""Wrap the abbreviations as a tuple in the option abbreviation list"""
# Assumes last #abrvs abbreviations are conflicting options
option.abrvs = option.abrvs[:-len(abrvs)] + [tuple(abrvs)]
def _expand_options(bitmap):
# Apply the bitmap to the options
opts = compress(option.abrvs, bitmap)
# Expand the permutations for all options
expanded = [[]]
for opt in opts:
if isinstance(opt, tuple):
expanded = [items + [prmtn] for items in expanded for prmtn in opt]
else:
expanded = [items + [opt] for items in expanded]
return expanded
def permutations():
"""Yields all possible permutations from the options list"""
count = len(option.abrvs)
# Each option is a binary choice, so we use an int as a quick bitmap.
# To iterate over every possible permutation, all we have to do is increment
# up to the maximum value 2^(#options)
bitmap_max = 1 << count
# Iterate over all possible permutations
for i in xrange(bitmap_max):
# Map the iteration's permutations using a bitmap
bitmap = [i >> n & 1 for n in xrange(count)]
for opts in _expand_options(bitmap):
yield(int(float(i)/bitmap_max*100), opts)
def _build(dstdir, font, permutations):
for prcnt, opts in permutations:
# Open the original font
fnt = fontforge.open(font)
# Get the base name for the font
name = splitext(basename(font))[0]
# Build a variant name based on applied options
variants = []
for opt in opts:
# Append this option to the font name
variants.append(str(opt))
# Run all the operations for this option
for oper in option.operations[opt]:
oper(fnt)
variant = '-'.join(variants) or 'Normal'
variant_dir = join(dstdir, variant)
print('Generating ' + variant_dir)
mkdir_p(join(variant_dir, 'TTF'))
mkdir_p(join(variant_dir, 'OTF'))
mkdir_p(join(variant_dir, 'Webfonts'))
# Output the files and cleanup
fnt.generate(join(variant_dir, 'TTF', name + '.ttf'), flags=("opentype", "dummy-dsig"))
fnt.generate(join(variant_dir, 'OTF', name + '.otf'), flags=("opentype", "dummy-dsig"))
fnt.generate(join(variant_dir, 'Webfonts', name + '.svg'))
fnt.close()
# Output other formats and the CSS declaration
subprocess.check_call(
[join(SCRIPTS, 'generate-other-formats'), font],
cwd=variant_dir
)
subprocess.check_call(
[join(SCRIPTS, 'generate-css-decl'), font],
cwd=variant_dir
)
def build(dstdir, font):
_build(dstdir, font, permutations())
def build_batch(dstdir, font, total_nodes, node_number):
# Starting at (i) node_number, build option every (n) total_nodes
_build(dstdir, font, list(permutations())[node_number::total_nodes])
# Operations
## NOTE:
## All operations return a closure with the 1st argument being a fontforge.font
def Line(ascent, descent):
"""Sets the ascent and/or descent of the font's line"""
def line_op(fnt):
fnt.os2_winascent = fnt.os2_typoascent = fnt.hhea_ascent = ascent
fnt.os2_windescent = descent
fnt.os2_typodescent = fnt.hhea_descent = -descent
return line_op
def Bearing(left=0, right=0):
"""Adjusts the left and/or right bearings of all glyphs"""
def bearing_op(fnt):
for glyph in fnt.glyphs():
if left != 0:
glyph.left_side_bearing += left
if right != 0:
glyph.right_side_bearing += right
return bearing_op
def Swap(glyph1, glyph2):
"""Swaps the places of two glyphs"""
def swap_op(fnt):
# Unlike selections, glyph layer data is returned as a copy
swp = fnt[glyph1].foreground
fnt[glyph1].foreground = fnt[glyph2].foreground
fnt[glyph2].foreground = swp
return swap_op
def SwapLookup(target_lookup):
"""Swaps the places of glyphs based on an OpenType lookup table"""
def swaplookup_op(fnt):
# Get every subtable for every matching lookup
lookups = [i for i in fnt.gsub_lookups if fnt.getLookupInfo(i)[2][0][0] == target_lookup]
subtables = []
for lookup in lookups:
for subtable in fnt.getLookupSubtables(lookup):
subtables.append(subtable)
for glyph in fnt.glyphs():
subbed = False
for subtable in subtables:
posSub = glyph.getPosSub(subtable)
if not subbed and posSub and posSub[0][1] == "Substitution":
subbed = True # Don't double tap if there are duplicates
sub = posSub[0][2]
swp = glyph.foreground
glyph.foreground = fnt[sub].foreground
fnt[sub].foreground = swp
return swaplookup_op
def DropCAltAndLiga():
"""Removes Contextual Alternates and Ligatures"""
def dropcaltandliga_op(fnt):
for lookup in fnt.gsub_lookups:
if fnt.getLookupInfo(lookup)[0] in ['gsub_ligature', 'gsub_contextchain']:
fnt.removeLookup(lookup)
return dropcaltandliga_op
def Variation(name):
"""Changes the subfamily/variation of the font"""
def variation_op(fnt):
# Get the SFNT information as dictionary {property: value}
# where English (US) is the language... Here be dragons.
#
# o
# /\
# /::\
# /::::\
# ,a_a /\::::/\
# {/ ''\_ /\ \::/\ \
# {\ ,_oo) /\ \ \/\ \ \
# {/ (_^____/ \ \ \ \ \ \
# .=. {/ \___)))*) \ \ \ \ \/
# (.=.`\ {/ /=; ~/ \ \ \ \/
# \ `\{/( \/\ / \ \ \/
# \ `. `\ ) ) \ \/
# \ // /_/_ \/
# '==''---))))
sfnt_dict = {sfnt[1]: sfnt[2] for sfnt in fnt.sfnt_names if sfnt[0] == 'English (US)'}
fnt.familyname = sfnt_dict['Family'] + ' ' + name
fnt.fullname = fnt.familyname + ' ' + sfnt_dict['SubFamily']
fnt.fontname = fnt.fullname.replace(' ', '-')
fnt.appendSFNTName('English (US)', 'Family', fnt.familyname)
fnt.appendSFNTName('English (US)', 'Fullname', fnt.fullname)
fnt.appendSFNTName('English (US)', 'PostScriptName', fnt.fontname)
fnt.appendSFNTName('English (US)', 'SubFamily', sfnt_dict['SubFamily'])
fnt.appendSFNTName('English (US)', 'UniqueID', sfnt_dict['UniqueID'] + ' : ' + name)
return variation_op

View File

@ -1,19 +1,17 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Generate font files with FontForge, and a CSS declaration for this font. # Generate a CSS declaration for the given font
if ! type fontforge &> /dev/null; then echo "ERROR: Missing dependency: fontforge" 1>&2; exit 1; fi if ! type fontforge &> /dev/null; then echo "ERROR: Missing dependency: fontforge" 1>&2; exit 1; fi
basename=$1 fullname=$1
ttf="${basename}.ttf" basename=$(basename "$fullname" .sfdir)
otf="OTF/${basename}.otf"
echo -e "\e[1;37mGenerating ${basename}... \e[0m" output=$(fontforge --quiet -lang=py -script - "$fullname" <<EOF
output=$(fontforge -lang=py -script - <<EOF
import fontforge; import fontforge;
import sys;
font = fontforge.open("Sources/${basename}.sfdir"); font = fontforge.open(sys.argv[1]);
# Extract interesting informations # Extract interesting informations
print("---") print("---")
@ -22,18 +20,8 @@ print(font.familyname)
print(font.fullname) print(font.fullname)
print(font.os2_weight) print(font.os2_weight)
print(font.italicangle) print(font.italicangle)
bitmask = font.validate();
if bitmask != 0:
exit(42);
font.generate("TTF/${basename}.ttf", flags=("opentype", "dummy-dsig"));
font.generate("OTF/${basename}.otf", flags=("opentype", "dummy-dsig"));
font.generate("Webfonts/${basename}.svg");
EOF EOF
) ) || exit 1
error=$?
output="${output##*--- output="${output##*---
}" }"
@ -54,7 +42,7 @@ else
fontstyle=italic fontstyle=italic
fi fi
cat > Webfonts/${basename}-decl.css <<EOF cat > "Webfonts/${basename}-decl.css" <<EOF
@font-face { @font-face {
font-family: '${familyname}'; font-family: '${familyname}';
src: url('${basename}.eot'); /* IE 9 Compatibility Mode */ src: url('${basename}.eot'); /* IE 9 Compatibility Mode */
@ -67,14 +55,3 @@ cat > Webfonts/${basename}-decl.css <<EOF
font-style: ${fontstyle}; font-style: ${fontstyle};
} }
EOF EOF
if [ "x$error" != "x0" ]; then
echo -e "\e[1;31mError in ${basename}.\e[0m"
if [ "x$error" = "x42" ]; then
echo "Font ${basename}.sfd is not valid"
fi
else
echo -e "\e[1;32m${basename} OK.\e[0m"
fi
exit $error

16
Scripts/generate-font-variants Executable file
View File

@ -0,0 +1,16 @@
#!/usr/bin/env bash
SCRIPTS=$(cd "$(dirname $0)"; pwd)
# Generate all possible variants of the font statically
if ! type fontforge &> /dev/null; then echo "ERROR: Missing dependency: fontforge" 1>&2; exit 1; fi
path="$(pwd)/$1"
basename=$(basename "$path" .sfdir)
output_dir=$2
echo -e "\e[1;37mGenerating ${basename} variants... \e[0m"
fontforge --quiet -lang=py -script "$SCRIPTS/build.py" 1 0 "$path" "$output_dir" || exit 1
echo -e "\e[1;32m${basename} OK.\e[0m"

14
Scripts/generate-other-formats Executable file
View File

@ -0,0 +1,14 @@
#!/usr/bin/env bash
SCRIPTS=$(cd "$(dirname $0)" && pwd)
name=$1
basename=$(basename "$name" .sfdir)
# TODO determine perfect parameters
ttfautohint "TTF/${basename}.ttf" "TTF/${basename}.hinted.ttf"
mv "TTF/${basename}.hinted.ttf" "TTF/${basename}.ttf"
sfnt2woff "OTF/${basename}.otf"
mv "OTF/${basename}.woff" Webfonts
woff2_compress "TTF/${basename}.ttf"
mv "TTF/${basename}.woff2" Webfonts
ttf2eot "TTF/${basename}.ttf" > "Webfonts/${basename}.eot"

32
Scripts/validate-font Executable file
View File

@ -0,0 +1,32 @@
#!/usr/bin/env bash
# Validate a font file with FontForge.
if ! type fontforge &> /dev/null; then echo "ERROR: Missing dependency: fontforge" 1>&2; exit 1; fi
name=$1
basename=$(basename "$name" .sfdir)
echo -e "\e[1;37mValidating ${basename}... \e[0m"
output=$(fontforge --quiet -lang=py -script - "$name" <<EOF
import fontforge;
import sys;
font = fontforge.open(sys.argv[1]);
bitmask = font.validate();
if bitmask != 0:
exit(42);
EOF
) || exit 1
error=$?
if [ "x$error" != "x0" ]; then
echo -e "\e[1;31mError in ${basename}.\e[0m"
if [ "x$error" = "x42" ]; then
echo "Font ${basename}.sfd is not valid"
fi
fi
exit $error

17
Scripts/zip-all-variants Executable file
View File

@ -0,0 +1,17 @@
#!/usr/bin/env bash
# Create a distributable ZIP file in each variant folder
variants=$1
for variant in $(find "$variants"/* -maxdepth 0 -type d); do
name=$(basename "$variant")
cp LICENSE.txt README.md CHANGELOG.md "$variant/"
(
cd "$variant"
echo "Zipping $name"
zip -r "../FantasqueSansMono-$name.zip" * > /dev/null || exit 1
echo "Targzing $name"
tar czvf "../FantasqueSansMono-$name.tar.gz" * > /dev/null || exit 1
)
done

View File

@ -1,4 +0,0 @@
In order to use the included CSS rules, upload in the same folder:
* the contents of `Webfonts/`
* mixed with the `.ttf` files from the `TTF/` folder
* mixed with the `.otf` files from the `OTF/` folder.

17
pkg.sh
View File

@ -19,14 +19,15 @@ fpm -s dir -t ${pkg} -a all \
--url ${url} \ --url ${url} \
--description "${desc}" \ --description "${desc}" \
--license OFL \ --license OFL \
TTF/FantasqueSansMono-Regular.ttf=/usr/share/fonts/truetype/${name}/ \ Variants/Normal/TTF/FantasqueSansMono-Regular.ttf=/usr/share/fonts/truetype/${name}/ \
TTF/FantasqueSansMono-Bold.ttf=/usr/share/fonts/truetype/${name}/ \ Variants/Normal/TTF/FantasqueSansMono-Bold.ttf=/usr/share/fonts/truetype/${name}/ \
TTF/FantasqueSansMono-Italic.ttf=/usr/share/fonts/truetype/${name}/ \ Variants/Normal/TTF/FantasqueSansMono-Italic.ttf=/usr/share/fonts/truetype/${name}/ \
TTF/FantasqueSansMono-BoldItalic.ttf=/usr/share/fonts/truetype/${name}/ \ Variants/Normal/TTF/FantasqueSansMono-BoldItalic.ttf=/usr/share/fonts/truetype/${name}/ \
OTF/FantasqueSansMono-Regular.otf=/usr/share/fonts/opentype/${name}/ \ Variants/Normal/OTF/FantasqueSansMono-Regular.otf=/usr/share/fonts/opentype/${name}/ \
OTF/FantasqueSansMono-Bold.otf=/usr/share/fonts/opentype/${name}/ \ Variants/Normal/OTF/FantasqueSansMono-Bold.otf=/usr/share/fonts/opentype/${name}/ \
OTF/FantasqueSansMono-Italic.otf=/usr/share/fonts/opentype/${name}/ \ Variants/Normal/OTF/FantasqueSansMono-Italic.otf=/usr/share/fonts/opentype/${name}/ \
OTF/FantasqueSansMono-BoldItalic.otf=/usr/share/fonts/opentype/${name}/ \ Variants/Normal/OTF/FantasqueSansMono-BoldItalic.otf=/usr/share/fonts/opentype/${name}/ \
LICENSE.txt=/usr/share/doc/${name}/copyright \ LICENSE.txt=/usr/share/doc/${name}/copyright \
README.md=/usr/share/doc/${name}/ \ README.md=/usr/share/doc/${name}/ \
CHANGELOG.md=/usr/share/doc/${name}/ \
Specimen=/usr/share/doc/${name}/ Specimen=/usr/share/doc/${name}/