xref: /openbsd-src/share/man/man9/wsfont_init.9 (revision 2fb8e6d071c124f7208b9b69cacbc40065c9f136)
1*2fb8e6d0Sschwarze.\"	$OpenBSD: wsfont_init.9,v 1.2 2019/05/10 17:24:53 schwarze Exp $
224a0573aSfcambus.\"     $NetBSD: wsfont.9,v 1.18 2012/01/13 23:09:51 wiz Exp $
324a0573aSfcambus.\"
424a0573aSfcambus.\" Copyright (c) 2001 The NetBSD Foundation, Inc.
524a0573aSfcambus.\" All rights reserved.
624a0573aSfcambus.\"
724a0573aSfcambus.\" This code is derived from software contributed to The NetBSD Foundation
824a0573aSfcambus.\" by Gregory McGarry.
924a0573aSfcambus.\"
1024a0573aSfcambus.\" Redistribution and use in source and binary forms, with or without
1124a0573aSfcambus.\" modification, are permitted provided that the following conditions
1224a0573aSfcambus.\" are met:
1324a0573aSfcambus.\" 1. Redistributions of source code must retain the above copyright
1424a0573aSfcambus.\"    notice, this list of conditions and the following disclaimer.
1524a0573aSfcambus.\" 2. Redistributions in binary form must reproduce the above copyright
1624a0573aSfcambus.\"    notice, this list of conditions and the following disclaimer in the
1724a0573aSfcambus.\"    documentation and/or other materials provided with the distribution.
1824a0573aSfcambus.\"
1924a0573aSfcambus.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
2024a0573aSfcambus.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2124a0573aSfcambus.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2224a0573aSfcambus.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
2324a0573aSfcambus.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2424a0573aSfcambus.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2524a0573aSfcambus.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2624a0573aSfcambus.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2724a0573aSfcambus.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2824a0573aSfcambus.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2924a0573aSfcambus.\" POSSIBILITY OF SUCH DAMAGE.
3024a0573aSfcambus.\"
3124a0573aSfcambus.Dd $Mdocdate: May 10 2019 $
3224a0573aSfcambus.Dt WSFONT_INIT 9
3324a0573aSfcambus.Os
3424a0573aSfcambus.Sh NAME
3524a0573aSfcambus.Nm wsfont_init ,
3624a0573aSfcambus.Nm wsfont_find ,
3724a0573aSfcambus.Nm wsfont_add ,
3824a0573aSfcambus.Nm wsfont_remove ,
3924a0573aSfcambus.Nm wsfont_enum ,
4024a0573aSfcambus.Nm wsfont_lock ,
4124a0573aSfcambus.Nm wsfont_unlock ,
4224a0573aSfcambus.Nm wsfont_map_unichar
4324a0573aSfcambus.Nd wscons font support
4424a0573aSfcambus.Sh SYNOPSIS
4524a0573aSfcambus.In dev/wscons/wsconsio.h
4624a0573aSfcambus.In dev/wsfont/wsfont.h
4724a0573aSfcambus.Ft void
4824a0573aSfcambus.Fn wsfont_init "void"
4924a0573aSfcambus.Ft int
5024a0573aSfcambus.Fn wsfont_find "const char *name" "int width" "int height" "int stride"
5124a0573aSfcambus.Ft int
5224a0573aSfcambus.Fn wsfont_add "struct wsdisplay_font *font" "int copy"
5324a0573aSfcambus.Ft int
5424a0573aSfcambus.Fn wsfont_remove "int cookie"
5524a0573aSfcambus.Ft void
5624a0573aSfcambus.Fn wsfont_enum "int (*cb)(void *, struct wsdisplay_font *)" "void *cbarg"
5724a0573aSfcambus.Ft int
5824a0573aSfcambus.Fn wsfont_lock "int cookie" "struct wsdisplay_font **ptr" "int bitorder" \
5924a0573aSfcambus"int byteorder"
6024a0573aSfcambus.Ft int
6124a0573aSfcambus.Fn wsfont_unlock "int cookie"
6224a0573aSfcambus.Ft int
6324a0573aSfcambus.Fn wsfont_map_unichar "struct wsdisplay_font *font" "int c"
6424a0573aSfcambus.Sh DESCRIPTION
6524a0573aSfcambusThe wsfont module is a component of the wscons
6624a0573aSfcambus.\" .Xr wscons 9
6724a0573aSfcambusframework to provide access to display fonts.
6824a0573aSfcambusFonts may be loaded dynamically into the kernel or included statically
6924a0573aSfcambusin the kernel at compile time.
7024a0573aSfcambusDisplay drivers which emulate a glass-tty console on a bit-mapped
7124a0573aSfcambusdisplay can add, remove and find fonts for use by device-dependent
7224a0573aSfcambusblitter operations.
7324a0573aSfcambus.Pp
7424a0573aSfcambusThe primary data type for manipulating fonts is the
75*2fb8e6d0Sschwarze.Vt wsdisplay_font
7624a0573aSfcambusstructure in
77*2fb8e6d0Sschwarze.In dev/wscons/wsconsio.h :
7824a0573aSfcambus.Bd -literal
7924a0573aSfcambusstruct wsdisplay_font {
8024a0573aSfcambus	char name[WSFONT_NAME_SIZE];	/* font name */
8124a0573aSfcambus	int index;
8224a0573aSfcambus	int firstchar;
8324a0573aSfcambus	int numchars;			/* size of font table */
8424a0573aSfcambus	int encoding;			/* font encoding */
8524a0573aSfcambus	u_int fontwidth;		/* character width */
8624a0573aSfcambus	u_int fontheight;		/* character height */
8724a0573aSfcambus	u_int stride;
8824a0573aSfcambus	int bitorder;
8924a0573aSfcambus	int byteorder;
9024a0573aSfcambus	void *cookie;
9124a0573aSfcambus	void *data;			/* pointer to font table */
9224a0573aSfcambus};
9324a0573aSfcambus.Ed
9424a0573aSfcambus.Pp
9524a0573aSfcambusThe maximum font table size is
96*2fb8e6d0Sschwarze.Dv WSDISPLAY_MAXFONTSZ .
9724a0573aSfcambus.Pp
9824a0573aSfcambusThe wsfont framework supports fonts with the following encodings:
9924a0573aSfcambus.Bl -tag -width compact
10024a0573aSfcambus.It Dv WSDISPLAY_FONTENC_ISO
10124a0573aSfcambusISO-encoded fonts.
10224a0573aSfcambus.It Dv WSDISPLAY_FONTENC_IBM
10324a0573aSfcambusIBM-encoded fonts commonly available for IBM CGA, EGA and VGA display
10424a0573aSfcambusadapters.
10524a0573aSfcambus.El
10624a0573aSfcambus.Sh FUNCTIONS
10724a0573aSfcambus.Bl -tag -width compact
10824a0573aSfcambus.It Fn wsfont_init "void"
10924a0573aSfcambusInitialise the font list with the built-in fonts.
11024a0573aSfcambus.It Fn wsfont_find "name" "width" "height" "stride"
11124a0573aSfcambusFind the font called
11224a0573aSfcambus.Fa name
11324a0573aSfcambusfrom the fonts loaded into the kernel.
11424a0573aSfcambusThe font aspect is specified by
11524a0573aSfcambus.Fa width ,
11624a0573aSfcambus.Fa height ,
11724a0573aSfcambusand
11824a0573aSfcambus.Fa stride .
11924a0573aSfcambusIf
12024a0573aSfcambus.Fn wsfont_find
12124a0573aSfcambusis called with any of the parameters as 0, it indicates that we don't
12224a0573aSfcambuscare about that aspect of the font.
12324a0573aSfcambusIf the font is found, a (nonnegative-valued) cookie is returned which
12424a0573aSfcambuscan be used with the other functions.
12524a0573aSfcambus.Pp
12624a0573aSfcambusWhen more flexibility is required,
12724a0573aSfcambus.Fn wsfont_enum
12824a0573aSfcambusshould be used.
12924a0573aSfcambus.It Fn wsfont_add "font" "copy"
13024a0573aSfcambusAdd a font
13124a0573aSfcambus.Fa font
13224a0573aSfcambusto the font list.
13324a0573aSfcambusIf the
13424a0573aSfcambus.Fa copy
13524a0573aSfcambusargument is non-zero, then the font is physically copied, otherwise a
13624a0573aSfcambusreference to the original font is made.
13724a0573aSfcambus.It Fn wsfont_remove "cookie"
13824a0573aSfcambusRemove the font specified by
13924a0573aSfcambus.Fa cookie
14024a0573aSfcambusfrom the font list.
14124a0573aSfcambusThe value of cookie was returned by
14224a0573aSfcambus.Fn wsfont_add .
14324a0573aSfcambus.It Fn wsfont_enum "callback" "cbarg"
14424a0573aSfcambusEnumerate the list of fonts.
14524a0573aSfcambusFor each font in the font list, the
14624a0573aSfcambus.Fa callback
14724a0573aSfcambusfunction argument is called with the
14824a0573aSfcambus.Fa cbarg
14924a0573aSfcambusargument.
15024a0573aSfcambus.It Fn wsfont_lock "cookie" "ptr" "bitorder" "byteorder"
15124a0573aSfcambusLock access to the font specified by
15224a0573aSfcambus.Fa cookie
15324a0573aSfcambusso that it cannot be unloaded from the kernel while it is being used.
15424a0573aSfcambusIf the bit or byte order of the font to be locked differs from what
15524a0573aSfcambushas been requested via the
15624a0573aSfcambus.Fa bitorder
15724a0573aSfcambusand
15824a0573aSfcambus.Fa byteorder
15924a0573aSfcambusarguments, then the glyph data will be modified to match.
16024a0573aSfcambus.Pp
161*2fb8e6d0SschwarzeThe address of the
162*2fb8e6d0Sschwarze.Vt wsdisplay_font
163*2fb8e6d0Sschwarzepointer for the specified font is returned in
16424a0573aSfcambusthe
16524a0573aSfcambus.Fa ptr
16624a0573aSfcambusargument.
16724a0573aSfcambus.Pp
16824a0573aSfcambus.Fn wsfont_lock
16924a0573aSfcambusreturns lockcount on success, or an error code on failure.
17024a0573aSfcambus.It Fn wsfont_unlock "cookie"
17124a0573aSfcambusUnlock the font specified by
17224a0573aSfcambus.Fa cookie .
17324a0573aSfcambusReturns lockcount on success, or an error code on failure.
17424a0573aSfcambus.It Fn wsfont_map_unichar "font" "c"
17524a0573aSfcambusRemap the unicode character
17624a0573aSfcambus.Fa c
17724a0573aSfcambusto glyph for font
17824a0573aSfcambus.Fa font .
17924a0573aSfcambusReturns the glyph on success or \-1 on error.
18024a0573aSfcambus.El
18124a0573aSfcambus.Sh CODE REFERENCES
18224a0573aSfcambusThe wscons subsystem is implemented within the directory
18324a0573aSfcambus.Pa sys/dev/wscons .
18424a0573aSfcambusThe wsfont subsystem itself is implemented within the file
18524a0573aSfcambus.Pa sys/dev/wsfont/wsfont.c .
18624a0573aSfcambus.Sh SEE ALSO
18724a0573aSfcambus.Xr wsfontload 8 ,
18824a0573aSfcambus.Xr intro 9
189