diff options
author | 2023-09-19 23:00:20 +0200 | |
---|---|---|
committer | 2023-09-19 23:00:20 +0200 | |
commit | be340a8cd822be1ea0fe4c1b1f3a62ca66d705b4 (patch) | |
tree | 38f6d1dc01bc3c32859b46b20e136daa0f90754e /graphics | |
parent | 9af0a27e675b71164f32f8d82eb4cde9cdd459f3 (diff) | |
download | iced-be340a8cd822be1ea0fe4c1b1f3a62ca66d705b4.tar.gz iced-be340a8cd822be1ea0fe4c1b1f3a62ca66d705b4.tar.bz2 iced-be340a8cd822be1ea0fe4c1b1f3a62ca66d705b4.zip |
Fix gamma correction for colored glyphs in `iced_wgpu`
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/src/text.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/graphics/src/text.rs b/graphics/src/text.rs index 5fcfc699..c10eacad 100644 --- a/graphics/src/text.rs +++ b/graphics/src/text.rs @@ -8,6 +8,7 @@ pub use paragraph::Paragraph; pub use cosmic_text; +use crate::color; use crate::core::font::{self, Font}; use crate::core::text::Shaping; use crate::core::{Color, Size}; @@ -131,7 +132,12 @@ pub fn to_shaping(shaping: Shaping) -> cosmic_text::Shaping { } pub fn to_color(color: Color) -> cosmic_text::Color { - let [r, g, b, a] = color.into_rgba8(); - - cosmic_text::Color::rgba(r, g, b, a) + let [r, g, b, a] = color::pack(color).components(); + + cosmic_text::Color::rgba( + (r * 255.0) as u8, + (g * 255.0) as u8, + (b * 255.0) as u8, + (a * 255.0) as u8, + ) } |