From 7b6fa1285475896ad8dbc2f4b11099b0c036e4b7 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Mon, 1 Jul 2024 09:47:31 +0400 Subject: Enable subpixel glyph positioning in Pango Makes things scale more smoothly. --- Cargo.lock | 1 + Cargo.toml | 1 + src/ui/config_error_notification.rs | 2 ++ src/ui/exit_confirm_dialog.rs | 2 ++ src/ui/hotkey_overlay.rs | 2 ++ 5 files changed, 8 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 0c1286e5..2cfd72d8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2186,6 +2186,7 @@ dependencies = [ "niri-ipc", "notify-rust", "ordered-float", + "pango", "pangocairo", "pipewire", "png", diff --git a/Cargo.toml b/Cargo.toml index 7076f114..f0b009d6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -64,6 +64,7 @@ niri-config = { version = "0.1.7", path = "niri-config" } niri-ipc = { version = "0.1.7", path = "niri-ipc", features = ["clap"] } notify-rust = { version = "~4.10.0", optional = true } ordered-float = "4.2.0" +pango = { version = "0.19.8", features = ["v1_44"] } pangocairo = "0.19.8" pipewire = { version = "0.8.0", optional = true } png = "0.17.13" diff --git a/src/ui/config_error_notification.rs b/src/ui/config_error_notification.rs index b120f494..aa218c91 100644 --- a/src/ui/config_error_notification.rs +++ b/src/ui/config_error_notification.rs @@ -192,6 +192,7 @@ fn render( let surface = ImageSurface::create(cairo::Format::ARgb32, 0, 0)?; let cr = cairo::Context::new(&surface)?; let layout = pangocairo::functions::create_layout(&cr); + layout.context().set_round_glyph_positions(false); layout.set_font_description(Some(&font)); layout.set_markup(&text); @@ -206,6 +207,7 @@ fn render( cr.move_to(padding.into(), padding.into()); let layout = pangocairo::functions::create_layout(&cr); + layout.context().set_round_glyph_positions(false); layout.set_font_description(Some(&font)); layout.set_markup(&text); diff --git a/src/ui/exit_confirm_dialog.rs b/src/ui/exit_confirm_dialog.rs index 9ffae3a7..6458558f 100644 --- a/src/ui/exit_confirm_dialog.rs +++ b/src/ui/exit_confirm_dialog.rs @@ -109,6 +109,7 @@ fn render(scale: f64) -> anyhow::Result { let surface = ImageSurface::create(cairo::Format::ARgb32, 0, 0)?; let cr = cairo::Context::new(&surface)?; let layout = pangocairo::functions::create_layout(&cr); + layout.context().set_round_glyph_positions(false); layout.set_font_description(Some(&font)); layout.set_alignment(Alignment::Center); layout.set_markup(TEXT); @@ -124,6 +125,7 @@ fn render(scale: f64) -> anyhow::Result { cr.move_to(padding.into(), padding.into()); let layout = pangocairo::functions::create_layout(&cr); + layout.context().set_round_glyph_positions(false); layout.set_font_description(Some(&font)); layout.set_alignment(Alignment::Center); layout.set_markup(TEXT); diff --git a/src/ui/hotkey_overlay.rs b/src/ui/hotkey_overlay.rs index bc53d573..6e5f24fa 100644 --- a/src/ui/hotkey_overlay.rs +++ b/src/ui/hotkey_overlay.rs @@ -250,6 +250,7 @@ fn render( let surface = ImageSurface::create(cairo::Format::ARgb32, 0, 0)?; let cr = cairo::Context::new(&surface)?; let layout = pangocairo::functions::create_layout(&cr); + layout.context().set_round_glyph_positions(false); layout.set_font_description(Some(&font)); let bold = AttrList::new(); @@ -301,6 +302,7 @@ fn render( cr.move_to(padding.into(), padding.into()); let layout = pangocairo::functions::create_layout(&cr); + layout.context().set_round_glyph_positions(false); layout.set_font_description(Some(&font)); cr.set_source_rgb(1., 1., 1.); -- cgit