471 Commits

Author SHA1 Message Date
Łukasz Niemier
f9be02a20f chore: clean up typos 2024-08-05 13:56:57 +02:00
Mitchell Hashimoto
77ee2f413c terminal: hasText no longer special cases kitty placeholders 2024-07-29 14:36:49 -07:00
Mitchell Hashimoto
4b5ad77b70 font: fontconfig always prefer monospace in pattern
Fixes #1984
2024-07-21 09:48:07 -07:00
Mitchell Hashimoto
f4c26dfaf5 shaper/coretext: use pointer address for cache comparison 2024-07-18 18:46:09 -07:00
Qwerasd
12e8d96b1a shaper/coretext: reset font cache on grid change
Not doing this caused issues with spacing of ligatures and
multi-substitutions when changing the font size with cmd +/-
2024-07-18 17:39:57 -04:00
Mitchell Hashimoto
3b36dbb53e font/coretext: cached fonts uses unmanaged arraylist 2024-06-22 20:56:23 -07:00
Mitchell Hashimoto
2607446235 font: add noop endFrame calls to all other shapers 2024-06-22 20:49:10 -07:00
Mitchell Hashimoto
71353d016e coretext shaper owns CFReleaseThread, works on both Metal and OpenGL now 2024-06-22 20:42:59 -07:00
Mitchell Hashimoto
4325dc51bc font: coretext shaper owns the cf release pool 2024-06-22 20:32:24 -07:00
Qwerasd
053500da38 shaper/coretext: update tests 2024-06-14 01:57:46 -04:00
Qwerasd
626ec2b5ac perf: introduce CFReleaseThread for running CoreFoundation releases
Some CoreFoundation objects, such as those produced by CoreText, have
expensive callbacks that run when they are released. By offloading the
CFRelease calls to another thread, we can avoid important threads being
blocked by unexpectedly expensive callbacks.

This commit also changes the way that the coretext shaper's run iterator
builds its string. Rather than using a CFMutableString, an ArrayList of
unichars is built which is passed to CFStringCreateWithCharactersNoCopy,
which is a lot more efficient since it avoids all the CoreFoundation
overhead.
2024-06-14 01:43:02 -04:00
Qwerasd
04896a14b4 perf(shaper/coretext): cache fonts between shape calls 2024-06-14 00:14:53 -04:00
Qwerasd
8d76b5f283 perf: introduce CacheTable strcture, use it for shaper cache 2024-06-10 13:58:35 -04:00
Mitchell Hashimoto
919b00571a font: preload deferred faces in SharedGrid to avoid data races
Fixes #1722

Previously, SharedGrid.getIndex would properly lock any access to search
for and load the face metadata for a font face that contains a
codepoint. However, that face may be "deferred" (metadata loaded but the
actual face not loaded).

Later, outside of the SharedGrid write lock, a deferred face may be
initialized and cause a data race if two threads are doing this at the
same time, sometimes loading to a crash.

This commit fixes the issue by always preloading font indexes in
getIndex because the usage of getIndex implies a very near term future
use of getFace.
2024-06-07 20:35:01 -07:00
Mitchell Hashimoto
80c0ba8758 font: when presentation isn't found, always fallback to any
Fixes #1808

When resolving a codepoint, we first attempt to find the default
presentation (if an explicit one is not given), but we were not falling
back to "any" in case that presentation was not found.
2024-05-30 14:22:42 -07:00
Mitchell Hashimoto
d978d05d7e font/coretext: glyphIndex must return u32 for noop shaper 2024-05-28 21:05:32 -07:00
Mitchell Hashimoto
f6e708c0fb font/coretext: cleanup unused comments 2024-05-28 20:58:06 -07:00
Mitchell Hashimoto
9a628d8a8e font: remove unused structs 2024-05-28 20:56:47 -07:00
Mitchell Hashimoto
6a8dc12ae1 font: remove deferred face todo, note why 2024-05-28 20:54:05 -07:00
Mitchell Hashimoto
adaeffb2b5 font/freetype: CBDT/CBLC tables imply color 2024-05-28 20:40:46 -07:00
Mitchell Hashimoto
4daa49fe27 font/freetype: update to new presentation APIs 2024-05-28 20:25:49 -07:00
Mitchell Hashimoto
326659c522 font: handle presentation at glyph layer 2024-05-28 20:09:05 -07:00
Mitchell Hashimoto
dc6b1b0b7a font/coretext: hasColor/isColored 2024-05-28 13:20:37 -07:00
Mitchell Hashimoto
d22c645a02 font/coretext: determine glyph colorization 2024-05-28 13:04:55 -07:00
Mitchell Hashimoto
8920f45fd8 font/freetype: API to load font table 2024-05-28 09:48:01 -07:00
Mitchell Hashimoto
9f885ff64f font/opentype: add SVG table parser, membership check 2024-05-27 21:35:33 -07:00
Mitchell Hashimoto
1a7cde9e3e font/coretext: can read font tables 2024-05-27 20:23:10 -07:00
Mitchell Hashimoto
9f4d4d3c61 font: treated fonts with mixed color/non-color glyphs as text
Related to #1768 but doesn't fix it properly.

