Commit Graph

59 Commits (199119967b3070b50150b59805341bfdbdc7b2b2)

Author SHA1 Message Date
Mitchell Hashimoto dbfc3eb679
Remove unused imports 2025-11-27 13:37:53 -08:00
Mitchell Hashimoto 2ecaf4a595
font/shaper: fix harfbuzz tests 2025-11-20 22:00:44 -08:00
Qwerasd 6d5b4a3426 perf: replace `std.debug.assert` with inlined version
See doc comment in `quirks.zig` for reasoning
2025-11-17 12:13:56 -07:00
Mitchell Hashimoto 4ba00dbe89
fix harfbuzz 2025-11-14 15:48:06 -08:00
Mitchell Hashimoto 368f4f565a
terminal: Screen opts is a structure 2025-11-14 14:10:37 -08:00
Leah Amelia Chen f107b2f910
font/{harfbuzz,coretext}: enable dlig for test shaper
Some of the tests rely on dlig and I'm far too lazy to rewrite those
tests now
2025-08-07 11:54:31 +08:00
Qwerasd 6af6357949 font: clean up Collection api somewhat
Move size adjustment logic out of `Entry`, I understand the impulse to
put it there but it results in passing a lot of stuff around which isn't
great.

Rework `add(...)` in to `add(...)` and `addDeferred(...)`, faces are
passed directly now instead of passing an entry, and an options struct
is used instead of positional arguments for things like style, fallback,
and size adjustment.

Change size adjustment test back to a half pixel tolerance instead of 5%
because the previous commit (allowing fractional pixel sizes) fixed the
root cause of large differences.
2025-07-25 11:50:59 -06:00
Qwerasd 9405522dd5 font: allow fractional pixel sizes 2025-07-25 11:36:03 -06:00
Daniel Wennberg e7d28a85c8 Make size normalization reference customizable per face 2025-07-17 17:04:47 -07:00
Mitchell Hashimoto 73ff4b8f74
move runIterator options to dedicated struct 2025-06-30 09:05:09 -07:00
Daniel Patterson beb961fb80 Introduce `font-shaping-break` config option 2025-06-30 08:06:00 -07:00
Qwerasd 2384bd69cc style: use decl literals
This commit changes a LOT of areas of the code to use decl literals
instead of redundantly referring to the type.

These changes were mostly driven by some regex searches and then manual
adjustment on a case-by-case basis.

I almost certainly missed quite a few places where decl literals could
be used, but this is a good first step in converting things, and other
instances can be addressed when they're discovered.

I tested GLFW+Metal and building the framework on macOS and tested a GTK
build on Linux, so I'm 99% sure I didn't introduce any syntax errors or
other problems with this. (fingers crossed)
2025-05-26 21:50:14 -06:00
Qwerasd cfedd477b2 font/freetype: introduce mutexes to ensure thread safety of Library and Face
For details see comments and FreeType docs @
https://freetype.org/freetype2/docs/reference/ft2-library_setup.html#ft_library
https://freetype.org/freetype2/docs/reference/ft2-face_creation.html#ft_face

tl;dr: FT_New_Face and FT_Done_Face require the Library to be locked for
thread safety, and FT_Load_Glyph and FT_Render_Glyph and friends need
the face to be locked for thread safety, since we're sharing faces
across threads.
2025-05-01 18:22:37 -06:00
Qwerasd f0080529c4 fix(font/shape): don't require emoji presentation for grapheme parts
Also update shaper test that fails because the run iterator can't apply
that logic since `testWriteString` doesn't do proper grpaheme clustering
so the parts are actually split across multiple cells.

Several other tests are technically incorrect for the same reason but
still pass, so I've decided not to fix them here.
2025-03-19 15:09:53 -06:00
Qwerasd 2d174f9bff font: allow non-boolean font feature settings
+ much more flexible syntax and lenient parser
+ allows comma-separated list as a single config value

This allows, e.g. `cv01 = 2` to select the second variant of `cv01`.
2024-12-30 21:15:25 -05:00
Mitchell Hashimoto f04b6c8768
font/harfbuzz: force LTR font shaping
Fixes #2570
Related to #1740

See #1740 for details.
2024-11-03 09:51:51 -08:00
Qwerasd ca59367164 harfbuzz: fix tests to account for removal of null cells 2024-10-09 16:05:09 -04:00
Qwerasd 7686cacde6 renderer, shaper: don't use null cells, handle bg and decorations separately
Significant rework that also removes a lot of unnecessarily duplicated
work while rebuilding cells in both renderers. Fixes multiple issues
with decorations and bg colors on wide chars and ligatures, while
reducing the amount of special case handling required.
2024-10-08 23:10:43 -04:00
Mitchell Hashimoto be3ae56bc8
font: add stylistic variants for built-in font, fix naming convention
Fixes #2364

