ReactOS 0.4.15-dev-7942-gd23573b
font.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING.ARM in the top level directory
3 * PROJECT: ReactOS UEFI Boot Library
4 * FILE: boot/environ/lib/misc/font.c
5 * PURPOSE: Boot Library Font Functions
6 * PROGRAMMER: Alex Ionescu (alex.ionescu@reactos.org)
7 */
8
9/* INCLUDES ******************************************************************/
10
11#include "bl.h"
12
13/* DATA VARIABLES ************************************************************/
14
16
17/* FUNCTIONS *****************************************************************/
18
21 _In_ PBL_DEVICE_DESCRIPTOR FontDevice,
22 _In_ PWCHAR FontPath
23 )
24{
25 EfiPrintf(L"Cannot load font %s, no font loader exists\r\n", FontPath);
27}
28
29VOID
31 _In_ PBL_DEFERRED_FONT_FILE DeferredFontFile
32 )
33{
34 /* Free the device copy if there was one */
35 if (DeferredFontFile->Device)
36 {
37 BlMmFreeHeap(DeferredFontFile->Device);
38 }
39
40 /* Free the path copy if there was one */
41 if (DeferredFontFile->FontPath)
42 {
43 BlMmFreeHeap(DeferredFontFile->FontPath);
44 }
45
46 /* Free the whole thing */
47 BlMmFreeHeap(DeferredFontFile);
48}
49
53 _In_ PWCHAR FontPath
54 )
55{
56 PBL_DEFERRED_FONT_FILE DeferredFont;
57 SIZE_T FontPathSize;
58
59 /* Allocate the deferred font structure */
60 DeferredFont = (PBL_DEFERRED_FONT_FILE)BlMmAllocateHeap(sizeof(*DeferredFont));
61 if (!DeferredFont)
62 {
63 return STATUS_NO_MEMORY;
64 }
65
66 /* Zero it out */
67 RtlZeroMemory(DeferredFont, sizeof(*DeferredFont));
68
69 /* Allocate a copy for the file path */
70 FontPathSize = sizeof(WCHAR) * wcslen(FontPath) + sizeof(UNICODE_NULL);
71 DeferredFont->FontPath = (PWCHAR)BlMmAllocateHeap(FontPathSize);
72 if (!DeferredFont->FontPath)
73 {
74 BfiFreeDeferredFontFile(DeferredFont);
75 return STATUS_NO_MEMORY;
76 }
77
78 /* Allocate a copy for the device */
79 DeferredFont->Device = BlMmAllocateHeap(Device->Size);
80 if (!DeferredFont->Device)
81 {
82 BfiFreeDeferredFontFile(DeferredFont);
83 return STATUS_NO_MEMORY;
84 }
85
86 /* Copy the path and device */
87 RtlCopyMemory(DeferredFont->FontPath, FontPath, FontPathSize);
88 RtlCopyMemory(DeferredFont->Device,Device, Device->Size);
89
90 /* Set pending flag? */
91 DeferredFont->Flags = 1;
92
93 /* Insert it into the list */
95 return STATUS_SUCCESS;
96}
97
100 VOID
101 )
102{
103 PLIST_ENTRY NextEntry;
104 PBL_DEFERRED_FONT_FILE DeferredFont;
105 NTSTATUS Status, LoadStatus;
106
107 /* Assume empty list */
109
110 /* Parse the list */
111 NextEntry = BfiDeferredListHead.Flink;
112 while (NextEntry != &BfiDeferredListHead)
113 {
114 /* Get the font */
115 DeferredFont = CONTAINING_RECORD(NextEntry, BL_DEFERRED_FONT_FILE, ListEntry);
116
117 /* Move to the next entry and remove this one */
118 NextEntry = NextEntry->Flink;
119 RemoveEntryList(&DeferredFont->ListEntry);
120
121 /* Load the font */
122 LoadStatus = BfiLoadFontFile(DeferredFont->Device,
123 DeferredFont->FontPath);
124 if (!NT_SUCCESS(LoadStatus))
125 {
126 /* Remember the load failure if there was one */
127 Status = LoadStatus;
128 }
129
130 /* Free the deferred font */
131 BfiFreeDeferredFontFile(DeferredFont);
132 }
133
134 /* Return load status */
135 return Status;
136}
137
141 _In_ BOOLEAN Visible
142 )
143{
144 /* not implemented */
146}
147
151 )
152{
153 /* not implemented */
155}
156
160 )
161{
163
164 /* Reset the cursor position */
165 Console->TextConsole.State.XPos = 0;
166 Console->TextConsole.State.YPos = 0;
167
168 /* Fill the screen with the background color */
170 Console->TextConsole.State.BgColor);
171 if (!NT_SUCCESS(Status))
172 {
173 return Status;
174 }
175
176 /* Check if the cursor should be visible */
177 if (Console->TextConsole.State.CursorVisible)
178 {
179 /* Load any fonts at this time */
181 {
183 }
184
185 /* Switch the cursor to visible */
187 }
188 else
189 {
190 /* Nothing left to do */
192 }
193
194 /* Return cursor flip result, if any */
195 return Status;
196}
unsigned char BOOLEAN
CConsole Console
LONG NTSTATUS
Definition: precomp.h:26
VOID EfiPrintf(_In_ PWCHAR Format,...)
Definition: firmware.c:126
PVOID BlMmAllocateHeap(_In_ SIZE_T Size)
Definition: heapalloc.c:569
struct _BL_DEFERRED_FONT_FILE * PBL_DEFERRED_FONT_FILE
NTSTATUS BlMmFreeHeap(_In_ PVOID Buffer)
Definition: heapalloc.c:663
NTSTATUS ConsoleGraphicalClearPixels(_In_ PBL_GRAPHICS_CONSOLE Console, _In_ ULONG Color)
Definition: guicons.c:275
NTSTATUS BfClearScreen(_In_ PBL_GRAPHICS_CONSOLE Console)
Definition: font.c:158
NTSTATUS BfClearToEndOfLine(_In_ PBL_GRAPHICS_CONSOLE Console)
Definition: font.c:149
NTSTATUS BfiLoadFontFile(_In_ PBL_DEVICE_DESCRIPTOR FontDevice, _In_ PWCHAR FontPath)
Definition: font.c:20
NTSTATUS BfLoadDeferredFontFiles(VOID)
Definition: font.c:99
NTSTATUS BfLoadFontFile(_In_ PBL_DEVICE_DESCRIPTOR Device, _In_ PWCHAR FontPath)
Definition: font.c:51
VOID BfiFreeDeferredFontFile(_In_ PBL_DEFERRED_FONT_FILE DeferredFontFile)
Definition: font.c:30
NTSTATUS BfiFlipCursorCharacter(_In_ PBL_GRAPHICS_CONSOLE Console, _In_ BOOLEAN Visible)
Definition: font.c:139
LIST_ENTRY BfiDeferredListHead
Definition: font.c:15
#define TRUE
Definition: types.h:120
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define InsertTailList(ListHead, Entry)
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
Status
Definition: gdiplustypes.h:25
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define _In_
Definition: ms_sal.h:308
#define UNICODE_NULL
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
#define L(x)
Definition: ntvdm.h:50
#define STATUS_SUCCESS
Definition: shellext.h:65
PBL_DEVICE_DESCRIPTOR Device
Definition: bl.h:1301
LIST_ENTRY ListEntry
Definition: bl.h:1299
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint16_t * PWCHAR
Definition: typedefs.h:56
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
__wchar_t WCHAR
Definition: xmlstorage.h:180