-
Notifications
You must be signed in to change notification settings - Fork 0
/
create-fntsample-pdf.sh
executable file
·104 lines (87 loc) · 2.82 KB
/
create-fntsample-pdf.sh
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/bin/sh
#
# This file is part of the SavaPage project <https://www.savapage.org>.
# Copyright (c) 2011-2020 Datraverse B.V.
# Author: Rijk Ravestein.
#
# SPDX-FileCopyrightText: 2011-2020 Datraverse B.V. <[email protected]>
# SPDX-License-Identifier: AGPL-3.0-or-later
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# For more information, please contact Datraverse B.V. at this
# address: [email protected]
#
#----------------------------------------------------------------------
# Creates a font sample PDF file from a TTF file
#
# Dependency:
#
# sudo apt-get install fntsample
#
# http://sourceforge.net/projects/fntsample/
#
# fntsample program generates font samples that show Unicode coverage
# of the font and are similar in appearance to Unicode charts.
#----------------------------------------------------------------------
#----------------------------------------------------------------------
#
# Parameters:
#
# $1 : path of TTF file
# $2 : target directory of PDF file
# $3 : (optional) the name of the font as replacement in the outline
#
# Output:
#
#----------------------------------------------------------------------
createFntSamplePdf () {
ttfFile="$1"
pdfFile="$2/`basename ${ttfFile} .ttf`.pdf"
tmpPdf=`mktemp`
tmpOutline=`mktemp`
tmpOutline2=`mktemp`
echo "Creating ${pdfFile} from ${ttfFile}"
fntsample -f ${ttfFile} -o ${tmpPdf} -l > ${tmpOutline}
if [ -n "$3" ]
then
echo "Replace font name in 1st line of outline with: $3"
echo "0 1 $3" > ${tmpOutline2}
more +2 ${tmpOutline} >> ${tmpOutline2}
tmpOutline=${tmpOutline2}
fi
pdfoutline ${tmpPdf} ${tmpOutline} ${pdfFile}
echo "done"
rm -f ${tmpPdf} ${tmpOutline} ${tmpOutline2}
return 0;
}
#----------------------------------------------------------------------
usage() {
echo "Usage: $1 <input file> <output directory> [font name]"
}
#----------------------------------------------------------------------
#
# Parameters:
#
# $1 : path of TTF file
# $2 : target directory of PDF file
# $3 : (optional) the name of the font as replacement in the outline
#----------------------------------------------------------------------
if [ $# -lt 2 ] ; then
usage $0
exit 0
fi
createFntSamplePdf $1 $2 $3
exit 0
# end-of-script