Fix gamma correction for colored glyphs in iced_wgpu

This commit is contained in:
Héctor Ramón Jiménez 2023-09-19 23:00:20 +02:00
parent 9af0a27e67
commit be340a8cd8
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
4 changed files with 43 additions and 14 deletions

View file

@ -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();
let [r, g, b, a] = color::pack(color).components();
cosmic_text::Color::rgba(r, g, b, a)
cosmic_text::Color::rgba(
(r * 255.0) as u8,
(g * 255.0) as u8,
(b * 255.0) as u8,
(a * 255.0) as u8,
)
}