457 Commits

Author SHA1 Message Date
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
Mitchell Hashimoto
0a69615670 font/shaper: add Cache 2024-05-01 18:55:22 -07:00
Mitchell Hashimoto
81a12b0d86 font/shaper: add hash to text runs 2024-05-01 18:28:53 -07:00
Mitchell Hashimoto
f99823ec38 Merge pull request #1713 from BvngeeCord/main
sprites: dont thicken via font-thicken, add cursor thickness adjustment
2024-04-30 14:09:04 -07:00
Mitchell Hashimoto
1072354747 build: add -Dfont-backend=coretext_harfbuzz to force Harfbuzz w/ CT 2024-04-30 14:03:38 -07:00
Mitchell Hashimoto
6858646843 font/coretext: tests for #1721 2024-04-30 11:55:18 -07:00
Mitchell Hashimoto
313c7f4cf1 font: runs do not split on bg color change
We previously split text runs for shaping on bg color changes. As
pointed out in Discord, this is not necessary, since we can always color
cells according to their desired background even if the text in the cell
shapes to something else.
2024-04-30 11:23:41 -07:00
Gordon Cassie
e77f9962a8 revert on comment removal 2024-04-30 10:21:31 -07:00
Gordon Cassie
e564454ff1 More log statements. 2024-04-30 10:21:08 -07:00
Gordon Cassie
b76f5976ee Remove unnecessary allocation. 2024-04-30 10:20:50 -07:00
Gordon Cassie
abd782a7aa Fix typo. 2024-04-30 10:20:31 -07:00
Mitchell Hashimoto
9b4e362a33 font/coretext: shaping ligatures adds padding cells for replaced cells
Fixes #1708

Harfbuzz does this automatically. Our tests for harfbuzz test this. We
had a todo in CoreText to mimic this but wasn't sure if it was useful.
Turns out, it is important (see bug!)
2024-04-30 10:14:43 -07:00
Jack N
8c8f1b6fde fix macos build 2024-04-22 23:35:48 -07:00
Jack N
346eba3152 sprites: dont thicken via font-thicken, + add cursor thickness adjustment 2024-04-22 20:35:23 -07:00
Mitchell Hashimoto
0f348e809e font: strikethrough uses sprite rendering 2024-04-22 10:25:33 -07:00