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