Commit c3f3655d authored by Kaushal Modi's avatar Kaushal Modi

Generate the WOFF2 font files correctly

Ref: https://github.com/fonttools/fonttools/issues/1294
parent 22737bbe
......@@ -158,16 +158,16 @@
/* *** Linux Biolinum */
@font-face {
font-family: 'Linux Biolinum';
src: url('../fonts/linux-libertine/5.3.0/subset/LinBiolinum_R.woff') format('woff');
src: url('../fonts/linux-libertine/5.3.0/subset/LinBiolinum_Rah.woff') format('woff');
}
@font-face {
font-family: 'Linux Biolinum';
src: url('../fonts/linux-libertine/5.3.0/subset/LinBiolinum_RI.woff') format('woff');
src: url('../fonts/linux-libertine/5.3.0/subset/LinBiolinum_RIah.woff') format('woff');
font-style: italic;
}
@font-face {
font-family: 'Linux Biolinum';
src: url('../fonts/linux-libertine/5.3.0/subset/LinBiolinum_RB.woff') format('woff');
src: url('../fonts/linux-libertine/5.3.0/subset/LinBiolinum_RBah.woff') format('woff');
font-weight: bold;
}
......
#!/usr/bin/env bash
# Time-stamp: <2018-07-11 23:38:49 kmodi>
# Time-stamp: <2018-07-12 10:32:45 kmodi>
# https://github.com/be5invis/Iosevka/issues/238#issuecomment-351527918
# pyftsubset - https://github.com/fonttools/fonttools
......@@ -24,7 +24,14 @@ IFS=$'\n\t'
# U+2000-205E : General Punctuation : https://unicode-table.com/en/blocks/general-punctuation/ (includes zero width space, curly quotes, etc.)
# U+25A0,U+25CB : Unicode chars BLACK SQUARE and WHITE CIRCLE for unordered list bullets
# U+2B89,U+2B8B : Unicode chars UPWARDS BLACK CIRCLED WHITE ARROW and DOWNWARDS BLACK CIRCLED WHITE ARROW for the top/bottom jump links
common_args='--layout-features=""'
print_glyph_count () {
font_file="${1}"
# echo ${font_file}
# https://github.com/fonttools/fonttools/issues/1294#issuecomment-404485282
count=$(ttx -q -o - -t GlyphOrder "${font_file}" | grep -c '<GlyphID id')
echo "Exported ${count} glyphs to ${font_file}"
}
run_pyftsubset () {
font="${1}"
......@@ -34,6 +41,8 @@ run_pyftsubset () {
out_dir="../../static/fonts/${font}/subset"
mkdir -p "${out_dir}"
common_args="--layout-features='' --unicodes=${unicodes}"
echo "${font}: Generating subset WOFF files .."
for file in ${font}/ttf/*
do
......@@ -46,18 +55,24 @@ run_pyftsubset () {
# https://stackoverflow.com/a/407334/1219634
if [[ $file == *.ttf ]] # The ${font}/ttf HAS to contain .ttf font files.
then
eval "pyftsubset ${file} ${common_args} --unicodes=${unicodes} --flavor=woff --with-zopfli --output-file=${out_dir}/${basename_no_ext}.woff"
font_ext="woff"
out_file="${out_dir}/${basename_no_ext}.${font_ext}"
eval "pyftsubset ${file} ${common_args} --flavor=${font_ext} --with-zopfli --output-file=${out_file}"
print_glyph_count "${out_file}"
fi
done
echo "${font}: Converting the subset WOFF files to WOFF2 .."
for file in ${out_dir}/*
echo "${font}: Generating subset WOFF2 files .."
for file in ${font}/ttf/*
do
tmp="${file##*/}"
basename_no_ext="${tmp%.*}"
if [[ $file == *.woff ]] # The ${out_dir} HAS to contain .woff font files.
if [[ $file == *.ttf ]] # The ${font}/ttf HAS to contain .ttf font files.
then
eval "pyftsubset ${file} ${common_args} --flavor=woff2 --output-file=${out_dir}/${basename_no_ext}.woff2"
font_ext="woff2"
out_file="${out_dir}/${basename_no_ext}.${font_ext}"
eval "pyftsubset ${file} ${common_args} --flavor=${font_ext} --output-file=${out_file}"
print_glyph_count "${out_file}"
fi
done
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment