Merge #1079: Gui: enable advanced text shaping 🎨
9cd36a76d09a1d563769f9c3dac81ec8ce1005eb gui: enable advanced text shaping (edouardparis) Pull request description: Set text shaping and font fallback to text widget. It enable Emojis based on #597 ACKs for top commit: edouardparis: Self-ACK 9cd36a76d09a1d563769f9c3dac81ec8ce1005eb Tree-SHA512: 1ed1621135c5bfbd624a9cf4bd96385db42d021e8432334429b2ec376d769715920d90d76cc000f43625367bdac85444b131be249197e4fab4d5629c7a0138e1
This commit is contained in:
commit
513ea7b18d
@ -21,7 +21,7 @@ liana_ui = { path = "ui" }
|
||||
backtrace = "0.3"
|
||||
hex = "0.4.3"
|
||||
|
||||
iced = { version = "0.12.1", default-features = false, features = ["tokio", "svg", "qr_code", "image", "lazy", "wgpu"] }
|
||||
iced = { version = "0.12.1", default-features = false, features = ["tokio", "svg", "qr_code", "image", "lazy", "wgpu", "advanced"] }
|
||||
iced_runtime = "0.12.1"
|
||||
|
||||
tokio = {version = "1.21.0", features = ["signal"]}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
use iced::{widget::row, Alignment};
|
||||
use iced::{advanced::text::Shaping, widget::row, Alignment};
|
||||
|
||||
use liana_ui::{
|
||||
component::{button, form},
|
||||
@ -17,7 +17,9 @@ pub fn label_editable(
|
||||
if !label.is_empty() {
|
||||
return Container::new(
|
||||
row!(
|
||||
iced::widget::Text::new(label).size(size),
|
||||
iced::widget::Text::new(label)
|
||||
.size(size)
|
||||
.shaping(Shaping::Advanced),
|
||||
button::primary(Some(icon::pencil_icon()), "Edit").on_press(
|
||||
view::Message::Label(
|
||||
labelled,
|
||||
|
||||
@ -425,7 +425,7 @@ pub fn signatures<'a>(
|
||||
Container::new(text(alias))
|
||||
.padding(10)
|
||||
.style(theme::Container::Pill(theme::Pill::Simple)),
|
||||
liana_ui::widget::Text::new(value.to_string()),
|
||||
text(value.to_string()),
|
||||
tooltip::Position::Bottom,
|
||||
)
|
||||
.style(theme::Container::Card(theme::Card::Simple)),
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
use crate::{font, theme::Theme};
|
||||
use iced::advanced::text::Shaping;
|
||||
use std::borrow::Cow;
|
||||
|
||||
pub const H1_SIZE: u16 = 40;
|
||||
@ -12,78 +13,91 @@ pub const CAPTION_SIZE: u16 = 12;
|
||||
|
||||
pub fn h1<'a>(content: impl Into<Cow<'a, str>>) -> iced::widget::Text<'a, Theme> {
|
||||
iced::widget::Text::new(content)
|
||||
.shaping(Shaping::Advanced)
|
||||
.font(font::BOLD)
|
||||
.size(H1_SIZE)
|
||||
}
|
||||
|
||||
pub fn h2<'a>(content: impl Into<Cow<'a, str>>) -> iced::widget::Text<'a, Theme> {
|
||||
iced::widget::Text::new(content)
|
||||
.shaping(Shaping::Advanced)
|
||||
.font(font::BOLD)
|
||||
.size(H2_SIZE)
|
||||
}
|
||||
|
||||
pub fn h3<'a>(content: impl Into<Cow<'a, str>>) -> iced::widget::Text<'a, Theme> {
|
||||
iced::widget::Text::new(content)
|
||||
.shaping(Shaping::Advanced)
|
||||
.font(font::BOLD)
|
||||
.size(H3_SIZE)
|
||||
}
|
||||
|
||||
pub fn h4_bold<'a>(content: impl Into<Cow<'a, str>>) -> iced::widget::Text<'a, Theme> {
|
||||
iced::widget::Text::new(content)
|
||||
.shaping(Shaping::Advanced)
|
||||
.font(font::BOLD)
|
||||
.size(H4_SIZE)
|
||||
}
|
||||
|
||||
pub fn h4_regular<'a>(content: impl Into<Cow<'a, str>>) -> iced::widget::Text<'a, Theme> {
|
||||
iced::widget::Text::new(content)
|
||||
.shaping(Shaping::Advanced)
|
||||
.font(font::REGULAR)
|
||||
.size(H4_SIZE)
|
||||
}
|
||||
|
||||
pub fn h5_medium<'a>(content: impl Into<Cow<'a, str>>) -> iced::widget::Text<'a, Theme> {
|
||||
iced::widget::Text::new(content)
|
||||
.shaping(Shaping::Advanced)
|
||||
.font(font::MEDIUM)
|
||||
.size(H5_SIZE)
|
||||
}
|
||||
|
||||
pub fn h5_regular<'a>(content: impl Into<Cow<'a, str>>) -> iced::widget::Text<'a, Theme> {
|
||||
iced::widget::Text::new(content)
|
||||
.shaping(Shaping::Advanced)
|
||||
.font(font::REGULAR)
|
||||
.size(H5_SIZE)
|
||||
}
|
||||
|
||||
pub fn p1_bold<'a>(content: impl Into<Cow<'a, str>>) -> iced::widget::Text<'a, Theme> {
|
||||
iced::widget::Text::new(content)
|
||||
.shaping(Shaping::Advanced)
|
||||
.font(font::BOLD)
|
||||
.size(P1_SIZE)
|
||||
}
|
||||
|
||||
pub fn p1_medium<'a>(content: impl Into<Cow<'a, str>>) -> iced::widget::Text<'a, Theme> {
|
||||
iced::widget::Text::new(content)
|
||||
.shaping(Shaping::Advanced)
|
||||
.font(font::MEDIUM)
|
||||
.size(P1_SIZE)
|
||||
}
|
||||
|
||||
pub fn p1_regular<'a>(content: impl Into<Cow<'a, str>>) -> iced::widget::Text<'a, Theme> {
|
||||
iced::widget::Text::new(content)
|
||||
.shaping(Shaping::Advanced)
|
||||
.font(font::REGULAR)
|
||||
.size(P1_SIZE)
|
||||
}
|
||||
|
||||
pub fn p2_medium<'a>(content: impl Into<Cow<'a, str>>) -> iced::widget::Text<'a, Theme> {
|
||||
iced::widget::Text::new(content)
|
||||
.shaping(Shaping::Advanced)
|
||||
.font(font::MEDIUM)
|
||||
.size(P2_SIZE)
|
||||
}
|
||||
|
||||
pub fn p2_regular<'a>(content: impl Into<Cow<'a, str>>) -> iced::widget::Text<'a, Theme> {
|
||||
iced::widget::Text::new(content)
|
||||
.shaping(Shaping::Advanced)
|
||||
.font(font::REGULAR)
|
||||
.size(P2_SIZE)
|
||||
}
|
||||
|
||||
pub fn caption<'a>(content: impl Into<Cow<'a, str>>) -> iced::widget::Text<'a, Theme> {
|
||||
iced::widget::Text::new(content)
|
||||
.shaping(Shaping::Advanced)
|
||||
.font(font::REGULAR)
|
||||
.size(CAPTION_SIZE)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user