-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds script to generate skeleton for new fonts
- Loading branch information
Showing
2 changed files
with
189 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
20,Space | ||
21,Exclamation mark | ||
22,Quotation mark | ||
23,Number sign | ||
24,Dollar sign | ||
25,Percent sign | ||
26,Ampersand | ||
27,Apostrophe | ||
28,Left parenthesis | ||
29,Right parenthesis | ||
2A,Asterisk | ||
2B,Plus sign | ||
2C,Comma | ||
2D,Hyphen | ||
2E,Full stop | ||
2F,Slash | ||
30,Digit Zero | ||
31,Digit One | ||
32,Digit Two | ||
33,Digit Three | ||
34,Digit Four | ||
35,Digit Five | ||
36,Digit Six | ||
37,Digit Seven | ||
38,Digit Eight | ||
39,Digit Nine | ||
3A,Colon | ||
3B,Semicolon | ||
3C,Less-than sign | ||
3D,Equal sign | ||
3E,Greater-than sign | ||
3F,Question mark | ||
40,At sign | ||
41,Latin Capital letter A | ||
42,Latin Capital letter B | ||
43,Latin Capital letter C | ||
44,Latin Capital letter D | ||
45,Latin Capital letter E | ||
46,Latin Capital letter F | ||
47,Latin Capital letter G | ||
48,Latin Capital letter H | ||
49,Latin Capital letter I | ||
4A,Latin Capital letter J | ||
4B,Latin Capital letter K | ||
4C,Latin Capital letter L | ||
4D,Latin Capital letter M | ||
4E,Latin Capital letter N | ||
4F,Latin Capital letter O | ||
50,Latin Capital letter P | ||
51,Latin Capital letter Q | ||
52,Latin Capital letter R | ||
53,Latin Capital letter S | ||
54,Latin Capital letter T | ||
55,Latin Capital letter U | ||
56,Latin Capital letter V | ||
57,Latin Capital letter W | ||
58,Latin Capital letter X | ||
59,Latin Capital letter Y | ||
5A,Latin Capital letter Z | ||
5B,Left Square Bracket | ||
5C,Backslash | ||
5D,Right Square Bracket | ||
5E,Circumflex accent | ||
5F,Low line | ||
60,Grave accent | ||
61,Latin Small Letter A | ||
62,Latin Small Letter B | ||
63,Latin Small Letter C | ||
64,Latin Small Letter D | ||
65,Latin Small Letter E | ||
66,Latin Small Letter F | ||
67,Latin Small Letter G | ||
68,Latin Small Letter H | ||
69,Latin Small Letter I | ||
6A,Latin Small Letter J | ||
6B,Latin Small Letter K | ||
6C,Latin Small Letter L | ||
6D,Latin Small Letter M | ||
6E,Latin Small Letter N | ||
6F,Latin Small Letter O | ||
70,Latin Small Letter P | ||
71,Latin Small Letter Q | ||
72,Latin Small Letter R | ||
73,Latin Small Letter S | ||
74,Latin Small Letter T | ||
75,Latin Small Letter U | ||
76,Latin Small Letter V | ||
77,Latin Small Letter W | ||
78,Latin Small Letter X | ||
79,Latin Small Letter Y | ||
7A,Latin Small Letter Z | ||
7B,Left Curly Bracket | ||
7C,Vertical bar | ||
7D,Right Curly Bracket | ||
7E,Tilde | ||
7F,DELETE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#!/bin/sh | ||
usage() { | ||
ret_val=$1 | ||
usage_msg="Creates a new pixel font \n \ | ||
$0 name width height \n \ | ||
" | ||
if [ $ret_val -eq 0 ] | ||
then | ||
echo $usage_msg | ||
else | ||
echo $usage_msg >&2 | ||
fi | ||
exit $ret_val | ||
} | ||
|
||
if [ "$1" = "-h" ] | ||
then | ||
usage 0 | ||
fi | ||
|
||
# Check all params supplied | ||
if [ $# -ne 3 ] | ||
then | ||
usage 1 | ||
fi | ||
|
||
font_name=$1 | ||
font_width=$2 | ||
font_height=$3 | ||
|
||
# Check width and height are numeric; see | ||
# https://stackoverflow.com/a/16444570/118592 | ||
case $font_width in | ||
(*[!0-9]*|'') | ||
echo "Error: Font width must be a number" >&2 | ||
exit 1 | ||
;; | ||
(*) | ||
: | ||
;; | ||
esac | ||
case $font_height in | ||
(*[!0-9]*|'') | ||
echo "Error: Font height must be a number" >&2 | ||
exit 1 | ||
;; | ||
(*) | ||
: | ||
;; | ||
esac | ||
|
||
font_dir=$font_name/${font_width}x${font_height} | ||
|
||
if [ -d "$font_dir" ] | ||
then | ||
echo "Error: Font already exists" >&2 | ||
exit 1 | ||
fi | ||
|
||
# Create directory structure | ||
mkdir -p "${font_dir}" | ||
mkdir -p "${font_dir}/glyphs" | ||
mkdir -p "${font_dir}/by-name" | ||
|
||
# Create the space glyph | ||
echo "P1" >> "${font_dir}/glyphs/20.pbm" | ||
echo "${font_width} ${font_height}" >> "${font_dir}/glyphs/20.pbm" | ||
j=$font_height | ||
while [ $j -ne 0 ] ; do | ||
i=$font_width | ||
while [ $i -ne 0 ] ; do | ||
echo -n "0 " >> "${font_dir}/glyphs/20.pbm" | ||
i=$(expr $i - 1) | ||
done | ||
echo >> "${font_dir}/glyphs/20.pbm" | ||
j=$(expr $j - 1) | ||
done | ||
|
||
IFS="," | ||
line_no=1 | ||
while read code_point name | ||
do | ||
if [ $line_no -ne 1 ] | ||
then | ||
# Make a copy of the space glyph for every other character in | ||
# the Basic Latin range | ||
cp "${font_dir}/glyphs/20.pbm" "${font_dir}/glyphs/${code_point}.pbm" | ||
fi | ||
# Create a symlink with the human name for each glyph so it's easier to edit | ||
ln -s "../glyphs/${code_point}.pbm" "${font_dir}/by-name/${code_point}-${name}.pbm" | ||
line_no=$(expr $line_no + 1) | ||
done < basic_latin.csv | ||
|