Skip to content

Commit 342fa60

Browse files
committed
Set font size
1 parent 0880988 commit 342fa60

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

installer-downloader/src/winapi_impl/mod.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ mod ui;
88

99
pub fn main() {
1010
nwg::init().expect("Failed to init Native Windows GUI");
11-
nwg::Font::set_global_family("Segoe UI").expect("Failed to set default font");
11+
let mut global_font = nwg::Font::default();
12+
nwg::FontBuilder::new()
13+
.family("Segoe UI")
14+
.size_absolute(ui::FONT_HEIGHT)
15+
.build(&mut global_font)
16+
.unwrap();
17+
nwg::Font::set_global_default(Some(global_font));
1218

1319
// Load "global" values and resources
1420
let environment = match Environment::load() {

installer-downloader/src/winapi_impl/ui.rs

+5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ use crate::resource::{
2020

2121
use super::delegate::QueueContext;
2222

23+
/// Font height
24+
pub const FONT_HEIGHT: u32 = 16;
25+
2326
static BANNER_IMAGE_DATA: &[u8] = include_bytes!("../../assets/logo-icon.png");
2427
static BANNER_TEXT_IMAGE_DATA: &[u8] = include_bytes!("../../assets/logo-text.png");
2528
static ERROR_IMAGE_DATA: &[u8] = include_bytes!("../../assets/alert-circle.png");
@@ -473,6 +476,8 @@ fn create_link_font() -> Result<&'static nwg::Font, nwg::NwgError> {
473476
// SAFETY: Trivially safe. `LOGFONTW` is a C struct
474477
let mut logfont: LOGFONTW = unsafe { std::mem::zeroed() };
475478
logfont.lfUnderline = 1;
479+
logfont.lfHeight = -i32::try_from(FONT_HEIGHT).unwrap();
480+
476481
for (dest, src) in logfont.lfFaceName.iter_mut().zip(face_name) {
477482
*dest = src;
478483
}

0 commit comments

Comments
 (0)