33 Commits

Author SHA1 Message Date
Qwerasd
4dbf404dc3 font/sprite: cleanup branch drawing character impl, implement fade-out lines 2024-11-06 18:44:12 -05:00
Meili C
0441987346 font feature: add git branch characters
addresses #2561 - adds support for most Git branch drawing characters as
specified in ![kitty/7681](https://github.com/kovidgoyal/kitty/pull/7681)
except for fading vertical and horizontal lines.

Adds git_draw_node function and a new Git node type.
Add this range (0xf5d0...0xf60d) for Git branch characters, to tests.
adds vline_middle_xy and hline_middle_xy for node connections.
add git characters to Face.zig.
2024-11-06 18:26:23 -05:00
Qwerasd
c66042d6e0 font/sprite: address PR review feedback
- Make canvas geometry primitives generic, use `Rect(u32)` for `rect`
function, so that we don't have to worry about negatives or rounding.
- Make `Quads` struct packed just in case it gets non-comptime use in
the future.
- Clarify comment on why we're discarding out of range pixels + runtime
unreachable for any other type of error which we shouldn't ever see.
- Move z2d import above in-tree imports.
2024-10-15 12:00:11 -04:00
Qwerasd
83a56afcb1 font/sprite: fix weird code 2024-10-14 20:52:42 -04:00
Qwerasd
37144fd5b8 font/sprite: fix light arc character for odd thicknesses
+ update Box.ppm ground truth image
2024-10-14 20:47:04 -04:00
Qwerasd
c0315a04b4 test(font/sprite): add second size to box regression test
Smaller, odd cell size, odd (1) thickness, catches more edge cases with
rounding etc.
2024-10-14 20:31:01 -04:00
Qwerasd
bb5b7b0274 font/sprite(Box): refactor smooth mosaic rendering
+ un-`comptime` the line spec and make it a packed struct, to reduce
codegen size.
2024-10-14 17:50:49 -04:00
Qwerasd
d38d0f30c4 font/sprite: replace pixman with z2d, extend Box coverage
More complete coverage of the Symbols For Legacy Computing block,
including characters from Unicode 16.0.

Pixman and the web canvas impl for Canvas have been removed in favor of
z2d for drawing, since it has a nicer API with more powerful methods,
and is in Zig with no specific platform optimizations so should compile
to wasm no problem.
2024-10-14 17:50:49 -04:00
Qwerasd
c86b5f44ce font/sprite: refactor box drawing quads/sextants
Move away from C-style bit sets, calculate sextants procedurally rather
than hard coding.
2024-10-14 17:50:49 -04:00
Qwerasd
d63cf6eaec test(font/sprite): generate diff image on failed regression check 2024-10-14 17:50:49 -04:00
Qwerasd
ced4247e55 font/sprite: refactor lines and fractional blocks, add ground truth for regression test
Use a single unified function for intersection-style line drawing chars,
and one for fractional block characters. Add a ground truth image based
on this commit for the regression test (differences from before changes
validated visually, 1 incorrect rendering actually fixed)
2024-10-14 17:50:49 -04:00
Qwerasd
f3e74384bb test(font/sprite): add regression test for box drawing sprites 2024-10-14 17:50:49 -04:00
Qwerasd
10b8ca3c69 spelling: normalize grey -> gray 2024-08-11 18:31:01 -04:00
Łukasz Niemier
f9be02a20f chore: clean up typos 2024-08-05 13:56:57 +02:00
Qwerasd
4b33f07b73 font/sprite: Fix U+255D
Double Up and Left '╝' previously had a hole in the bottom, extend line to fill gap.
2024-04-08 23:10:00 -04:00
Mitchell Hashimoto
555f6e159f font/sprite: remove comptime arg for box drawing 2024-04-02 08:38:36 -07:00
Qwerasd
5abc63193e font/sprite: improve rendering of dashed lines
Previous implementation would draw dashes to the edge of the character
cell, which would result in double-wide dashes at the point where they
tiled. This fixes that, and also generally implements it in a cleaner
way than before.
2024-04-01 18:35:34 -04:00
Mitchell Hashimoto
85b40874cf font/sprite: manually determine which box codepoints are unadjusted
Some box codepoints (the cursor) want to use the original font metrics
height but others (corners) want to use the full grid height. I can't
see a better way to do this than manually maintaining a switch here. We
can add codepoints as needed.
2023-12-13 10:32:16 -08:00
Mitchell Hashimoto
3a5f12b8ab font: box sprite use saturated subtraction
Fixes #757

The x/y is unsigned (as it should be, since top-left is 0,0). In the
case of a very small grid size and certain thickness settings, its
possible to overflow. In this scenario, the only reasonable thing to do
is just clamp to 0 because some sprites are going to look weird with
small enough grids anyways.
2023-10-30 09:01:14 -07:00
Mitchell Hashimoto
4ed240515c font/sprite: fix horizontal dash drawing math for cells too small
Fixes #143

There were multiple issues with the previous calculation. First, we
expected dash width COULD be negative and protected against it, but our
dash width calculation type was unsigned! With the proper font metrics,
this led to an underflow safey panic.

Second, as part of the dash width calculation, we are tryign to downstep
the size of the gaps so we can try to fit dashes within a cell. But we
were not using those adjusted gap sizes. With the proper font metrics,
this could lead to an assertion failure seen in #143.

This fixes the calculations. They produce the same numbers, but do so in
a more Zig-idiomatic way while fixing the above two issues.
2023-08-29 11:25:49 -07:00
Mitchell Hashimoto
9300404603 font: block cursor was not taking full cell width 2023-07-10 11:45:35 -07:00
Mitchell Hashimoto
853f15ef19 bar cursor was short by a couple pixels 2023-07-04 13:12:21 -07:00
Mitchell Hashimoto
314f9287b1 Update Zig (#164)
* update zig

* pkg/fontconfig: clean up @as

* pkg/freetype,harfbuzz: clean up @as

* pkg/imgui: clean up @as

* pkg/macos: clean up @as

* pkg/pixman,utf8proc: clean up @as

* clean up @as

* lots more @as cleanup

* undo flatpak changes

* clean up @as
2023-06-30 12:15:31 -07:00
Mitchell Hashimoto
56f8e39e5b Update zig, mach, fmt 2023-06-25 11:08:20 -07:00
Mitchell Hashimoto
97d9157d22 update zig version 2023-05-07 20:50:51 -07:00
Mitchell Hashimoto
cf519bcd75 Use procedurally generated sprites for cursors rather than shaders 2023-03-04 15:14:10 -08:00
Mitchell Hashimoto
c391d0f3de font: web canvas sprite font can composite 2022-12-13 22:17:27 -08:00
Mitchell Hashimoto
ead8610604 font: Box font uses canvas abstraction 2022-12-13 21:08:45 -08:00
Mitchell Hashimoto
b21e18a9e6 font: start converting Box font to our abstract canvas interface 2022-12-13 16:16:56 -08:00
Mitchell Hashimoto
f871630fa4 move Atlas to font 2022-11-28 10:35:46 -08:00
Mitchell Hashimoto
84efd2ac5f font: use Canvas more, Canvas rect 2022-11-27 14:08:15 -08:00
Mitchell Hashimoto
28d386967d font: introduce Canvas, start converting Box 2022-11-27 13:54:43 -08:00
Mitchell Hashimoto
b34e336c5c rearrange box rendering to prepare for more sprite drawing 2022-11-27 10:17:12 -08:00