This file is indexed.

/usr/bin/unipng2hex is in unifont-bin 1:6.3.20131221-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
#!/usr/bin/perl

#  unipng2hex - program to turn a .png glyph matrix into a
#               GNU Unifont hex glyph set of 256 characters
#
#  Synopsis: unipng2hex [-i in_file.png] [-o out_file.hex] [-w]
#
#
#  Author: Paul Hardy, unifoundry <at> unifoundry.com, December 2007
#
#  Perl conversion: Andrew Miller, August 2013
#
#
#   Copyright (C) 2007-2008 Paul Hardy
#
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 2 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 General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.

use Getopt::Long;
use GD qw (:DEFAULT :cmp);

$result = GetOptions (
	"help|?",
	"input|i=s" => \$input,
	"output|o=s" => \$output,
	"width|w=i" => \$minwidth
);

if ($opt_help) {
	print << "END";

Turn a .png glyph matrix into a GNU Unifont hex glyph set of 256 characters

Syntax:

   unipng2hex -i <Input_File> [-o <Output_File>] [-w <width>]

   -i, --input               the input PNG file
   -o, --output              the output hex file (write to STDOUT if not
                             specified)
   -w, --width               the minimum width of the output glyphs - valid
                             values are 16, 24 and 32 (default is no minimum
                             width)
   -?, --help                display this help and exit


Example:

   unipng2hex -i u83.png -o u83.hex
END
	exit ()
}

if (not $input) {
	die ("No input file specified\n")
}

#if (not $output) {
#	die ("No output file specified\n")
#}

GD::Image->trueColor (1);
$im = new GD::Image ("$input") or die ("Cannot open image\n");

if ($im->isTrueColor ()) {
	$im->trueColorToPalette ();
}

# Disable transparency if it has been set
$im->transparent (-1);

$black = $im->colorClosest (0, 0, 0);
$white = $im->colorClosest (255, 255, 255);

# Exit if black and white are not in the image's palette
if ($white == -1 || $black == -1) {
	die ("Invalid image - colors do not match\n");
} else {
	($black_red, $black_green, $black_blue) = $im->rgb ($black);
	($white_red, $white_green, $white_blue) = $im->rgb ($white);
}

($imagewidth, $imageheight) = $im->getBounds();

$charxoffset = 4;
$gridxoffset = 48;
$gridyoffset = 32;

$boxsize = ($imagewidth - $gridxoffset) / 16;

if ($boxsize == 32) {
	# try to determine if charheight is 16 or 24 by examining grid
	$pixel = $im->getPixel ($imagewidth - 1, $imageheight - 5);

	if ($im->rgb ($pixel) == ($black_red, $black_green, $black_blue)) {
		$charyoffset = 7;
		$charheight = 16;
		$charmaxwidth = 3;
	} elsif ($im->rgb ($pixel) == ($white_red, $white_green, $white_blue)) {
		$charyoffset = 4;
		$charheight = 24;
		$charmaxwidth = 3;
	} else {
		die ("Cannot determine font height\n")
	}
} elsif ($boxsize == 40) {
	$charyoffset = 4;
	$charheight = 32;
	$charmaxwidth = 4;
} else {
	die ("Invalid image - incorrect size\n")
}

if ($minwidth) {
	if ($charheight == 16 || $charheight == 24) {
		if (!($minwidth == 16 || $minwidth == 24)) {
			die ("invalid width\n");
		}
	} elsif ($charheight == 32) {
		if (!($minwidth == 16 || $minwidth == 24 || $minwidth == 32)) {
			die ("Invalid width\n");
		}
	}

	$minwidth /= 8;
}

# Build an array of single digit hex character images
for ($count = 0; $count < 16; $count++) {
	$digit = new GD::Image (8, 16, 0);
	$black = $digit->colorAllocate ($black_red, $black_green, $black_blue);
	$white = $digit->colorAllocate ($white_red, $white_green, $white_blue);

	$digit->fill (0, 0, $white);

	$digit->string (gdLargeFont, 0, 0, sprintf ('%X', $count), $black);

	push (@digits, $digit);
}

$codepoint = 0;

# Get plane
for ($d = 0; $d < 2; $d++) {
	$c = new GD::Image (8, 16);
	$c->copy ($im, 0, 0, 24 + ($d * 8), 9, 8, 16);

	for ($count = 0; $count < 16; $count++) {
		if (!($c->compare ($digits[$count]) & GD_CMP_IMAGE)) {
			$codepoint = ($codepoint << 4) + $count;
		}
	}
}

# Get page
for ($d = 0; $d < 3; $d++) {
	$c = new GD::Image (8, 16);
	$c->copy ($im, 0, 0, (($boxsize - 24) / 2) + $gridxoffset + ($d * 8), 9, 8, 16);

	for ($count = 0; $count < 16; $count++) {
		if (!($c->compare ($digits[$count]) & GD_CMP_IMAGE)) {
			$codepoint = ($codepoint << 4) + $count;
		}
	}
}

# Calculate the first codepoint and it's display width
$codepoint = ($codepoint << 4);
$display_width = $codepoint > 0xFFFF ? 6 : 4;

if ($output) {
	open (HEXFILE, ">$output") or die ("Cannot save file\n");
} else {
	*HEXFILE = *STDOUT;
}
binmode HEXFILE;

for ($col = 0; $col < 16; $col++) {
	for ($row = 0; $row < 16; $row++) {
		# Calculate glyph width
		$charwidth = 0;

		for ($count = 0; $count < $charmaxwidth; $count++) {
			$c = new GD::Image (8, $charheight, 0);
			$c->copy ($im, 0, 0, ($col * $boxsize) + ($count * 8) + $gridxoffset + $charxoffset, ($row * $boxsize) + $gridyoffset + $charyoffset, 8, $charheight);

			if ($c->colorsTotal > 1 || $c->colorExact ($white_red, $white_green, $white_blue) == -1) {
				$charwidth = $count + 1
			}
		}

		# Force glyphs to minimum width if minwidth is set
		if ($charwidth < $minwidth) {
			$charwidth = $minwidth;
		}

		if ($charwidth != 0) {
			$char = sprintf ("%0*X:", $display_width, $codepoint);

			# Loop through the glyph and build up it's hex representation
			for ($j = 0; $j < $charheight; $j++) {
				$line = 0;

				for ($i = 0; $i < $charwidth * 8; $i++) {
					$bit = $im->getPixel (($col * $boxsize)+ $i + $gridxoffset + $charxoffset, ($row * $boxsize) + $j + $gridyoffset + $charyoffset) == $black ? 1 : 0;

					$line = ($line << 1) + $bit;
				}

				$char = $char . sprintf ("%0*X", $charwidth * 2, $line);
			}

			print HEXFILE "$char\n";
		}

		$codepoint += 1;
	}
}

# Only close HEXFILE if it isn't mapped to STDOUT.
if ($output) {
	close HEXFILE;
}