2018-07-09 16:20:40 +02:00
|
|
|
#!/usr/bin/env bash
|
2022-09-07 10:05:53 +02:00
|
|
|
# Nerd Fonts Version: 2.2.2
|
2019-08-11 23:20:42 +02:00
|
|
|
# Script Version: 1.1.1
|
2017-04-27 01:54:53 +02:00
|
|
|
# Generates CSS file for the font
|
|
|
|
|
2018-01-13 05:20:52 +02:00
|
|
|
# shellcheck disable=SC1091
|
2017-04-27 01:54:53 +02:00
|
|
|
source ./lib/i_all.sh
|
|
|
|
|
2017-05-02 01:45:47 +02:00
|
|
|
output_css_file="../../css/nerd-fonts-generated.css"
|
|
|
|
header_css_file="./css-header.txt"
|
2017-04-27 01:54:53 +02:00
|
|
|
output_cheat_sheet_file="../../temp/nerd-fonts-generated-cheat-sheet.txt"
|
2017-05-19 10:14:53 +02:00
|
|
|
LINE_PREFIX="# [Nerd Fonts] "
|
2022-09-07 10:05:53 +02:00
|
|
|
version="2.2.2"
|
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
|
|
|
|
true > "$output_cheat_sheet_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"
|
|
|
|
printf " */\\n\\n"
|
2017-07-30 03:17:11 +02:00
|
|
|
# add top section of CSS
|
|
|
|
cat $header_css_file
|
|
|
|
} >> "$output_css_file"
|
|
|
|
|
2017-04-27 01:54:53 +02:00
|
|
|
|
|
|
|
echo;
|
|
|
|
|
2018-01-12 04:47:59 +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}"
|
|
|
|
|
|
|
|
echo "$glyph_name"
|
|
|
|
echo "$glyph_char"
|
|
|
|
echo "$glyph_code"
|
|
|
|
#printf "%x" "'$glyph_char'"
|
|
|
|
|
|
|
|
# generate css rules
|
|
|
|
{
|
2019-08-11 23:20:42 +02:00
|
|
|
printf ".nf-%s:before {" "$glyph_name"
|
2018-01-13 05:20:52 +02:00
|
|
|
printf "\\n"
|
|
|
|
printf " content: \"\\%s\";" "$glyph_code"
|
|
|
|
printf "\\n"
|
2017-04-27 01:54:53 +02:00
|
|
|
printf "}"
|
2018-01-13 05:20:52 +02:00
|
|
|
printf "\\n"
|
2017-04-27 01:54:53 +02:00
|
|
|
} >> "$output_css_file"
|
|
|
|
|
|
|
|
# generate HTML cheat sheet
|
|
|
|
{
|
|
|
|
printf "<div class=\"column\">"
|
2018-01-13 05:20:52 +02:00
|
|
|
printf "\\n"
|
2019-08-11 23:20:42 +02:00
|
|
|
printf " <div class=\"nf nf-%s center\"></div>" "$glyph_name"
|
2018-01-13 05:20:52 +02:00
|
|
|
printf "\\n"
|
2018-04-01 16:36:48 +02:00
|
|
|
printf " <span><div class=\"class-name\">nf-%s</div><div class=\"codepoint\">%s</div></span>" "$glyph_name" "$glyph_code"
|
2018-01-13 05:20:52 +02:00
|
|
|
printf "\\n"
|
2017-04-27 01:54:53 +02:00
|
|
|
printf "</div>"
|
2018-01-13 05:20:52 +02:00
|
|
|
printf "\\n"
|
2017-04-27 01:54:53 +02:00
|
|
|
} >> "$output_cheat_sheet_file"
|
|
|
|
|
|
|
|
done
|
|
|
|
|
2018-01-13 05:20:52 +02:00
|
|
|
printf "Generated CSS and Cheat Sheet HTML\\n"
|