iconflow 1.0.0

Unified icon library for Rust GUI apps with 10+ embedded icon packs (Bootstrap, Heroicons, Phosphor, Lucide, Tabler). Type-safe API for egui, iced and more
Documentation
  • Coverage
  • 32.5%
    13 out of 40 items documented0 out of 0 items with examples
  • Size
  • Source code size: 40.93 MB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.9 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 22s Average build duration of successful builds.
  • all releases: 22s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • FerrisMind/iconflow
    3 1 1
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • FerrisMind

iconflow

Install

Enable at least one pack feature so the fonts and icon data are included.

[dependencies]
iconflow = { version = "1.0", features = ["all-packs"] }

Quickstart guide

See docs/quickstart.md for a fast end-to-end setup guide and API overview.

Core API

  • fonts() returns the enabled font assets for registered packs.
  • try_icon(pack, name, style, size) resolves an icon reference or returns IconError.
  • list(pack) returns the icon names for a pack.

egui quickstart

Register every FontAsset in egui::FontDefinitions, then render IconRef.codepoint with FontFamily::Name(icon.family):

use eframe::egui::{self, FontData, FontDefinitions, FontFamily, FontId, RichText};
use iconflow::{fonts, try_icon, Pack, Size, Style};
use std::sync::Arc;

fn install_icon_fonts(ctx: &egui::Context) {
    let mut definitions = FontDefinitions::default();
    let fallback_fonts: Vec<String> = definitions.font_data.keys().cloned().collect();

    for font in fonts() {
        definitions.font_data.insert(
            font.family.to_string(),
            Arc::new(FontData::from_static(font.bytes)),
        );
        let family = definitions
            .families
            .entry(FontFamily::Name(font.family.into()))
            .or_default();
        family.insert(0, font.family.to_string());
        for fallback in &fallback_fonts {
            if fallback != font.family {
                family.push(fallback.clone());
            }
        }
    }

    ctx.set_fonts(definitions);
}

fn icon_label(ui: &mut egui::Ui) {
    let samples = [
        (Pack::Bootstrap, "alarm", Style::Regular, Size::Regular),
        (Pack::Bootstrap, "alarm", Style::Filled, Size::Regular),
        (Pack::Heroicons, "academic-cap", Style::Filled, Size::Regular),
    ];

    for (pack, name, style, size) in samples {
        let icon = try_icon(pack, name, style, size).expect("icon missing");
        let glyph = char::from_u32(icon.codepoint).unwrap_or('?');
        let font_id = FontId::new(32.0, FontFamily::Name(icon.family.into()));

        ui.label(RichText::new(glyph.to_string()).font(font_id));
    }
}

Runnable example: cargo run --example egui_demo --features all-packs

iced 0.14 quickstart

In iced 0.14, fonts are loaded asynchronously via Task. Load the bytes from fonts() and render a glyph with Font::with_name once loading completes.

use iced::{Task, font};
use iced::widget::text;
use iconflow::{fonts, try_icon, Pack, Size, Style};

#[derive(Debug, Clone)]
enum Message {
    FontLoaded(Result<(), font::Error>),
}

fn load_all_fonts() -> Task<Message> {
    Task::batch(fonts().iter().map(|font| {
        font::load(font.bytes).map(Message::FontLoaded)
    }))
}

fn icon_text() -> iced::widget::Text<'static> {
    let icon = try_icon(Pack::Bootstrap, "alarm", Style::Regular, Size::Regular)
        .expect("icon missing");
    let glyph = char::from_u32(icon.codepoint).unwrap_or('?');
    text(glyph.to_string())
        .size(48)
        .font(iced::font::Font::with_name(icon.family))
}

Runnable example: cargo run --example iced_demo --features all-packs

Example READMEs: examples/egui_demo/README.md, examples/iced_demo/README.md.

FAQ

See docs/faq.md.

Development

  • cargo xtask gen regenerates src/generated/** from assets/maps/*.json.
  • cargo xtask gen --check verifies generated output without writing files.

Icon Fonts and Licenses

iconflow includes icon fonts from 14 open-source icon packs. All fonts are distributed under permissive licenses (MIT, Apache-2.0, or ISC).

Included Icon Packs

Icon Pack License Source
Bootstrap Icons MIT twbs/icons
Carbon Icons Apache-2.0 carbon-design-system/carbon-icons
Devicon MIT devicons/devicon
Feather Icons MIT feathericons/feather
Fluent UI System Icons MIT microsoft/fluentui-system-icons
Heroicons MIT tailwindlabs/heroicons
Iconoir MIT iconoir-icons/iconoir
Ionicons MIT ionic-team/ionicons
Lobe Icons MIT lobehub/lobe-icons
Lucide ISC lucide-icons/lucide
Octicons MIT primer/octicons
Phosphor Icons MIT phosphor-icons/web
Remix Icon Apache-2.0 Remix-Design/remixicon
Tabler Icons MIT tabler/tabler-icons

Total: 34 TTF font files across 14 icon packs.

Acknowledgments

iconflow is built on top of these excellent open-source icon libraries. We are grateful to all the contributors and maintainers of these projects:

  • Bootstrap Icons by Bootstrap team
  • Carbon Icons by IBM Carbon Design System
  • Devicon by Devicon and contributors
  • Feather Icons by Cole Bemis and contributors
  • Fluent UI System Icons by Microsoft
  • Heroicons by Tailwind Labs
  • Iconoir by Luca Burgio and contributors
  • Ionicons by Ionic team
  • Lobe Icons by LobeHub
  • Lucide by Lucide contributors
  • Octicons by GitHub (Primer)
  • Phosphor Icons by Phosphor Icons team
  • Remix Icon by Remix Design
  • Tabler Icons by codecalm and contributors

All icon fonts are converted from their original SVG sources and embedded as TTF files in this project. The fonts are included in the crate binary when corresponding feature flags are enabled.

License

This project is licensed under MIT License.

Third-party dependencies and fonts have their own licenses. See: