mirror of
https://github.com/belluzj/fantasque-sans.git
synced 2024-12-22 07:21: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
|
||||
*.rpm
|
||||
*~
|
||||
Webfonts/*
|
||||
|
|
25
Makefile
25
Makefile
|
@ -3,24 +3,35 @@ BASENAMES=$(patsubst Sources/%.sfd,%,$(SOURCES))
|
|||
TTF_FILES=$(patsubst %,%.ttf,$(BASENAMES))
|
||||
# TTF_HINTED_FILES=$(patsubst %,%-autohint.ttf,$(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
|
||||
|
||||
OTF/%.otf %.ttf: Sources/%.sfd
|
||||
mkdir -p OTF TeX
|
||||
./validate-generate.sh $*
|
||||
OTF/%.otf %.ttf Webfonts/%.svg Webfonts/%.eot Webfonts/%.woff Webfonts/%-decl.css: Sources/%.sfd
|
||||
mkdir -p OTF TeX Webfonts
|
||||
./validate-generate.sh "$*"
|
||||
# TODO determine perfect parameters
|
||||
ttfautohint $*.ttf $*.hinted.ttf
|
||||
mv $*.hinted.ttf $*.ttf
|
||||
ttfautohint "$*.ttf" "$*.hinted.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
|
||||
install: $(TTF_FILES)
|
||||
cp $^ ~/.fonts/
|
||||
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 $^
|
||||
|
||||
clean:
|
||||
rm -f *.ttf OTF/* TeX/*
|
||||
rm -f *.ttf OTF/* TeX/* Webfonts/*
|
||||
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Generate font files with FontForge, and a CSS declaration for this font.
|
||||
|
||||
basename=$1
|
||||
ttf="${basename}.ttf"
|
||||
otf="OTF/${basename}.otf"
|
||||
texFamily="cm" # arbitrary two letters out of the font's name
|
||||
|
||||
texCut="r" # Regular
|
||||
if [[ "${basename,,}" == *bold* ]]; then
|
||||
texCut="b" # Bold
|
||||
|
@ -22,6 +25,7 @@ if bitmask != 0:
|
|||
|
||||
font.generate("${basename}.ttf");
|
||||
font.generate("OTF/${basename}.otf");
|
||||
font.generate("Webfonts/${basename}.svg");
|
||||
|
||||
# TeX stuff
|
||||
font.encoding = "AdobeStandard";
|
||||
|
@ -29,6 +33,18 @@ font.generate("TeX/f${texFamily}${texCut}8a.pfb",
|
|||
flags=("afm", "tfm", "pfm"));
|
||||
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=$?
|
||||
if [ "x$error" != "x0" ]; then
|
||||
echo -e "\e[1;31mError in ${basename}.\e[0m"
|
||||
|
|
Loading…
Reference in New Issue
Block a user