initial commit
This commit is contained in:
2
scripts/.gitignore
vendored
Normal file
2
scripts/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*.ttf
|
||||
*.woff2
|
||||
42
scripts/generate_iconfont_subset.sh
Executable file
42
scripts/generate_iconfont_subset.sh
Executable file
@@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Font URL
|
||||
fontUrl="https://raw.githubusercontent.com/google/material-design-icons/master/font/MaterialIcons-Regular.ttf"
|
||||
fontFile="$(basename "$fontUrl")"
|
||||
|
||||
# Codepoints can be found at https://fonts.google.com/icons?icon.set=Material+Icons
|
||||
unicodePoints=(
|
||||
"61-7a,5f" # ascii lowercase + underscore
|
||||
"e2c4" # file_download
|
||||
"e037" # play_arrow
|
||||
"e034" # pause
|
||||
"e04f" # volume_off
|
||||
"e04e" # volume_mute
|
||||
"e04d" # volume_down
|
||||
"e050" # volume_up
|
||||
)
|
||||
unicodeStr=$(
|
||||
IFS=,
|
||||
echo "${unicodePoints[*]}"
|
||||
)
|
||||
|
||||
# Command extracts the needed iconfont codepoints and compresses as woff2 for small bundled size
|
||||
fontToolsBinary="fonttools"
|
||||
fontToolsArgs=("subset" "$fontFile" "--output-file=../static/fonts/MaterialIcons-Regular-subset.woff2" "--no-layout-closure" "--unicodes=${unicodeStr}" "--flavor=woff2" "--verbose")
|
||||
|
||||
# Check if file exists
|
||||
if [ -f "$fontFile" ]; then
|
||||
echo "Font file already exists. Skipping download."
|
||||
else
|
||||
echo "Font file not found. Downloading..."
|
||||
curl -s -o "$fontFile" "$fontUrl"
|
||||
fi
|
||||
|
||||
# Check if fonttools binary exists
|
||||
if ! command -v "$fontToolsBinary" &>/dev/null; then
|
||||
echo "Error: $fontToolsBinary not found. Please install it and try again."
|
||||
else
|
||||
echo "$fontToolsBinary is installed. Running command..."
|
||||
echo "${fontToolsArgs[@]}"
|
||||
"$fontToolsBinary" "${fontToolsArgs[@]}"
|
||||
fi
|
||||
Reference in New Issue
Block a user