Repository navigation
feat(image): add Linux freedesktop icon-theme lookup, ImageCache::themed_icon, and Image::is_not_found - #1979
Merged
Merged
Conversation
…med_icon, and Image::is_not_found
Hona
force-pushed
the
feat/21-freedesktop-themed-icons
branch
from
November 24, 2026 16:03
578bf23 to
3562f6f
Compare
This was referenced Nov 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #21
Implements full Linux Freedesktop Icon Theme Specification lookup in
crates/rune-image/src/freedesktop.rs, exposesImageCache::themed_icon,rune::image::themed_icon_rgba, andImage::is_not_found(), upgrades Linux.desktopresolution inapp_icon/app_icon_scaled, and wires themed icon resolution withis_not_found()fallback intoexamples/launcher.Outside answer followed
https://specifications.freedesktop.org/icon-theme-spec/latest/):index.theme([Icon Theme]Inherits,Directories,ScaledDirectories; per-directorySize,Scale,Type=Fixed | Scalable | Threshold,MinSize,MaxSize,Threshold,Context, with spec defaultsScale=1,Type=Threshold,Threshold=2),DirectoryMatchesSize,DirectorySizeDistance, breadth-firstInheritsending athicolorthenpixmaps, and$HOME/.icons+$XDG_DATA_HOME/icons+$XDG_DATA_DIRS/icons.settings.ini([Settings] gtk-icon-theme-name), GTK 2.gtkrc-2.0, and KDEkdeglobals([Icons] Theme) respectingXDG_CURRENT_DESKTOPfor KDE vs GTK precedence, falling back toAdwaita→hicolor. Fallbacknamesare tried most-specific first across the theme chain (matching GTK 4gtk_icon_theme_lookup_icon/GThemedIcon).API & usage
ImageCache::themed_icon(&self, names: &[&str], theme: Option<&str>, size_pt: f32, scale: f32) -> Imagerune::image::themed_icon_rgba(names: &[&str], theme: Option<&str>, px: u32, scale: u32) -> Result<Option<(u32, u32, Vec<u8>)>, ImageError>Image::is_not_found(&self) -> bool(backed by an internal flag alongsideImageError(pub String), keepingImageErrorunchanged)Key changes
crates/rune-image/src/freedesktop.rs:index.themeparser (rejecting path traversal),DirectoryMatchesSize/DirectorySizeDistanceselection with downscale tie-breaking, BFSInheritswith cycle protection, GTK/KDE theme detection, bounded LRUThemeCache(cap 64 themes and 4 MiB, I/O outside lock), and bounded regular-file/raster decoding.crates/rune-image/src/app_icon.rs,crates/rune-image/src/lib.rs: upgraded Linux.desktopapp_icon/app_icon_scaledto the full theme chain; addedDecodeFailuresoImage::is_not_found()separates missing icons/files from corrupt-file decode errors.crates/rune-image/src/freedesktop_tests.rs,crates/rune-image/src/tests.rs: cross-platform fixture tests covering spec parsing, size/scale/threshold selection, BFS inheritance and cycles, multi-context fallback lists, GTK/KDE detection, PNG/SVG rasterization,is_not_found()vs corrupt files, and 64-theme/byte-cap LRU eviction.examples/launcher/src/main.rs,examples/README.md,crates/rune/README.md,changelog/unreleased/2026-11-25-freedesktop-themed-icons.md: themed icons +is_not_found()monogram fallback and--scene themed-iconsinlauncher, docs, and changelog.Verification
cargo test -p rune-image(74 unit + 8 doc),cargo test -p rune-image --no-default-features(67 unit + 8 doc),cargo check -p rune -p rune-kit -p launcher,cargo test -p rune --lib render::image_tests(8),el::pills(10),--test pixels_streaming(3),cargo test -p launcher(1),cargo check-wasm,cargo check-webgl,scripts/file-size.sh.cargo test -p rune-image(73 unit + 8 doc).cargo test -p rune-image(75 unit + 8 doc).check -p rune -p rune-kit -p launcheron Linux/macOS.