mirror of
https://github.com/ryanoasis/nerd-fonts.git
synced 2024-09-19 09:51:48 +02:00
generate-casks: Decouple from patched-fonts dir
[why] It does not really make sense to couple the casks, which checksums are based on the zip files in the archive directory to files currently existing in the repo. They could be different from the archived ones. [how] Use solely the archives. For this they must be unpacked temporarely so that the fonts can be examined for family names. We do not try to automatically determine the release tag of the archive files. They could in principle we different for each. Instead it usually has to be specified on the command line. Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
parent
c5cb976db8
commit
1cbe7a1813
2 changed files with 46 additions and 13 deletions
|
@ -9,7 +9,7 @@ Note: Usually you need to call the scripts in this directory while actually bein
|
|||
* `docker-entrypoint.sh`: This script is packaged into the docker container and is usually used to start patching [2]
|
||||
* `fetch-archives.sh`: Script to download the release zip archives [4]
|
||||
* `fpfix.py`: Can be used to set isFixedPitch property in a font [x]
|
||||
* `generate-casks.sh`: Generates cask files for fonts from data in `patched-fonts/` and `archives/` [3]
|
||||
* `generate-casks.sh`: Generates cask files for fonts from data in `archives/` [3]
|
||||
* `generate-css.sh`: Generates the Nerd Fonts CCS, which can be used to access the glyphs on a web page [1]
|
||||
* `generate-fontconfig.sh`: Generates font configuration to enable use of unpatched fonts with Symbols Only Nerd Font [1]
|
||||
* `generate-font-image-previews.sh`: Generates the preview images for `nerdfonts.com` (i.e. gh-pages) [3]
|
||||
|
|
|
@ -1,26 +1,52 @@
|
|||
#!/usr/bin/env bash
|
||||
# Nerd Fonts Version: 2.3.0-RC
|
||||
# Script Version: 2.1.1
|
||||
# Iterates over all [*] patched fonts directories
|
||||
# Script Version: 2.2.0
|
||||
#
|
||||
# Iterates over all [*] archived fonts
|
||||
# to generate ruby cask files for homebrew-fonts (https://github.com/caskroom/homebrew-fonts)
|
||||
# * Only adds non-Windows versions of the fonts
|
||||
# * Needs the zip archives in archives/ (i.e. run `./archive-fonts.sh` first)
|
||||
#
|
||||
# Uses the current release version (including drafts) of the repo.
|
||||
# You can specify a different version with the --setversion parameter.
|
||||
# A leading 'v' from the version is removed.
|
||||
# Must be the first parameter.
|
||||
#
|
||||
# [1] Accepts one parameter, a pattern which fonts to examine, if not given defaults
|
||||
# to "*" which is all fonts. Example `./generate-casks.sh 'Hasklig'`
|
||||
# to "*" which is all fonts.
|
||||
#
|
||||
# Example runs
|
||||
# generate-casks.sh Hasklig
|
||||
# generate-casks.sh --setversion 2.2.0
|
||||
# generate-casks.sh Hasklig
|
||||
# generate-casks.sh --setversion 2.2.0 Hasklig
|
||||
|
||||
#set -x
|
||||
# set -x
|
||||
set -e
|
||||
|
||||
version="2.3.0-RC"
|
||||
homepage="https://github.com/ryanoasis/nerd-fonts"
|
||||
downloadarchive="https://github.com/ryanoasis/nerd-fonts/releases/download/v#{version}/"
|
||||
LINE_PREFIX="# [Nerd Fonts] "
|
||||
scripts_root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/"
|
||||
patched_parent_dir="${scripts_root_dir}/../../patched-fonts/"
|
||||
scripts_root_dir="$(cd "$(dirname "$0")" && pwd)"
|
||||
archivedir=$(realpath "${scripts_root_dir}/../../archives")
|
||||
|
||||
cd $patched_parent_dir || {
|
||||
echo >&2 "$LINE_PREFIX Could not find patched fonts directory"
|
||||
if [ $# -ge 1 ]; then
|
||||
if [ "$1" = "--setversion" ]; then
|
||||
if [ $# -lt 2 ]; then
|
||||
echo >&2 "$LINE_PREFIX Missing argument for --setversion"
|
||||
exit 1
|
||||
fi
|
||||
version=$2
|
||||
shift; shift
|
||||
if [ "${version:0:1}" = "v" ]; then
|
||||
version="${version:1}"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
cd ${archivedir} || {
|
||||
echo >&2 "$LINE_PREFIX Could not find archives directory"
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
@ -109,7 +135,7 @@ function write_body {
|
|||
individualfont=$(basename "${fonts[$i]}")
|
||||
individualdir=$(dirname "${fonts[$i]}")
|
||||
|
||||
printf " %-${longest}s %s\\n" "${individualfont}" "${individualdir}"
|
||||
printf " %-${longest}s %s\\n" "${individualfont}" "${individualdir}/"
|
||||
|
||||
if [ "$i" == 0 ]; then
|
||||
{
|
||||
|
@ -140,16 +166,16 @@ function write_footer {
|
|||
} >> "$outputfile"
|
||||
}
|
||||
|
||||
pattern=$1
|
||||
pattern="$1.*"
|
||||
if [ "$pattern" = "" ]; then
|
||||
pattern=".*"
|
||||
fi
|
||||
|
||||
find . -maxdepth 1 -mindepth 1 -type d -iregex "\./$pattern" | sort |
|
||||
find . -maxdepth 1 -mindepth 1 -type f -iregex "\./$pattern" -regex ".*\.zip" | sort |
|
||||
while read -r filename; do
|
||||
|
||||
dirname=$(dirname "$filename")
|
||||
basename=$(basename "$filename")
|
||||
basename=$(basename "$filename" .zip)
|
||||
if [ ! -f "../archives/${basename}.zip" ]; then
|
||||
echo "${LINE_PREFIX} No archive for: ${basename}, skipping..."
|
||||
continue
|
||||
|
@ -164,6 +190,11 @@ while read -r filename; do
|
|||
continue
|
||||
fi
|
||||
|
||||
rm -Rf "${basename}"
|
||||
echo "$LINE_PREFIX Unpacking $basename"
|
||||
unzip -q "${basename}" -d "${basename}"
|
||||
searchdir=${basename}
|
||||
|
||||
FONTS=()
|
||||
while IFS= read -d $'\0' -r file; do
|
||||
FONTS=("${FONTS[@]}" "$file")
|
||||
|
@ -183,5 +214,7 @@ while read -r filename; do
|
|||
write_body "$originalname" "$to" "${FONTS[@]}"
|
||||
write_footer "$to"
|
||||
|
||||
rm -Rf "${basename}"
|
||||
|
||||
echo "## Created casks: $(realpath ${to})"
|
||||
done
|
||||
|
|
Loading…
Reference in a new issue