mirror-ghostty/pkg/macos
Mitchell Hashimoto 8dd810521c
Fix Weird Behavior in CoreText Shaper (#9002)
You can pretty simply reproduce a crash on `main` in `Debug` mode by
running `printf "مرحبًا \n"` with your primary font set to one that
supports Arabic such as Cascadia Code/Mono or Kawkab Mono, which will
cause CoreText to output the shaped glyphs non-monotonically which hits
the assert we have in the renderer.

In `ReleaseFast` this assert is skipped and because we already moved
ahead to the space glyph (which belongs at the end but is emitted first)
all of the glyphs up to that point are lost. I believe this is probably
the cause of #8280, I tested and this change seems to fix it at least.

Included in this PR is a little optimization: we were allocating buffers
to copy glyphs etc. from runs to every time, even though CoreText
provides `CTRunGet*Ptr` functions which get *pointers* to the internal
storage of these values- these aren't guaranteed to return a usable
pointer but in that case we can always fall back to allocating again.
Also avoided allocation while processing glyphs by ensuring capacity
beforehand immediately after creating the `CTLine`.

The performance impact of this PR is negligible on my machine and
actually seems to be positive, probably due to avoiding allocations if I
had to guess.
2025-10-06 09:04:48 -07:00
..
animation pkg/macos: clean up for Zig 0.14, consolidate C imports into one decl 2025-03-15 07:02:53 -07:00
carbon pkg/macos: clean up for Zig 0.14, consolidate C imports into one decl 2025-03-15 07:02:53 -07:00
dispatch pkg/macos: clean up for Zig 0.14, consolidate C imports into one decl 2025-03-15 07:02:53 -07:00
foundation renderer: big rework, graphics API abstraction layers, unified logic 2025-06-20 15:18:41 -06:00
graphics font: add constraint logic to rasterizers 2025-07-04 15:47:28 -06:00
iosurface renderer: big rework, graphics API abstraction layers, unified logic 2025-06-20 15:18:41 -06:00
os macos: add benchmark tests to our Xcode project 2025-07-09 15:06:24 -07:00
text Fix Weird Behavior in CoreText Shaper (#9002) 2025-10-06 09:04:48 -07:00
video unwrap unnecessary @"" identifiers 2025-06-20 15:18:41 -06:00
animation.zig renderer: big rework, graphics API abstraction layers, unified logic 2025-06-20 15:18:41 -06:00
build.zig build-system: Replace deprecated usages of root_source_file on addTests (#8031) 2025-07-22 15:28:11 -07:00
build.zig.zon pkg/macos: clean up for Zig 0.14, consolidate C imports into one decl 2025-03-15 07:02:53 -07:00
carbon.zig pkg/macos: expose carbon API 2024-09-19 09:22:07 -07:00
dispatch.zig renderer: big rework, graphics API abstraction layers, unified logic 2025-06-20 15:18:41 -06:00
foundation.zig renderer: big rework, graphics API abstraction layers, unified logic 2025-06-20 15:18:41 -06:00
graphics.zig pkg/macos: graphics usingns yeet 2024-08-16 16:38:04 -07:00
iosurface.zig renderer: big rework, graphics API abstraction layers, unified logic 2025-06-20 15:18:41 -06:00
main.zig macos: add signpost API 2025-07-09 15:06:23 -07:00
os.zig macos: add signpost API 2025-07-09 15:06:23 -07:00
text.zig Fix Weird Behavior in CoreText Shaper (#9002) 2025-10-06 09:04:48 -07:00
video.zig renderer: big rework, graphics API abstraction layers, unified logic 2025-06-20 15:18:41 -06:00