mirror of
https://github.com/belluzj/fantasque-sans.git
synced 2024-12-22 15:31:31 +01:00
generate webfonts and css rules WIP
This commit is contained in:
parent
52abd750e7
commit
929f82fbeb
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -3,3 +3,4 @@ TeX
|
||||||
*.deb
|
*.deb
|
||||||
*.rpm
|
*.rpm
|
||||||
*~
|
*~
|
||||||
|
Webfonts/*
|
||||||
|
|
25
Makefile
25
Makefile
|
@ -3,24 +3,35 @@ BASENAMES=$(patsubst Sources/%.sfd,%,$(SOURCES))
|
||||||
TTF_FILES=$(patsubst %,%.ttf,$(BASENAMES))
|
TTF_FILES=$(patsubst %,%.ttf,$(BASENAMES))
|
||||||
# TTF_HINTED_FILES=$(patsubst %,%-autohint.ttf,$(BASENAMES))
|
# TTF_HINTED_FILES=$(patsubst %,%-autohint.ttf,$(BASENAMES))
|
||||||
OTF_FILES=$(patsubst %,OTF/%.otf,$(BASENAMES))
|
OTF_FILES=$(patsubst %,OTF/%.otf,$(BASENAMES))
|
||||||
|
SVG_FILES=$(patsubst %,Webfonts/%.svg,$(BASENAMES))
|
||||||
|
WOFF_FILES=$(patsubst %,Webfonts/%.woff,$(BASENAMES))
|
||||||
|
EOT_FILES=$(patsubst %,Webfonts/%.eot,$(BASENAMES))
|
||||||
|
CSS_FRAGMENTS=$(patsubst %,Webfonts/%-decl.css,$(BASENAMES))
|
||||||
|
CSS_FILE=Webfonts/stylesheet.css
|
||||||
|
|
||||||
all: zip
|
all: zip
|
||||||
|
|
||||||
OTF/%.otf %.ttf: Sources/%.sfd
|
OTF/%.otf %.ttf Webfonts/%.svg Webfonts/%.eot Webfonts/%.woff Webfonts/%-decl.css: Sources/%.sfd
|
||||||
mkdir -p OTF TeX
|
mkdir -p OTF TeX Webfonts
|
||||||
./validate-generate.sh $*
|
./validate-generate.sh "$*"
|
||||||
# TODO determine perfect parameters
|
# TODO determine perfect parameters
|
||||||
ttfautohint $*.ttf $*.hinted.ttf
|
ttfautohint "$*.ttf" "$*.hinted.ttf"
|
||||||
mv $*.hinted.ttf $*.ttf
|
mv "$*.hinted.ttf" "$*.ttf"
|
||||||
|
sfnt2woff "OTF/$*.otf"
|
||||||
|
mv "OTF/$*.woff" Webfonts
|
||||||
|
ttf2eot "$*.ttf" > "Webfonts/$*.eot"
|
||||||
|
|
||||||
|
$(CSS_FILE): $(CSS_FRAGMENTS)
|
||||||
|
cat $(CSS_FRAGMENTS) > $(CSS_FILE)
|
||||||
|
|
||||||
.PHONY: install clean zip
|
.PHONY: install clean zip
|
||||||
install: $(TTF_FILES)
|
install: $(TTF_FILES)
|
||||||
cp $^ ~/.fonts/
|
cp $^ ~/.fonts/
|
||||||
fc-cache -f
|
fc-cache -f
|
||||||
|
|
||||||
zip: $(TTF_FILES) $(OTF_FILES) $(SOURCES)
|
zip: $(TTF_FILES) $(OTF_FILES) $(SVG_FILES) $(EOT_FILES) $(WOFF_FILES) $(SOURCES) $(CSS_FILE)
|
||||||
zip CosmicSansNeueMono.zip OFL.txt README.md $^
|
zip CosmicSansNeueMono.zip OFL.txt README.md $^
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.ttf OTF/* TeX/*
|
rm -f *.ttf OTF/* TeX/* Webfonts/*
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Generate font files with FontForge, and a CSS declaration for this font.
|
||||||
|
|
||||||
basename=$1
|
basename=$1
|
||||||
ttf="${basename}.ttf"
|
ttf="${basename}.ttf"
|
||||||
otf="OTF/${basename}.otf"
|
otf="OTF/${basename}.otf"
|
||||||
texFamily="cm" # arbitrary two letters out of the font's name
|
texFamily="cm" # arbitrary two letters out of the font's name
|
||||||
|
|
||||||
texCut="r" # Regular
|
texCut="r" # Regular
|
||||||
if [[ "${basename,,}" == *bold* ]]; then
|
if [[ "${basename,,}" == *bold* ]]; then
|
||||||
texCut="b" # Bold
|
texCut="b" # Bold
|
||||||
|
@ -22,6 +25,7 @@ if bitmask != 0:
|
||||||
|
|
||||||
font.generate("${basename}.ttf");
|
font.generate("${basename}.ttf");
|
||||||
font.generate("OTF/${basename}.otf");
|
font.generate("OTF/${basename}.otf");
|
||||||
|
font.generate("Webfonts/${basename}.svg");
|
||||||
|
|
||||||
# TeX stuff
|
# TeX stuff
|
||||||
font.encoding = "AdobeStandard";
|
font.encoding = "AdobeStandard";
|
||||||
|
@ -29,6 +33,18 @@ font.generate("TeX/f${texFamily}${texCut}8a.pfb",
|
||||||
flags=("afm", "tfm", "pfm"));
|
flags=("afm", "tfm", "pfm"));
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
cat > Webfonts/${basename}-decl.css <<EOF
|
||||||
|
@font-face {
|
||||||
|
font-family: '${basename}';
|
||||||
|
src: url('${basename}.eot'); /* IE 9 Compatibility Mode */
|
||||||
|
src: url('${basename}.eot?#iefix') format('embedded-opentype'), /* IE < 9 */
|
||||||
|
url('${basename}.woff') format('woff'), /* Firefox >= 3.6, any other modern browser */
|
||||||
|
url('${basename}.ttf') format('truetype'), /* Safari, Android, iOS */
|
||||||
|
url('${basename}.svg#${basename}') format('svg'); /* Chrome < 4, Legacy iOS */
|
||||||
|
}
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
error=$?
|
error=$?
|
||||||
if [ "x$error" != "x0" ]; then
|
if [ "x$error" != "x0" ]; then
|
||||||
echo -e "\e[1;31mError in ${basename}.\e[0m"
|
echo -e "\e[1;31mError in ${basename}.\e[0m"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user