GRUB-1.98 changes
[grub2/jjazz.git] / include / grub / font.h
blob7c5c1740386b5eaa3688bc0e717a53aea071e300
1 /*
2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 2003,2007,2008,2009 Free Software Foundation, Inc.
5 * GRUB is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * GRUB is distributed in the hope that it will be useful,
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.
15 * You should have received a copy of the GNU General Public License
16 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef GRUB_FONT_HEADER
20 #define GRUB_FONT_HEADER 1
22 #include <grub/types.h>
23 #include <grub/video.h>
24 #include <grub/file.h>
26 /* Forward declaration of opaque structure grub_font.
27 Users only pass struct grub_font pointers to the font module functions,
28 and do not have knowledge of the structure contents. */
29 struct grub_font;
31 /* Font type used to access font functions. */
32 typedef struct grub_font *grub_font_t;
34 struct grub_font_node
36 struct grub_font_node *next;
37 grub_font_t value;
40 /* Global font registry. */
41 extern struct grub_font_node *grub_font_list;
43 struct grub_font_glyph
45 /* Reference to the font this glyph belongs to. */
46 grub_font_t font;
48 /* Glyph bitmap width in pixels. */
49 grub_uint16_t width;
51 /* Glyph bitmap height in pixels. */
52 grub_uint16_t height;
54 /* Glyph bitmap x offset in pixels. Add to screen coordinate. */
55 grub_int16_t offset_x;
57 /* Glyph bitmap y offset in pixels. Subtract from screen coordinate. */
58 grub_int16_t offset_y;
60 /* Number of pixels to advance to start the next character. */
61 grub_uint16_t device_width;
63 /* Row-major order, packed bits (no padding; rows can break within a byte).
64 The length of the array is (width * height + 7) / 8. Within a
65 byte, the most significant bit is the first (leftmost/uppermost) pixel.
66 Pixels are coded as bits, value 1 meaning of opaque pixel and 0 is
67 transparent. If the length of the array does not fit byte boundary, it
68 will be padded with 0 bits to make it fit. */
69 grub_uint8_t bitmap[0];
72 /* Initialize the font loader.
73 Must be called before any fonts are loaded or used. */
74 void grub_font_loader_init (void);
76 /* Load a font and add it to the beginning of the global font list.
77 Returns: 0 upon success; nonzero upon failure. */
78 int grub_font_load (const char *filename);
80 /* Get the font that has the specified name. Font names are in the form
81 "Family Name Bold Italic 14", where Bold and Italic are optional.
82 If no font matches the name specified, the most recently loaded font
83 is returned as a fallback. */
84 grub_font_t EXPORT_FUNC (grub_font_get) (const char *font_name);
86 const char *EXPORT_FUNC (grub_font_get_name) (grub_font_t font);
88 int EXPORT_FUNC (grub_font_get_max_char_width) (grub_font_t font);
90 int EXPORT_FUNC (grub_font_get_max_char_height) (grub_font_t font);
92 int EXPORT_FUNC (grub_font_get_ascent) (grub_font_t font);
94 int EXPORT_FUNC (grub_font_get_descent) (grub_font_t font);
96 int EXPORT_FUNC (grub_font_get_leading) (grub_font_t font);
98 int EXPORT_FUNC (grub_font_get_height) (grub_font_t font);
100 int EXPORT_FUNC (grub_font_get_string_width) (grub_font_t font,
101 const char *str);
103 struct grub_font_glyph *EXPORT_FUNC (grub_font_get_glyph) (grub_font_t font,
104 grub_uint32_t code);
106 struct grub_font_glyph *EXPORT_FUNC (grub_font_get_glyph_with_fallback) (grub_font_t font,
107 grub_uint32_t code);
109 grub_err_t EXPORT_FUNC (grub_font_draw_glyph) (struct grub_font_glyph *glyph,
110 grub_video_color_t color,
111 int left_x, int baseline_y);
113 grub_err_t EXPORT_FUNC (grub_font_draw_string) (const char *str,
114 grub_font_t font,
115 grub_video_color_t color,
116 int left_x, int baseline_y);
118 #endif /* ! GRUB_FONT_HEADER */