1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-27 07:03:14 -04:00
Commit Graph

4280 Commits

Author SHA1 Message Date
Emil Ernerfeldt
cc560acc2b cleanup 2026-03-28 17:13:42 +01:00
Emil Ernerfeldt
cb6e91204a cleanup 2026-03-28 16:39:20 +01:00
Emil Ernerfeldt
b03d81fa4f Simplify layout_section 2026-03-28 16:31:20 +01:00
Emil Ernerfeldt
23ae8fdacb Move layout-related code into text_layout.rs 2026-03-28 16:26:50 +01:00
Emil Ernerfeldt
c340d2f139 Deduplicate code 2026-03-28 16:17:25 +01:00
Emil Ernerfeldt
2b275d4055 Sort dependencies 2026-03-28 15:41:25 +01:00
Emil Ernerfeldt
e080e0d5de Remove the old pair_kerning path 2026-03-28 15:31:06 +01:00
gcailly
bde3294423 Update Bézier Curve snapshot after harfrust integration 2026-03-28 15:11:34 +01:00
gcailly
c7ce4eeb6f Bump vello_cpu 0.0.6 → 0.0.7 and update snapshots
Update vello_cpu to 0.0.7, which produces slightly different
rasterization output. All snapshot tests have been regenerated.

Note: skrifa cannot be bumped to 0.41.0 in this PR because it
pulls in read-fonts 0.38, while harfrust 0.5.2 depends on
read-fonts 0.37. The two FontRef types are incompatible.
2026-03-28 14:15:57 +01:00
gcailly
b2d549c78c Refactor allocate_glyph_by_id to use ShapedGlyph struct
Replace 5 loose parameters with a ShapedGlyph struct, removing the
need for #[expect(clippy::too_many_arguments)].
2026-03-27 13:19:16 +01:00
gcailly
210b54ad82 Fix tab character advance width after harfrust shaping
The text shaper doesn't handle tab stops — override the advance width
to TAB_SIZE × space width in layout_shaped_run, matching the previous
character-by-character behavior.
2026-03-27 12:23:37 +01:00
gcailly
4a37a07de7 Update should_wait_for_images snapshot from CI 2026-03-26 22:53:28 +01:00
gcailly
fecea1804c Update Bézier Curve snapshot from CI 2026-03-26 22:47:35 +01:00
gcailly
3f65ee8624 Force-update all remaining snapshots (Windows-generated)
These will differ from macOS CI — the next CI run will produce
.new.png for ALL of them at once, allowing a single bulk fix.
2026-03-26 22:40:40 +01:00
gcailly
65e37c90cf Update layout and visuals snapshots from CI
Text shaping changes widget widths by ~1px on macOS,
causing image size mismatches (e.g. 850->849px).
24 snapshots updated from CI run artifacts.
2026-03-26 22:29:34 +01:00
gcailly
d9b4778d21 Update sides snapshots from CI artifacts
These were never updated on our branch. Text shaping changes
the rendered output for text-heavy side containers.
Local UPDATE_SNAPSHOTS=1 confirms only sides/ and rotated/
snapshots needed updating — layout/, visuals/ etc. pass as-is.
2026-03-26 21:03:27 +01:00
gcailly
9ce6fa0162 Fix rotated_rect and rotated_ellipse snapshots
These were incorrectly overwritten by commit 50d820ce.
Restored to the correct CI-generated versions.
2026-03-26 19:20:44 +01:00
gcailly
04da44032f Update test_atoms snapshots (lost during earlier reset) 2026-03-26 18:37:56 +01:00
gcailly
61cd937f23 Fix text_edit_delay snapshots (lost during earlier reset) 2026-03-26 18:27:09 +01:00
gcailly
50d820ceaa Update sides and remaining egui_tests snapshots 2026-03-26 18:19:53 +01:00
gcailly
2e91a881f5 Update rotated_rect and rotated_ellipse snapshots 2026-03-26 18:11:35 +01:00
gcailly
37372f9e04 Update all remaining egui_tests snapshots 2026-03-26 18:01:31 +01:00
gcailly
d712e63351 Update text_edit_delay snapshots 2026-03-26 17:48:26 +01:00
gcailly
f3d60d32da Update masking and tooltip snapshots 2026-03-26 17:02:54 +01:00
gcailly
8b5dafbd61 Update menu snapshots (text shaping affects menu layout) 2026-03-26 16:45:32 +01:00
gcailly
24154bff10 Update image_kerning snapshots (GPOS kerning changes positioning) 2026-03-26 16:37:39 +01:00
gcailly
7bec43f0f7 Update snapshot tests after merge with v0.34.0
Regenerated from macOS CI run #23602213577.
56 snapshots updated to reflect both text shaping changes
and v0.34.0 visual updates (scroll fade, etc.).
2026-03-26 16:29:01 +01:00
gcailly
4ec3260842 Merge main (v0.34.0) into feat/harfrust-text-shaping 2026-03-26 16:15:40 +01:00
gcailly
1251c6df80 Update snapshot tests from CI artifacts
Text shaping changes glyph positioning, which affects rendered output.
Snapshots regenerated from macOS CI run #23601039294.
2026-03-26 16:11:37 +01:00
gcailly
8a88f7c6c4 Apply cargo fmt formatting fixes 2026-03-26 15:19:19 +01:00
gcailly
c5cb18f769 Clean up docstrings: GlyphAllocation.id, shaper y_offset, segment_into_runs
- Update GlyphAllocation.id docstring to reflect its actual usage
  (overflow character kerning via legacy kern table)
