1use super::image::ImageOutput;
6use super::{HiiHandle, StringId};
7use crate::protocol::console::GraphicsOutputBltPixel;
8use crate::{Char8, Char16, Guid, Status, guid};
9
10pub type FontHandle = *mut core::ffi::c_void;
11
12#[derive(Debug)]
13#[repr(C)]
14pub struct HiiGlyphInfo {
15 pub width: u16,
16 pub height: u16,
17 pub offset_x: i16,
18 pub offset_y: i16,
19 pub advance_x: i16,
20}
21
22bitflags::bitflags! {
23 #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
25 #[repr(transparent)]
26 pub struct FontInfoMask: u32 {
27 const SYS_FONT = 1 << 0;
28 const SYS_SIZE = 1 << 1;
29 const SYS_STYLE = 1 << 2;
30 const SYS_FORE_COLOR = 1 << 4;
31 const SYS_BACK_COLOR = 1 << 5;
32 const RESIZE = 1 << 12;
33 const RESTYLE = 1 << 13;
34 const ANY_FONT = 1 << 16;
35 const ANY_SIZE = 1 << 17;
36 const ANY_STYLE = 1 << 18;
37 }
38}
39
40bitflags::bitflags! {
41 #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
43 #[repr(transparent)]
44 pub struct HiiFontStyle: u32 {
45 const BOLD = 1 << 0;
46 const ITALIC = 1 << 1;
47 const EMBOSS = 1 << 16;
48 const OUTLINE = 1 << 17;
49 const SHADOW = 1 << 18;
50 const UNDERLINE = 1 << 19;
51 const DBL_UNDER = 1 << 20;
52 }
53}
54
55impl HiiFontStyle {
56 pub const NORMAL: Self = Self::empty();
57}
58
59#[derive(Debug)]
61#[repr(C)]
62pub struct FontInfo {
63 pub font_style: HiiFontStyle,
64 pub font_size: u16,
65 pub font_name: [Char16; 0],
66}
67
68#[derive(Debug)]
70#[repr(C)]
71pub struct FontDisplayInfo {
72 pub foreground_color: GraphicsOutputBltPixel,
73 pub background_color: GraphicsOutputBltPixel,
74 pub font_mask_info: FontInfoMask,
75 pub font_info: FontInfo,
76}
77
78bitflags::bitflags! {
79 #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
81 #[repr(transparent)]
82 pub struct HiiOutFlags: u32 {
83 const CLIP = 1 << 0;
84 const WRAP = 1 << 1;
85 const CLIP_CLEAN_Y = 1 << 2;
86 const CLIP_CLEAN_X = 1 << 3;
87 const TRANSPARENT = 1 << 4;
88 const IGNORE_IF_NO_GLYPH = 1 << 5;
89 const IGNORE_LINE_BREAK = 1 << 6;
90 const DIRECT_TO_SCREEN = 1 << 7;
91 }
92}
93
94#[derive(Debug)]
96#[repr(C)]
97pub struct HiiRowInfo {
98 pub start_index: usize,
99 pub end_index: usize,
100 pub line_height: usize,
101 pub line_width: usize,
102 pub baseline_offset: usize,
103}
104
105#[derive(Debug)]
107#[repr(C)]
108pub struct HiiFontProtocol {
109 pub string_to_image: unsafe extern "efiapi" fn(
110 this: *const Self,
111 flags: HiiOutFlags,
112 string: *const Char16,
113 string_info: *const FontDisplayInfo,
114 blt: *mut *mut ImageOutput,
115 blt_x: usize,
116 blt_y: usize,
117 row_info_array: *mut *mut HiiRowInfo,
118 row_info_array_size: *mut usize,
119 column_info_array: *mut usize,
120 ) -> Status,
121 pub string_id_to_image: unsafe extern "efiapi" fn(
122 this: *const Self,
123 flags: HiiOutFlags,
124 package_list: HiiHandle,
125 string_id: StringId,
126 language: *const Char8,
127 string_info: *const FontDisplayInfo,
128 blt: *mut *mut ImageOutput,
129 blt_x: usize,
130 blt_y: usize,
131 row_info_array: *mut *mut HiiRowInfo,
132 row_info_array_size: *mut usize,
133 column_info_array: *mut usize,
134 ) -> Status,
135 pub get_glyph: unsafe extern "efiapi" fn(
136 this: *const Self,
137 char: Char16,
138 string_info: *const FontDisplayInfo,
139 blt: *mut *mut ImageOutput,
140 baseline: *mut usize,
141 ) -> Status,
142 pub get_font_info: unsafe extern "efiapi" fn(
143 this: *const Self,
144 font_handle: *mut FontHandle,
145 string_info_in: *const FontDisplayInfo,
146 string_info_out: *mut *mut FontDisplayInfo,
147 string: *const Char16,
148 ) -> Status,
149}
150
151impl HiiFontProtocol {
152 pub const GUID: Guid = guid!("e9ca4775-8657-47fc-97e7-7ed65a084324");
153}
154
155#[derive(Debug)]
158#[repr(C)]
159pub struct HiiFontExProtocol {
160 pub string_to_image_ex: unsafe extern "efiapi" fn(
161 this: *const Self,
162 flags: HiiOutFlags,
163 string: *const Char16,
164 string_info: *const FontDisplayInfo,
165 blt: *mut *mut ImageOutput,
166 blt_x: usize,
167 blt_y: usize,
168 row_info_array: *mut *mut HiiRowInfo,
169 row_info_array_size: *mut usize,
170 column_info_array: *mut usize,
171 ) -> Status,
172 pub string_id_to_image_ex: unsafe extern "efiapi" fn(
173 this: *const Self,
174 flags: HiiOutFlags,
175 package_list: HiiHandle,
176 string_id: StringId,
177 language: *const Char8,
178 string_info: *const FontDisplayInfo,
179 blt: *mut *mut ImageOutput,
180 blt_x: usize,
181 blt_y: usize,
182 row_info_array: *mut *mut HiiRowInfo,
183 row_info_array_size: *mut usize,
184 column_info_array: *mut usize,
185 ) -> Status,
186 pub get_glyph_ex: unsafe extern "efiapi" fn(
187 this: *const Self,
188 char: Char16,
189 string_info: *const FontDisplayInfo,
190 blt: *mut *mut ImageOutput,
191 baseline: *mut usize,
192 ) -> Status,
193 pub get_font_info_ex: unsafe extern "efiapi" fn(
194 this: *const Self,
195 font_handle: *mut FontHandle,
196 string_info_in: *const FontDisplayInfo,
197 string_info_out: *mut *mut FontDisplayInfo,
198 string: *const Char16,
199 ) -> Status,
200 pub get_glyph_info: unsafe extern "efiapi" fn(
201 this: *const Self,
202 char: Char16,
203 font_display_info: *const FontDisplayInfo,
204 glyph_info: *mut HiiGlyphInfo,
205 ) -> Status,
206}
207
208impl HiiFontExProtocol {
209 pub const GUID: Guid = guid!("849e6875-db35-4df8-b41e-c8f33718073f");
210}