87 Commits

Author SHA1 Message Date
Marijn Besseling
4496e7d314 implement overline decoration (SGR 53/55) 2024-10-21 08:36:08 -04:00
Qwerasd
2a4398b319 font/sprite: undercurl minimum thickness improvement 2024-10-17 21:07:52 -04:00
Mitchell Hashimoto
8a38c87d90 font: use explicit error sets where we can 2024-10-15 09:37:51 -07:00
Mitchell Hashimoto
bb2c8e479d font/sprite: clarify log 2024-10-15 09:30:55 -07: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
2462921681 font/sprite(underline): make undercurl segment symmetrical
Previously was biased half a pixel to one side.
2024-10-14 14:53:09 -04:00
Qwerasd
63f82119cd font/sprite(underline): add thickness correction to undercurl 2024-10-14 14:46:43 -04:00
Qwerasd
06a37f32be font/sprite: use offset curve approximation for undercurl 2024-10-06 01:43:11 -04:00
Qwerasd
c454ef627b fix(font/sprite): avoid underflow
There's a degenerate case where height < line_pos
2024-10-05 22:12:59 -04:00
Qwerasd
fd49fb7338 font/sprite: improve double underline legibility with min 2px gap
At small thicknesses, the legibility of the double underline is not
great when it's a 1px line, a 1px gap, and another 1px line.
2024-10-05 22:08:17 -04:00
Qwerasd
156f735f8d font/sprite: fix undercurl rendering
- Limit max amplitude relative to cell width to avoid being too wavy
- Fix application of xiaolin-wu's for anti-aliasing too always be at
least 1px thick.
- Fix height calculation to avoid clipping bottom of wave at small
sizes.
2024-10-05 22:01:43 -04:00
Mitchell Hashimoto
bbacee66d0 font/sprite: fix out of bounds right on curly underline
Fixes #2321
2024-09-29 09:39:32 -07:00
Mitchell Hashimoto
f67a647a12 font/sprite: bounds checking for pixel writes on Pixman 2024-09-29 09:38:38 -07:00
Qwerasd
9a87001fa6 font/sprite: correct underline placement calculation 2024-09-25 11:56:01 -06:00
Qwerasd
49a3008919 font/sprite: reduce uneven gaps in dotted underline 2024-09-23 20:08:57 -06:00
Qwerasd
b3a7901b79 font/sprite: rework underline rendering, adjust positioning 2024-09-23 18:22:11 -06:00
Qwerasd
6917bcacad font/sprite: fix 1px gap at right edge of dotted and dashed underlines 2024-09-23 18:13:46 -06:00
Mitchell Hashimoto
c9523a6ee0 font/sprite: avoid invalid glyph if unsupported codepoint is attempted 2024-09-05 20:22:51 -07: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
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
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
796d1312ff font/sprite: rect must be smaller than canvas dims 2024-02-24 13:19:49 -08:00
Mitchell Hashimoto
759c8cddb4 font/sprite: test for thick underline, assertion on x/y for rect 2024-02-24 09:30:04 -08:00
em-dash
0f19251aa6 fix crash in underline drawing math 2024-02-24 20:49:51 +11:00
Chris Marchesi
dfefe953fc Powerline: add trapezoid rendering
This adds Powerline rendering for the trapezoid characters (E0D2 and
E0D4).

This is the last of the Powerline additions for now. These are the
shapes that 1) render the most egregiously with stock fonts (off-center,
bleeding background, visible gaps), and 2) are simple enough to be
rendered without resorting to more complex measures like embedding SVG.
2023-12-19 11:36:05 -08: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
8fc0cdb220 font: cursor size remains original cell height if height adjusted
Fixes #1067
2023-12-12 20:43:11 -08:00
Chris Marchesi
c03ae47a27 Powerline: add references for the ellipse algorithm
Further to the additional comments in #1055, this adds some references
to the comments in the ellipse algorithm (including the original
reference for the circle algorithm).
2023-12-12 00:10:40 -08:00
Chris Marchesi
4aa56ab8dd Powerline: Change half-circle algorithm to ellipse
This changes the half-circle drawing algorithm for glyphs E0B4 and E0B6
to an ellipse algorithm.

This fixes a shortcoming in the circle approach - how do you handle
drawing for a box that is not a typical 2:1 H*W? We were trying to
anticipate this by taking the smaller of the two axes and using that for
the radius. This works when there's some error in the zoom and the x
radius somehow becomes larger than the y radius (in observation, this
happens occasionally in some zoom steps, but only slightly).

However, turns out a more realistic anticipation is for fonts that have
a much *larger* height-to-width ratio. Iosevka, for example, has an
approx. 2.6:1 ratio (observed in the inspector). In this instance, this
approach does nothing except lock the circle to an extremely small
radius. For this instance, we need an ellipse, which will handle all
cases in an expected fashion.

Fixes #1050.
2023-12-11 21:01:11 -08:00
Chris Marchesi
d34b5571d8 Powerline: Add half-circle rendering
This adds in-terminal rendering for the powerline glyphs E0B4 and E0B6,
similar to how we are rendering the triangle shapes currently.

The circle glyphs use a much more complex rendering due to the nuances
of drawing them: we use a midpoint algorithm for drawing on a 4x
supersampled matrix, fill, and then downsample. We use the same
downsampling approach as is done in the arc box drawing code.

The midpoint variant we're using here is described by Dennis Yurichev:
https://yurichev.com/news/20220322_circle/, although there are similar
variants elsewhere (some cited at the bottom of his article).
2023-12-07 22:29:59 -08:00
Krzysztof Wolicki
0750698b62 Update to latest master,
update libxev dependency,
change mach_glfw to an updated fork until upstream updates
2023-11-30 21:41:33 +01:00
Chris Marchesi
e0d458004f font/sprite: add Powerline face
This adds the Powerline face to our set of built-in faces, which
represents glyphs that are used to draw Powerline-style shell prompts
and status lines.

Since these are used similar to box-drawing characters, alignment is
important, and this gives us the most control in preventing related
artifacts.

This initial commit is scaffolding and support for the various solid
triangles - additional glyphs will come in other commits.

Fixes #675.
2023-11-23 01:29:12 -08:00
Krzysztof Wolicki
44a48f62f1 change unmodified vars to consts in anticipation of zig changes 2023-11-17 15:46:46 +01:00
Matthew Winter
a81c7b7bb2 feat: improve variable naming 2023-11-01 19:04:20 +11:00
Matthew Winter
212b30a163 feat: change minimum height to 2 2023-11-01 11:51:32 +11:00
Matthew Winter
d7a16e0245 feat: update undercurl thickness and wave height 2023-10-31 21:53:04 +11:00
Matthew Winter
60b69a32d0 feat: update undercurl thickness and wave height 2023-10-31 21:23:53 +11:00