Skip to content

Fit images to their aspect ratio; app icons on Windows and Linux - #9

Merged
kitlangton merged 1 commit into
devfrom
raster-images
Oct 23, 2026
Merged

kitlangton merged 1 commit into
devfrom
raster-images

Conversation

@kitlangton

Copy link
Copy Markdown
Contributor

What it does

  • El::pixels_fit(&pixels, SurfaceFit::Fit | Fill) draws an image at its own aspect ratio: Fit letterboxes on whole device pixels and rounds the image's own corners, Fill covers the rect and crops the centre. El::pixels still stretches.
  • ImageCache::app_icon now works on Windows (an executable's or .ico's first icon via PrivateExtractIconsW) and Linux (a .desktop entry's Icon= from hicolor, closest size at or above, then scalable SVG via resvg, then pixmaps). Paths without an icon still resolve to Image::error.

How it works

pixels::fit maps the image size and element rect to a draw rect and a uv window; the runtime picks the mip for the uncropped drawn size. No shader change.

Risk

Apps that relied on app_icon erroring on Windows/Linux now draw icons. Adds resvg (no default features) as a Linux-only dependency.

Proof

  • fit_letterboxes_on_whole_pixels_and_fill_crops_the_centre, gpu_pixels_fit_letterboxes_and_fill_crops (headless GPU readback), desktop_entries_resolve_the_closest_theme_size_then_scalable_then_pixmaps, and a Windows notepad.exe icon test.
  • cargo check --target x86_64-pc-windows-msvc passes.

…nd Linux

El::pixels_fit letterboxes (SurfaceFit::Fit) or crops (Fill) an image inside
its rect. ImageCache::app_icon now reads an executable's first icon on Windows
and a .desktop entry's hicolor or pixmaps icon (PNG or SVG) on Linux.
@kitlangton
kitlangton merged commit 654c4a2 into dev Oct 23, 2026
@kitlangton
kitlangton deleted the raster-images branch October 30, 2026 13:16
Hona added a commit that referenced this pull request Nov 12, 2026
… fields and fonts (#725)

- El::isolate and rune::text::ltr_units: runs that keep their own order (paths, URLs, calls,
  flags, file names, references, signed numbers); static pills are Auto isolates.
- Kit Markdown: per-block direction (paragraphs, headings, one per list, quotes, tables), code
  and diffs left to right, neutral blocks follow the block before, Markdown::dir_tentative.
- dir(Auto) with no strong character takes its parent's direction; by-paragraph lines with none
  follow the line before; an empty right-to-left line's caret at its right; Left/Right collapse
  a selection to the end drawn that way; truncate_fade fades the text's own end.
- Fonts: Arabic comma after Latin no longer tofu; Windows script fallbacks load whole families;
  monospace Arabic and Hebrew (Courier New, DejaVu Sans Mono) in code.
- vendor/parley_engine: UAX #9 L1 at a paragraph's end; BidiTest.txt 770,241/770,241.
Hona added a commit that referenced this pull request Nov 12, 2026
Three caches in Rune's vendored parley_engine (vendor/parley_engine.patch, beside the UAX #9 L1
fix), each for work shaping repeated from identical inputs:

- Analyzer keeps the ICU line and word segmenters it made (analysis.rs Segmenters). Making one
  looked up its rules and, with complex-scripts, loaded the dictionaries, for every text. The
  segmenters are 'static and Copy, so a kept one is the value a new one would be.
- Shaper keeps each run's font metrics per font instance and size (run_metrics_cache, an LRU of
  16 beside its shaper caches), instead of skrifa::Metrics::new for every run.
- FontMetrics::from_font_instance, which parley's style metrics call once per style per layout,
  keeps its answers per thread (64 entries, keyed by blob id, index, synthesis, size and
  variations).

Proof, every layout of 7 screens x 11 UI languages (en ar he ja zh ko th km my hi ru; 5,933
texts), a digest of each finished layout (line boxes, runs, fonts, sizes, coordinates, every
glyph's id and position, clusters, inline boxes): 0 differ, each cache alone and together.
Warm cost per Parley build, the three variants interleaved in one batch: 25.8 us a text -> 24.4
(segmenters) -> 22.1 (and metrics), 14.3% less. A returning user's launch (tabs10, release,
visible desktop, n=9): the texts shaped between the first frame and live content 9,433 -> 7,254
us p50, those before the first frame 1,897 -> 1,689.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant