void
wsfont_init(
void
)
int
wsfont_matches(
struct wsdisplay_font *font
, const char *name
, int width
, int height
, int stride
)
int
wsfont_find(
const char *name
, int width
, int height
, int stride
, int bitorder
, int byteorder
)
int
wsfont_add(
struct wsdisplay_font *font
, int copy
)
int
wsfont_remove(
int cookie
)
void
wsfont_enum(
void (*callback)(const char *, int, int, int)
)
int
wsfont_lock(
int cookie
, struct wsdisplay_font **ptr
)
int
wsfont_unlock(
int cookie
)
int
wsfont_getflg(
int cookie
, int *flg
, int *lc
)
int
wsfont_map_unichar(
struct wsdisplay_font *font
, int c
)
The primary data type for manipulating fonts is the
wsdisplay_font
structure in
dev/wscons/wsconsio.h
:
struct wsdisplay_font {
char *name; /* font name */
int firstchar;
int numchars; /* size of font table */
int encoding; /* font encoding
u_int fontwidth; /* character width */
u_int fontheight; /* character width */
u_int stride;
int bitorder;
int byteorder;
void *data; /* pointer to font table */
};
The maximum font table size is WSDISPLAY_MAXFONTSZ.
The wsfont framework supports fonts with the following encodings:
void
)
font
, name
, width
, height
, stride
)
font
with the specifications
name
,
width
,
height
and
stride
.
Return zero if not matched and non-zero if matched.
name
, width
, height
, stride
, bitorder
, byteorder
)
name
from the fonts loaded into the kernel.
The font aspect is specified by
width
,
height
,
and
stride
.
If
wsfont_find(
)
is called with any of the parameters as 0, it indicates that we don't
care about that aspect of the font.
If the font is found a (nonnegative-valued) cookie is returned which
can used with the other functions.
The
bitorder
and
byteorder
arguments are the bit order and byte order required.
Valid values are:
When more flexibility is required,
wsfont_enum()
should be used.
font
, copy
)
font
to the font list.
If the
copy
argument is non-zero, then the font is physically copied, otherwise a
reference to the original font is made.
cookie
)
cookie
from the font list.
The value of cookie was returned by
wsfont_add(
).
callback
)
callback
function argument is called with the arguments specifying the font
name, width, height and stride.
cookie
, ptr
)
cookie
so that it cannot be unloaded from the kernel while is being used.
If the bit or byte order of the font to be locked differs from what
has been requested with
wsfont_find(
)
then the glyph data will be modified to match.
At this point it may be necessary for
wsfont_lock(
)
to make a copy of the font data; this action is transparent to the caller.
A later call to
wsfont_unlock(
)
will free resources used by temporary copies.
The address of the wsdisplay_font pointer for the specified font is return in
the
ptr
argument.
wsfont_lock()
returns zero on success, or an error code on failure.
cookie
)
cookie
.
Returns zero on success, or an error code on failure.
font
, c
)
c
to glyph for font
font
.
Returns the glyph or success or -1 on error.
/usr/src
.
The wscons subsystem is implemented within the directory
sys/dev/wscons
.
The wsfont subsystem itself is implemented within the file
sys/dev/wsfont/wsfont.c
.