thing
This commit is contained in:
commit
68b04317c2
10
README.md
Normal file
10
README.md
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
# mkfont.sh but better
|
||||||
|
|
||||||
|
here's what i use to generate comic code fonts
|
||||||
|
|
||||||
|
./mkfont.sh Comic-Code-Ligatures-Regular 12 1 ~/comic-code-ligatures-regular-12.png 8 14
|
||||||
|
./mkfont.sh Comic-Code-Ligatures-Regular 14 1 ~/comic-code-ligatures-regular-14.png 9 16
|
||||||
|
./mkfont.sh Comic-Code-Ligatures-Regular 16 1 ~/comic-code-ligatures-regular-16.png 10 18
|
||||||
|
./mkfont.sh Comic-Code-Ligatures-Regular 24 1 ~/comic-code-ligatures-regular-24.png 15 26
|
||||||
|
./mkfont.sh Comic-Code-Ligatures-Regular 28 1 ~/comic-code-ligatures-regular-28.png 17 30
|
||||||
|
./mkfont.sh Comic-Code-Ligatures-Regular 32 2 ~/comic-code-ligatures-regular-32.png 20 36
|
75
mkfont.sh
Executable file
75
mkfont.sh
Executable file
|
@ -0,0 +1,75 @@
|
||||||
|
#!/usr/bin/bash
|
||||||
|
#
|
||||||
|
# copyright (c) 2013 by Roderick W. Smith
|
||||||
|
#
|
||||||
|
# This program is licensed under the terms of the GNU GPL, version 3,
|
||||||
|
# or (at your option) any later version.
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
# Program to generate a PNG file suitable for use as a rEFInd font
|
||||||
|
# To obtain a list of available font names, type:
|
||||||
|
#
|
||||||
|
# convert -list font | less
|
||||||
|
#
|
||||||
|
# The font used MUST be a monospaced font; searching for the string
|
||||||
|
# "Mono" will turn up most suitable candidates.
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
# ./mkfont.sh font-name font-size font-Y-offset bitmap-filename.png
|
||||||
|
#
|
||||||
|
# This script is part of the rEFInd package. Version numbers refer to
|
||||||
|
# the rEFInd version with which the script was released.
|
||||||
|
#
|
||||||
|
# Version history:
|
||||||
|
#
|
||||||
|
# 0.6.6 - Initial release
|
||||||
|
|
||||||
|
if [[ $# != 4 ]] && [[ $# != 6 ]]; then
|
||||||
|
echo "Usage: $0 font-name font-size y-offset bitmap-filename.png [char-width char-height]"
|
||||||
|
echo " font-name: Name of font (use 'convert -list font | less' to get list)"
|
||||||
|
echo " NOTE: Font MUST be monospaced!"
|
||||||
|
echo " font-size: Font size in points"
|
||||||
|
echo " y-offset: pixels font is shifted (may be negative)"
|
||||||
|
echo " bitmap-filename.png: output filename"
|
||||||
|
echo " char-{width, height}: size of canvas to render the image onto"
|
||||||
|
echo ""
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
Convert="$(command -v convert 2> /dev/null)"
|
||||||
|
if [[ ! -x $Convert ]] ; then
|
||||||
|
echo "The 'convert' program is required but could not be found. It's part of the"
|
||||||
|
echo "ImagMagick program, usually installed in the 'imagemagick' package."
|
||||||
|
echo ""
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
Height=${6:-$2}
|
||||||
|
let CellWidth=(${Height}*6+5)/10
|
||||||
|
CellWidth=${5:-$CellWidth}
|
||||||
|
#let CellWidth=(${Height}*5)/10
|
||||||
|
let Width=${CellWidth}*96
|
||||||
|
echo $Width $Height $CellWidth $CellHeight
|
||||||
|
echo "Creating ${Width}x${Height} font bitmap...."
|
||||||
|
|
||||||
|
# create a folder to store our temporary renders of each character
|
||||||
|
dir="$4-temp"
|
||||||
|
[ -d $dir ] || mkdir $dir
|
||||||
|
|
||||||
|
# render each character
|
||||||
|
chars=" !\"#\$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_\`abcdefghijklmnopqrstuvwxyz{|}~?"
|
||||||
|
#echo $chars
|
||||||
|
for (( i=0; i<${#chars}; i++ )); do
|
||||||
|
char="${chars:$i:1}"
|
||||||
|
char="${char//"\\"/"\\\\"}"
|
||||||
|
char="${char//"'"/"\'"}"
|
||||||
|
$Convert -size ${CellWidth}x${Height} xc:transparent -gravity NorthWest -font $1 -pointsize $2 \
|
||||||
|
-draw "text 0,$3 '$char'" "$dir/$(printf %03d $i).png"
|
||||||
|
done
|
||||||
|
|
||||||
|
# stitch together
|
||||||
|
$Convert +append "$dir"/*.png $4
|
||||||
|
|
||||||
|
rm -r "$dir"
|
||||||
|
echo woo
|
Loading…
Reference in a new issue