aboutsummaryrefslogtreecommitdiff
path: root/findfont.pl
blob: ead5392692da15920c025526657f89703bc6770e (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
48
49
#!/usr/bin/perl -w

# we're looking for this:

# 00111000
# 01000100
# 10101000
# 10100000
# 10100000
# 01000100
# 00111000

#@want = (
#0b10101000,
#0b10100000,
#);

@want = (
0b00000101,
0b00000101,
);

#@want = (
#0b00111000,
#0b01000100,
#0b10101000,
#0b10100000,
#0b10100000,
#0b01000100,
#0b00111000,
#);

# or possibly a version of it shifted 1 or 2 bits to the right

undef $/;
$img = <>;
@bytes = map { ord($_) } split //, $img;
for($i = 0; $i < @bytes - 7; $i++) {
	my $found = 1;
	for($j = 0; $j < @want; $j++) {
		if($bytes[$i+$j] != $want[$j]) {
			$found = 0;
		}
	}
	if($found) {
		printf "offset: %x\n",  $i;
	}
}