I don’t get any glyphs, just plain symbols. I’m doing something wrong or there are no support for ligatures?
use iced::widget::text::Shaping;
use iced::widget::{container, text, Text};
use iced::{alignment, executor, font, Application, Command, Element, Length, Settings, Theme};
pub fn main() -> iced::Result {
Editor::run(Settings::default())
}
enum Editor {
Loading,
Loaded(State),
}
#[derive(Clone, Debug)]
enum Message {
#[allow(dead_code)]
Loaded(Result<(), String>),
FontLoaded(Result<(), font::Error>),
}
async fn load() -> Result<(), String> {
Ok(())
}
#[derive(Debug)]
struct State {
#[allow(dead_code)]
number: i32,
}
impl Application for Editor {
type Message = Message;
type Theme = Theme;
type Executor = executor::Default;
type Flags = ();
// include_bytes!("FiraCode-Regular.ttf")
fn new(_flags: ()) -> (Editor, Command<Message>) {
(
Editor::Loading,
Command::batch(vec![
font::load(include_bytes!("FiraCode-Regular.ttf")).map(Message::FontLoaded),
Command::perform(load(), Message::Loaded),
]),
)
}
fn title(&self) -> String {
String::from("QGen Next")
}
fn update(&mut self, message: Message) -> Command<Message> {
match self {
Editor::Loading => {
if let Message::Loaded(_) = message {
*self = Editor::Loaded(State { number: 1 })
}
}
Editor::Loaded(_state) => match message {
_ => {}
},
}
Command::none()
}
fn view(&self) -> Element<Message> {
match self {
Editor::Loading => container(
text("Loading...")
.horizontal_alignment(alignment::Horizontal::Center)
.size(50),
)
.width(Length::Fill)
.height(Length::Fill)
.center_y()
.center_x()
.into(),
Editor::Loaded(state) => {
println!("{:?}", state);
Text::new("Hello -> => == === <=> >= <=")
.shaping(Shaping::Advanced)
.size(30)
.into()
}
}
}
}