summaryrefslogtreecommitdiffstats
path: root/graphics/src/text.rs
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/src/text.rs')
-rw-r--r--graphics/src/text.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/graphics/src/text.rs b/graphics/src/text.rs
index b4aeb2be..5fcfc699 100644
--- a/graphics/src/text.rs
+++ b/graphics/src/text.rs
@@ -10,7 +10,7 @@ pub use cosmic_text;
use crate::core::font::{self, Font};
use crate::core::text::Shaping;
-use crate::core::Size;
+use crate::core::{Color, Size};
use once_cell::sync::OnceCell;
use std::borrow::Cow;
@@ -129,3 +129,9 @@ pub fn to_shaping(shaping: Shaping) -> cosmic_text::Shaping {
Shaping::Advanced => cosmic_text::Shaping::Advanced,
}
}
+
+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)
+}