]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFrameworkModulePkg/Universal/HiiDataBaseDxe/Fonts.c
Correct all header files for doxygen format and correct the license issue for VgaClas...
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / HiiDataBaseDxe / Fonts.c
CommitLineData
3db51098 1/**@file\r
2\r
3 This file contains the keyboard processing code to the HII database.\r
103b6520 4\r
ececc2eb 5Copyright (c) 2006, Intel Corporation\r
6All rights reserved. This program and the accompanying materials\r
7are licensed and made available under the terms and conditions of the BSD License\r
8which accompanies this distribution. The full text of the license may be found at\r
3db51098 9http://opensource.org/licenses/bsd-license.php\r
10\r
ececc2eb 11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
103b6520 13\r
3db51098 14**/\r
103b6520 15\r
16\r
103b6520 17#include "HiiDatabase.h"\r
18\r
19//\r
20// We only need to define a wide glyph, since we will seed the narrow glyph with EFI_NARROW_GLYPH size of\r
21// this data structure\r
22//\r
23UINT8 mUnknownGlyph[38] = {\r
24 0xaa,\r
25 0x55,\r
26 0xaa,\r
27 0x55,\r
28 0xaa,\r
29 0x55,\r
30 0xaa,\r
31 0x55,\r
32 0xaa,\r
33 0x55,\r
34 0xaa,\r
35 0x55,\r
36 0xaa,\r
37 0x55,\r
38 0xaa,\r
39 0x55,\r
40 0xaa,\r
41 0x55,\r
42 0xAA,\r
43 0xaa,\r
44 0x55,\r
45 0xaa,\r
46 0x55,\r
47 0xaa,\r
48 0x55,\r
49 0xaa,\r
50 0x55,\r
51 0xaa,\r
52 0x55,\r
53 0xaa,\r
54 0x55,\r
55 0xaa,\r
56 0x55,\r
57 0xaa,\r
58 0x55,\r
59 0xaa,\r
60 0x55,\r
61 0xAA\r
62};\r
63\r
64EFI_STATUS\r
65EFIAPI\r
66HiiGetGlyph (\r
67 IN EFI_HII_PROTOCOL *This,\r
68 IN CHAR16 *Source,\r
69 IN OUT UINT16 *Index,\r
70 OUT UINT8 **GlyphBuffer,\r
71 OUT UINT16 *BitWidth,\r
72 IN OUT UINT32 *InternalStatus\r
73 )\r
74/*++\r
75\r
76Routine Description:\r
ececc2eb 77 Translates a Unicode character into the corresponding font glyph.\r
103b6520 78 If the Source was pointing to a non-spacing character, the next Source[*Index]\r
79 character will be parsed and OR'd to the GlyphBuffer until a spacing character\r
80 is found in the Source. Since non-spacing characters are considered to be the\r
81 same pixel width as a regular character their BitWidth will be reflected correctly\r
82 however due to their special attribute, they are considered to be zero advancing width.\r
83 This basically means that the cursor would not advance, thus the character that follows\r
84 it would overlay the non-spacing character. The Index is modified to reflect both the\r
85 incoming array entry into the Source string but also the outgoing array entry after having\r
86 parsed the equivalent of a single Glyph's worth of data.\r
87\r
88Arguments:\r
89\r
ececc2eb 90Returns:\r
103b6520 91\r
92--*/\r
93{\r
94 EFI_HII_GLOBAL_DATA *GlobalData;\r
95 EFI_HII_DATA *HiiData;\r
96 UINTN Count;\r
97 BOOLEAN Narrow;\r
98 UINTN Location;\r
99 UINTN SearchLocation;\r
100 UINTN Value;\r
101 CHAR16 Character;\r
102 UINTN Attributes;\r
103\r
104 if (This == NULL) {\r
105 return EFI_INVALID_PARAMETER;\r
106 }\r
107\r
108 HiiData = EFI_HII_DATA_FROM_THIS (This);\r
109\r
110 GlobalData = HiiData->GlobalData;\r
111 Count = sizeof (GlobalData->NarrowGlyphs->GlyphCol1);\r
112\r
113 Location = *Index;\r
114 SearchLocation = *Index;\r
115 Narrow = TRUE;\r
116\r
117 if (Source[Location] == NARROW_CHAR || Source[Location] == WIDE_CHAR) {\r
118 *InternalStatus = 0;\r
119 }\r
120 //\r
121 // We don't know what glyph database to look in - let's figure it out\r
122 //\r
123 if (*InternalStatus == 0) {\r
124 //\r
125 // Determine if we are looking for narrow or wide glyph data\r
126 //\r
127 do {\r
128 if (Source[SearchLocation] == NARROW_CHAR || Source[SearchLocation] == WIDE_CHAR) {\r
129 //\r
130 // We found something that identifies what glyph database to look in\r
131 //\r
132 if (Source[SearchLocation] == WIDE_CHAR) {\r
133 Narrow = FALSE;\r
134 *BitWidth = WIDE_WIDTH;\r
135 *InternalStatus = WIDE_CHAR;\r
136 Location++;\r
137 break;\r
138 } else {\r
139 Narrow = TRUE;\r
140 *BitWidth = NARROW_WIDTH;\r
141 *InternalStatus = NARROW_CHAR;\r
142 Location++;\r
143 break;\r
144 }\r
145 }\r
146 } while (SearchLocation-- > 0);\r
147 }\r
148\r
149 if (*InternalStatus == NARROW_CHAR) {\r
150 Narrow = TRUE;\r
151 *BitWidth = NARROW_WIDTH;\r
152 } else if (*InternalStatus == WIDE_CHAR) {\r
153 Narrow = FALSE;\r
154 *BitWidth = WIDE_WIDTH;\r
155 } else {\r
156 //\r
157 // Without otherwise knowing what the width is narrow (e.g. someone passed in a string with index of 0\r
158 // we wouldn't be able to determine the width of the data.)\r
159 // BUGBUG - do we go to wide database and if exist, ignore narrow? Check Unicode spec....\r
160 //\r
161 Narrow = TRUE;\r
162 *BitWidth = NARROW_WIDTH;\r
163 }\r
164\r
165 Character = Source[Location];\r
166\r
167 if (Narrow) {\r
168 if (GlobalData->NarrowGlyphs[Character].UnicodeWeight != 0x0000) {\r
169 *GlyphBuffer = (UINT8 *) (&GlobalData->NarrowGlyphs[Character]);\r
170 Attributes = GlobalData->NarrowGlyphs[Character].Attributes & EFI_GLYPH_NON_SPACING;\r
171 } else {\r
172 //\r
173 // Glyph is uninitialized - return an error, but hand back the glyph\r
174 //\r
175 *GlyphBuffer = (UINT8 *) (&GlobalData->NarrowGlyphs[Character]);\r
176 *Index = (UINT16) (Location + 1);\r
177 return EFI_NOT_FOUND;\r
178 }\r
179 } else {\r
180 //\r
181 // Wide character\r
182 //\r
183 if (GlobalData->WideGlyphs[Character].UnicodeWeight != 0x0000) {\r
184 *GlyphBuffer = (UINT8 *) (&GlobalData->WideGlyphs[Character]);\r
185 Attributes = GlobalData->WideGlyphs[Character].Attributes & EFI_GLYPH_NON_SPACING;\r
186 } else {\r
187 //\r
188 // Glyph is uninitialized - return an error, but hand back the glyph\r
189 //\r
190 *GlyphBuffer = (UINT8 *) (&GlobalData->WideGlyphs[Character]);\r
191 *Index = (UINT16) (Location + 1);\r
192 return EFI_NOT_FOUND;\r
193 }\r
194 }\r
195 //\r
196 // This is a non-spacing character. It will be followed by either more non-spacing\r
197 // characters or a regular character. We need to OR together the data associated with each.\r
198 //\r
199 for (; Attributes != 0; Location++) {\r
200 //\r
201 // Character is the Unicode value which is the index into the Glyph array.\r
202 //\r
203 Character = Source[Location];\r
204\r
205 if (Narrow) {\r
206 for (Value = 0; Value != Count; Value++) {\r
207 *GlyphBuffer[Location + Value] = (UINT8) (*GlyphBuffer[Location + Value] |\r
208 GlobalData->NarrowGlyphs[Character].GlyphCol1[Value]);\r
209 }\r
210\r
211 Attributes = GlobalData->NarrowGlyphs[Character].Attributes & EFI_GLYPH_NON_SPACING;\r
212 } else {\r
213 for (Value = 0; Value != Count; Value++) {\r
ececc2eb 214 *GlyphBuffer[Location + Value] = (UINT8) (*GlyphBuffer[Location + Value] |\r
103b6520 215 GlobalData->WideGlyphs[Character].GlyphCol1[Value]);\r
216 *GlyphBuffer[Location + Value + Count] = (UINT8) (*GlyphBuffer[Location + Value + Count] |\r
217 GlobalData->WideGlyphs[Character].GlyphCol2[Value]);\r
218 }\r
219\r
220 Attributes = GlobalData->WideGlyphs[Character].Attributes & EFI_GLYPH_NON_SPACING;\r
221 }\r
222 }\r
223 //\r
224 // Source[*Index] should point to the next character to process\r
225 //\r
226 *Index = (UINT16) (Location + 1);\r
227 return EFI_SUCCESS;\r
228}\r
229\r
230EFI_STATUS\r
231EFIAPI\r
232HiiGlyphToBlt (\r
233 IN EFI_HII_PROTOCOL *This,\r
234 IN UINT8 *GlyphBuffer,\r
235 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground,\r
236 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background,\r
237 IN UINTN Count,\r
238 IN UINTN Width,\r
239 IN UINTN Height,\r
240 IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer\r
241 )\r
242{\r
243 UINTN X;\r
244 UINTN Y;\r
245\r
246 //\r
247 // Convert Monochrome bitmap of the Glyph to BltBuffer structure\r
248 //\r
249 for (Y = 0; Y < Height; Y++) {\r
250 for (X = 0; X < Width; X++) {\r
251 if ((((EFI_NARROW_GLYPH *) GlyphBuffer)->GlyphCol1[Y] & (1 << X)) != 0) {\r
252 BltBuffer[Y * Width * Count + (Width - X - 1)] = Foreground;\r
253 } else {\r
254 BltBuffer[Y * Width * Count + (Width - X - 1)] = Background;\r
255 }\r
256 }\r
257 }\r
258\r
259 return EFI_SUCCESS;\r
260}\r