Skip to content

Instantly share code, notes, and snippets.

@eliandoran
Created January 7, 2019 09:56
Show Gist options
  • Save eliandoran/f27a40f35b276ba350d5e98ad73fbd25 to your computer and use it in GitHub Desktop.
Save eliandoran/f27a40f35b276ba350d5e98ad73fbd25 to your computer and use it in GitHub Desktop.
Extract script for MicroEJ fonts
#!/bin/bash
FONT_PATH=$1
# Check if the font was provided as an argument.
if [ -z $FONT_PATH ]
then
echo "Usage: $0 <font>"
echo "Where <font> is the .ejf font to be extracted."
exit
fi
# Check if the font actually exists.
if [ ! -f $FONT_PATH ]
then
echo "Font $FONT_PATH does not exist."
exit
fi
# Generate a unique directory for the extraction
NUMBER=0
while test -e "$FONT_PATH$SUFFIX"; do
(( ++ number ))
SUFFIX="$( printf -- '-%02d' "$number" )"
done
OUT_DIR="$FONT_PATH$SUFFIX";
echo "Extracting $FONT_PATH to $OUT_DIR..."
mkdir -p $OUT_DIR
unzip $FONT_PATH -d $OUT_DIR -x design_* Header
cd $OUT_DIR
for FILE in *
do
mv "$FILE" "$FILE.png"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment