use crate::core::{FontAsset, IconError, IconRef, Size, Style};
#[cfg(feature = "pack-bootstrap")]
pub mod bootstrap;
#[cfg(feature = "pack-carbon")]
pub mod carbon;
#[cfg(feature = "pack-devicon")]
pub mod devicon;
#[cfg(feature = "pack-feather")]
pub mod feather;
#[cfg(feature = "pack-fluentui")]
pub mod fluentui;
#[cfg(feature = "pack-heroicons")]
pub mod heroicons;
#[cfg(feature = "pack-iconoir")]
pub mod iconoir;
#[cfg(feature = "pack-ionicons")]
pub mod ionicons;
#[cfg(feature = "pack-lobe")]
pub mod lobe;
#[cfg(feature = "pack-lucide")]
pub mod lucide;
#[cfg(feature = "pack-octicons")]
pub mod octicons;
#[cfg(feature = "pack-phosphor")]
pub mod phosphor;
#[cfg(feature = "pack-remixicon")]
pub mod remixicon;
#[cfg(feature = "pack-tabler")]
pub mod tabler;
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
pub enum Pack {
#[cfg(feature = "pack-bootstrap")]
Bootstrap,
#[cfg(feature = "pack-carbon")]
Carbon,
#[cfg(feature = "pack-devicon")]
Devicon,
#[cfg(feature = "pack-feather")]
Feather,
#[cfg(feature = "pack-fluentui")]
Fluentui,
#[cfg(feature = "pack-heroicons")]
Heroicons,
#[cfg(feature = "pack-iconoir")]
Iconoir,
#[cfg(feature = "pack-ionicons")]
Ionicons,
#[cfg(feature = "pack-lobe")]
Lobe,
#[cfg(feature = "pack-lucide")]
Lucide,
#[cfg(feature = "pack-octicons")]
Octicons,
#[cfg(feature = "pack-phosphor")]
Phosphor,
#[cfg(feature = "pack-remixicon")]
Remixicon,
#[cfg(feature = "pack-tabler")]
Tabler,
}
pub fn fonts() -> &'static [FontAsset] {
&[
#[cfg(feature = "pack-bootstrap")]
bootstrap::FONT_ASSET_BOOTSTRAP_BOOTSTRAP_FILLED,
#[cfg(feature = "pack-bootstrap")]
bootstrap::FONT_ASSET_BOOTSTRAP_BOOTSTRAP_REGULAR,
#[cfg(feature = "pack-carbon")]
carbon::FONT_ASSET_CARBON_CARBON_FILLED,
#[cfg(feature = "pack-carbon")]
carbon::FONT_ASSET_CARBON_CARBON_GLYPH,
#[cfg(feature = "pack-carbon")]
carbon::FONT_ASSET_CARBON_CARBON_OUTLINE,
#[cfg(feature = "pack-carbon")]
carbon::FONT_ASSET_CARBON_CARBON_REGULAR,
#[cfg(feature = "pack-devicon")]
devicon::FONT_ASSET_DEVICON_DEVICON_REGULAR,
#[cfg(feature = "pack-feather")]
feather::FONT_ASSET_FEATHER_FEATHER_REGULAR,
#[cfg(feature = "pack-fluentui")]
fluentui::FONT_ASSET_FLUENTUI_FLUENTUI_FILLED,
#[cfg(feature = "pack-fluentui")]
fluentui::FONT_ASSET_FLUENTUI_FLUENTUI_LIGHT,
#[cfg(feature = "pack-fluentui")]
fluentui::FONT_ASSET_FLUENTUI_FLUENTUI_REGULAR,
#[cfg(feature = "pack-fluentui")]
fluentui::FONT_ASSET_FLUENTUI_FLUENTUI_RESIZABLE,
#[cfg(feature = "pack-heroicons")]
heroicons::FONT_ASSET_HEROICONS_HEROICONS_FILLED,
#[cfg(all(feature = "pack-heroicons", feature = "heroicons-mini"))]
heroicons::FONT_ASSET_HEROICONS_HEROICONS_MINI,
#[cfg(feature = "pack-heroicons")]
heroicons::FONT_ASSET_HEROICONS_HEROICONS_OUTLINE,
#[cfg(all(feature = "pack-heroicons", feature = "heroicons-tiny"))]
heroicons::FONT_ASSET_HEROICONS_HEROICONS_TINY,
#[cfg(feature = "pack-iconoir")]
iconoir::FONT_ASSET_ICONOIR_ICONOIR_FILLED,
#[cfg(feature = "pack-iconoir")]
iconoir::FONT_ASSET_ICONOIR_ICONOIR_REGULAR,
#[cfg(feature = "pack-ionicons")]
ionicons::FONT_ASSET_IONICONS_IONICONS_OUTLINE,
#[cfg(feature = "pack-ionicons")]
ionicons::FONT_ASSET_IONICONS_IONICONS_REGULAR,
#[cfg(feature = "pack-ionicons")]
ionicons::FONT_ASSET_IONICONS_IONICONS_SHARP,
#[cfg(feature = "pack-lobe")]
lobe::FONT_ASSET_LOBE_LOBE_REGULAR,
#[cfg(feature = "pack-lucide")]
lucide::FONT_ASSET_LUCIDE_LUCIDE_REGULAR,
#[cfg(feature = "pack-octicons")]
octicons::FONT_ASSET_OCTICONS_OCTICONS_REGULAR,
#[cfg(all(feature = "pack-octicons", feature = "octicons-tiny"))]
octicons::FONT_ASSET_OCTICONS_OCTICONS_TINY,
#[cfg(feature = "pack-phosphor")]
phosphor::FONT_ASSET_PHOSPHOR_PHOSPHOR_BOLD,
#[cfg(feature = "pack-phosphor")]
phosphor::FONT_ASSET_PHOSPHOR_PHOSPHOR_DUOTONE,
#[cfg(feature = "pack-phosphor")]
phosphor::FONT_ASSET_PHOSPHOR_PHOSPHOR_FILLED,
#[cfg(feature = "pack-phosphor")]
phosphor::FONT_ASSET_PHOSPHOR_PHOSPHOR_LIGHT,
#[cfg(feature = "pack-phosphor")]
phosphor::FONT_ASSET_PHOSPHOR_PHOSPHOR_REGULAR,
#[cfg(feature = "pack-phosphor")]
phosphor::FONT_ASSET_PHOSPHOR_PHOSPHOR_THIN,
#[cfg(feature = "pack-remixicon")]
remixicon::FONT_ASSET_REMIXICON_REMIXICON_REGULAR,
#[cfg(feature = "pack-tabler")]
tabler::FONT_ASSET_TABLER_TABLER_FILLED,
#[cfg(feature = "pack-tabler")]
tabler::FONT_ASSET_TABLER_TABLER_REGULAR,
]
}
#[cfg(any(
feature = "pack-bootstrap",
feature = "pack-carbon",
feature = "pack-devicon",
feature = "pack-feather",
feature = "pack-fluentui",
feature = "pack-heroicons",
feature = "pack-iconoir",
feature = "pack-ionicons",
feature = "pack-lobe",
feature = "pack-lucide",
feature = "pack-octicons",
feature = "pack-phosphor",
feature = "pack-remixicon",
feature = "pack-tabler"
))]
pub fn list(pack: Pack) -> &'static [&'static str] {
match pack {
#[cfg(feature = "pack-bootstrap")]
Pack::Bootstrap => bootstrap::ICON_NAMES,
#[cfg(feature = "pack-carbon")]
Pack::Carbon => carbon::ICON_NAMES,
#[cfg(feature = "pack-devicon")]
Pack::Devicon => devicon::ICON_NAMES,
#[cfg(feature = "pack-feather")]
Pack::Feather => feather::ICON_NAMES,
#[cfg(feature = "pack-fluentui")]
Pack::Fluentui => fluentui::ICON_NAMES,
#[cfg(feature = "pack-heroicons")]
Pack::Heroicons => heroicons::ICON_NAMES,
#[cfg(feature = "pack-iconoir")]
Pack::Iconoir => iconoir::ICON_NAMES,
#[cfg(feature = "pack-ionicons")]
Pack::Ionicons => ionicons::ICON_NAMES,
#[cfg(feature = "pack-lobe")]
Pack::Lobe => lobe::ICON_NAMES,
#[cfg(feature = "pack-lucide")]
Pack::Lucide => lucide::ICON_NAMES,
#[cfg(feature = "pack-octicons")]
Pack::Octicons => octicons::ICON_NAMES,
#[cfg(feature = "pack-phosphor")]
Pack::Phosphor => phosphor::ICON_NAMES,
#[cfg(feature = "pack-remixicon")]
Pack::Remixicon => remixicon::ICON_NAMES,
#[cfg(feature = "pack-tabler")]
Pack::Tabler => tabler::ICON_NAMES,
}
}
#[cfg(not(any(
feature = "pack-bootstrap",
feature = "pack-carbon",
feature = "pack-devicon",
feature = "pack-feather",
feature = "pack-fluentui",
feature = "pack-heroicons",
feature = "pack-iconoir",
feature = "pack-ionicons",
feature = "pack-lobe",
feature = "pack-lucide",
feature = "pack-octicons",
feature = "pack-phosphor",
feature = "pack-remixicon",
feature = "pack-tabler"
)))]
pub fn list(_pack: Pack) -> &'static [&'static str] {
&[]
}
#[cfg(any(
feature = "pack-bootstrap",
feature = "pack-carbon",
feature = "pack-devicon",
feature = "pack-feather",
feature = "pack-fluentui",
feature = "pack-heroicons",
feature = "pack-iconoir",
feature = "pack-ionicons",
feature = "pack-lobe",
feature = "pack-lucide",
feature = "pack-octicons",
feature = "pack-phosphor",
feature = "pack-remixicon",
feature = "pack-tabler"
))]
pub fn try_icon(pack: Pack, name: &str, style: Style, size: Size) -> Result<IconRef, IconError> {
match pack {
#[cfg(feature = "pack-bootstrap")]
Pack::Bootstrap => resolve_icon(
bootstrap::PACK_ID,
name,
style,
size,
bootstrap::icon_available(name),
bootstrap::variant_info(style, size).map(|info| info.family),
bootstrap::icon_codepoint(name, crate::core::VariantKey { style, size }),
),
#[cfg(feature = "pack-carbon")]
Pack::Carbon => resolve_icon(
carbon::PACK_ID,
name,
style,
size,
carbon::icon_available(name),
carbon::variant_info(style, size).map(|info| info.family),
carbon::icon_codepoint(name, crate::core::VariantKey { style, size }),
),
#[cfg(feature = "pack-devicon")]
Pack::Devicon => resolve_icon(
devicon::PACK_ID,
name,
style,
size,
devicon::icon_available(name),
devicon::variant_info(style, size).map(|info| info.family),
devicon::icon_codepoint(name, crate::core::VariantKey { style, size }),
),
#[cfg(feature = "pack-feather")]
Pack::Feather => resolve_icon(
feather::PACK_ID,
name,
style,
size,
feather::icon_available(name),
feather::variant_info(style, size).map(|info| info.family),
feather::icon_codepoint(name, crate::core::VariantKey { style, size }),
),
#[cfg(feature = "pack-fluentui")]
Pack::Fluentui => resolve_icon(
fluentui::PACK_ID,
name,
style,
size,
fluentui::icon_available(name),
fluentui::variant_info(style, size).map(|info| info.family),
fluentui::icon_codepoint(name, crate::core::VariantKey { style, size }),
),
#[cfg(feature = "pack-heroicons")]
Pack::Heroicons => resolve_icon(
heroicons::PACK_ID,
name,
style,
size,
heroicons::icon_available(name),
heroicons::variant_info(style, size).map(|info| info.family),
heroicons::icon_codepoint(name, crate::core::VariantKey { style, size }),
),
#[cfg(feature = "pack-iconoir")]
Pack::Iconoir => resolve_icon(
iconoir::PACK_ID,
name,
style,
size,
iconoir::icon_available(name),
iconoir::variant_info(style, size).map(|info| info.family),
iconoir::icon_codepoint(name, crate::core::VariantKey { style, size }),
),
#[cfg(feature = "pack-ionicons")]
Pack::Ionicons => resolve_icon(
ionicons::PACK_ID,
name,
style,
size,
ionicons::icon_available(name),
ionicons::variant_info(style, size).map(|info| info.family),
ionicons::icon_codepoint(name, crate::core::VariantKey { style, size }),
),
#[cfg(feature = "pack-lobe")]
Pack::Lobe => resolve_icon(
lobe::PACK_ID,
name,
style,
size,
lobe::icon_available(name),
lobe::variant_info(style, size).map(|info| info.family),
lobe::icon_codepoint(name, crate::core::VariantKey { style, size }),
),
#[cfg(feature = "pack-lucide")]
Pack::Lucide => resolve_icon(
lucide::PACK_ID,
name,
style,
size,
lucide::icon_available(name),
lucide::variant_info(style, size).map(|info| info.family),
lucide::icon_codepoint(name, crate::core::VariantKey { style, size }),
),
#[cfg(feature = "pack-octicons")]
Pack::Octicons => resolve_icon(
octicons::PACK_ID,
name,
style,
size,
octicons::icon_available(name),
octicons::variant_info(style, size).map(|info| info.family),
octicons::icon_codepoint(name, crate::core::VariantKey { style, size }),
),
#[cfg(feature = "pack-phosphor")]
Pack::Phosphor => resolve_icon(
phosphor::PACK_ID,
name,
style,
size,
phosphor::icon_available(name),
phosphor::variant_info(style, size).map(|info| info.family),
phosphor::icon_codepoint(name, crate::core::VariantKey { style, size }),
),
#[cfg(feature = "pack-remixicon")]
Pack::Remixicon => resolve_icon(
remixicon::PACK_ID,
name,
style,
size,
remixicon::icon_available(name),
remixicon::variant_info(style, size).map(|info| info.family),
remixicon::icon_codepoint(name, crate::core::VariantKey { style, size }),
),
#[cfg(feature = "pack-tabler")]
Pack::Tabler => resolve_icon(
tabler::PACK_ID,
name,
style,
size,
tabler::icon_available(name),
tabler::variant_info(style, size).map(|info| info.family),
tabler::icon_codepoint(name, crate::core::VariantKey { style, size }),
),
}
}
#[cfg(not(any(
feature = "pack-bootstrap",
feature = "pack-carbon",
feature = "pack-devicon",
feature = "pack-feather",
feature = "pack-fluentui",
feature = "pack-heroicons",
feature = "pack-iconoir",
feature = "pack-ionicons",
feature = "pack-lobe",
feature = "pack-lucide",
feature = "pack-octicons",
feature = "pack-phosphor",
feature = "pack-remixicon",
feature = "pack-tabler"
)))]
pub fn try_icon(
_pack: Pack,
_name: &str,
_style: Style,
_size: Size,
) -> Result<IconRef, IconError> {
Err(IconError::PackDisabled { pack: "none" })
}
#[cfg(any(
feature = "pack-bootstrap",
feature = "pack-carbon",
feature = "pack-devicon",
feature = "pack-feather",
feature = "pack-fluentui",
feature = "pack-heroicons",
feature = "pack-iconoir",
feature = "pack-ionicons",
feature = "pack-lobe",
feature = "pack-lucide",
feature = "pack-octicons",
feature = "pack-phosphor",
feature = "pack-remixicon",
feature = "pack-tabler"
))]
fn resolve_icon(
pack: &'static str,
name: &str,
style: Style,
size: Size,
available: Option<&'static [(Style, Size)]>,
family: Option<&'static str>,
codepoint: Option<u32>,
) -> Result<IconRef, IconError> {
let available = match available {
Some(available) => available,
None => {
return Err(IconError::IconNotFound {
pack,
name: name.to_string(),
});
}
};
if !available.contains(&(style, size)) {
return Err(IconError::VariantUnavailable {
pack,
name: name.to_string(),
requested: (style, size),
available,
});
}
let family = family.expect("Icon variant should have a font family");
let codepoint = codepoint.expect("Icon variant should have a codepoint");
Ok(IconRef { family, codepoint })
}