freebsd-dev/sys/dev/syscons/fonts/cursor.awk
Bruce Evans aa24f48b36 Add files to help manage the (vga) syscons mouse cursor.
To mostly fix distortion of mouse cursors by non-square pixels, I
needed 8 variants of the same cursor shape for large fonts and
another 7 variants for small fonts.  Some variants are shared,
leaving only 13 variants in 26 glyphs altogether.  Keep these in
the BDF source file cursor.bdf.  cursor.bdf has another 5 unused
experimental cursors in 10 glyphs.  cursor.awk is a simple awk
script for converting this and similar bdf files into C declarations
for copying into scvgarndr.c.  syscons doesn't use any of this yet.
2017-07-08 15:01:55 +00:00

49 lines
1.4 KiB
Awk

# $FreeBSD$
#
# 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
}