Skip to content

Commit

Permalink
SWELL: Fix CreateFontIndirect on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
helgoboss committed Feb 14, 2024
1 parent f66fd33 commit 8acf80b
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions main/low/src/swell_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#![allow(non_snake_case)]
#![allow(unused_variables)]

use std::ptr::null;
use crate::{
bindings::root, register_plugin_destroy_hook, PluginContext, Swell, SwellFunctionPointers,
};
Expand Down Expand Up @@ -348,8 +347,8 @@ impl Swell {
if font.is_null() {
return std::ptr::null_mut();
}
let font = *font;
let mut wide_font = winapi::um::wingdi::LOGFONTW{
let font = &*font;
let mut wide_font = winapi::um::wingdi::LOGFONTW {
lfHeight: font.lfHeight,
lfWidth: font.lfWidth,
lfEscapement: font.lfEscapement,
Expand All @@ -365,10 +364,10 @@ impl Swell {
lfPitchAndFamily: font.lfPitchAndFamily as _,
lfFaceName: [0; 32],
};

winapi::um::wingdi::CreateFontIndirectW(
&mut wide_font as *mut _
) as _
for (i, ch) in font.lfFaceName.iter().take(15).enumerate() {
(*ch as u8 as char).encode_utf16(&mut wide_font.lfFaceName[i * 2..]);
}
winapi::um::wingdi::CreateFontIndirectW(&mut wide_font as *mut _) as _
}

/// # Safety
Expand Down

0 comments on commit 8acf80b

Please sign in to comment.