Skip to content

add iced logo to Iced-Icons.ttf #2902

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions core/src/renderer/null.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ impl text::Renderer for () {
const ICON_FONT: Font = Font::DEFAULT;
const CHECKMARK_ICON: char = '0';
const ARROW_DOWN_ICON: char = '0';
const ICED_LOGO: char = '0';

fn default_font(&self) -> Self::Font {
Font::default()
Expand Down
5 changes: 5 additions & 0 deletions core/src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,11 @@ pub trait Renderer: crate::Renderer {
/// [`ICON_FONT`]: Self::ICON_FONT
const ARROW_DOWN_ICON: char;

/// The 'char' representing the iced logo in the built-in ['ICON_FONT'].
///
/// ['ICON_FONT']: Self::ICON_FONT
const ICED_LOGO: char;

/// Returns the default [`Self::Font`].
fn default_font(&self) -> Self::Font;

Expand Down
Binary file modified graphics/fonts/Iced-Icons.ttf
Binary file not shown.
1 change: 1 addition & 0 deletions renderer/src/fallback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ where
const ICON_FONT: Self::Font = A::ICON_FONT;
const CHECKMARK_ICON: char = A::CHECKMARK_ICON;
const ARROW_DOWN_ICON: char = A::ARROW_DOWN_ICON;
const ICED_LOGO: char = A::ICED_LOGO;

fn default_font(&self) -> Self::Font {
delegate!(self, renderer, renderer.default_font())
Expand Down
1 change: 1 addition & 0 deletions tiny_skia/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ impl core::text::Renderer for Renderer {
const ICON_FONT: Font = Font::with_name("Iced-Icons");
const CHECKMARK_ICON: char = '\u{f00c}';
const ARROW_DOWN_ICON: char = '\u{e800}';
const ICED_LOGO: char = '\u{e801}';

fn default_font(&self) -> Self::Font {
self.default_font
Expand Down
1 change: 1 addition & 0 deletions wgpu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,7 @@ impl core::text::Renderer for Renderer {
const ICON_FONT: Font = Font::with_name("Iced-Icons");
const CHECKMARK_ICON: char = '\u{f00c}';
const ARROW_DOWN_ICON: char = '\u{e800}';
const ICED_LOGO: char = '\u{e801}';

fn default_font(&self) -> Self::Font {
self.default_font
Expand Down
36 changes: 26 additions & 10 deletions widget/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1884,7 +1884,6 @@ where
///
/// Useful for showing some love to your favorite GUI library in your "About" screen,
/// for instance.
#[cfg(feature = "svg")]
pub fn iced<'a, Message, Theme, Renderer>(
text_size: impl Into<Pixels>,
) -> Element<'a, Message, Theme, Renderer>
Expand All @@ -1894,20 +1893,37 @@ where
+ core::text::Renderer<Font = core::Font>
+ core::svg::Renderer
+ 'a,
Theme: text::Catalog + crate::svg::Catalog + 'a,
Theme: text::Catalog + container::Catalog + 'a,
<Theme as container::Catalog>::Class<'a>:
From<container::StyleFn<'a, Theme>>,
<Theme as text::Catalog>::Class<'a>: From<text::StyleFn<'a, Theme>>,
{
use crate::core::{Alignment, Font};
use crate::svg;
use std::sync::LazyLock;

static LOGO: LazyLock<svg::Handle> = LazyLock::new(|| {
svg::Handle::from_memory(include_bytes!("../assets/iced-logo.svg"))
});
use crate::core::{
Alignment, Color, Font, Radians, border, border::radius, color,
gradient::Linear,
};

let text_size = text_size.into();

row![
svg(LOGO.clone()).width(text_size * 1.3),
container(
text(Renderer::ICED_LOGO)
.line_height(1.0)
.size(text_size)
.font(Renderer::ICON_FONT)
.color(Color::WHITE)
)
.padding(text_size * 0.15)
.style(move |_| container::Style {
background: Some(
Linear::new(Radians::PI / 4.0)
.add_stop(0.0, color!(0x2820ff))
.add_stop(1.0, color!(0x1177ff))
.into()
),
border: border::rounded(radius(text_size * 0.4)),
..container::Style::default()
}),
text("iced").size(text_size).font(Font::MONOSPACE)
]
.spacing(text_size.0 / 3.0)
Expand Down