]> git.proxmox.com Git - grub2.git/blame - include/grub/font.h
Merge powerpc grub-mkrescue flavour with common. Use xorriso HFS+
[grub2.git] / include / grub / font.h
CommitLineData
18d9c7cd 1/*
4b13b216 2 * GRUB -- GRand Unified Bootloader
1e901a75 3 * Copyright (C) 2003,2007,2008,2009 Free Software Foundation, Inc.
18d9c7cd 4 *
5a79f472 5 * GRUB is free software: you can redistribute it and/or modify
18d9c7cd 6 * it under the terms of the GNU General Public License as published by
5a79f472 7 * the Free Software Foundation, either version 3 of the License, or
18d9c7cd 8 * (at your option) any later version.
9 *
5a79f472 10 * GRUB is distributed in the hope that it will be useful,
18d9c7cd 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
5a79f472 16 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
18d9c7cd 17 */
18
4b13b216 19#ifndef GRUB_FONT_HEADER
20#define GRUB_FONT_HEADER 1
18d9c7cd 21
4b13b216 22#include <grub/types.h>
1e901a75 23#include <grub/video.h>
a9b7a540 24#include <grub/file.h>
0a239a82 25#include <grub/unicode.h>
18d9c7cd 26
1e901a75 27/* Forward declaration of opaque structure grub_font.
28 Users only pass struct grub_font pointers to the font module functions,
29 and do not have knowledge of the structure contents. */
30struct grub_font;
31
32/* Font type used to access font functions. */
33typedef struct grub_font *grub_font_t;
34
35struct grub_font_node
36{
37 struct grub_font_node *next;
38 grub_font_t value;
39};
40
41/* Global font registry. */
42extern struct grub_font_node *grub_font_list;
18d9c7cd 43
bd0d7896 44struct grub_font_glyph
45{
1e901a75 46 /* Reference to the font this glyph belongs to. */
47 grub_font_t font;
48
49 /* Glyph bitmap width in pixels. */
50 grub_uint16_t width;
51
52 /* Glyph bitmap height in pixels. */
53 grub_uint16_t height;
54
55 /* Glyph bitmap x offset in pixels. Add to screen coordinate. */
56 grub_int16_t offset_x;
57
58 /* Glyph bitmap y offset in pixels. Subtract from screen coordinate. */
59 grub_int16_t offset_y;
60
61 /* Number of pixels to advance to start the next character. */
62 grub_uint16_t device_width;
63
64 /* Row-major order, packed bits (no padding; rows can break within a byte).
65 The length of the array is (width * height + 7) / 8. Within a
66 byte, the most significant bit is the first (leftmost/uppermost) pixel.
67 Pixels are coded as bits, value 1 meaning of opaque pixel and 0 is
68 transparent. If the length of the array does not fit byte boundary, it
69 will be padded with 0 bits to make it fit. */
70 grub_uint8_t bitmap[0];
bd0d7896 71};
72
e6d428c1
VS
73/* Part of code field which is really used as such. */
74#define GRUB_FONT_CODE_CHAR_MASK 0x001fffff
75#define GRUB_FONT_CODE_RIGHT_JOINED 0x80000000
76#define GRUB_FONT_CODE_LEFT_JOINED 0x40000000
77
1e901a75 78/* Initialize the font loader.
79 Must be called before any fonts are loaded or used. */
80void grub_font_loader_init (void);
81
82/* Load a font and add it to the beginning of the global font list.
83 Returns: 0 upon success; nonzero upon failure. */
a79b8a15 84grub_font_t grub_font_load (const char *filename);
1e901a75 85
86/* Get the font that has the specified name. Font names are in the form
87 "Family Name Bold Italic 14", where Bold and Italic are optional.
88 If no font matches the name specified, the most recently loaded font
89 is returned as a fallback. */
c140a180 90grub_font_t EXPORT_FUNC (grub_font_get) (const char *font_name);
1e901a75 91
c140a180 92const char *EXPORT_FUNC (grub_font_get_name) (grub_font_t font);
1e901a75 93
c140a180 94int EXPORT_FUNC (grub_font_get_max_char_width) (grub_font_t font);
1e901a75 95
c140a180 96int EXPORT_FUNC (grub_font_get_max_char_height) (grub_font_t font);
1e901a75 97
c140a180 98int EXPORT_FUNC (grub_font_get_ascent) (grub_font_t font);
1e901a75 99
c140a180 100int EXPORT_FUNC (grub_font_get_descent) (grub_font_t font);
1e901a75 101
c140a180 102int EXPORT_FUNC (grub_font_get_leading) (grub_font_t font);
1e901a75 103
c140a180 104int EXPORT_FUNC (grub_font_get_height) (grub_font_t font);
1e901a75 105
53f312c1 106int EXPORT_FUNC (grub_font_get_xheight) (grub_font_t font);
97ea65d4 107
c140a180
VS
108struct grub_font_glyph *EXPORT_FUNC (grub_font_get_glyph) (grub_font_t font,
109 grub_uint32_t code);
1e901a75 110
c140a180
VS
111struct grub_font_glyph *EXPORT_FUNC (grub_font_get_glyph_with_fallback) (grub_font_t font,
112 grub_uint32_t code);
1e901a75 113
c140a180
VS
114grub_err_t EXPORT_FUNC (grub_font_draw_glyph) (struct grub_font_glyph *glyph,
115 grub_video_color_t color,
116 int left_x, int baseline_y);
bd0d7896 117
0a239a82
VS
118int
119EXPORT_FUNC (grub_font_get_constructed_device_width) (grub_font_t hinted_font,
120 const struct grub_unicode_glyph *glyph_id);
121struct grub_font_glyph *
122EXPORT_FUNC (grub_font_construct_glyph) (grub_font_t hinted_font,
123 const struct grub_unicode_glyph *glyph_id);
124
4b13b216 125#endif /* ! GRUB_FONT_HEADER */