Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions res/open-sans/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
Copyright 2020 The Open Sans Project Authors (https://github.com/googlefonts/opensans)

-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font
creation efforts of academic and linguistic communities, and to
provide a free and open framework in which fonts may be shared and
improved in partnership with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply to
any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).

"Original Version" refers to the collection of Font Software
components as distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to,
deleting, or substituting -- in part or in whole -- any of the
components of the Original Version, by changing formats or by porting
the Font Software to a new environment.

"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed,
modify, redistribute, and sell modified and unmodified copies of the
Font Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components, in
Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the
corresponding Copyright Holder. This restriction only applies to the
primary font name as presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created using
the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are
not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
Binary file added res/open-sans/OpenSans-Regular.ttf
Binary file not shown.
152 changes: 73 additions & 79 deletions src/fde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,7 @@ fn wait_for_events(form: &Form) -> Result<EventType> {
events.push(form.FormRefreshEvent);
}

Result::from((uefi.BootServices.WaitForEvent)(
events.len(),
events.as_mut_ptr(),
&mut index,
))?;
Result::from((uefi.BootServices.WaitForEvent)(events.len(), events.as_mut_ptr(), &mut index))?;

if index == 0 {
Ok(EventType::Keyboard)
Expand All @@ -378,6 +374,9 @@ fn form_display_inner(form: &Form, user_input: &mut UserInput) -> Result<()> {
&mut *DISPLAY
};

// If you want to test the security screen, uncomment this line:
// crate::security::confirm(display);

let (display_w, display_h) = (display.width(), display.height());

let scale = if display_h > 1440 {
Expand All @@ -389,7 +388,7 @@ fn form_display_inner(form: &Form, user_input: &mut UserInput) -> Result<()> {
};

// Style {
let margin_lr = 8 * scale;
let margin_lr = 12 * scale;
let margin_tb = 4 * scale;

let title_font_size = (20 * scale) as f32;
Expand Down Expand Up @@ -417,9 +416,7 @@ fn form_display_inner(form: &Form, user_input: &mut UserInput) -> Result<()> {
let option_ptr = option as *const _;
if let Some(op) = option.OptionOpCode() {
let value = unsafe { op.Value.to_enum(op.Kind) };
let prompt = ui
.font
.render(&string(op.Option).unwrap_or_default(), font_size);
let prompt = ui.font.render(&string(op.Option).unwrap_or_default(), font_size);
options.push(ElementOption {
option_ptr,
prompt,
Expand All @@ -428,86 +425,83 @@ fn form_display_inner(form: &Form, user_input: &mut UserInput) -> Result<()> {
}
}

let add_element =
|header: IfrStatementHeader, selectable: bool, editable: bool, list: bool| {
let value = unsafe {
statement
.CurrentValue
.Value
.to_enum(statement.CurrentValue.Kind)
let add_element = |header: IfrStatementHeader,
selectable: bool,
editable: bool,
list: bool| {
let value =
unsafe { statement.CurrentValue.Value.to_enum(statement.CurrentValue.Kind) };
let buffer_opt = if statement.CurrentValue.Buffer.is_null() {
None
} else {
let buffer = unsafe {
slice::from_raw_parts_mut(
statement.CurrentValue.Buffer,
statement.CurrentValue.BufferLen as usize,
)
};
let buffer_opt = if statement.CurrentValue.Buffer.is_null() {
None
} else {
let buffer = unsafe {
slice::from_raw_parts_mut(
statement.CurrentValue.Buffer,
statement.CurrentValue.BufferLen as usize,
)
};
// Order list according to buffer
if list {
let mut offset = 0;
for i in 0..options.len() {
for j in i..options.len() {
macro_rules! check_option {
($x:ident) => {{
let next_offset = offset + mem::size_of_val(&$x);
if next_offset <= buffer.len() {
let mut x_copy = $x;
unsafe {
ptr::copy(
buffer.as_ptr().add(offset) as *const _,
&mut x_copy,
1,
);
};
if $x == x_copy {
offset = next_offset;
true
} else {
false
}
// Order list according to buffer
if list {
let mut offset = 0;
for i in 0..options.len() {
for j in i..options.len() {
macro_rules! check_option {
($x:ident) => {{
let next_offset = offset + mem::size_of_val(&$x);
if next_offset <= buffer.len() {
let mut x_copy = $x;
unsafe {
ptr::copy(
buffer.as_ptr().add(offset) as *const _,
&mut x_copy,
1,
);
};
if $x == x_copy {
offset = next_offset;
true
} else {
false
}
}};
}
let matches = match options[j].value {
IfrTypeValueEnum::U8(u8) => check_option!(u8),
IfrTypeValueEnum::U16(u16) => check_option!(u16),
IfrTypeValueEnum::U32(u32) => check_option!(u32),
IfrTypeValueEnum::U64(u64) => check_option!(u64),
_ => false,
};
if matches {
if i != j {
options.swap(i, j);
} else {
false
}
break;
}};
}
let matches = match options[j].value {
IfrTypeValueEnum::U8(u8) => check_option!(u8),
IfrTypeValueEnum::U16(u16) => check_option!(u16),
IfrTypeValueEnum::U32(u32) => check_option!(u32),
IfrTypeValueEnum::U64(u64) => check_option!(u64),
_ => false,
};
if matches {
if i != j {
options.swap(i, j);
}
break;
}
}
}
Some(buffer)
};
if statement_ptr == form.HighLightedStatement || (selected == !0 && selectable)
{
selected = elements.len();
}
elements.push(Element {
statement_ptr,
prompt: string(header.Prompt).unwrap_or_default(),
help: string(header.Help).unwrap_or_default(),
value,
options,
selectable,
editable,
list,
list_i: 0,
buffer_opt,
});
Some(buffer)
};
if statement_ptr == form.HighLightedStatement || (selected == !0 && selectable) {
selected = elements.len();
}
elements.push(Element {
statement_ptr,
prompt: string(header.Prompt).unwrap_or_default(),
help: string(header.Help).unwrap_or_default(),
value,
options,
selectable,
editable,
list,
list_i: 0,
buffer_opt,
});
};

if let Some(op) = statement.OpCode() {
macro_rules! cast {
Expand Down Expand Up @@ -672,7 +666,7 @@ fn form_display_inner(form: &Form, user_input: &mut UserInput) -> Result<()> {
if selected == !0 {
render_hotkey_help("");
} else if !editing || !editing_value {
render_hotkey_help("↑↓=Move Highlight");
render_hotkey_help("Up/Down=Move Highlight");
}

if editing {
Expand Down
4 changes: 1 addition & 3 deletions src/image/bmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ pub fn parse(file_data: &[u8]) -> core::result::Result<Image, String> {
};

let gets = |start: usize, len: usize| -> String {
(start..start + len)
.map(|i| get(i) as char)
.collect::<String>()
(start..start + len).map(|i| get(i) as char).collect::<String>()
};

if gets(0, 2) == "BM" {
Expand Down
8 changes: 3 additions & 5 deletions src/image/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ impl ImageRoi<'_> {
pub fn draw<R: Renderer>(&self, renderer: &mut R, x: i32, mut y: i32) {
let stride = self.image.w;
let mut offset = (self.y * stride + self.x) as usize;
let last_offset = cmp::min(
((self.y + self.h) * stride + self.x) as usize,
self.image.data.len(),
);
let last_offset =
cmp::min(((self.y + self.h) * stride + self.x) as usize, self.image.data.len());
while offset < last_offset {
let next_offset = offset + stride as usize;
renderer.image_legacy(x, y, self.w, 1, &self.image.data[offset..]);
Expand Down Expand Up @@ -68,7 +66,7 @@ impl Image {
) -> core::result::Result<Self, String> {
if (width * height) as usize != data.len() {
return Err(
"not enough or too much data given compared to width and height".to_string(),
"not enough or too much data given compared to width and height".to_string()
);
}

Expand Down
6 changes: 1 addition & 5 deletions src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,7 @@ pub fn raw_key(wait: bool) -> Result<TextInputKey> {

if wait {
let mut index = 0;
Result::from((uefi.BootServices.WaitForEvent)(
1,
&uefi.ConsoleIn.WaitForKey,
&mut index,
))?;
Result::from((uefi.BootServices.WaitForEvent)(1, &uefi.ConsoleIn.WaitForKey, &mut index))?;
}

let mut key = TextInputKey {
Expand Down
7 changes: 1 addition & 6 deletions src/rng.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ pub struct Rng(pub &'static mut RngProtocol);

impl Rng {
pub fn read(&self, buf: &mut [u8]) -> Result<()> {
Result::from((self.0.GetRNG)(
self.0,
ptr::null(),
buf.len(),
buf.as_mut_ptr(),
))?;
Result::from((self.0.GetRNG)(self.0, ptr::null(), buf.len(), buf.as_mut_ptr()))?;
Ok(())
}
}
Expand Down
Loading
Loading