1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-27 15:13:12 -04:00
Commit Graph

286 Commits

Author SHA1 Message Date
valadaptive
623c4c6d3c Disable subpixel binning for CJK glyphs 2025-09-08 05:38:15 -04:00
valadaptive
61351d170e Apply documentation changes 2025-09-08 05:30:32 -04:00
valadaptive
abe9a2d91d Apply review suggestion about GlyphCacheKey 2025-09-08 05:27:42 -04:00
valadaptive
d659df6655 Subpixel glyph positioning 2025-09-08 05:22:29 -04:00
valadaptive
03a4f2c181 Stop accumulating rounding error on purpose 2025-09-08 04:43:07 -04:00
valadaptive
dcb6420a41 Update inaccurate comment 2025-09-07 21:40:57 -04:00
valadaptive
91d3384a6c Remove busted glyph-centering code
Not sure *what* I replaced this with, but it's unnecessary now
2025-09-07 21:38:10 -04:00
valadaptive
4325c8f3c8 Optimize glyph allocation cache lookups 2025-09-07 21:36:04 -04:00
valadaptive
38fbae0541 Cache GlyphIds for allocation instead of full info 2025-09-07 21:36:04 -04:00
valadaptive
95458f4b52 Stop using ab_glyph scaling entirely 2025-09-07 21:36:04 -04:00
valadaptive
f560b6a9ff Cache scaled font metrics 2025-09-07 21:36:04 -04:00
valadaptive
3a6cb2e273 Refactor replace_last_glyph_with_overflow_character
Muuuuuch nicer.
2025-09-07 21:36:04 -04:00
valadaptive
1ccd809b61 Fix glyph cache key 2025-09-07 21:36:03 -04:00
Emil Ernerfeldt
58cbca1016 Change argument order 2025-09-07 21:36:03 -04:00
Emil Ernerfeldt
6f53261f4a Refactor GlyphInfo 2025-09-07 21:36:03 -04:00
Emil Ernerfeldt
0d628e6db3 Change parameter order and fix bug in test 2025-09-07 21:34:16 -04:00
Emil Ernerfeldt
3385ad5bcb Pre-hash contents of FontFaceKey 2025-09-07 21:34:16 -04:00
Emil Ernerfeldt
560346d007 add docstring 2025-09-07 21:34:16 -04:00
valadaptive
1ddd143e45 Fix panic if no fonts loaded 2025-09-07 21:34:16 -04:00
valadaptive
e5a22395a6 Fix docs 2025-09-07 21:34:16 -04:00
valadaptive
52ce61a305 Please the linter 2025-09-07 21:34:16 -04:00
valadaptive
9a774097a1 Rename font_impls field to fonts_by_name 2025-09-07 21:34:15 -04:00
valadaptive
a113907005 Include pixels_per_point in galley cache key 2025-09-07 21:34:15 -04:00
valadaptive
9aaee3354d Let Fonts handle multiple pixels_per_point 2025-09-07 21:34:15 -04:00
valadaptive
837fc7fef7 Remove more Arc<Mutex<...>> from font code
By making `Font` a view type and indexing by font ID, we can avoid
wrapping `FontImpl` and `TextureAtlas` in an `Arc<Mutex<...>>`.
2025-09-07 21:34:15 -04:00
valadaptive
02d45d70bc Make Font+FontImpl resolution and size independent 2025-09-07 21:34:15 -04:00
valadaptive
955e678577 Remove FontTweak::baseline_offset_factor
Even testing this out *with* font fallback, which seems to be its
intended purpose, this does exactly the same thing as y_offset_factor.
It's likely that some subsequent change (perhaps
https://github.com/emilk/egui/pull/2724) removed the code path that
made it function differently.
2025-09-07 21:34:15 -04:00
valadaptive
bbf9ac4d4b Stop wrapping FontsImpl in an Arc<Mutex<_>>
We never need to clone it, and none of its methods took `self` as
mutable, meaning it wasn't making use of the semantic difference between
the two.

