NetBSD/share/man/man9/wsfont.9

248 lines
7.4 KiB
Groff
Raw Normal View History

2002-10-14 17:43:14 +04:00
.\" $NetBSD: wsfont.9,v 1.7 2002/10/14 13:43:38 wiz Exp $
2001-10-22 07:29:58 +04:00
.\"
.\" Copyright (c) 2001 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to The NetBSD Foundation
.\" by Gregory McGarry.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the NetBSD
.\" Foundation, Inc. and its contributors.
.\" 4. Neither the name of The NetBSD Foundation nor the names of its
.\" contributors may be used to endorse or promote products derived
.\" from this software without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
2001-10-22 07:29:58 +04:00
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd October 7, 2001
.Dt WSFONT 9
.Os
.Sh NAME
.Nm wsfont ,
.Nm wsfont_init ,
.Nm wsfont_matches ,
.Nm wsfont_find ,
.Nm wsfont_add ,
.Nm wsfont_remove ,
.Nm wsfont_enum ,
.Nm wsfont_lock ,
.Nm wsfont_unlock ,
.Nm wsfont_getflg ,
2002-03-14 00:45:38 +03:00
.Nm wsfont_map_unichar
2001-10-22 07:29:58 +04:00
.Nd wscons font support
.Sh SYNOPSIS
.Fd #include \*[Lt]dev/wscons/wsconsio.h\*[Gt]
.Fd #include \*[Lt]dev/wsfont/wsfont.h\*[Gt]
2001-10-22 07:29:58 +04:00
.Ft void
.Fn wsfont_init "void"
.Ft int
.Fn wsfont_matches "struct wsdisplay_font *font" "char *name" \
"int width" "int height" "int stride"
.Ft int
2002-03-16 15:10:18 +03:00
.Fn wsfont_find "char *name" "int width" "int height" "int stride" \
"int bitorder" "int byteorder"
2001-10-22 07:29:58 +04:00
.Ft int
.Fn wsfont_add "struct wsdisplay_font *font" "int copy"
.Ft int
.Fn wsfont_remove "int cookie"
.Ft void
.Fn wsfont_enum "void (*callback)(char *, int, int, int)"
.Ft int
2002-03-16 15:10:18 +03:00
.Fn wsfont_lock "int cookie" "struct wsdisplay_font **ptr"
2001-10-22 07:29:58 +04:00
.Ft int
.Fn wsfont_unlock "int cookie"
.Ft int
.Fn wsfont_getflg "int cookie" "int *flg" "int *lc"
.Ft int
.Fn wsfont_map_unichar "struct wsdisplay_font *font" "int c"
.Sh DESCRIPTION
The
.Nm
module is a component of the
.Xr wscons 9
2002-10-14 17:43:14 +04:00
framework to provide access to display fonts.
Fonts may be loaded dynamically into the kernel or included statically
in the kernel at compile time.
Display drivers which emulate a glass-tty console on a bit-mapped
display can add, remove and find fonts for use by device-dependent
blitter operations.
2001-10-22 07:29:58 +04:00
.Pp
The primary data type for manipulating fonts is the
.Em wsdisplay_font
structure in
.Pa dev/wscons/wsconsio.h :
.Bd -literal
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 */
};
.Ed
.Pp
The maximum font table size is
.Em WSDISPLAY_MAXFONTSZ .
.Pp
The
.Nm
framework supports fonts with the following encodings:
.Bl -tag -width compact
.It WSDISPLAY_FONTENC_ISO
ISO-encoded fonts.
.It WSDISPLAY_FONTENC_IBM
IBM-encoded fonts commonly available for IBM CGA, EGA and VGA display
adapters.
.It WSDISPLAY_FONTENC_PCVT
PCVT-encoding fonts distributed as part of the old PCVT terminal
emulation driver.
.It WSDISPLAY_FONTENC_ISO7
ISO-encoded Greek fonts.
.It WSDISPLAY_FONTENC_ISO2
ISO-encoded East European fonts.
.El
.Sh FUNCTIONS
.Bl -tag -width compact
.It Fn wsfont_init "void"
Initialise the font list with the built-in fonts.
.It Fn wsfont_matches "font" "name" "width" "height" "stride"
Matches the font
.Fa font
with the specifications
.Fa name ,
.Fa width ,
.Fa height
and
.Fa stride .
Return zero if not matched and non-zero if matched.
2002-03-16 15:10:18 +03:00
.It Fn wsfont_find "name" "width" "height" "stride" "bitorder" "byteorder"
2001-10-22 07:29:58 +04:00
Find the font called
.Fa name
2002-10-14 17:43:14 +04:00
from the fonts loaded into the kernel.
The font aspect is specified by
2001-10-22 07:29:58 +04:00
.Fa width ,
.Fa height ,
2002-01-21 20:39:18 +03:00
and
2001-10-22 07:29:58 +04:00
.Fa stride .
If
.Fn wsfont_find
is called with any of the parameters as 0, it indicates that we don't
2002-10-14 17:43:14 +04:00
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.
2001-10-22 07:29:58 +04:00
.Pp
2002-03-16 15:10:18 +03:00
The
.Fa bitorder
and
.Fa byteorder
2002-10-14 17:43:14 +04:00
arguments are the bit order and byte order required.
Valid values are:
2002-03-16 15:10:18 +03:00
.Bl -tag -width compact
.It WSDISPLAY_FONTORDER_KNOWN
The font is in known ordered format and doesn't need converting.
.It WSDISPLAY_FONTORDER_L2R
The font is ordered left to right.
.It WSDISPLAY_FONTORDER_R2L
The font is ordered right to left.
.El
.Pp
2001-10-22 07:29:58 +04:00
When more flexibility is required,
.Fn wsfont_enum
should be used.
.It Fn wsfont_add "font" "copy"
Add a font
.Fa font
to the font list.
If the
2001-10-22 07:29:58 +04:00
.Fa copy
argument is non-zero, then the font is physically copied, otherwise a
reference to the original font is made.
.It Fn wsfont_remove "cookie"
Remove the font specified by
.Fa cookie
from the font list.
The value of cookie was returned by
.Fn wsfont_add .
.It Fn wsfont_enum "callback"
2002-10-14 17:43:14 +04:00
Enumerate the list of fonts.
For each font in the font list, the
2001-10-22 07:29:58 +04:00
.Fa callback
function argument is called with the arguments specifying the font
name, width, height and stride.
2002-03-16 15:10:18 +03:00
.It Fn wsfont_lock "cookie" "ptr"
2001-10-22 07:29:58 +04:00
Lock access to the font specified by
.Fa cookie
so that it cannot be unloaded from the kernel while is being used.
2002-03-16 15:10:18 +03:00
If the bit or byte order of the font to be locked differs from what
has been requested with
.Fn wsfont_find
2002-10-14 17:43:14 +04:00
then the glyph data will be modified to match.
At this point it may be necessary for
2002-03-16 15:10:18 +03:00
.Fn wsfont_lock
to make a copy of the font data; this action is transparent to the caller.
A later call to
.Fn wsfont_unlock
will free resources used by temporary copies.
.Pp
The address of the wsdisplay_font pointer for the specified font is return in
the
2001-10-22 07:29:58 +04:00
.Fa ptr
2002-03-16 15:10:18 +03:00
argument.
2001-10-22 07:29:58 +04:00
.Pp
.Fn wsfont_lock
2002-03-16 15:10:18 +03:00
returns zero on success, or an error code on failure.
2001-10-22 07:29:58 +04:00
.It Fn wsfont_unlock "cookie"
Unlock the font specified by
.Fa cookie .
2002-03-16 15:10:18 +03:00
Returns zero on succss, or an error code on failure.
2001-10-22 07:29:58 +04:00
.It Fn wsfont_map_unichar "font" "c"
Remap the unicode character
.Fa c
to glyph for font
.Fa font .
Returns the glyph or success or -1 on error.
.El
.Sh CODE REFERENCES
This section describes places within the
.Nx
source tree where actual code implementing or utilising the
2002-10-14 17:43:14 +04:00
machine-independent wsfont subsystem can be found.
All pathnames are relative to
.Pa /usr/src .
2001-10-22 07:29:58 +04:00
.Pp
The wscons subsystem is implemented within the directory
.Pa sys/dev/wscons .
The wsfont subsystem itself is implemented within the file
.Pa sys/dev/wsfont/wsfont.c .
.Sh SEE ALSO
.Xr autoconf 9 ,
.Xr driver 9 ,
.Xr intro 9 ,
.Xr wscons 9 ,
.Xr wsdisplay 9