- Replace planning artifact comment on shaper y_offset caching
- Document script-mixing limitation in segment_into_runs
2026-03-26 15:03:03 +01:00
gcailly
96b370e0aa Fix NOTDEF fallback using wrong font face and reset cluster tracking between runs
Two bugs in layout_shaped_run:

1. When the shaper returned NOTDEF, glyph_info was resolved via font
   fallback but the returned FontFaceKey was discarded. The glyph was
   then allocated with run.font_key (the face that couldn't render it),
   causing the glyph to silently render as invisible. Now uses the
   correct fallback font face and its metrics for both allocation and
   Glyph font_face_height/font_face_ascent.

2. prev_cluster was not reset between runs. Since harfrust cluster
   values are byte offsets within each run's text, comparing clusters
   across runs is semantically wrong and could skip extra_letter_spacing
   at run boundaries (e.g. when both runs start at cluster 0).
2026-03-26 12:27:11 +01:00
Lucas Meurer
82a578e58c Release 0.34.0 - More Ui, less Context (#8028)
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2026-03-26 12:15:41 +01:00
Alexander Schütz
1c9f74b8bd Add raw key methods to TypeIdMap (#8007)
This PR fundamentally solves the same problem as
https://github.com/emilk/egui/pull/5827 just implemented with a lot less
ambition and api surface on my end. It contains the bare minimum amount
of changes that I need in order to be able to solve my problem.

My Problem:
I am still suffering from the problem that the TypeIdMap blows up over a
very long time when using my application. (The user generally never
turns off the application, it is intended to be just kept running
forever, some users also never restart their computers) My application
generates a lot of content dynamically so it may for some time display
widgets with a certain set of TypeId's + Id's later hiding them. Some of
the elements that were hidden may turn visible again once an external
event occurs, some may forever be discarded.
I do know myself when which sections of the UI have to be purged because
they will never become visible again, so this PR contains the minimum
amount of necessary functions that allow me to implement this
housekeeping logic on my end.

The existing facilities are insufficient to handle this as the type T
which the TypeId and the hash is derived from are sometimes pub(crate)
privates of widget subcrates or even pub(crate) of egui internals
itself, so its impossible to manually remove those from the TypeIdMap
the only build-in method to remove them is to call "clear" on the
TypeIdMap, however that gets rid of everything, even the elements that
are still shown and should still be in the TypeIdMap.

If the changes in this PR are agreeable to you and you want me to write
unit test for the 4 functions that I have added then tell me and I will
write the tests for you.

If you need anything else changed please tell me.

I ran cargo clippy and cargo fmt, but your check.sh does not work on my
computer.

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2026-03-26 08:03:39 +01:00
gcailly
fc9ac39a6b Fix duplicated docstring and symmetrize BEGINNING_OF_TEXT flag
Remove copy-pasted docstring on segment_into_runs, and set
BEGINNING_OF_TEXT on the first run of every paragraph segment
(not just the first segment) to match END_OF_TEXT behavior.
2026-03-25 20:45:08 +01:00
gcailly
7020573def Add test_gpos_kerning to verify OpenType GPOS kerning
Verify that letter pairs like AV, VA, AT are measurably tighter
when laid out together than the sum of their individual widths.
This test fails without harfrust text shaping (kern adjustment ≈ 0)
and passes with it (kern adjustment > 0.5px).
2026-03-25 19:58:56 +01:00
Lucas Meurer
f1236f1c61 Fix missing objc2-app-kit features (#8025)
Was missing some features
2026-03-25 19:00:28 +01:00
gcailly
6b60ca1353 Integrate harfrust for OpenType text shaping in epaint
Replace the character-by-character glyph lookup in `layout_section()`
with a proper text shaping pipeline using harfrust (a Rust port of
HarfBuzz). This enables GPOS kerning, ligatures (fi, fl), and correct
positioning of combining diacritical marks.

The shaping pipeline works as follows:
1. Split text into font-fallback runs (grapheme-cluster-aware)
2. Shape each run with harfrust (GSUB + GPOS)
3. Allocate and position glyphs from the shaping output

Key changes:
- Add harfrust, unicode-segmentation, unicode-general-category deps
- Cache ShaperData on FontFace (parsed GSUB/GPOS tables)
- Add shape_text() with buffer flags and variable font support
- Add allocate_glyph_by_id() for shaper-produced glyph IDs
- Recycle harfrust UnicodeBuffer across layout calls
- Handle NOTDEF fallback (combining marks via unicode-general-category)

Addresses #2517.
2026-03-25 16:00:59 +01:00
Emil Ernerfeldt
048f8ccd2a Tweak ScrollArea fade effect (#8023)
* Follow-up to https://github.com/emilk/egui/pull/8018
2026-03-25 15:44:41 +01:00
eason
02ff040b74 Fix: Visuals::interact_cursor support in Button (#7986)
Closes #7947

## Problem

`Visuals::interact_cursor` stopped working for buttons after the
`AtomLayout` refactor in commit 6eb7bb6e. Setting `interact_cursor` to
e.g. `CursorIcon::PointingHand` no longer changes the cursor when
hovering over a `Button`.

## Root Cause

When `Button` was rewritten to use `AtomLayout` in #5830, the
cursor-override block at the end of the old `Button::ui` was not carried
over to the new `Button::atom_ui` method.

The old code had:
```rust
if let Some(cursor) = ui.visuals().interact_cursor {
    if response.hovered() {
        ui.ctx().set_cursor_icon(cursor);
    }
}
```

This was the only place `interact_cursor` was checked, so the setting
became entirely non-functional.

## Fix

Re-add the same `interact_cursor` check in `Button::atom_ui`, right
after painting and before `widget_info`, matching the original behavior.

---------

Co-authored-by: easonysliu <easonysliu@tencent.com>
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2026-03-25 14:48:22 +01:00
Lucas Meurer
d232be740f Fix bug in ui stack color blending (#8021)
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2026-03-25 13:40:54 +01:00
Emil Ernerfeldt
0b0c561a81 Fade out the edges of ScrollAreas (#8018)
## Before:
<img width="381" height="307" alt="image"
src="https://github.com/user-attachments/assets/0528ae2a-44bf-4d9e-89a4-c3f4ab438eb2"
/>

It is very hard here to realize this is a scrollable area

## After
<img width="383" height="310" alt="image"
src="https://github.com/user-attachments/assets/9e0ee6de-8b96-4e5c-a505-f57977010990"
/>

The fade at the bottom tells the user they should try scrolling.

You can turn if off with `style.spacing.scroll.fade.enabled`
2026-03-25 12:53:00 +01:00
Lucas Meurer
845b8c2f09 Make egui::IdSet public (#8019)
It wasn't public before
2026-03-25 12:46:49 +01:00
Emil Ernerfeldt
e8f04292a9 Add UiStack::bg_color (#8020)
This lets you ask for the background color of a ui with
`ui.stack().bg_color()`
2026-03-25 12:41:35 +01:00
Emil Ernerfeldt
0887b54c93 Add eframe::WindowChromeMetrics (macOS only) (#8015)
When using `egui::ViewportBuilder::with_fullsize_content_view` one must
be careful not to paint anything where the "traffic light" buttons are:

<img width="87" height="47" alt="image"
src="https://github.com/user-attachments/assets/0e878c8e-7141-4fed-bbc8-4d542ddb5251"
/>

`eframe::WindowChromeMetrics` helps you with that!
2026-03-25 10:54:17 +01:00
Emil Ernerfeldt
bfbf23b4fb Add Ui::is_tooltip (#8016) 2026-03-25 10:11:30 +01:00
Emil Ernerfeldt
12b5045633 Add Context::time (#8017) 2026-03-25 10:11:21 +01:00
Emil Ernerfeldt
2ccc8e8bab Add Context::text_edit_focused (#8014) 2026-03-25 09:21:39 +01:00
Lucas Meurer
4feac890aa Respect WidgetVisuals::expansion in TextEdit (#8013)
This broke in #7587

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2026-03-24 17:33:20 +01:00
Lucas Meurer
0d065f9e78 Add Response::parent_id and improve warn_if_rect_changes_id (#8010)
Reduces the amount of false positives

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2026-03-24 16:22:44 +01:00