blob: 59fb05c5c337f2f80f1f5c9558b3e67b21dcae61 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#!/bin/sh
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Generates font source images.
SCRIPT="$(readlink -f "$0")"
SCRIPT_DIR="$(dirname "$SCRIPT")"
GLYPHS='* 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ{}-_'
COLOR="#888888"
FONT="Droid Sans Bold"
MARGIN="3"
die() {
echo "ERROR: $*" >&2
exit 1
}
main() {
[ "$#" = "1" ] || die "Usage: $0 output_dir"
local output="$1"
mkdir -p "$output"
local i=1
local c=''
echo "Generating glyph text source..."
while true; do
c="$(echo "$GLYPHS" | cut -b $i)"
[ -z "$c" ] && break
ord="0x$(echo "$c" | od -t x1 -A none | awk '{print $1}')"
echo "$c" >"$output/idx$(printf "%03d" $ord)_$(printf "%x" $ord).txt"
i=$((i + 1))
done
echo "Converting glyph images..."
"$SCRIPT_DIR/text_to_png" --margin=0 --font="$FONT" --color="$COLOR" \
"$output/*.txt"
echo "Adding vertical margin to images..."
for i in $output/*.png; do
convert $i -bordercolor white -border 0x$MARGIN $i
done
}
set -e
main "$@"
|