mirror-ghostty/pkg
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
..
apple-sdk build: use a libc txt file to point to correct Apple SDK 2025-05-29 15:04:05 -07:00
breakpad build-system: Replace deprecated usages of addStaticLibrary with addLibrary (#8029) 2025-07-22 14:47:18 -07:00
cimgui build-system: Replace deprecated usages of root_source_file on addTests (#8031) 2025-07-22 15:28:11 -07:00
fontconfig build-system: Replace deprecated usages of root_source_file on addTests (#8031) 2025-07-22 15:28:11 -07:00
freetype fix(font): Improve FreeType glyph measurements and add unit tests for face metrics (#8738) 2025-09-29 12:50:49 -07:00
glslang build-system: Replace deprecated usages of root_source_file on addTests (#8031) 2025-07-22 15:28:11 -07:00
gtk4-layer-shell gtk(wayland): prevent gtk4-layer-shell crash on old versions 2025-06-28 16:41:19 +02:00
harfbuzz build-system: Replace deprecated usages of root_source_file on addTests (#8031) 2025-07-22 15:28:11 -07:00
highway build-system: Replace deprecated usages of root_source_file on addTests (#8031) 2025-07-22 15:28:11 -07:00
libintl build-system: Replace deprecated usages of addStaticLibrary with addLibrary (#8029) 2025-07-22 14:47:18 -07:00
libpng build-system: Replace deprecated usages of addStaticLibrary with addLibrary (#8029) 2025-07-22 14:47:18 -07:00
libxml2 build-system: Replace deprecated usages of addStaticLibrary with addLibrary (#8029) 2025-07-22 14:47:18 -07:00
macos Fix Weird Behavior in CoreText Shaper (#9002) 2025-10-06 09:04:48 -07:00
oniguruma build-system: Replace deprecated usages of root_source_file on addTests (#8031) 2025-07-22 15:28:11 -07:00
opengl renderer: create explicit sampler state for custom shaders 2025-09-29 12:51:48 -07:00
sentry build-system: Replace deprecated usages of addStaticLibrary with addLibrary (#8029) 2025-07-22 14:47:18 -07:00
simdutf build-system: Replace deprecated usages of addStaticLibrary with addLibrary (#8029) 2025-07-22 14:47:18 -07:00
spirv-cross build-system: Replace deprecated usages of root_source_file on addTests (#8031) 2025-07-22 15:28:11 -07:00
utf8proc build-system: Replace deprecated usages of addStaticLibrary with addLibrary (#8029) 2025-07-22 14:47:18 -07:00
utfcpp build-system: Replace deprecated usages of addStaticLibrary with addLibrary (#8029) 2025-07-22 14:47:18 -07:00
wuffs wuffs: simplify the build 2025-08-20 10:08:24 -05:00
zlib build-system: Replace deprecated usages of addStaticLibrary with addLibrary (#8029) 2025-07-22 14:47:18 -07:00
README.md license: update copyright notices to include contributors 2025-06-10 10:20:26 -06:00

README.md

Packages

This folder contains packages written for and used by Ghostty that could potentially be useful for other projects. These are in-tree with Ghostty because I don't want to maintain them as separate projects (i.e. get dedicated issues, PRs, etc.). If you want to use them, you can copy and paste them into your project.

License

This license only applies to the contents of the pkg folder within the Ghostty project. This license does not apply to the rest of the Ghostty project.

Copyright © 2024 Mitchell Hashimoto, Ghostty contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.