Giter Site home page Giter Site logo

Icon size bug about iced_aw HOT 3 CLOSED

iced-rs avatar iced-rs commented on June 19, 2024
Icon size bug

from iced_aw.

Comments (3)

genusistimelord avatar genusistimelord commented on June 19, 2024

ahh yeah, the font stuff in iced might be making changes soon which can help with this too.

from iced_aw.

rctlmk avatar rctlmk commented on June 19, 2024

There is a horizontal clipping bug as well, but it goes away if the font is changed (even to itself):

// Converted from `.woff2` from the latest release
// https://github.com/twbs/icons/releases/tag/v1.10.3
const BOOTSTRAP_ICONS: iced::Font = iced_native::Font::External {
    name: "Bootstrap-Icons",
    bytes: include_bytes!("../resources/bootstrap-icons.ttf"),
};

fn view(&self) -> iced::Element<'_, Self::Message, iced::Renderer<Self::Theme>> {
    use iced::widget::text;
    use iced_aw::graphics::IconText;
    use iced_aw::ICON_FONT;
    use iced_native::Alignment::Center;

    let gear = '\u{F3E5}';
    let icons = "\u{F159}\u{F156}";

    let content = container(
        column![
            row![text("Icon::Gear"), IconText::new(Icon::Gear).size(40.0),].align_items(Center),
            row![
                text("Icon::Gear, ICON_FONT"),
                IconText::new(Icon::Gear).font(ICON_FONT).size(40.0)
            ]
            .align_items(Center),
            row![
                text("Icon::Gear, bootstrap-icons.ttf"),
                IconText::new(Icon::Gear).font(BOOTSTRAP_ICONS).size(40.0)
            ]
            .align_items(Center),
            row![text("Gear code"), IconText::new(gear).size(40.0)].align_items(Center),
            row![
                text("Gear code, ICON_FONT"),
                IconText::new(gear).font(ICON_FONT).size(40.0)
            ]
            .align_items(Center),
            row![
                text("Hourglass, bootstrap-icons.ttf"),
                IconText::new('\u{F420}').font(BOOTSTRAP_ICONS).size(40.0)
            ]
            .align_items(Center),
            row![
                text("Gear code, bootstrap-icons.ttf"),
                IconText::new(gear).font(BOOTSTRAP_ICONS).size(40.0)
            ]
            .align_items(Center),
            row![text("IconText"), IconText::new(icons).size(40.0)].align_items(Center),
            row![text("IconText, ICON_FONT"), text(icons).font(ICON_FONT).size(40.0)].align_items(Center),
            row![text("text, ICON_FONT"), text(icons).font(ICON_FONT).size(40.0)].align_items(Center),
            row![
                text("IconText, bootstrap-icons.ttf"),
                IconText::new(icons).font(BOOTSTRAP_ICONS).size(40.0)
            ]
            .align_items(Center),
            row![
                text("text, bootstrap-icons.ttf"),
                text(icons).font(BOOTSTRAP_ICONS).size(40.0)
            ]
            .align_items(Center),
        ]
        .spacing(20),
    )
    .padding(10);
}

Screenshot

Here is bootstrap-icons.ttf I was using (it's not a .zip file, change the extension to .ttf): bootstrap-icons.zip
The vertical clipping is still there, though, but it is much less noticeable.
It also seems that the current icons file has other problems and is somewhat outdated.

from iced_aw.

genusistimelord avatar genusistimelord commented on June 19, 2024

After investigating I have found that this is 100% a iced issue.

it occurs when the Renderer measures the Text size and returns a incorrect Size.
let (width, height) =
renderer.measure(&self.content, size, self.font.unwrap_or_default(), bounds);

This somehow is not correct and I hope the newer Text renderer will fix this issue.

from iced_aw.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.