]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/sys/font.h
THIS BRANCH IS OBSOLETE, PLEASE READ:
[FreeBSD/FreeBSD.git] / sys / sys / font.h
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3  *
4  * Copyright (c) 2009, 2013 The FreeBSD Foundation
5  * All rights reserved.
6  *
7  * This software was developed by Ed Schouten under sponsorship from the
8  * FreeBSD Foundation.
9  *
10  * Portions of this software were developed by Oleksandr Rybalko
11  * under sponsorship from the FreeBSD Foundation.
12  *
13  * Redistribution and use in source and binary forms, with or without
14  * modification, are permitted provided that the following conditions
15  * are met:
16  * 1. Redistributions of source code must retain the above copyright
17  *    notice, this list of conditions and the following disclaimer.
18  * 2. Redistributions in binary form must reproduce the above copyright
19  *    notice, this list of conditions and the following disclaimer in the
20  *    documentation and/or other materials provided with the distribution.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32  * SUCH DAMAGE.
33  *
34  * $FreeBSD$
35  */
36
37 #ifndef _SYS_FONT_H_
38 #define _SYS_FONT_H_
39
40 #include <sys/queue.h>
41
42 /*
43  * Fonts.
44  *
45  * Remapping tables are used to map Unicode points to glyphs.  They need
46  * to be sorted, because vtfont_lookup() performs a binary search.  Each
47  * font has two remapping tables, for normal and bold.  When a character
48  * is not present in bold, it uses a normal glyph.  When no glyph is
49  * available, it uses glyph 0, which is normally equal to U+FFFD.
50  */
51
52 enum vfnt_map_type {
53         VFNT_MAP_NORMAL = 0,    /* Normal font. */
54         VFNT_MAP_NORMAL_RIGHT,  /* Normal font right hand. */
55         VFNT_MAP_BOLD,          /* Bold font. */
56         VFNT_MAP_BOLD_RIGHT,    /* Bold font right hand. */
57         VFNT_MAPS               /* Number of maps. */
58 };
59
60 struct font_info {
61         int32_t fi_checksum;
62         uint32_t fi_width;
63         uint32_t fi_height;
64         uint32_t fi_bitmap_size;
65         uint32_t fi_map_count[VFNT_MAPS];
66 };
67
68 struct vfnt_map {
69         uint32_t         vfm_src;
70         uint16_t         vfm_dst;
71         uint16_t         vfm_len;
72 } __packed;
73 typedef struct vfnt_map vfnt_map_t;
74
75 struct vt_font {
76         vfnt_map_t      *vf_map[VFNT_MAPS];
77         uint8_t         *vf_bytes;
78         uint32_t         vf_height;
79         uint32_t         vf_width;
80         uint32_t         vf_map_count[VFNT_MAPS];
81         uint32_t         vf_refcount;
82 };
83
84 typedef struct vt_font_bitmap_data {
85         uint32_t        vfbd_width;
86         uint32_t        vfbd_height;
87         uint32_t        vfbd_compressed_size;
88         uint32_t        vfbd_uncompressed_size;
89         uint8_t         *vfbd_compressed_data;
90         struct vt_font  *vfbd_font;
91 } vt_font_bitmap_data_t;
92
93 typedef enum {
94         FONT_AUTO,
95         FONT_MANUAL,
96         FONT_BOOT
97 } FONT_FLAGS;
98
99 struct fontlist {
100         char                    *font_name;
101         FONT_FLAGS              font_flags;
102         vt_font_bitmap_data_t   *font_data;
103         vt_font_bitmap_data_t   *(*font_load)(char *);
104         STAILQ_ENTRY(fontlist)  font_next;
105 };
106
107 #define BORDER_PIXELS   10      /* space from screen border */
108 typedef STAILQ_HEAD(font_list, fontlist) font_list_t;
109
110 #define FONT_HEADER_MAGIC       "VFNT0002"
111 struct font_header {
112         uint8_t         fh_magic[8];
113         uint8_t         fh_width;
114         uint8_t         fh_height;
115         uint16_t        fh_pad;
116         uint32_t        fh_glyph_count;
117         uint32_t        fh_map_count[VFNT_MAPS];
118 } __packed;
119
120 #endif /* !_SYS_FONT_H_ */