mirror of
https://github.com/emilk/egui.git
synced 2026-06-26 22:53:14 -04:00
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>
egui demo app
This app demonstrates egui and eframe.
View the demo app online at https://egui.rs.
Run it locally with cargo run --release -p egui_demo_app.
egui_demo_app can be compiled to WASM and viewed in a browser locally with:
./scripts/start_server.sh &
./scripts/build_demo_web.sh --open
egui_demo_app uses egui_demo_lib.
Running with wgpu backend
(cd egui_demo_app && cargo r --features wgpu)