Skip to content

Commit

Permalink
Update some dependencies (#833)
Browse files Browse the repository at this point in the history
- Updates `windows-sys` to the latest version.
- Updates `cosmic-text` to the latest version. This unfortunately brings
  a regression with the Thaana script. It's such a minor issue that we
  can live with that for now.
- Fixes a few minor warnings.
  • Loading branch information
CryZe authored Aug 15, 2024
1 parent 8639b02 commit e475332
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 28 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ image = { version = "0.25.0", features = [
# Currently doesn't require any additional dependencies.

# Default Text Engine
cosmic-text = { version = "0.10.0", default-features = false, features = [
cosmic-text = { version = "0.12.1", default-features = false, features = [
"no_std",
], optional = true }

Expand Down Expand Up @@ -112,7 +112,7 @@ web-sys = { version = "0.3.28", default-features = false, features = [

[target.'cfg(windows)'.dependencies]
# We need windows-sys to use GDI to resolve fonts on Windows.
windows-sys = { version = "0.52.0", features = [
windows-sys = { version = "0.59.0", features = [
"Win32_Foundation",
"Win32_Graphics_Gdi",
], optional = true }
Expand Down
6 changes: 3 additions & 3 deletions crates/livesplit-auto-splitting/src/runtime/api/wasi.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{path::Path, str};
use std::path::Path;

use wasmtime_wasi::{preview1::WasiP1Ctx, DirPerms, FilePerms, WasiCtxBuilder};

Expand Down Expand Up @@ -26,8 +26,8 @@ pub fn build(script_path: Option<&Path>) -> WasiP1Ctx {
let drive = drive_idx as u8 + b'a';
// Unfortunate if this fails, but we should still continue.
let _ = wasi.preopened_dir(
str::from_utf8(&[b'\\', b'\\', b'?', b'\\', drive, b':', b'\\']).unwrap(),
str::from_utf8(&[b'/', b'm', b'n', b't', b'/', drive]).unwrap(),
std::str::from_utf8(&[b'\\', b'\\', b'?', b'\\', drive, b':', b'\\']).unwrap(),
std::str::from_utf8(&[b'/', b'm', b'n', b't', b'/', drive]).unwrap(),
DirPerms::READ,
FilePerms::READ,
);
Expand Down
4 changes: 2 additions & 2 deletions crates/livesplit-auto-splitting/src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,10 +416,10 @@ impl CompiledAutoSplitter {
store.data_mut().timer.log(format_args!("This auto splitter uses WASI. The API is subject to change, because WASI is still in preview. Auto splitters using WASI may need to be recompiled in the future."));

// These may be different in future WASI versions.
if let Ok(func) = instance.get_typed_func(&mut store, "_initialize") {
if let Ok(func) = instance.get_typed_func::<(), ()>(&mut store, "_initialize") {
func.call(&mut store, ())
.map_err(|source| CreationError::WasiStart { source })?;
} else if let Ok(func) = instance.get_typed_func(&mut store, "_start") {
} else if let Ok(func) = instance.get_typed_func::<(), ()>(&mut store, "_start") {
func.call(&mut store, ())
.map_err(|source| CreationError::WasiStart { source })?;
}
Expand Down
2 changes: 1 addition & 1 deletion src/component/separator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ impl Component {
/// This panics if the type of the value to be set is not compatible with
/// the type of the setting's value. A panic can also occur if the index of
/// the setting provided is out of bounds.
#[allow(clippy::needless_pass_by_value)]
#[allow(clippy::needless_pass_by_value, clippy::needless_pass_by_ref_mut)]
pub fn set_value(&mut self, _index: usize, _value: Value) {}
}
4 changes: 2 additions & 2 deletions src/hotkey_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl<S: event::CommandSink + Clone + Send + 'static> HotkeySystem<S> {

// This method should never be public, because it might mess up the internal
// state and we might leak a registered hotkey
fn register_inner(&mut self, action: Action) -> Result<()> {
fn register_inner(&self, action: Action) -> Result<()> {
let inner = self.command_sink.clone();
if let Some(hotkey) = action.get_hotkey(&self.config) {
self.hook.register(hotkey, action.callback(inner))?;
Expand All @@ -145,7 +145,7 @@ impl<S: event::CommandSink + Clone + Send + 'static> HotkeySystem<S> {

// This method should never be public, because it might mess up the internal
// state and we might leak a registered hotkey
fn unregister_inner(&mut self, action: Action) -> Result<()> {
fn unregister_inner(&self, action: Action) -> Result<()> {
if let Some(hotkey) = action.get_hotkey(&self.config) {
self.hook.unregister(hotkey)?;
}
Expand Down
8 changes: 4 additions & 4 deletions src/layout/parser/font_resolving/gdi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ impl DeviceContext {
// parameters to `CreateCompatibleDC`. We also properly check the
// result.
unsafe {
let res = CreateCompatibleDC(0);
if res == 0 {
let res = CreateCompatibleDC(ptr::null_mut());
if res.is_null() {
return None;
}
Some(Self(res))
Expand All @@ -39,7 +39,7 @@ impl DeviceContext {
// `HFONT`. We also properly check the result.
unsafe {
let res = SelectObject(self.0, font.0);
if res == 0 || res == GDI_ERROR as HANDLE {
if res.is_null() || res == GDI_ERROR as HANDLE {
return None;
}
Some(())
Expand Down Expand Up @@ -131,7 +131,7 @@ impl Font {
DEFAULT_PITCH as _,
name_buf.as_ptr(),
);
if res == 0 {
if res.is_null() {
return None;
}
Some(Self(res))
Expand Down
8 changes: 4 additions & 4 deletions src/rendering/default_text_engine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ impl<P: SharedOwnership> TextEngine<P> {
glyph_text,
attrs_list,
Shaping::Advanced,
4,
);
if let [span] = &*shape_line.spans {
if let [word] = &*span.words {
Expand Down Expand Up @@ -230,6 +231,7 @@ impl<P: SharedOwnership> TextEngine<P> {
text,
&font.attrs_list,
Shaping::Advanced,
4,
);
let [mut x, mut y] = [0.0; 2];

Expand Down Expand Up @@ -287,8 +289,7 @@ impl<P: SharedOwnership> TextEngine<P> {
y -= glyph.y_advance;
}
} else {
x += word.x_advance;
y -= word.y_advance;
x += word.width(1.0);
}
}
}
Expand Down Expand Up @@ -325,8 +326,7 @@ impl<P: SharedOwnership> TextEngine<P> {
glyph_y -= glyph.y_advance;
}
}
x += word.x_advance;
y -= word.y_advance;
x += word.width(1.0);
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/rendering/entity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ fn hash_float(f: f32, state: &mut impl Hasher) {

#[inline]
fn hash_transform(f: &Transform, state: &mut impl Hasher) {
const _: () = assert!(core::mem::size_of::<Transform>() == 16);
const {
assert!(core::mem::size_of::<Transform>() == 16);
}
let [a, b]: [u64; 2] = bytemuck::cast(*f);
u64::hash(&a, state);
u64::hash(&b, state);
Expand Down
14 changes: 7 additions & 7 deletions src/run/parser/splitterino.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ struct Splits<'a> {
// timing: SplitterinoTimingMethod,
}

/// Timing methods which can be used for segment times
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
enum SplitterinoTimingMethod {
Igt,
Rta,
}
// /// Timing methods which can be used for segment times
// #[derive(Deserialize)]
// #[serde(rename_all = "camelCase")]
// enum SplitterinoTimingMethod {
// Igt,
// Rta,
// }

/// Detailed information about the game and run details
#[derive(Deserialize, Default)]
Expand Down
7 changes: 5 additions & 2 deletions tests/rendering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ fn font_fallback() {
// Meitei
"ꯃꯩꯇꯩ ꯃꯌꯦꯛ",
// Thaana
// FIXME: Fails font fallback because it's a cursive font, but we never
// specified that we want a cursive font:
// https://github.com/pop-os/cosmic-text/issues/277
"ދިވެހި",
// Canadian Syllabics
"ᖃᓂᐅᔮᖅᐸᐃᑦ ᒐᐦᑲᓯᓇᐦᐃᑫᐤ ᑯᖾᖹ ᖿᐟᖻ ᓱᖽᐧᖿ ᑐᑊᘁᗕᑋᗸ",
Expand All @@ -164,8 +167,8 @@ fn font_fallback() {
&state,
&image_cache,
[320, 750],
"2b3e4a75f3eafdc4",
"cdbbe94245ed4f69",
"0379ab7ed4cad84f",
"fea17ece738ce1be",
"font_fallback",
);
}
Expand Down

0 comments on commit e475332

Please sign in to comment.