summaryrefslogtreecommitdiff
path: root/sys/dev/syscons/fonts/cursor.awk
blob: b4070ca06a891b80fdfebbb67cb49791ee61700b (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
#
# awk script to convert a bdf file to C declarations in a form specialized
# for the mouse cursors in syscons/scvgarndr.c.  Usage:
#     awk -f thisfile < file.bdf < file.c
# The accompanying syscons mouse cursor bdf file has specialized comments
# which this script converts to details in the C declarations.
# This is not a general conversion utility, but produces reasonable output
# if the input is for a monospaced font of size between 9x16 and 16x16.

/^COMMENT cn.*mouse/ {
	gsub("[(),]", "")
	i = index($3, "-")
	n = substr($3, 1, i - 1)
	name[n] = $4
	i = index($4, "e")
	j = index($4, "x")
	k = index($4, "_")
	width[n] = substr($4, i + 1, j - i - 1)
	height[n] = substr($4, j + 1, k - j - 1)
	baspect[n] = $6
	iaspect[n] = $8
}
state == 0 && /^STARTCHAR/ {
	n = substr($2, 5)
	printf("static const struct mousedata %s = { {\n\t", name[n])
	state = 1
}
state >= 1 && state < 7 || state >= 7 + 16 && state < 7 + 16 + 7 {
	state++
	next
}
state >= 7 && state < 7 + 16 || state >= 7 + 16 + 7 && state < 7 + 16 + 7 +16 {
	printf("0x%s,", $1)
	if (state == 7 + 7 || state == 7 + 16 + 7 + 7)
		printf("\n\t")
	else if (state == 7 + 15)
		printf(" }, {\n\t")
	else if (state == 7 + 16 + 7 + 15) {
		printf(" },\n\t%s, %s, %s, %s, \"%s\",",
		    width[n], height[n], baspect[n], iaspect[n], name[n])
		printf("\n};\n\n")
		state = -1
	} else
		printf(" ")
	state++
	next
}