Commit Graph
364 Commits
Author SHA1 Message Date
Emil Ernerfeldt db63b6d176 Update some crates (#8746) 2026-10-19 07:54:29 +00:00
Emil Ernerfeldt 37119162c7 Make the internals of ColorImage private (#8714)
`ColorImage` fields are now private. Use `resolution()`, `pixels()`,
`pixels_mut()`, and `source_size()` instead.

Also renames `size` to `resolution` in several texture-related APIs
(`ImageData`, `TextureHandle`, `TextureMeta`, `TextureAtlas`,
`Fonts::font_image_resolution`).

`ColorImage::new` now panics if `width * height != pixels.len()`.

## Motivation
A) Make `ColorImage` always valid
B) Stop confusing using the confusing word `size` where `resolution` is
better
2026-10-19 09:22:26 +02:00
Lucas MeurerandClaude Opus 5.5 86099aca12 Release 0.37.0 - Color emojis (#8725)
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-15 17:52:45 +02:00
Lucas MeurerandClaude Opus 5.5 eee824c0ac Rename egui_system_fonts to egui_system_font_provider (#8724)
The name egui_system_fonts is already taken on crates.io. The new name
matches the crate's `SystemFontProvider` type.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-15 17:24:04 +02:00
Vitaly Kravchenko 43743e2c32 Make Margin::sum const (#8711)
Make `Margin::sum` usable in constant initializers.
2026-10-14 10:10:12 +02:00
Emil Ernerfeldt dc28236466 Enable clippy::std_instead_of_alloc in core egui crates (#8702)
* Part of https://github.com/emilk/egui/issues/5735

Enables the `clippy::std_instead_of_alloc` lint in `egui`, `emath`,
`epaint`, `ecolor`, `epaint_default_fonts` and `egui_extras`, and fixes
all the warnings (`std::sync::Arc` → `alloc::sync::Arc`, etc). Each
crate gets `extern crate alloc;` where needed.

This is enabled per-crate (via `#![warn(…)]` in `lib.rs`) rather than
workspace-wide, to avoid sprinkling `extern crate alloc;` across every
example and test.
2026-10-12 07:41:15 +00:00
Emil Ernerfeldt b148f131ca Add CCursor::end_of_str and CCursorRange::select_all_str (#8680)
`CCursor::new` was a bit of a foot-gun: it had no docstring, and it's
easy to accidentally pass it a byte offset instead of a character
offset.

* Document that `CCursor::new` takes a character offset, NOT a byte
offset
* Add `CCursor::end_of_str(text)`: a cursor after the last character of
`text` (i.e. `text.chars().count()`)
* Add `CCursorRange::select_all_str(text)`: select all of `text`
* Use these in `DragValue` and the `TextEdit` demo

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-10-08 14:25:31 +00:00
rustbasicandEmil Ernerfeldt 3dc897b6f0 Fix: TextFormat::valign not applied correctly with custom line_height (#8030)
Fix: TextFormat::valign not applied correctly with custom line_height

This PR resolves an issue where `TextFormat::valign` (vertical
alignment) was not correctly applied when `TextFormat::line_height` was
explicitly set, especially when it matched the `max_row_height`.

**Problem:**
The vertical positioning logic in `galley_from_rows()` calculated
`valign` based on the difference `(max_row_height - glyph.line_height)`.
When `glyph.line_height` was explicitly set to a larger value (e.g.,
`row_height + 6.0`) and became the `max_row_height` for the row, this
difference became zero. As a result, `valign` had no effect, and glyphs
consistently appeared top-aligned within the allocated line space.

**Solution:**
The `valign` calculation is now updated to use `glyph.font_face_height`
instead of `glyph.line_height`. This correctly applies vertical
alignment to the glyph's actual visual content within the
`max_row_height`, ensuring `Align::Center` and `Align::Max` (Bottom)
settings function as intended for customized line heights.

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2026-10-06 07:17:48 +00:00
Oscar GustafssonandEmil Ernerfeldt e1e2a5c46b Optimize CubicBezierShape::find_cross_t (#8413)
<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/main/CONTRIBUTING.md)
before opening a Pull Request!

* Keep your PR:s small and focused.
* The PR title is what ends up in the changelog, so make it descriptive!
* If applicable, add a screenshot or gif.
* If it is a non-trivial addition, consider adding a demo for it to
`egui_demo_lib`, or a new example.
* Do NOT open PR:s from your `master` branch, as that makes it hard for
maintainers to test and add commits to your PR.
* Remember to run `cargo fmt` and `cargo clippy`.
* Open the PR as a draft until you have self-reviewed it and run
`./scripts/check.sh`.
* When you have addressed a PR comment, mark it as resolved.

Please be patient! I will review your PR, but my time is limited!
-->

* [x] I have followed the instructions in the PR template

Factor out common constants to reduce the number of multiplications.
During checking the results (comparing my hand-optimized code with the
previous version using AI), the AI pointed out that d is always 0, so I
removed that as well.

It is possible to rewrite the equations a bit further, like: 
`let p = (a / c - h * h);`
but not sure that it will be beneficial (on superscalar machines) due to
introduced data dependencies.

I also have a doubt what will happen when p = 0. I think it may have to
be special cased as p = 0 => r = 0 => division by zero (before taking
acos).

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2026-10-06 07:06:59 +00:00
Ted LandClaude Opus 5.5 a6a2d6c4b4 Don't start a CJK row with full-width closing punctuation (#8658)
* Closes <https://github.com/emilk/egui/issues/8659>
* [x] I have followed the instructions in the PR template

`is_cjk_break_allowed` keeps closing marks off the start of a row, but
it only lists the ASCII and Japanese forms. Chinese writes full-width
ones, so wrapped Chinese text could start a row with `,`. This adds the
full-width forms (`!%),.:;?]`) and the closing quotes and ellipsis
Chinese uses (`” ’ …`), from [Wikipedia's
list](https://en.wikipedia.org/wiki/Line_breaking_rules_in_East_Asian_languages#Characters_not_permitted_on_the_start_of_a_line),
with a test that wraps a Chinese line at every few-glyph width (it fails
without the change).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-05 18:45:02 +01:00
Oscar GustafssonandEmil Ernerfeldt 2078a31e09 Replace constant divisions with constant multiplications (#8412)
<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/main/CONTRIBUTING.md)
before opening a Pull Request!

* Keep your PR:s small and focused.
* The PR title is what ends up in the changelog, so make it descriptive!
* If applicable, add a screenshot or gif.
* If it is a non-trivial addition, consider adding a demo for it to
`egui_demo_lib`, or a new example.
* Do NOT open PR:s from your `master` branch, as that makes it hard for
maintainers to test and add commits to your PR.
* Remember to run `cargo fmt` and `cargo clippy`.
* Open the PR as a draft until you have self-reviewed it and run
`./scripts/check.sh`.
* When you have addressed a PR comment, mark it as resolved.

Please be patient! I will review your PR, but my time is limited!
-->

* [x] I have followed the instructions in the PR template

Compiler optimization will replace these later on, but when building
without optimization they will (most often) stay divisions and divisions
are clearly slower than multiplications.

Note that the `/ 2.5` replacement is not bit-exact (since 0.4 cannot be
represented exactly, but 2.5 can), but my guess is that the
approximation is good enough. The others should be bit-exact.

(Division by 2 for unsigned numbers will be replaced to >>1 earlier in
the compile chain, so no point in doing the same there.)

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2026-10-05 12:44:07 +00:00
Emil ErnerfeldtandClaude Fable 5.1 6b420bc1b1 Replace #[test] Send + Sync assertions with compile-time const asserts (#8649)
This ensures they hold on wasm32 too

* See https://github.com/emilk/egui/pull/8638

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-29 17:11:39 +00:00
Lucas MeurerandClaude Opus 5 ab7d768a80 Allow transforming after shapes were tessellated and rounded (#8587)
Via a new `TransformedShape`. When the transform is applied before
rounding during an animation, it introduces a ugly snap once the
transform ends:


https://github.com/user-attachments/assets/1e75cd21-4bc4-4869-b3fa-cde749991518

When the transform is applied after rounding it looks way smoother:


https://github.com/user-attachments/assets/ccba1562-66dc-4b93-b187-53928510c0b8

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-24 11:02:47 +00:00
Emil ErnerfeldtandCopilot Autofix powered by AI a55f23a1ec Add BandShape (#8476)
Add `BandShape` to epaint, supporting and varying width band along some
direction.

This can be useful in egui_plot, e.g. for filling the area under a
curve, or for visualizing a audio waveform, for instance.

The band has feathering for the fill, plus an optional stroke that is
just drawn on top of the fill.

This solves a small subset of non-convex polygons (since the general
solution is quite difficult, at least if you want feathered edges).

<img width="493" height="180" alt="Screenshot 2026-09-01 at 20 56 33"
src="https://github.com/user-attachments/assets/f79ae9bc-3512-4c87-b166-d1240a8dd3e4"
/>

Includes an interactive waveform demo and alpha screenshot coverage.

Related work:

- https://github.com/emilk/egui/issues/513
- https://github.com/emilk/egui_plot/pull/260

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-09-22 12:27:54 +02:00
rustbasicandEmil Ernerfeldt 06921cda05 [performance] Avoid cross-viewport GalleyCache eviction (#8528)
[performance] Avoid cross-viewport GalleyCache eviction

This changes `Fonts` to keep `GalleyCache` entries partitioned by
viewport.

Previously, multiple viewports shared one galley cache. Since each
viewport flushes the cache at the start of its pass, root and child
viewports could repeatedly evict each other's text layouts.

As viewport text workload grows, this can force repeated layout of large
text contents and cause severe performance degradation, with the frame
rate dropping below 10 FPS in some cases.

Font data and the texture atlas remain shared. Only layout caches are
separated by an opaque viewport namespace.

* Closes #5249 
* Related #5836
* Related #7885 
* Related #8284
* Closes #8419

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2026-09-22 10:13:31 +00:00
Emil ErnerfeldtandClaude Fable 5.1 4146d6366a Apply font changes right away while no text has been laid out this pass (#8609)
Generalizes #8602 from "no font loaded yet" to "nothing laid out yet
this pass": any font, provider, rasterizer or glyph-policy change made
before the first text of a pass takes effect in that pass, since nothing
is laid out with the old fonts.

#8602 missed the case where `default_fonts` is on: an app that installs
its own fonts during its first pass then laid that pass out with the
bundled fonts, and under `MissingGlyphPolicy::Panic` any glyph they lack
(Rerun's ⏎, on a Linux CI box with no system fonts) panics. New
`Fonts::used_since_begin_pass` is what the check reads.

Written by Claude (an LLM) for @emilk.

* [x] I have followed the instructions in the PR template

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-21 15:07:42 +02:00
Emil ErnerfeldtandClaude Fable 5.1 25f0cf491e Draw tofu for families without fonts, and add MissingGlyphPolicy (panics by default in egui_kittest) (#8601)
A font family with no font at all used to lay out to an *empty galley*:
the run had no face to shape with, so it was dropped.
`Galley::clamp_cursor` on that empty galley returns 0, so a `TextEdit`
lost its cursor the frame after typing — text stayed, cursor jumped to
0, and e.g. completion popups never opened. Found in rerun's tests after
dropping `default_fonts`, where nothing installed a font for the bare
kittest harness.

### Changes
* epaint: a family without fonts now lays out **one synthetic tofu box
per grapheme cluster**, with metrics derived from the font size.
`glyphs.len() == char_count` and non-zero row heights hold even with no
font.
* epaint: new `MissingGlyphPolicy { Tofu, Panic }` on `Fonts`, consulted
only after every font, `FontProvider` and `GlyphRasterizer` had its
turn. Control characters (`\t`, `\n`, …) never panic, since fonts have
no glyphs for them. The panic names the character, the family and the
installed fonts.
* egui: `Context::set_missing_glyph_policy` / `missing_glyph_policy`.
* egui_kittest: **panics on a missing glyph by default**, since tofu in
a snapshot is easy to miss. Opt out with
`HarnessBuilder::allow_missing_glyphs()`. One demo test needed it (the
emoji completion popup lists emoji the bundled fonts lack).

Top: with fonts, U+10FFFD drawn with Ubuntu's `.notdef`. Bottom: the
same UI with `FontDefinitions::empty()`, all synthetic tofu (3× zoom):

<picture>
<img
src="https://static.rerun.io/tofu_cmp/1c2a567a1f53c301897e716452974a0b6fbc8e12/full.png"
alt="">
<source media="(max-width: 480px)"
srcset="https://static.rerun.io/tofu_cmp/1c2a567a1f53c301897e716452974a0b6fbc8e12/480w.png">
<source media="(max-width: 768px)"
srcset="https://static.rerun.io/tofu_cmp/1c2a567a1f53c301897e716452974a0b6fbc8e12/768w.png">
</picture>

Written by Claude (LLM) together with @emilk.

* [x] I have followed the instructions in the PR template

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-21 13:03:24 +02:00
Emil ErnerfeldtandClaude Fable 5.1 9d7fee57e0 Make Context::add_glyph_rasterizer idempotent (#8600)
`Context::add_glyph_rasterizer` appended a rasterizer and requested a
repaint on every call. Calling it from a setup path that runs each frame
piled up duplicates and kept the UI repainting forever (we hit this in
rerun's tests, where `apply_style_and_install_loaders` runs every frame
and the harness never settled).

* `GlyphRasterizer::new` now takes a mandatory `key`: adding a
rasterizer whose key is already installed is a no-op.
* `Context`/`Fonts`/`FontsImpl::add_glyph_rasterizer` only reload fonts,
clear caches and request a repaint when something actually changed.
`Fonts::add_glyph_rasterizer` returns whether it did.
* `SvgGlyph::into_rasterizer` is keyed by cluster, the web canvas
rasterizer by a fixed name.

Written by an LLM (Claude) together with @emilk.

* [x] I have followed the instructions in the PR template

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-21 10:36:40 +00:00
Emil ErnerfeldtandClaude Opus 5 523152aaa8 ⚠️ Remove default_fonts from default features (#8583)
Remove `default_fonts` from the list of default features of `egui` and
`epaint`, but keep it for `eframe`.

This is so that 3rd party egui crates don't accidentally force the
`default_fonts` feature on all upstream users.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-17 14:14:26 +02:00
Emil ErnerfeldtandClaude Fable 5.1 24c6061a58 Allow multiple GlyphRasterizers, with priority over installed fonts (#8545)
`GlyphRasterizer` now has a `FontPriority`:

* `FontPriority::Highest`: asked about every cluster, before any font.
Use it to override how specific glyphs looks
* `FontPriority::Lowest` (default): a fallback, only asked about
clusters no installed font (or `FontProvider`) has. Same as before.

Several rasterizers can be installed; within a tier they are asked in
order, and the first `Some` wins.

```rust
ctx.add_glyph_rasterizer(
    egui::GlyphRasterizer::new(|request| (request.cluster == "…").then(|| my_ellipsis(request)))
        .with_priority(egui::FontPriority::Highest),
);
```

API changes (all unreleased): `Context::set_glyph_rasterizer(Option)` →
`add_glyph_rasterizer` / `set_glyph_rasterizers(Vec)`, same on
`epaint::Fonts`.

Follow-up to:
* https://github.com/emilk/egui/pull/8512

* [x] I have followed the instructions in the PR template

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-10 13:09:13 +02:00
Lucas MeurerandClaude Opus 5 9396036534 Paint SubMenuButton arrow as a triangle instead of a glyph (#8525)
Eguis built in widgets should work right even if there are no
default/system fonts. This renders the submenubutton triangle with
epaint so it will always look right and isn't system-font dependent.

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-10 12:08:47 +02:00
7053d3917a Merge 0.36.2 changelog (#8533)
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-08 15:29:48 +00:00
Emil ErnerfeldtandClaude Fable 5.1 f2de65f636 Render any glyph and colored emoji on native 🚀 (#8512)
Add full emoji support to eframe on native! Also supports any glyph that
your system fonts support.

Test string: ✨ We support ไทย, 한국어, and 🦀 🚀 🤖/🦾/📷/🎞️

Chain, in order, all merged into `emilk/emojis`:

* https://github.com/emilk/egui/pull/8491
* https://github.com/emilk/egui/pull/8492
* https://github.com/emilk/egui/pull/8493
* https://github.com/emilk/egui/pull/8508
* https://github.com/emilk/egui/pull/8509
* https://github.com/emilk/egui/pull/8510
* https://github.com/emilk/egui/pull/8511

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-06 08:27:50 +02:00
Emil ErnerfeldtandClaude Fable 5.1 e39e793d5c Remove the Font borrow-bag; put its methods on FontsImpl (#8504)
`Font<'a>` was a hand-rolled split borrow of every field of `FontsImpl`,
and it grew a new `&'a mut` for each new feature. `text_layout` now
calls `FontsImpl` directly (`resolve_face`, `glyph_info`,
`allocate_glyph`, `rasterize_cluster`, …) with a cheap `FamilyKey` index
instead of re-hashing the `FontFamily` per glyph.

`font.rs` is renamed to `font_face.rs`, since only `FontFace` is left in
it. `FontsView::characters` replaces `f.fonts.font(family).characters()`
in the font book demo.

`FontsImpl` and `epaint::text::layout` are now crate-private: nothing
outside `epaint` used them, and `Fonts` / `FontsView` cover the public
API. The `fonts` fields of `Fonts` and `FontsView` are private too. The
benchmark that used `layout` directly now calls the new
`Fonts::layout_uncached`.

* [x] I have followed the instructions in the PR template

PR chain, in order:
* #8490
* #8500
* #8501
* #8502
* #8503
* #8504
* #8491
* #8492
* #8493

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-05 17:01:45 +00:00
Emil ErnerfeldtandClaude Fable 5.1 0132e5dbb9 Replace CachedFamily with Family, which owns the fallback walk (#8503)
`Family::resolve` is now the only place that decides which face renders
a char: it walks the chain, consults the per-char cache, and falls back
to the replacement face. `Font` no longer reaches into the family's
fields. Asking font providers (#8491) for a missing char becomes one
more branch in `Family::resolve`.

* [x] I have followed the instructions in the PR template

PR chain, in order:
* #8490
* #8500
* #8501
* #8502
* #8503
* #8504
* #8491
* #8492
* #8493

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-05 16:27:43 +00:00
Emil ErnerfeldtandClaude Fable 5.1 c457299367 Add FaceStore: one place that parses and stores font faces (#8502)
`FaceStore` wraps the old `fonts_by_id` and `fonts_by_name` maps and
owns `FontFaceKey`. It has a single `install(name, &FontData)` so fonts
from `FontDefinitions` and fonts found later by a font provider (#8491)
go through the same code.

* [x] I have followed the instructions in the PR template

PR chain, in order:
* #8490
* #8500
* #8501
* #8502
* #8503
* #8504
* #8491
* #8492
* #8493

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-05 15:49:47 +00:00
Emil ErnerfeldtandClaude Fable 5.1 79d823e67e Move glyph bitmap caches out of FontFace into a new GlyphAtlas (#8501)
`GlyphAtlas` owns the `TextureAtlas` plus every cache that points into
it (outline glyphs keyed by face, and platform-rasterized glyphs).
`FontFace` no longer knows about the atlas: it just renders an outline
to a bitmap.

When the atlas gets full, `Fonts::begin_pass` now clears the bitmaps
instead of reparsing and re-hinting every font face. That also removes
the duplicated `glyph_rasterizer` field on `Fonts`, which only existed
to survive the rebuild. Fonts found by font providers (#8491) will
survive an atlas clear the same way.

* [x] I have followed the instructions in the PR template

PR chain, in order:
* #8490
* #8500
* #8501
* #8502
* #8503
* #8504
* #8491
* #8492
* #8493

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-05 15:22:14 +00:00
Emil ErnerfeldtandClaude Fable 5.1 f08c4ff404 Split fonts.rs and font.rs into one file per type (#8500)
Pure move, no logic changes. First step of a chain that untangles
`Font`, `FontsImpl`, and `CachedFamily` ahead of font providers (#8491).

New files under `crates/epaint/src/text/`: `font_id.rs`, `font_data.rs`,
`font_tweak.rs`, `font_definitions.rs`, `glyph_rasterizer.rs`,
`galley_cache.rs`, `styled_metrics.rs`, `unicode.rs`.

* [x] I have followed the instructions in the PR template

PR chain, in order:
* #8490
* #8500
* #8501
* #8502
* #8503
* #8504
* #8491
* #8492
* #8493

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-05 14:47:03 +00:00
Emil ErnerfeldtandClaude Fable 5.1 f7b4e41cf1 Render any glyph and colored emoji on web (#8490)
* Closes https://github.com/emilk/egui/pull/7852
* Web-only support for https://github.com/emilk/egui/issues/2551
* Related to https://github.com/emilk/egui/issues/7325

This adds support for rendering _any glyph_ on web, including colored
emojis!

Test string: ✨ We support ไทย, 한국어, and 🦀 🚀 🤖/🦾/📷/🎞️

<img width="435" height="115" alt="Screenshot 2026-09-03 at 20 29 43"
src="https://github.com/user-attachments/assets/86133103-8474-48b8-8792-e48ac3a4286c"
/>
<img width="465" height="111" alt="Screenshot 2026-09-03 at 20 29 36"
src="https://github.com/user-attachments/assets/7f7fb2a6-a6c6-42b1-85df-6c5745523ea4"
/>

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-05 07:43:38 +00:00
Emil Ernerfeldt dcda8664ab Fix rendering of thin, angled rectangles (#8482)
We had a fast path for very thin rectangles, but it did not heed the
angle of the rect
2026-09-02 19:23:52 +00:00
Emil ErnerfeldtandClaude Fable 5 726b995608 Round the corners of the color picker (#8439)
The color picker's gradients and background checkers now follow the
style's corner radius, giving it a softer look.

This required changing the painting from being Mesh-based to being
texture-based

it's subtle with the default settings:

<img width="286" height="397" alt="Screenshot 2026-08-21 at 15 08 18"
src="https://github.com/user-attachments/assets/3a9d5289-71fb-4f34-8a20-1fe96891ba36"
/>


But you can [increase it](https://github.com/emilk/egui/pull/8445):


<img width="285" height="391" alt="Screenshot 2026-08-21 at 15 08 41"
src="https://github.com/user-attachments/assets/b0dfa7da-5b96-40e0-a80d-1da385d57a1a"
/>


### Before
for reference
<img width="286" height="392" alt="Screenshot 2026-08-21 at 19 08 27"
src="https://github.com/user-attachments/assets/7c754f36-795c-4381-9f9f-1fc8dd9a0264"
/>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-24 09:28:14 +00:00
Emil Ernerfeldt f5c9373e26 Add epaint::RoundedRect primitive (#8440) 2026-08-21 01:33:54 -07:00
Emil ErnerfeldtandClaude Opus 5 34b39d564b Enable the clippy::pedantic lint group (#8429)
Instead of opting in to pedantic lints one by one, enable the whole
group and opt out of the noisy ones.

64% of the pedantic lints were already listed individually. This deletes
90 explicit lint lines, enables 51 pedantic lints we never listed, and
picks up new pedantic lints for free. Each opt-out carries its hit
count, so the cost of turning one back on is visible.

`restriction` and `nursery` stay opt-in per lint.

Stacked on top of #8430, which fixes the one real bug the new lints
found.

* [x] I have followed the instructions in the PR template

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-18 06:55:53 +02:00
Lucas Meurer 46ba6405bf Release 0.36.1 - Fix Sense::drag bug (#8397) 2026-08-07 15:08:38 +02:00
Emil Ernerfeldt 6aea7eff94 Enable the clippy::std_instead_of_core lint (#8394)
Prefer `core::` over `std::` where either work

* Part of https://github.com/emilk/egui/issues/5735
2026-08-06 13:19:13 +02:00
Lucas Meurer 2397194d5e Release 0.36.0 - Improved mobile keyboard support (#8390) 2026-08-05 10:55:25 +00:00
Emil Ernerfeldt 90e03028f7 Fix a few nightly clippy lints (#8388) 2026-08-04 21:40:56 +02:00
Emil Ernerfeldt 65109a0da0 Update crates (#8379)
Routine dependency update.

Updated: `font-types` 0.12, `harfrust` 0.12, `jiff` 0.2.35, `open` 5.4,
`pollster` 1.0, `rand` 0.10.2, `self_cell` 1.3, `skrifa` 0.44, `tokio`
1.53, `toml` 1.1, `vello_cpu` 0.1.
2026-08-03 06:38:37 +00:00
Emil Ernerfeldt cb2b306f11 Add LayoutJob::clear (#8376)
## Summary

- Add `LayoutJob::clear` to reuse layout settings while rebuilding text.
- Cover preservation of every layout setting.

## Test

- `cargo clippy -p epaint --all-features --all-targets`
- `cargo test -p epaint --all-features`

* [x] I have followed the instructions in the PR template
2026-08-02 19:26:27 +00:00
Lucas MeurerandClaude Opus 5 6268c84d8a Prevent accidentally dropping TexturesDelta (#8356)
We had a ton of issues around `TexturesDelta` that weren't properly
applied because we early-out of some function:
* https://github.com/emilk/egui/pull/8313
* https://github.com/emilk/egui/pull/8250
* https://github.com/emilk/egui/pull/8279

This PR changes texture updates, so that we always store them after
taking them out of `FullOutput` and keep the delta around until it's
actually applied (by passing &mut refs and draining instead of
iterating). So even if we add a new early return somewhere, that can't
break texture updates.

It also optimizes `TexturesDelta::append` by dropping any previous
deltas if there's a new `whole` delta or a `free`.

It also adds a debug assert that any `TexturesDelta` is empty when
dropped, as an additional safeguard in case the bug sneaks back in.

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-29 16:16:48 +00:00
Emil ErnerfeldtandClaude Opus 5 b730815797 Update MSRV from 1.92 to 1.95 (#8348)
No particular reason

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-28 08:37:03 +00:00
Davy e6eb00a31c Fix comment style: add space after // (#8333)
## Summary

- [x] I have followed the instructions in the PR template

Fixes comment-style violations of the `CONTRIBUTING.md` code style rule:

> `// Comment like this.` and not `//like this`

### Files changed

- `crates/epaint/src/shapes/bezier_shape.rs`: `//temporary solution` →
`// temporary solution`, and 22× `//add the start point` → `// add the
start point`
- `crates/egui/src/animation_manager.rs`: `//start new animation…` → `//
start new animation…`
- `crates/eframe/src/web/web_painter_wgpu.rs`:
`//create_new.instance_descriptor…` → `//
create_new.instance_descriptor…`

No code logic changes — only adding the missing space after `//` in
inline and standalone comments.

## Test plan

- [x] `cargo fmt --check`
- [x] `cargo clippy -p epaint -p egui`
- [x] `cargo test -p epaint --lib`
2026-07-24 08:24:33 +00:00
Lucas Meurer 68b74530b7 Release 0.35.0 - Inspection, egui_mcp, classes and improved IME (#8268) 2026-06-25 18:48:18 +00:00
Umaĵoandlucasmerlin 5bf62ca4b3 Implement proper visuals for IME composition (#8083)
<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/main/CONTRIBUTING.md)
before opening a Pull Request!

* Keep your PR:s small and focused.
* The PR title is what ends up in the changelog, so make it descriptive!
* If applicable, add a screenshot or gif.
* If it is a non-trivial addition, consider adding a demo for it to
`egui_demo_lib`, or a new example.
* Do NOT open PR:s from your `master` branch, as that makes it hard for
maintainers to test and add commits to your PR.
* Remember to run `cargo fmt` and `cargo clippy`.
* Open the PR as a draft until you have self-reviewed it and run
`./scripts/check.sh`.
* When you have addressed a PR comment, mark it as resolved.

Please be patient! I will review your PR, but my time is limited!
-->

* Closes N/A
* [x] I have followed the instructions in the PR template

This PR adds visual support for IME composition, including the cursor
and conversion segment.
These visuals works (mostly) well on native platforms (`egui-winit`). On
the web (`eframe/web`), support is limited by browser capabilities:
Chromium works well, Firefox shows partial improvement, and Safari
remains subpar.

> [!NOTE]
>
> For `eframe` on Windows, this feature is currently gated behind the
`windows_new_ime_composition_visuals` feature flag.

## Details

We extend `egui::ImeEvent::Preedit(String)` to `egui::ImeEvent::Preedit
{ text: String, active_range_chars: Option<std::ops::Range<usize>> }`.
The new `active_range_chars` field enables rendering of:
- the cursor (when the range is empty), and
- the conversion segment (when the range is non-empty)

in IME composition.

In `egui-winit`, we now use the range provided by
`winit::event::Ime::Preedit` instead of ignoring it.

In `eframe/web`, we derive the range from `selectionStart` and
`selectionEnd` on the text agent. This mapping is fully accurate only in
Chromium, but represents the best available approach for now.

## Demonstrations

### Chinese IMEs (Shuangpin)

We can see where the cursor is now.

| What | With this PR | Without this PR |
|-|-|-|
| macOS builtin |<video
src=https://github.com/user-attachments/assets/487c7e7c-ef6d-4a86-8dbc-8c71871b4470
/>|<video
src=https://github.com/user-attachments/assets/49bd5a60-4b90-4e4a-99e0-cd01d3f7030c
/>|
| macOS builtin (light)|<video
src=https://github.com/user-attachments/assets/e84546f6-947b-4cea-a87e-fda903f49164
/>|——|
| Windows builtin |<video
src=https://github.com/user-attachments/assets/fd331884-1f0c-4822-a99e-8140aed54815
/>|——|
| Wayland iBus Intelligent Pinyin |<video
src=https://github.com/user-attachments/assets/b6796c75-1c4e-45e5-b43a-5d8dea320485
/>|——|
| Chromium (Chrome) macOS | Identical to `macOS builtin`. |——|
| Safari macOS | We can now differentiate between IME composition and
text selection, but we still can't tell where the cursor is. |——|
| Firefox (Zen) macOS | Identical to `macOS builtin`. |——|

### Japanese IMEs

We can see where the conversion segment is now.

| What | With this PR | Without this PR |
|-|-|-|
| macOS builtin |<video
src=https://github.com/user-attachments/assets/f2994cd4-a966-4ff0-9590-d263c202ec76
/>|<video
src=https://github.com/user-attachments/assets/7cf5ff35-003d-4f60-8fbf-15c725c3ecb9
/>|
| macOS builtin (light)|<video
src=https://github.com/user-attachments/assets/6f562bdd-12fc-4486-b37b-8fcf11643295
/>|——|
| Windows builtin |<video
src=https://github.com/user-attachments/assets/f0905659-5335-4034-abda-c25cf8f2fd57
/>|——|
| Wayland iBus Anthy |<video
src=https://github.com/user-attachments/assets/94cd3a24-3158-4d79-ae02-d9b30fdfa738
/>|——|
| Chromium (Chrome) macOS | Identical to `macOS builtin`. |——|
| Safari macOS | We can now differentiate between IME composition and
text selection, but we still can't tell where the conversion segment is.
|——|
| Firefox (Zen) macOS | (Limited improvement.) <video
src=https://github.com/user-attachments/assets/3daf9b63-6e75-467b-8515-31c2a44adf61
/> |——|

### Korean IMEs

We can clearly tell whether we are in composition (in contrast to
selection) now.

| What | With this PR | Without this PR |
|-|-|-|
|macOS builtin|<video
src=https://github.com/user-attachments/assets/73ca28c7-22a0-493f-8f4d-c6e59a2dec54
/>|<video
src=https://github.com/user-attachments/assets/f582de7d-7ec0-48fe-910f-0139ef1620d3
/>|
|macOS builtin (light)|<video
src=https://github.com/user-attachments/assets/269f03bd-6f95-498b-9fb1-1adcb043c738
/>|——|
| Windows builtin| (With a workaround for [this `winit`
bug](https://github.com/emilk/egui/pull/8083#issuecomment-4206742668)
applied.) <video
src=https://github.com/user-attachments/assets/1e82583d-0c41-4f1c-98cf-0606bee5af05
/>|——|
| Wayland iBus Hangul |<video
src=https://github.com/user-attachments/assets/8c9a0de1-9027-4b37-93a3-e9da0251d176
/>|——|
| Chromium (Chrome) macOS | Identical to `macOS builtin`. |——|
| Safari macOS | Identical to `Windows builtin`. |——|
| Firefox (Zen) macOS | Identical to `macOS builtin`. (ignoring the fact
that the composition breaks when typing the second Hangul. (This bug
predates this PR.)) |——|

---------

Co-authored-by: lucasmerlin <hi@lucasmerlin.me>
2026-06-25 18:21:19 +02:00
Emil ErnerfeldtandClaude Opus 4.8 3e19bd1404 Make font hinting target configurable via FontTweak (#8262)
Fixes #8079, where font hinting only sharpens the vertical axis
(vertical stems stay blurry), and none of the skrifa knobs were
reachable — only switching to `Target::Mono` helped, but that wasn't
exposed.

This makes the hinting target configurable instead of hardcoding
`Target::Smooth { symmetric_rendering: true, preserve_linear_metrics:
true }`.

### API
- New `epaint::text::HintingTarget` mirroring `skrifa::outline::Target`:
  - `Mono`
- `Smooth(SmoothHinting)` where `SmoothHinting { light,
symmetric_rendering, preserve_linear_metrics }`
- New field `FontTweak::hinting_target: HintingTarget`.
- Each variant/field is documented with what it does and the
egui-specific caveats (e.g. `symmetric_rendering` only affects
interpreter-hinted fonts; egui positions glyphs from shaper advances so
`preserve_linear_metrics` mostly affects sharpness, not layout).

### Render
- `font.rs` converts `HintingTarget` → `skrifa::outline::Target` and
threads it into the per-glyph `reconfigure` call; the hinting instance
is also reconfigured when the target changes.

### UI
- The font-tweak settings panel gets a `hinting_target` row: Smooth/Mono
radios, `light` / `symmetric_rendering` / `preserve_linear_metrics`
checkboxes, and a `Reset` button — all with tooltips.

### Behavior
- `HintingTarget::default()` matches egui's previous hardcoded target,
so **rendering is unchanged** unless you opt in. To fix the horizontal
blur from #8079, uncheck `preserve_linear_metrics` (or pick `Mono`).
Whether to flip the *default* is left as a follow-up.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 03:18:21 +02:00
Emil ErnerfeldtandClaude Opus 4.8 7c600b3c76 Pre-populate font variation axes in the FontTweak UI (#8258)
The `FontTweak` settings UI previously let you edit variable-font
variation coordinates only via free-form tag + value entry — you had to
*know* that e.g. `wght` exists and what range is valid.

This PR queries the font's actual variation axes and pre-populates the
UI.

### Changes
- **`epaint`**: new `FontData::variation_axes() ->
Vec<FontVariationAxis>` (skrifa-backed). Each `FontVariationAxis`
exposes the axis `tag`, human-readable `name`, `min`/`default`/`max`,
and `hidden`. Empty for static (non-variable) fonts.
- **`egui`**: extracted the `FontTweak` body into a public
`style::font_tweak_ui(ui, tweak, axes)`. When `axes` is non-empty, each
axis is shown as a named **slider** pre-filled with the font's default
and clamped to its valid range, with a ⟲ button to drop the override.
`impl Widget for &mut FontTweak` still exists and delegates with no axes
(free-form fallback, also used for unknown/manual tags).
- The font settings panel (`Context::fonts_tweak_ui`) now passes
`data.variation_axes()`.
- UI label renamed `coords` → **Axes** (matching Google Fonts'
terminology); the underlying `FontTweak.coords` field keeps the OpenType
"design coordinates" name.

🤖 Generated with [Claude Code](https://claude.com/claude-code)


Example (Weight and Width):
<img width="340" height="239" alt="Screenshot 2026-06-24 at 11 51 33"
src="https://github.com/user-attachments/assets/f898289a-e329-453a-ba86-c60858901466"
/>

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 20:55:57 +02:00
Emil Ernerfeldt 428e027ec7 Export ByteRange and CharRange (#8247) 2026-06-22 03:45:48 +00:00
Emil ErnerfeldtandClaude Opus 4.8 13d6b5afcf Use strongly typed CharIndex and ByteIndex + bug fixes (#8245)
Less risk of confusing the two.

Found and fix a couple real bugs in the process!

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-21 02:24:00 +02:00
eac51da9ca Add LayoutJob::format_at_byte (#8244)
This PR adds two small additions to `LayoutJob`:

- `LayoutJob::format_at_byte` to query the `TextFormat` of the section
covering a given byte index.
- An optimization to `LayoutJob::append` that merges newly appended text
into the previous section when the format matches and there is no
leading space.

It also documents the `LayoutJob::sections` invariant (sections are
ordered and together cover the whole text with no gaps or overlaps) and
adds `LayoutJob::debug_sanity_check`, which verifies this in debug
builds. It is called from `format_at_byte` and from the text layouter.

## Why the `easymarkeditor` snapshot changed

The `append` optimization changes how many sections a `LayoutJob` ends
up with: consecutive runs of identically-formatted text now collapse
into a single section instead of one section per `append` call. The
easymark editor produces many such adjacent same-format sections, so it
is affected.

This matters because text is **shaped per section**: `layout_section`
runs the shaper once per section, so each section is an independent
shaping run. Merging two adjacent sections into one means the text
across the old boundary is now shaped together as a single run, which
enables cross-boundary kerning (and, in principle, ligatures) that
previously did not happen. Additionally, `extra_letter_spacing` is
skipped before the first glyph of a section, so merging removes a "first
glyph" boundary and lets the spacing apply there.

The net effect is sub-pixel glyph position shifts at the former section
boundaries, which is why `easymarkeditor.png` was regenerated. The new
output is the more correct one — the text is now shaped as the author
wrote it, rather than being artificially split at `append` boundaries.

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-20 22:07:18 +02:00
Lucas Meurer 654a2a974d Bump version to 0.34.3 and update changelogs (#8207) 2026-05-27 11:27:25 +02:00