This API is about to get reworked, and simplifying it is a first step.
2025-09-07 21:34:15 -04:00
Andrew Farkas
1c460b6dc0 Skip zero-length layout job sections (#7430)
Fixes #7378 

Includes a regression test that previously failed and now succeeds.

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

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
Co-authored-by: Lucas Meurer <hi@lucasmerlin.me>
2025-09-04 13:17:59 +02:00
Lucas Meurer
80d61a7c53 Remove the deadlock_detection feature (#7497)
* related #7494 

Removes the `deadlock_detection` feature, since we now have a more
primitive panic-after-30s deadlock detection which works well enough and
even detects kinds of deadlocks that the `deadlock_detection` feature
never supported.
2025-09-04 12:57:09 +02:00
Lucas Meurer
fa4bee3bf7 Fix deadlock in ImageLoader, FileLoader, EhttpLoader (#7494)
* Recently CI runs started to hang randomly:
https://github.com/emilk/egui/actions/runs/17427449210/job/49477714447?pr=7359

This fixes the deadlock and adds the basic deadlock detection we also
added to Mutexes in #7468.

Also, interestingly, the more sophisticated deadlock detection (behind
the deadlock_detection feature) didn't catch this for some reason. I
wonder why it exists in the first place, when parking_lot also has built
in deadlock detection? It also seems to make tests slower, widget_tests
usually needs ~30s, with the deadlock detection removed its only ~12s.
2025-09-04 10:31:26 +02:00
Oscar Gustafsson
b9414bd4cc Selectively update dependencies to reduce total number (#7488)
<!--
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

Update some of the core dependencies and run cargo update for selected
dependencies to remove total number and older versions.
2025-09-04 09:42:46 +02:00
Emil Ernerfeldt
1da1d57c11 Panic mutexes that can't lock for 30 seconds, in debug builds (#7468)
I'm trying to debug a suspected deadlock in the CI for
https://github.com/emilk/egui/pull/7467

Since we use our own mutex wrappers, we can just panic if the lock is
too slow. Ugly and effective :)
2025-08-21 15:31:56 +02:00
Emil Ernerfeldt
6a355c3808 Add 0.32.1 to changelogs 2025-08-15 13:42:49 +02:00
Emil Ernerfeldt
36a4981f29 Enable clippy::iter_over_hash_type lint (#7421)
This helped discover a few things that _might_ have been buggy.
2025-08-06 13:55:53 +02:00
Emil Ernerfeldt
ef039aa566 Enable more clippy lints (#7418)
More is more!
2025-08-05 19:47:26 +02:00
Hubert Głuchowski
31eb4d498b Fix multi-line TextShape rotation (#7404)
* Closes <https://github.com/emilk/egui/issues/7397>
* [X] I have followed the instructions in the PR template
I do admit I got a peak NixOS `RequestDeviceError` and deemed it
entirely not worth it to think about that.

https://github.com/emilk/egui/pull/5411 broke rotation of multi-line
`TextShape`s because `PlacedRow::pos` was no longer being rotated, so
let's rotate it.

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
Co-authored-by: Lucas Meurer <hi@lucasmerlin.me>
2025-08-05 13:11:45 +02:00
Emil Ernerfeldt
b9a5081490 Fix glyph rendering: clamp coverage to [0, 1] (#7415)
* Closes  #7366
* Closes https://github.com/emilk/egui/pull/7388
2025-08-05 13:03:39 +02:00
Emil Ernerfeldt
fabd4aa7a5 Release 0.32.0 - Atoms, popups, and better SVG support (#7329) 2025-07-10 16:58:39 +02:00
Lucas Meurer
087e56abae Fix wrong galley split behavior when text ends with new line (#7320)
* Fixes a bug introduced by #7316 

The last `\n` was ignored for texts ending with `\n` in the galley split
logic.
2025-07-09 18:18:06 +02:00
Lucas Meurer
9fd0ad36e0 Implement BitOr and BitOrAssign for Rect (#7319) 2025-07-09 15:29:51 +02:00
Lucas Meurer
207e71c2ae Exclude \n when splitting Galleys (#7316)
* Follow up to #7146 

Previously when galleys were splitted, each exept the last had an extra
empty row that had to be removed when they were concated. This changes
it to remove the `\n` from the layout jobs when splitting.
2025-07-09 14:53:19 +02:00
Lucas Meurer
508c60b2e2 Add Galley::intrinsic_size and use it in AtomLayout (#7146)
- part of https://github.com/emilk/egui/issues/5762
- also allows me to simplify sizing logic in egui_flex
2025-07-09 08:19:04 +02:00
valadaptive
7ac137bfc1 Make the font atlas use a color image (#7298)
* [x] I have followed the instructions in the PR template

Splitting this out from the Parley work as requested. This removes
`FontImage` and makes the font atlas use a `ColorImage`. It converts
alpha to coverage at glyph-drawing time, not at delta-upload time.

This doesn't do much now, but will allow for color emoji rendering once
we start using Parley.

I've changed things around so that we pass in `text_alpha_to_coverage`
to the `Fonts` the same way we do with `pixels_per_point` and
`max_texture_side`, reusing the existing code to check if the setting
differs and recreating the font atlas if so. I'm not quite sure why this
wasn't done in the first place.

I've left `ImageData` as an enum for now, in case we want to add support
for more texture pixel formats in the future (which I personally think
would be worthwhile). If you'd like, I can just remove that enum
entirely.
2025-07-04 13:15:48 +02:00
Emil Ernerfeldt
dc79998044 Improve text rendering in light mode (#7290)
This changes how we convert glyph coverage to alpha (and ultimately a
color), but only in light mode.

This is a bit of a hack, because it doesn't fix dark-on-light text in
_dark mode_ (if you have any), but for the common case this PR is a huge
improvement.

You can also tweak this yourself now using
`Visuals::text_alpha_from_coverage` or from the UI (bottom of the
image):


![image](https://github.com/user-attachments/assets/350210d4-c0bb-44b6-84cc-47c2e9d4b9f0)



## Before / After

![widget_gallery_light_x1](https://github.com/user-attachments/assets/21f5a2a0-6b4e-4985-b17f-cd1c7cc01b46)
![widget_gallery_light_x1](https://github.com/user-attachments/assets/5dfec04a-c81c-43ef-8d86-fc48ef7958f1)


## Black text Before/after
If you think the text above looks too weak, it's only because of the
default text color. Here's how it looks like with perfectly `#000000`
black text:


![image](https://github.com/user-attachments/assets/56a4a4f3-c431-4991-b941-a566a4ae94ed)
![Screenshot 2025-07-02 at 13 59
30](https://github.com/user-attachments/assets/df5a91ad-0bb8-4a0f-81a2-50852e7556c1)
2025-07-02 14:58:37 +02:00
Emil Ernerfeldt
b2995dcb83 Use Rust edition 2024 (#7280) 2025-06-30 14:01:57 +02:00
Emil Ernerfeldt
2525546fef Simplify some bezier math 2025-06-30 10:03:54 +02:00
valadaptive
54fded362d Clamp text cursor positions in the same places where we used to (#7081)
Closes #7077.

This fixes the problem shown in #7077 where clearing a `TextEdit`
wouldn't reset its cursor position. I've fixed that by adding back the
`TextCursorState::range` method, which clamps the selection range to
that of the passed `Galley`, and calling it in the same places where it
was called before #5785.

(/cc @juancampa)

* [x] I have followed the instructions in the PR template
2025-06-16 01:53:00 +02:00
Patrick Marks
df2c16ef0a Add anchored text rotation method, and clarify related docs (#7130)
Add a helper method to perform rotation about a specified anchor.

* Closes #7051
2025-06-16 01:42:01 +02:00
Emil Ernerfeldt
92fea8a18f Remove things that have been deprecated for over a year (#7099)
Removes all things that were marked `#[deprecated]` more than 12 months
ago
2025-05-28 09:47:15 +02:00