xref: /freebsd/sys/dev/syscons/fonts/cursor.awk (revision a03411e84728e9b267056fd31c7d1d9d1dc1b01e)
1#
2# awk script to convert a bdf file to C declarations in a form specialized
3# for the mouse cursors in syscons/scvgarndr.c.  Usage:
4#     awk -f thisfile < file.bdf < file.c
5# The accompanying syscons mouse cursor bdf file has specialized comments
6# which this script converts to details in the C declarations.
7# This is not a general conversion utility, but produces reasonable output
8# if the input is for a monospaced font of size between 9x16 and 16x16.
9
10/^COMMENT cn.*mouse/ {
11	gsub("[(),]", "")
12	i = index($3, "-")
13	n = substr($3, 1, i - 1)
14	name[n] = $4
15	i = index($4, "e")
16	j = index($4, "x")
17	k = index($4, "_")
18	width[n] = substr($4, i + 1, j - i - 1)
19	height[n] = substr($4, j + 1, k - j - 1)
20	baspect[n] = $6
21	iaspect[n] = $8
22}
23state == 0 && /^STARTCHAR/ {
24	n = substr($2, 5)
25	printf("static const struct mousedata %s = { {\n\t", name[n])
26	state = 1
27}
28state >= 1 && state < 7 || state >= 7 + 16 && state < 7 + 16 + 7 {
29	state++
30	next
31}
32state >= 7 && state < 7 + 16 || state >= 7 + 16 + 7 && state < 7 + 16 + 7 +16 {
33	printf("0x%s,", $1)
34	if (state == 7 + 7 || state == 7 + 16 + 7 + 7)
35		printf("\n\t")
36	else if (state == 7 + 15)
37		printf(" }, {\n\t")
38	else if (state == 7 + 16 + 7 + 15) {
39		printf(" },\n\t%s, %s, %s, %s, \"%s\",",
40		    width[n], height[n], baspect[n], iaspect[n], name[n])
41		printf("\n};\n\n")
42		state = -1
43	} else
44		printf(" ")
45	state++
46	next
47}
48