This is a temporary hack to avoid some issues with fonts that have mixed
color/non-color glyphs. If there are mixed presentations and the font
does not have emoji codepoints, then we assume it is text. This fixes
the typical scenarios.

This is not a long term solution. A proper long term solution is to
detect this scenario and on a per-glyph basis handle colorization (or
the lack thereof) correctly. It looks like to do this we'll have to
parse some font tables which is considerably more work so I wanted to do
this first.
2024-05-26 10:17:20 -07:00
Mitchell Hashimoto
e427312282 modify var name 2024-05-26 09:28:16 -07:00
Peter Cardenas
e56acef775 🧹 make strikethrough calculation slightly clearer
followup to https://github.com/mitchellh/ghostty/pull/1796
the sources of the strikethrough calculation are made more explicit
here: the ascent and the subtraction of the leading
2024-05-26 01:44:26 -07:00
Mitchell Hashimoto
bc99082242 font/coretext: adjust strikethrough position for fonts with leading
Fixes #1795

This only affected CoreText. When testing with Freetype the
strikethroughs looked correct for fonts with and without leading
metrics.

This commit adjusts our strikethrough position for fonts that have a
leading metric set to better center it. Previously, we centered the
position _including_ the leading value. The leading value is blank, so
we must center it excluding that value.
2024-05-25 15:20:16 -07:00
Mitchell Hashimoto
d7c64f57b1 font/shaper: periodically reset LRU in cache to avoid slowdown
See: https://github.com/ziglang/zig/issues/17851

Users were noticing that frame render times got slower over time. I
believe (thanks to community for pointing it out) that this is the
culprit.

This works around this issue by clearing and reinitializing the LRU
after a certain number of evictions. When the Zig issue has a better
resolution (either rehash() as a workaround or a better hash
implementation overall) we can change this.
2024-05-18 10:06:41 -04:00
Qwerasd
d01db9f793 revert dpi type to u16 2024-05-09 00:03:40 -04:00
Qwerasd
fa45c18a6a fix point size type 2024-05-09 00:03:40 -04:00
Qwerasd
a9daba6d6d fix freetype face size calculation 2024-05-09 00:03:40 -04:00
Qwerasd
3156df261f fix a couple test failures 2024-05-09 00:03:40 -04:00
Qwerasd
d4a7549222 feat(font): Non-integer point sizes
Allows for high dpi displays to get odd numbered pixel sizes, for
example, 13.5pt @ 2px/pt for 27px font. This implementation performs
all the sizing calculations with f32, rounding to the nearest pixel
size when it comes to rendering. In the future this can be enhanced
by adding fractional scaling to support fractional pixel sizes.
2024-05-09 00:03:40 -04:00
Mitchell Hashimoto
6dcf567554 font: fix coretext test issues with harfbuzz shaper 2024-05-08 18:33:14 -07:00
Mitchell Hashimoto
435bd32cfd font: SharedGridSet works without font discovery 2024-05-08 18:24:55 -07:00
Mitchell Hashimoto
3c882e364a font: disable CJK unification fallback with freetype rasterizer 2024-05-08 12:18:35 -07:00
Mitchell Hashimoto
1cb70d6e40 font/coretext: force LTR shaping 2024-05-08 10:11:57 -07:00
Mitchell Hashimoto
18e5382909 font/coretext: do not assume capacity on arraylist append
Now that we're padding the cells with blanks if we have shaped ligatures
we don't actually know the exact count based on the CoreText APIs, so we
should just dynamically add.
2024-05-08 08:55:28 -07:00
Mitchell Hashimoto
91bcc3de39 font/coretext: choose proper original font for CJK search 2024-05-07 15:39:17 -07:00
Mitchell Hashimoto
84095025d5 font: fontconfig has proper function 2024-05-07 15:10:53 -07:00
Mitchell Hashimoto
7c5d829274 font: use CoreText API for CJK unified ideographs 2024-05-07 15:05:34 -07:00
Mitchell Hashimoto
851b1fe2ac font: noop shaper 2024-05-01 20:31:50 -07:00
Mitchell Hashimoto
a8b97d4061 font/coretext: only pad shaped text ltr 2024-05-01 20:27:40 -07:00
Mitchell Hashimoto
6683b159ce font/shaper: run hash should include font index 2024-05-01 19:53:27 -07:00
Mitchell Hashimoto
74236d2db6 renderer/metal: log some cache info 2024-05-01 19:49:22 -07:00
Mitchell Hashimoto
d7de26ef58 renderer/metal: integrate shaping cache 2024-05-01 19:01:08 -07:00