Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gui: enable advanced text shaping 🎨 #1079

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]}
Expand Down
6 changes: 4 additions & 2 deletions gui/src/app/view/label.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use iced::{widget::row, Alignment};
use iced::{advanced::text::Shaping, widget::row, Alignment};

use liana_ui::{
component::{button, form},
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion gui/src/app/view/psbt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down
14 changes: 14 additions & 0 deletions gui/ui/src/component/text.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::{font, theme::Theme};
use iced::advanced::text::Shaping;
use std::borrow::Cow;

pub const H1_SIZE: u16 = 40;
Expand All @@ -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)
}
Expand Down
Loading