• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /** @file
2   Language settings
3 
4 Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution.  The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9 
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 
13 **/
14 
15 #include "Language.h"
16 #include "FrontPage.h"
17 
18 EFI_GUID  mFontPackageGuid = {
19   0x78941450, 0x90ab, 0x4fb1, {0xb7, 0x5f, 0x58, 0x92, 0x14, 0xe2, 0x4a, 0xc}
20 };
21 
22 #define NARROW_GLYPH_NUMBER 8
23 #define WIDE_GLYPH_NUMBER   75
24 
25 typedef struct {
26   ///
27   /// This 4-bytes total array length is required by HiiAddPackages()
28   ///
29   UINT32                 Length;
30 
31   //
32   // This is the Font package definition
33   //
34   EFI_HII_PACKAGE_HEADER Header;
35   UINT16                 NumberOfNarrowGlyphs;
36   UINT16                 NumberOfWideGlyphs;
37   EFI_NARROW_GLYPH       NarrowArray[NARROW_GLYPH_NUMBER];
38   EFI_WIDE_GLYPH         WideArray[WIDE_GLYPH_NUMBER];
39 } FONT_PACK_BIN;
40 
41 FONT_PACK_BIN mFontBin = {
42   sizeof (FONT_PACK_BIN),
43   {
44     sizeof (FONT_PACK_BIN) - sizeof (UINT32),
45     EFI_HII_PACKAGE_SIMPLE_FONTS,
46   },
47   NARROW_GLYPH_NUMBER,
48   0,
49   {     // Narrow Glyphs
50     {
51       0x05d0,
52       0x00,
53       {
54         0x00,
55         0x00,
56         0x00,
57         0x4E,
58         0x6E,
59         0x62,
60         0x32,
61         0x32,
62         0x3C,
63         0x68,
64         0x4C,
65         0x4C,
66         0x46,
67         0x76,
68         0x72,
69         0x00,
70         0x00,
71         0x00,
72         0x00
73       }
74     },
75     {
76       0x05d1,
77       0x00,
78       {
79         0x00,
80         0x00,
81         0x00,
82         0x78,
83         0x7C,
84         0x0C,
85         0x0C,
86         0x0C,
87         0x0C,
88         0x0C,
89         0x0C,
90         0x0C,
91         0x0C,
92         0x7E,
93         0x7E,
94         0x00,
95         0x00,
96         0x00,
97         0x00
98       }
99     },
100     {
101       0x05d2,
102       0x00,
103       {
104         0x00,
105         0x00,
106         0x00,
107         0x78,
108         0x7C,
109         0x0C,
110         0x0C,
111         0x0C,
112         0x0C,
113         0x0C,
114         0x0C,
115         0x1C,
116         0x3E,
117         0x66,
118         0x66,
119         0x00,
120         0x00,
121         0x00,
122         0x00
123       }
124     },
125     {
126       0x05d3,
127       0x00,
128       {
129         0x00,
130         0x00,
131         0x00,
132         0x7E,
133         0x7E,
134         0x0C,
135         0x0C,
136         0x0C,
137         0x0C,
138         0x0C,
139         0x0C,
140         0x0C,
141         0x0C,
142         0x0C,
143         0x0C,
144         0x00,
145         0x00,
146         0x00,
147         0x00
148       }
149     },
150     {
151       0x05d4,
152       0x00,
153       {
154         0x00,
155         0x00,
156         0x00,
157         0x7C,
158         0x7E,
159         0x06,
160         0x06,
161         0x06,
162         0x06,
163         0x66,
164         0x66,
165         0x66,
166         0x66,
167         0x66,
168         0x66,
169         0x00,
170         0x00,
171         0x00,
172         0x00
173       }
174     },
175     {
176       0x05d5,
177       0x00,
178       {
179         0x00,
180         0x00,
181         0x00,
182         0x3C,
183         0x3C,
184         0x0C,
185         0x0C,
186         0x0C,
187         0x0C,
188         0x0C,
189         0x0C,
190         0x0C,
191         0x0C,
192         0x0C,
193         0x0C,
194         0x00,
195         0x00,
196         0x00,
197         0x00
198       }
199     },
200     {
201       0x05d6,
202       0x00,
203       {
204         0x00,
205         0x00,
206         0x00,
207         0x38,
208         0x38,
209         0x1E,
210         0x1E,
211         0x18,
212         0x18,
213         0x18,
214         0x18,
215         0x18,
216         0x18,
217         0x18,
218         0x18,
219         0x00,
220         0x00,
221         0x00,
222         0x00
223       }
224     },
225     {
226       0x0000,
227       0x00,
228       {
229         0x00,
230         0x00,
231         0x00,
232         0x00,
233         0x00,
234         0x00,
235         0x00,
236         0x00,
237         0x00,
238         0x00,
239         0x00,
240         0x00,
241         0x00,
242         0x00,
243         0x00,
244         0x00,
245         0x00,
246         0x00,
247         0x00
248       }
249     }
250   }
251 };
252 
253 /**
254   Routine to export glyphs to the HII database.  This is in addition to whatever is defined in the Graphics Console driver.
255 
256 **/
257 EFI_HII_HANDLE
ExportFonts(VOID)258 ExportFonts (
259   VOID
260   )
261 {
262   return HiiAddPackages (
263            &mFontPackageGuid,
264            gImageHandle,
265            &mFontBin,
266            NULL
267            );
268 }
269 
270 /**
271   Get next language from language code list (with separator ';').
272 
273   If LangCode is NULL, then ASSERT.
274   If Lang is NULL, then ASSERT.
275 
276   @param  LangCode    On input: point to first language in the list. On
277                                  output: point to next language in the list, or
278                                  NULL if no more language in the list.
279   @param  Lang           The first language in the list.
280 
281 **/
282 VOID
283 EFIAPI
GetNextLanguage(IN OUT CHAR8 ** LangCode,OUT CHAR8 * Lang)284 GetNextLanguage (
285   IN OUT CHAR8      **LangCode,
286   OUT CHAR8         *Lang
287   )
288 {
289   UINTN  Index;
290   CHAR8  *StringPtr;
291 
292   ASSERT (LangCode != NULL);
293   ASSERT (*LangCode != NULL);
294   ASSERT (Lang != NULL);
295 
296   Index = 0;
297   StringPtr = *LangCode;
298   while (StringPtr[Index] != 0 && StringPtr[Index] != ';') {
299     Index++;
300   }
301 
302   CopyMem (Lang, StringPtr, Index);
303   Lang[Index] = 0;
304 
305   if (StringPtr[Index] == ';') {
306     Index++;
307   }
308   *LangCode = StringPtr + Index;
309 }