1#!/bin/bash
2#
3# Copyright 2017, Data61, CSIRO (ABN 41 687 119 230)
4#
5# SPDX-License-Identifier: BSD-2-Clause
6#
7
8# Generate XBM representations of the characters from the font Nimbus Mono
9# Regular.
10
11echo '#include <stdlib.h>'>chars.c
12for i in a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z; do
13    convert -resize 14x26\! -font Nimbus-Mono-Regular -pointsize 26 label:$i $i.xbm
14    cat $i.xbm >>chars.c
15    rm $i.xbm
16done
17for i in 1 2 3 4 5 6 7 8 9 0; do
18    convert -resize 14x26\! -font Nimbus-Mono-Regular -pointsize 26 label:$i digit$i.xbm
19    cat digit$i.xbm >>chars.c
20    rm digit$i.xbm
21done
22
23cat - >>chars.c <<EOT
24char *to_pixels(char c) {
25    static char space_bits[sizeof(Z_bits)] = { 0 };
26    switch(c) {
27        case ' ':
28            return space_bits;
29EOT
30
31for i in a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z; do
32    cat - >>chars.c <<EOT
33case '$i':
34    return ${i}_bits;
35EOT
36done
37for i in 1 2 3 4 5 6 7 8 9 0; do
38    cat - >>chars.c <<EOT
39case '$i':
40    return digit${i}_bits;
41EOT
42done
43cat - >>chars.c <<EOT
44default:
45    return NULL;
46    }
47}
48EOT
49