This adds the bold, italic, and bold italic variants of JB Mono so it is
built-in. This also fixes up the naming convention for the embedded font
files across tests and removes redundant embedded font files.
2024-10-02 15:17:18 -07:00
Mitchell Hashimoto 5befe75a1f
font/harfbuzz: work with new collection API 2024-08-23 15:30:57 -07:00
Mitchell Hashimoto 2607446235
font: add noop endFrame calls to all other shapers 2024-06-22 20:49:10 -07:00
Mitchell Hashimoto 6dcf567554
font: fix coretext test issues with harfbuzz shaper 2024-05-08 18:33:14 -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 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
Jack N 346eba3152 sprites: dont thicken via font-thicken, + add cursor thickness adjustment 2024-04-22 20:35:23 -07:00
Mitchell Hashimoto b77513de1a
font/harfbuzz: work with new font structures 2024-04-05 21:48:53 -07:00
Mitchell Hashimoto 9b4ab0e209
zig build test with renamed terminal package 2024-03-22 20:27:44 -07:00
Mitchell Hashimoto 05470bb36a
font/shaper: new API 2024-03-22 20:27:41 -07:00
Mitchell Hashimoto efe037bb9f
font/shaper: test with bg only cells 2024-03-22 20:27:41 -07:00
Mitchell Hashimoto 34200a3e83
font/shaper: more tests passing 2024-03-22 20:27:41 -07:00
Mitchell Hashimoto e3230cf1e6
font/shaper: start converting run to new terminal 2024-03-22 20:27:41 -07:00
Mitchell Hashimoto adb7958f61
remove tracy usage from all files 2024-01-13 15:06:08 -08:00
Mitchell Hashimoto 2082751a65
font/shaper: prevent underflow in multi-cell lig detection
Fixes #1251

See the comment for details.
2024-01-07 22:16:11 -08:00
Mitchell Hashimoto f447e6f9df
font: insert blank cells for multi-cell ligatures for styling
Up to this point, every font I've experienced with ligatures has
replaced the codepoints that were replaced for combining with a space.
For example, if a font has a ligature for "!=" to turn it into a glyph,
it'd shape to `[not equal glyph, space]`, so it'd still take up two
cells, allowing us to style both.

Monaspace, however, does not do this. It turns "!=" into `[not equal
glyph]` so styles like backgrounds, underlines, etc. were not extending.

This commit detects multi-cell glyphs and inserts synthetic blank cells
so that styling returns. I decided to do this via synthetic blank cells
instead of introducing a `cell_width` to the shaper result because this
simplifies the renderers to assume each shaper cell is one cell. We can
change this later if we need to.

Annoyingly, this does make the shaper slightly slower for EVERYONE to
accomodate one known font that behaves this way. I haven't benchmarked
it but my belief is that the performance impact will be negligible
because to figure out cell width we're only accessing subsequent cells
so they're likely to be in the CPU cache and also 99% of cells are going
to be width 1.
2024-01-06 19:22:25 -08:00
Gregory Anders 060bdff117 terminal: track palette color in cell state
Rather than immediately converting a color palette index into an RGB
value for a cell color, when a palette color is used track the palette
color directly in the cell state and convert to an RGB value in the
renderer.

This causes palette color changes to take effect immediately instead of
only for newly drawn cells.
2024-01-02 22:34:06 -06:00
Mitchell Hashimoto 489ed57e2f
font/harfbuzz: track x/y offsets 2023-12-11 21:41:13 -08:00
Mitchell Hashimoto 54b9b45a7f
font: rework font init to use a struct with modifiersets everywhere 2023-10-04 17:23:57 -07:00
Mitchell Hashimoto 1127330b3a
font/coretext: score discovered fonts 2023-10-03 09:17:41 -07:00
Mitchell Hashimoto 5c1fbd09cd
font: shaper dynamically allocates cell buffer
Pathlogical grapheme clusters can use a LOT of memory, so we need to be
able to grow.
2023-09-26 17:59:16 -07:00
Mitchell Hashimoto 49dbd8d151
font/shaper: fix failing test on macos 2023-09-24 11:10:04 -07:00
Mitchell Hashimoto a2236d1ceb
font: fallback search must verify presentation 2023-09-13 14:27:04 -07:00
Mitchell Hashimoto ed5c001690
font/shaper: split ligature around cell style change 2023-08-29 14:09:21 -07:00
Mitchell Hashimoto f733e58dc4
font/shaper: on macos load apple color emoji for tests 2023-08-26 17:14:22 -07:00
Mitchell Hashimoto e6edf3105e
font: grapheme clusters need to find a single font for all codepoints
When font shaping grapheme clusters, we erroneously used the font index
of a font that only matches the first codepoint in the cell. This led to the
combining characters being [usually] unknown and rendering as boxes.

For a grapheme, we must find a font face that has a glyph for _all codepoints_
in the grapheme.

This also fixes an issue where we now properly render the unicode replacement
character if we can't find a font satisfying a codepoint.
2023-08-26 09:35:56 -07:00
Mitchell Hashimoto f4738210e1
font: determine quirks modes on font face load 2023-08-25 14:44:16 -07:00
Mitchell Hashimoto 167bf6f098
font: DeferredFace can no longer represent a loaded face 2023-08-25 13:28:46 -07:00
Mitchell Hashimoto ad6c2b6cc8
font: move auto-italicization to Group 2023-08-25 13:16:42 -07:00
Mitchell Hashimoto ea3b957bc7
quirks: Menlo/Monaco should disable ligatures by default (#331)
* font: disable default font features for Menlo and Monaco

Both of these fonts have a default ligature on "fi" which makes terminal
rendering super ugly. The easiest thing to do is special-case these
fonts and disable ligatures. It appears other terminals do the same
thing.
2023-08-25 09:29:15 -07:00
Mitchell Hashimoto 4137c6cf69
font/shaper: do not break on merged emoji if cursor is directly on it 2023-07-18 16:38:02 -07:00
Mitchell Hashimoto 4b062dc45c
font/shaper: text runs should split around block cursors
Fixes #206
2023-07-18 16:20:30 -07:00