2018-07-09 16:20:40 +02:00
|
|
|
#!/usr/bin/env bash
|
2023-05-13 07:48:24 +02:00
|
|
|
# Nerd Fonts Version: 3.0.1
|
2023-06-01 10:50:04 +02:00
|
|
|
# Script Version: 1.2.1
|
2022-09-11 18:41:34 +02:00
|
|
|
# Generates CSS file for the font and cheat sheet code
|
2017-04-27 01:54:53 +02:00
|
|
|
|
2023-06-01 10:50:04 +02:00
|
|
|
# shellcheck disable=SC1091 # Do not pull in the sourced file
|
2023-05-03 17:54:44 +02:00
|
|
|
source ./lib/i_all.sh include-old-material
|
2017-04-27 01:54:53 +02:00
|
|
|
|
2017-05-02 01:45:47 +02:00
|
|
|
output_css_file="../../css/nerd-fonts-generated.css"
|
2022-09-11 15:37:15 +02:00
|
|
|
output_css_min_file="../../css/nerd-fonts-generated.min.css"
|
2023-05-03 17:54:44 +02:00
|
|
|
output_css_min_rem_file="../../css/nerd-fonts-generated-removed.min.css"
|
2022-09-11 18:23:02 +02:00
|
|
|
header_css_file="./data/css-header.txt"
|
|
|
|
header_css_min_file="./data/css-min-header.txt"
|
2023-05-03 17:54:44 +02:00
|
|
|
header_css_min_rem_file="./data/css-min-removed-header.txt"
|
2023-03-02 13:14:49 +02:00
|
|
|
output_json_file="../../glyphnames.json"
|
2022-09-11 18:41:34 +02:00
|
|
|
|
|
|
|
if [ ! -d "../../temp" ]; then
|
|
|
|
mkdir "../../temp"
|
2022-09-10 17:16:05 +02:00
|
|
|
fi
|
2022-09-11 18:41:34 +02:00
|
|
|
output_cheat_sheet_file="../../temp/2017-01-04-icon-cheat-sheet.md"
|
|
|
|
cheat_sheet_head_file="./data/cheatsheet-head.txt"
|
|
|
|
cheat_sheet_foot_file="./data/cheatsheet-foot.txt"
|
|
|
|
|
2017-05-19 10:14:53 +02:00
|
|
|
LINE_PREFIX="# [Nerd Fonts] "
|
2023-05-13 07:48:24 +02:00
|
|
|
version="3.0.1"
|
2017-04-27 01:54:53 +02:00
|
|
|
|
|
|
|
# clear files
|
2018-01-13 05:20:52 +02:00
|
|
|
true > "$output_css_file" 2> /dev/null
|
2022-09-11 15:37:15 +02:00
|
|
|
true > "$output_css_min_file" 2> /dev/null
|
2023-05-03 17:54:44 +02:00
|
|
|
true > "$output_css_min_rem_file" 2> /dev/null
|
2018-01-13 05:20:52 +02:00
|
|
|
true > "$output_cheat_sheet_file" 2> /dev/null
|
2023-03-02 13:14:49 +02:00
|
|
|
true > "$output_json_file" 2> /dev/null
|
2017-04-27 01:54:53 +02:00
|
|
|
|
2017-05-02 01:45:47 +02:00
|
|
|
# describe how the classes were established
|
2017-07-30 03:17:11 +02:00
|
|
|
{
|
2018-01-13 05:20:52 +02:00
|
|
|
printf "/*\\n"
|
|
|
|
printf " *%s Website: https://www.nerdfonts.com\\n" "$LINE_PREFIX"
|
|
|
|
printf " *%s Development Website: https://github.com/ryanoasis/nerd-fonts\\n" "$LINE_PREFIX"
|
|
|
|
printf " *%s Version: %s\\n" "$LINE_PREFIX" "$version"
|
|
|
|
printf " *%s The following is generated from the build script\\n" "$LINE_PREFIX"
|
2022-09-11 15:37:15 +02:00
|
|
|
printf " */\\n"
|
2023-05-03 17:54:44 +02:00
|
|
|
} | tee "$output_css_min_file" | tee "$output_css_min_rem_file" >> "$output_css_file"
|
2017-07-30 03:17:11 +02:00
|
|
|
|
2022-09-11 15:37:15 +02:00
|
|
|
# add top section of CSS
|
|
|
|
{
|
|
|
|
printf "\\n"
|
|
|
|
cat "$header_css_file"
|
|
|
|
} >> "$output_css_file"
|
2023-06-01 10:50:04 +02:00
|
|
|
tr -d '\n' < "$header_css_min_file" >> "$output_css_min_file"
|
|
|
|
tr -d '\n' < "$header_css_min_rem_file" >> "$output_css_min_rem_file"
|
2017-04-27 01:54:53 +02:00
|
|
|
|
2022-09-11 18:41:34 +02:00
|
|
|
cat "$cheat_sheet_head_file" > "$output_cheat_sheet_file"
|
|
|
|
|
2023-03-02 13:14:49 +02:00
|
|
|
# add top section of json
|
|
|
|
{
|
|
|
|
printf "{\"METADATA\":{"
|
|
|
|
printf "\"website\":\"https://www.nerdfonts.com\","
|
|
|
|
printf "\"development-website\":\"https://github.com/ryanoasis/nerd-fonts\","
|
2023-06-01 10:50:04 +02:00
|
|
|
printf "\"version\":\"%s\"," "$version"
|
|
|
|
printf "\"date\":\"%s\"" "$(date -u --rfc-3339=seconds)"
|
2023-03-02 13:14:49 +02:00
|
|
|
printf "}"
|
|
|
|
} >> "$output_json_file"
|
|
|
|
|
2017-04-27 01:54:53 +02:00
|
|
|
echo;
|
|
|
|
|
2023-06-01 10:50:04 +02:00
|
|
|
# shellcheck disable=SC2154 # we know the '$i' is from the sourced file
|
2017-04-27 01:54:53 +02:00
|
|
|
for var in "${!i@}"; do
|
|
|
|
# trim 'i_' prefix
|
|
|
|
glyph_name=${var#*_}
|
|
|
|
# replace _ with -
|
|
|
|
glyph_name=${glyph_name/_/-}
|
|
|
|
glyph_char=${!var}
|
|
|
|
glyph_code=$(printf "%x" "'$glyph_char'")
|
|
|
|
|
|
|
|
#echo "$var=${!var}"
|
|
|
|
|
2022-09-10 17:16:05 +02:00
|
|
|
#echo "$glyph_name"
|
|
|
|
#echo "$glyph_char"
|
|
|
|
#echo "$glyph_code"
|
2017-04-27 01:54:53 +02:00
|
|
|
#printf "%x" "'$glyph_char'"
|
|
|
|
|
2023-05-03 17:54:44 +02:00
|
|
|
if [[ "$glyph_name" != mdi-* ]]; then
|
|
|
|
# generate css rules
|
|
|
|
{
|
|
|
|
printf ".nf-%s:before {" "$glyph_name"
|
|
|
|
printf "\\n"
|
|
|
|
printf " content: \"\\%s\";" "$glyph_code"
|
|
|
|
printf "\\n"
|
|
|
|
printf "}"
|
|
|
|
printf "\\n"
|
|
|
|
} >> "$output_css_file"
|
|
|
|
|
|
|
|
# generate css min rules
|
|
|
|
{
|
|
|
|
printf ".nf-%s:before{content:\"\\%s\"}" "$glyph_name" "$glyph_code"
|
|
|
|
} >> "$output_css_min_file"
|
|
|
|
|
|
|
|
# generate json entry
|
|
|
|
{
|
|
|
|
printf ",\"%s\":{\"char\":\"%s\",\"code\":\"%s\"}" "$glyph_name" "$glyph_char" "$glyph_code"
|
|
|
|
} >> "$output_json_file"
|
|
|
|
|
|
|
|
else
|
|
|
|
# generate css min rules for removed glyphs
|
|
|
|
{
|
|
|
|
printf ".nfold-%s:before{content:\"\\%s\"}" "$glyph_name" "$glyph_code"
|
|
|
|
} >> "$output_css_min_rem_file"
|
|
|
|
fi
|
2022-09-11 15:37:15 +02:00
|
|
|
|
2017-04-27 01:54:53 +02:00
|
|
|
# generate HTML cheat sheet
|
|
|
|
{
|
2023-02-01 14:28:35 +02:00
|
|
|
if [[ "$glyph_name" = mdi-* ]]; then
|
2023-05-21 09:53:27 +02:00
|
|
|
namespace="nfold"
|
2023-05-03 17:54:44 +02:00
|
|
|
else
|
2023-05-21 09:53:27 +02:00
|
|
|
namespace="nf"
|
2023-02-01 14:28:35 +02:00
|
|
|
fi
|
2023-05-21 09:53:27 +02:00
|
|
|
printf " \"%s-%s\": \"%s\",\\n" "$namespace" "$glyph_name" "$glyph_code"
|
2017-04-27 01:54:53 +02:00
|
|
|
} >> "$output_cheat_sheet_file"
|
|
|
|
|
|
|
|
done
|
|
|
|
|
2022-09-11 18:41:34 +02:00
|
|
|
cat "$cheat_sheet_foot_file" >> "$output_cheat_sheet_file"
|
2023-03-02 13:14:49 +02:00
|
|
|
printf "}\n" >> "$output_json_file"
|
2022-09-11 18:41:34 +02:00
|
|
|
|
2023-06-01 10:50:04 +02:00
|
|
|
printf "%s\n" "Generated CSS, json, and Cheat Sheet HTML"
|
|
|
|
printf "%s\n" "$output_css_file"
|
|
|
|
printf "%s\n" "$output_css_min_file [needs to also go into gh-pages:_includes/css/]"
|
|
|
|
printf "%s\n" "$output_css_min_rem_file [needs to only go into gh-pages:_includes/css/]"
|
|
|
|
printf "%s\n" "$output_cheat_sheet_file [needs to only go into gh-pages:_posts/]"
|
|
|
|
printf "%s\n" "$output_json_file"
|