This file is indexed.

/usr/bin/ttf2ufm_convert is in ttf2ufm 3.4.4~r2+gbp-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
#!/bin/sh
# 
#  Copyright (c) 1998-2000
#   Sergey A. Babkin.  All rights reserved.
# 
#  Redistribution and use in source and binary forms, with or without
#  modification, are permitted provided that the following conditions
#  are met:
#  1. Redistributions of source code must retain the above copyright
#     notice, this list of conditions and the following disclaimer.
#  2. Redistributions in binary form must reproduce the above copyright
#     notice, this list of conditions and the following disclaimer in the
#     documentation and/or other materials provided with the distribution.
# 
#  THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
#  WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
#  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
# 
#  Sergey A. Babkin (sab123@hotmail.com, babkin@bellatlantic.net)
# 

# Use : convert [cfgfile]

# Convert TTF fonts from source directory to Type1 fonts in the destination
# directory, converted to the specified encodings. Also generate the
# fonts.scale, fonts.dir and fonts.alias files in the destination directory.

# clean some variables so that they won't be inherited from environment

ENCDIR=
MAPDIR=

# path to the configuration file

if [ $# -eq 1 ]
then
	CFGFILE=$1
else
	CFGFILE=`pwd`/convert.cfg
fi

# these setting would be edited during installation

TTF2PT1_BINDIR=/usr/bin
TTF2PT1_LIBXDIR=/usr/lib/ttf2ufm
TTF2PT1_SHAREDIR=/usr/share/ttf2ufm

[ -z "$TTF2PT1_BINDIR" ] && {
	TTF2PT1_BINDIR=`pwd`/..
}
[ -z "$TTF2PT1_LIBXDIR" ] && {
	TTF2PT1_LIBXDIR=`pwd`/..
}
[ -z "$TTF2PT1_SHAREDIR" ] && {
	TTF2PT1_SHAREDIR=`pwd`/..
}

# directory from where we are started

RUNDIR=`pwd`

# paths to various utilities

T1ASM=$TTF2PT1_LIBXDIR/t1asm
[ -f $T1ASM -a -x $T1ASM ] || {
	# if it's not in libxdir, use whatever t1asm the system provides
	T1ASM=t1asm
}
TTF2PT1=$TTF2PT1_BINDIR/ttf2pt1
TRANS=$TTF2PT1_SHAREDIR/scripts/trans
T1FDIR=$TTF2PT1_SHAREDIR/scripts/t1fdir
FORCEISO=$TTF2PT1_SHAREDIR/scripts/forceiso
X2GS=$TTF2PT1_SHAREDIR/scripts/x2gs
SUFFIX="pfa"

MYSELF=convert

# include the configuration

if [ -r $CFGFILE ] 
then {
	. $CFGFILE
} else {
	echo "
Can't find the configuration file 
   $CFGFILE
Please look at the sample file convert.cfg.sample,
copy it to convert.cfg and modify for
you actual configuration." >&2
	exit 1
} fi

# path to the directory with descriptions of encodings
[ -z "$ENCDIR" ] && {
	ENCDIR=$TTF2PT1_SHAREDIR/encodings
}

# directory with the external Unicode maps
[ -z "$MAPDIR" ] && {
	MAPDIR=$TTF2PT1_SHAREDIR/maps
}

LOG=$DSTDIR/convert.log

# configure the ttf2pt1 options from our options

# artefact of backwards-compatibility with .cfg
[ -z "$CORRECTWIDTH" -a YES != "$DONTCORRECTWIDTH" ] && {
	TTF2PT1="$TTF2PT1 -OW"
}
[ YES = "$CORRECTWIDTH" ] && {
	TTF2PT1="$TTF2PT1 -OW"
}

[ YES != "$HINTSUBST" ] && {
	TTF2PT1="$TTF2PT1 -Ou" # meaning changed past 3.22
}

[ YES = "$ALLGLYPHS" -a YES = "$ENFORCEISO" ] && {
	echo "$MYSELF: options ALLGLYPHS and ENFORCEISO are mutually exclusive" >&2
	exit 1
}

[ YES = "$ALLGLYPHS" ] && {
	TTF2PT1="$TTF2PT1 -a"
}

[ YES = "$GENUID" ] && {
	TTF2PT1="$TTF2PT1 -uA"
}

[ YES != "$ENFORCEISO" ] && {
	FORCEISO=cat
}

[ YES = "$CREATEPFB" ] && {
	T1ASM="$T1ASM -b"
	SUFFIX="pfb"
}

# parse the information about the source files

eval "`echo \"$SRCDIRS\" | awk '
	BEGIN	{ n=0; }
	/^ *$/	{ next; }
		{ 
			if(n>9) { 
				printf(\"echo \\\"Only 9 encodings are supported at once!\\\" >&2\n\");
				printf(\"exit 1\\n\");
			} else {
				printf(\"SRCDIR%d=%s\n\",n,$1);
				printf(\"SRCLANG%d=%s\n\",n,$2);
				printf(\"SRCENC%d=%s\n\",n,$3);
				printf(\"SRCMAP%d=%s\n\",n,$4);
				n++;
			}
		}'`"

# check whether we have the directories

mkdir $DSTDIR 2>/dev/null >/dev/null
[ -d $DSTDIR -a -r $DSTDIR -a -w $DSTDIR -a -x $DSTDIR ] || {
	echo "$MYSELF: can't access the directory $DSTDIR" >&2
	exit 1
}

# go to our destination directory

cd $DSTDIR || {
	echo "$MYSELF: can't chdir to $DSTDIR" >&2
	exit 1
}

rm -f ./* 2>/dev/null
>$LOG

for dirno in 0 1 2 3 4 5 6 7 8 9
do {
	
	SRCDIR=`eval "echo \\\$SRCDIR$dirno"`
	SRCLANG=`eval "echo \\\$SRCLANG$dirno"`
	SRCENC=`eval "echo \\\$SRCENC$dirno"`
	SRCMAP=`eval "echo \\\$SRCMAP$dirno"`
	DSTENC=`eval "echo \\\$DSTENC$SRCLANG"`

	echo $SRCDIR
	echo $SRCENC

	[ -z "$SRCDIR" ] && break;

	[ "`ls $SRCDIR/*.[tT][tT][fF] 2>/dev/null |wc -l`" -gt 0 ] || {
		echo "$MYSELF: no TTF files in $SRCDIR" >&2
		exit 1
	}

	# check whether we have the encoding tables

	[ -n "$SRCENC" ] || {
		echo "$MYSELF: you must specify some source encoding" >&2
		exit 1
	}

	[ unknown = "$SRCLANG" -o -n "$DSTENC" ] || {
		echo "$MYSELF: you must specify some destination encodings" >&2
		exit 1
	}

	# handle aliases of the destination encodings

	XDSTENC=
	DSTALIAS=

	[ -r $ENCDIR/$SRCLANG/encodings.alias ] && {
		for i in $DSTENC
		do {
			TO=`awk  '$1=="'$i'" { print $2; }' <$ENCDIR/$SRCLANG/encodings.alias`
			if [ -n "$TO" ]
			then {
				[ -f $ENCDIR/$SRCLANG/$i.tbl -a -r $ENCDIR/$SRCLANG/$i.tbl ] && {
					echo "WARNING: $SRCLANG encoding $i found as both table and alias" >&2
					echo "WARNING: The alias takes precedence" >&2
				}
				DSTALIAS="$TO $i
$DSTALIAS"
				XDSTENC="$TO
$XDSTENC"
			} else {
				XDSTENC="$i
$XDSTENC"
			} fi
		} done
		DSTENC=`echo "$XDSTENC" | sort -u | tr '
' ' '`
	}

	[ unknown != "$SRCLANG" ] && {
		for i in $SRCENC $DSTENC
		do {
			[ -f $ENCDIR/$SRCLANG/$i.tbl -a -r $ENCDIR/$SRCLANG/$i.tbl ] || {
				echo "$MYSELF: can't read $ENCDIR/$SRCLANG/$i.tbl" >&2
				exit 1
			}
		} done
	}

	# OK convert the files

	for file in $SRCDIR/*.[tT][tT][fF]
	do {
		name=`echo $file | tr A-Z a-z`
		name=`basename $name .ttf`

		echo "Converting $name"

		# generate the assembler code

		echo "******* $name -> t1a ************" >>$LOG
		
		if [ -n "$SRCMAP" ]
		then {
			$TTF2PT1 -L $MAPDIR/$SRCMAP $file ./$name.$SRCENC 2>>$LOG
		} else {
			$TTF2PT1 -l $SRCLANG $file ./$name.$SRCENC 2>>$LOG
		} fi

		[ -s ./$name.$SRCENC.t1a ] || {
			echo "$MYSELF: can't generate Type1 assembler code for $name" >&2
			continue;
		}

		[ -s ./$name.$SRCENC.afm ] || {
			echo "$MYSELF: can't generate AFM metrics file for $name" >&2
			continue;
		}

		mv ./$name.$SRCENC.afm ./$name.$SRCENC.xafm

		psname=`$T1FDIR -g $FOUNDRY " " -f ./$name.$SRCENC.t1a \
			| awk '{print substr($1,2);}'`

		# now for each destination encoding generate a .pfa/b file
		# and record for fonts.scale

		if [ unknown != "$SRCLANG" ]
		then {
			for enc in $DSTENC
			do {
				echo "******* $name -> $enc ************" >>$LOG

				sed 's|^\/FontName.*$|/FontName /'$psname$enc' def|' <./$name.$SRCENC.t1a \
					| $TRANS $ENCDIR/$SRCLANG/$SRCENC.tbl $ENCDIR/$SRCLANG/$enc.tbl \
					| $FORCEISO | $T1ASM >./$name.$enc.$SUFFIX
				[ -s ./$name.$enc.$SUFFIX ] || {
					echo "$MYSELF: can't convert/assemble Type1 file for $name.$enc" >&2
					continue;
				}

				sed 's|^FontName.*$|FontName '$psname$enc'|' <./$name.$SRCENC.xafm \
					| $TRANS $ENCDIR/$SRCLANG/$SRCENC.tbl $ENCDIR/$SRCLANG/$enc.tbl \
					| uniq | $FORCEISO >./$name.$enc.afm
				[ -s ./$name.$enc.afm ] || {
					echo "$MYSELF: can't convert AFM file for $name.$enc" >&2
				}

				aliases=`echo "$DSTALIAS" | grep "^$enc" | cut -d\  -f2`
				echo "******* aliases: $aliases" >>$LOG

				$T1FDIR -d fonts.ttf fonts.alias $FOUNDRY $enc $aliases -f ./$name.$enc.$SUFFIX
				echo "/$psname$enc	($name.$enc.$SUFFIX)	;" >>Fontmap.ttf
			} done
		} else {
			enc="$SRCENC"
			echo "******* $name -> $enc ************" >>$LOG

			sed 's|^\/FontName.*$|/FontName /'$psname$enc' def|' <./$name.$SRCENC.t1a \
				| $FORCEISO | $T1ASM >./$name.$enc.$SUFFIX
			[ -s ./$name.$enc.$SUFFIX ] || {
				echo "$MYSELF: can't convert/assemble Type1 file for $name.$enc" >&2
				continue;
			}

			sed 's|^FontName.*$|FontName '$psname$enc'|' <./$name.$SRCENC.xafm \
				| uniq | $FORCEISO >./$name.$enc.afm
			[ -s ./$name.$enc.afm ] || {
				echo "$MYSELF: can't convert AFM file for $name.$enc" >&2
			}

			$T1FDIR -d fonts.ttf fonts.alias $FOUNDRY $enc -f ./$name.$enc.$SUFFIX
			echo "/$psname$enc	($name.$enc.$SUFFIX)	;" >>Fontmap.ttf
		} fi

		[ YES = "$REMOVET1A" ] && {
			rm -f ./$name.$SRCENC.t1a
			rm -f ./$name.$SRCENC.xafm
		}

	} done
} done

wc -l <fonts.ttf >fonts.scale
cat fonts.ttf >>fonts.scale
mkfontdir

[ YES = "$GENUID" ] && {
	echo "Checking for duplicate UniqueIDs..."
	for id in `find . -name "*.$SUFFIX" -exec grep UniqueID {} \; \
			| cut -d" " -f2 | sort | uniq -d`
	do {
		echo "Warning: duplicate UniqueID $id in files:" | tee -a $LOG
		find  . -name "*.$SUFFIX" -exec grep -l "UniqueID $id " {} \; 2>&1 | tee -a $LOG
	} done
}

[ -n "$GSDIR" ] || {
	echo "$MYSELF: The Ghostscript base directory is not specified.\n" >&2
	echo "$MYSELF: Installation of the Ghostscript fonts is deferred.\n" >&2
	echo "$MYSELF: You can do it later by running x2gs\n" >&2
	exit 0
}

echo "Installing the Ghostscript fonts"
cd $RUNDIR
$X2GS $CFGFILE || {
	echo "$MYSELF: Installation of the Ghostscript fonts has failed.\n" >&2
	echo "$MYSELF: You can correct the problem and run x2gs to repeat\n" >&2
	exit 0
}