2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2009, 2013 The FreeBSD Foundation
7 * This software was developed by Ed Schouten under sponsorship from the
10 * Portions of this software were developed by Oleksandr Rybalko
11 * under sponsorship from the FreeBSD Foundation.
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
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.
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
40 #include <sys/queue.h>
45 * Fonts support normal and bold weights, and single and double width glyphs.
46 * Mapping tables are used to map Unicode points to glyphs. They are sorted by
47 * code point, and vtfont_lookup() uses this to perform a binary search. Each
48 * font has four mapping tables: two weights times two halves (left/single,
49 * right). When a character is not present in a bold map the glyph from the
50 * normal map is used. When no glyph is available, it uses glyph 0, which is
51 * normally equal to U+FFFD.
55 VFNT_MAP_NORMAL = 0, /* Normal font. */
56 VFNT_MAP_NORMAL_RIGHT, /* Normal font right hand. */
57 VFNT_MAP_BOLD, /* Bold font. */
58 VFNT_MAP_BOLD_RIGHT, /* Bold font right hand. */
59 VFNT_MAPS /* Number of maps. */
66 uint32_t fi_bitmap_size;
67 uint32_t fi_map_count[VFNT_MAPS];
75 typedef struct vfnt_map vfnt_map_t;
78 vfnt_map_t *vf_map[VFNT_MAPS];
82 uint32_t vf_map_count[VFNT_MAPS];
86 typedef struct vt_font_bitmap_data {
89 uint32_t vfbd_compressed_size;
90 uint32_t vfbd_uncompressed_size;
91 uint8_t *vfbd_compressed_data;
92 struct vt_font *vfbd_font;
93 } vt_font_bitmap_data_t;
96 FONT_AUTO, /* This font is loaded by software */
97 FONT_MANUAL, /* This font is loaded manually by user */
98 FONT_BUILTIN, /* This font was built in at compile time */
99 FONT_RELOAD /* This font is marked to be re-read from file */
104 FONT_FLAGS font_flags;
105 vt_font_bitmap_data_t *font_data;
106 vt_font_bitmap_data_t *(*font_load)(char *);
107 STAILQ_ENTRY(fontlist) font_next;
110 typedef STAILQ_HEAD(font_list, fontlist) font_list_t;
112 #define FONT_HEADER_MAGIC "VFNT0002"
118 uint32_t fh_glyph_count;
119 uint32_t fh_map_count[VFNT_MAPS];
122 #endif /* !_SYS_FONT_H_ */