source: grub-pc/trunk/fuentes/include/grub/font.h @ 22

Last change on this file since 22 was 22, checked in by mabarracus, 4 years ago

updated version and apply net.ifnames=0 into debian/rules

File size: 4.8 KB
Line 
1/*
2 *  GRUB  --  GRand Unified Bootloader
3 *  Copyright (C) 2003,2007,2008,2009  Free Software Foundation, Inc.
4 *
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.
9 *
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.
14 *
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/>.
17 */
18
19#ifndef GRUB_FONT_HEADER
20#define GRUB_FONT_HEADER        1
21
22#include <grub/types.h>
23#include <grub/video.h>
24#include <grub/file.h>
25#include <grub/unicode.h>
26
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.  */
30/* Full structure was moved here for inline function but still
31   shouldn't be used directly.
32 */
33struct grub_font
34{
35  char *name;
36  grub_file_t file;
37  char *family;
38  short point_size;
39  short weight;
40  short max_char_width;
41  short max_char_height;
42  short ascent;
43  short descent;
44  short leading;
45  grub_uint32_t num_chars;
46  struct char_index_entry *char_index;
47  grub_uint16_t *bmp_idx;
48};
49
50/* Font type used to access font functions.  */
51typedef struct grub_font *grub_font_t;
52
53struct grub_font_node
54{
55  struct grub_font_node *next;
56  grub_font_t value;
57};
58
59/* Global font registry.  */
60extern struct grub_font_node *grub_font_list;
61
62struct grub_font_glyph
63{
64  /* Reference to the font this glyph belongs to.  */
65  grub_font_t font;
66
67  /* Glyph bitmap width in pixels.  */
68  grub_uint16_t width;
69
70  /* Glyph bitmap height in pixels.  */
71  grub_uint16_t height;
72
73  /* Glyph bitmap x offset in pixels.  Add to screen coordinate.  */
74  grub_int16_t offset_x;
75
76  /* Glyph bitmap y offset in pixels.  Subtract from screen coordinate.  */
77  grub_int16_t offset_y;
78
79  /* Number of pixels to advance to start the next character.  */
80  grub_uint16_t device_width;
81
82  /* Row-major order, packed bits (no padding; rows can break within a byte).
83     The length of the array is (width * height + 7) / 8.  Within a
84     byte, the most significant bit is the first (leftmost/uppermost) pixel.
85     Pixels are coded as bits, value 1 meaning of opaque pixel and 0 is
86     transparent.  If the length of the array does not fit byte boundary, it
87     will be padded with 0 bits to make it fit.  */
88  grub_uint8_t bitmap[0];
89};
90
91/* Part of code field which is really used as such.  */
92#define GRUB_FONT_CODE_CHAR_MASK     0x001fffff
93#define GRUB_FONT_CODE_RIGHT_JOINED  0x80000000
94#define GRUB_FONT_CODE_LEFT_JOINED   0x40000000
95
96/* Initialize the font loader.
97   Must be called before any fonts are loaded or used.  */
98void grub_font_loader_init (void);
99
100/* Load a font and add it to the beginning of the global font list.
101   Returns: 0 upon success; nonzero upon failure.  */
102grub_font_t EXPORT_FUNC(grub_font_load) (const char *filename);
103
104/* Get the font that has the specified name.  Font names are in the form
105   "Family Name Bold Italic 14", where Bold and Italic are optional.
106   If no font matches the name specified, the most recently loaded font
107   is returned as a fallback.  */
108grub_font_t EXPORT_FUNC (grub_font_get) (const char *font_name);
109
110const char *EXPORT_FUNC (grub_font_get_name) (grub_font_t font);
111
112int EXPORT_FUNC (grub_font_get_max_char_width) (grub_font_t font);
113
114/* Get the maximum height of any character in the font in pixels.  */
115static inline int
116grub_font_get_max_char_height (grub_font_t font)
117{
118  return font->max_char_height;
119}
120
121/* Get the distance in pixels from the top of characters to the baseline.  */
122static inline int
123grub_font_get_ascent (grub_font_t font)
124{
125  return font->ascent;
126}
127
128int EXPORT_FUNC (grub_font_get_descent) (grub_font_t font);
129
130int EXPORT_FUNC (grub_font_get_leading) (grub_font_t font);
131
132int EXPORT_FUNC (grub_font_get_height) (grub_font_t font);
133
134int EXPORT_FUNC (grub_font_get_xheight) (grub_font_t font);
135
136struct grub_font_glyph *EXPORT_FUNC (grub_font_get_glyph) (grub_font_t font,
137                                                           grub_uint32_t code);
138
139struct grub_font_glyph *EXPORT_FUNC (grub_font_get_glyph_with_fallback) (grub_font_t font,
140                                                                         grub_uint32_t code);
141
142grub_err_t EXPORT_FUNC (grub_font_draw_glyph) (struct grub_font_glyph *glyph,
143                                               grub_video_color_t color,
144                                               int left_x, int baseline_y);
145
146int
147EXPORT_FUNC (grub_font_get_constructed_device_width) (grub_font_t hinted_font,
148                                        const struct grub_unicode_glyph *glyph_id);
149struct grub_font_glyph *
150EXPORT_FUNC (grub_font_construct_glyph) (grub_font_t hinted_font,
151                           const struct grub_unicode_glyph *glyph_id);
152
153#endif /* ! GRUB_FONT_HEADER */
Note: See TracBrowser for help on using the repository browser.