summaryrefslogtreecommitdiffstats
path: root/native/src/command/action.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2023-02-24 20:52:10 +0100
committerLibravatar GitHub <noreply@github.com>2023-02-24 20:52:10 +0100
commit368cadd25a8b57ee5c41e45d1abe8d1dfb194c69 (patch)
tree191cb7cc7807a5fe513b3d485b2fda21d3bf0bde /native/src/command/action.rs
parent573d27eb52bbfacf1b06983b4282f00eb5265bdc (diff)
parent8059c40142d601588e01c152ce1bb72a1295dde8 (diff)
downloadiced-368cadd25a8b57ee5c41e45d1abe8d1dfb194c69.tar.gz
iced-368cadd25a8b57ee5c41e45d1abe8d1dfb194c69.tar.bz2
iced-368cadd25a8b57ee5c41e45d1abe8d1dfb194c69.zip
Merge pull request #1697 from iced-rs/text-glyphon
Text shaping, font fallback, and `iced_wgpu` overhaul
Diffstat (limited to 'native/src/command/action.rs')
-rw-r--r--native/src/command/action.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/native/src/command/action.rs b/native/src/command/action.rs
index a51b8c21..d1589c05 100644
--- a/native/src/command/action.rs
+++ b/native/src/command/action.rs
@@ -1,10 +1,12 @@
use crate::clipboard;
+use crate::font;
use crate::system;
use crate::widget;
use crate::window;
use iced_futures::MaybeSend;
+use std::borrow::Cow;
use std::fmt;
/// An action that a [`Command`] can perform.
@@ -27,6 +29,15 @@ pub enum Action<T> {
/// Run a widget action.
Widget(widget::Action<T>),
+
+ /// Load a font from its bytes.
+ LoadFont {
+ /// The bytes of the font to load.
+ bytes: Cow<'static, [u8]>,
+
+ /// The message to produce when the font has been loaded.
+ tagger: Box<dyn Fn(Result<(), font::Error>) -> T>,
+ },
}
impl<T> Action<T> {
@@ -49,6 +60,10 @@ impl<T> Action<T> {
Self::Window(window) => Action::Window(window.map(f)),
Self::System(system) => Action::System(system.map(f)),
Self::Widget(widget) => Action::Widget(widget.map(f)),
+ Self::LoadFont { bytes, tagger } => Action::LoadFont {
+ bytes,
+ tagger: Box::new(move |result| f(tagger(result))),
+ },
}
}
}
@@ -63,6 +78,7 @@ impl<T> fmt::Debug for Action<T> {
Self::Window(action) => write!(f, "Action::Window({action:?})"),
Self::System(action) => write!(f, "Action::System({action:?})"),
Self::Widget(_action) => write!(f, "Action::Widget"),
+ Self::LoadFont { .. } => write!(f, "Action::LoadFont"),
}
}
}