Commit graph

102 commits

Author SHA1 Message Date
Daniel Eklöf
22b280b355
box-drawing: fix compiler warning
../../box-drawing.c: In function 'box_drawing':
../../box-drawing.c:2774:13: error: 'y1' may be used uninitialized in this function [-Werror=maybe-uninitialized]
 2774 |     int y0, y1;
      |             ^~
../../box-drawing.c:2774:9: error: 'y0' may be used uninitialized in this function [-Werror=maybe-uninitialized]
 2774 |     int y0, y1;
      |         ^~
2021-08-06 22:29:33 +02:00
Daniel Eklöf
130cf791e9
box-drawing: re-align sextants and wedges
Improve the visual quality of sextants (and wedges) when the cell height isn’t a
multiple of three.
2021-08-06 22:26:49 +02:00
Daniel Eklöf
6f59186193
box-drawing: don’t inline functions called for multiple codepoints
In several cases, this expanded to multiple calls, and when inlined, resulted in
much larger code size.
2021-08-05 19:51:43 +02:00
Daniel Eklöf
97e64e2caf
box-drawing: wedges: pre-load x_halfs[] and y_thirds[]
This reduces the number of loads in the rest of the function.
2021-08-05 19:51:43 +02:00
Daniel Eklöf
0e10d2b1a2
box-drawing: wedges: avoid floating point math
Re-use the pre-calculated offsets used by the sextants. This is the correct
thing to do since wedges *should* align with sextants.
2021-08-05 19:51:42 +02:00
Daniel Eklöf
950c1b6010
box-drawing: pre-calculate sextant x,y offsets
We’re using floating point math, as a way to ensure that sextant primitives
overlap, rather than leaving empty spaces, or being uneven, when the cell
width/height isn’t divisible with 2 (width) or 3 (height).

This gets rid of all floating point math from the sextant drawing functions.
2021-08-05 19:51:42 +02:00
Daniel Eklöf
469d5abc69
box-drawing: deal with quads in the same as sextants
That is, encode which “pieces” make up each quad in a static array, and use a
single function to draw all quads using the four primitives “upper left/right,
lower left/right”.
2021-08-05 19:51:42 +02:00
Daniel Eklöf
1dcdc42091
box-drawing: don’t inline horizontal-one-eighth-block-N 2021-08-05 19:51:42 +02:00
Daniel Eklöf
67e285f16c
box-drawing: don’t inline light diagional 2021-08-05 19:51:42 +02:00
Daniel Eklöf
36ecd0baed
box-drawing: wedges: fix alignment of inverted wedges
We render the inverted wedges by first rendering a non-inverted triangle, and
then inverting it with PIXMAN_OP_OUT.

In cases where truncating and round():ing the triangle points have different
results, the final, inverted wedge ends up being unaligned with the
corresponding sixel(s).

This patch fixes that by handling the pre-inverted triangles
specifically. I.e. we don’t re-use the same triangle coordinates as the
corresponding non-inverted triangle.
2021-08-05 18:25:01 +02:00
Daniel Eklöf
56d7a51d35
box-drawing: wedges: don’t group similar cases together
Since they’re not exactly alike, we still need branches within each case. Better
to split them up - one case per codepoint.
2021-08-05 18:25:01 +02:00
Daniel Eklöf
1c43fdbea4
box-drawing: add U+1FB3C-U+1FB6F, U+1FB9A and U+1FB9B
These are the “wedges” from the Unicode 13 “Legacy Computing” symbols.

Closes #474
2021-08-05 18:25:01 +02:00
Daniel Eklöf
34f42b3dd6
box-drawing: big-endian support when setting bits manually 2021-07-14 19:46:21 +02:00
Daniel Eklöf
8473deeed3
box-drawing: pre-calculate the LIGHT and HEAVY thicknesses 2021-05-17 17:58:30 +02:00
Daniel Eklöf
3dbb906325
box-drawing: always pass ‘buf’ as the first parameter
This way, the compiler doesn’t have to waste instructions on
re-ordering the parameters
2021-05-17 17:58:30 +02:00
Daniel Eklöf
25ce458281
box-drawing: don’t inline _thickness()
It results in quite a lot of floating point instructions being emitted
in almost every box drawing function we have...
2021-05-17 17:58:30 +02:00
Daniel Eklöf
b48414e72c
box-drawing: use fill_boxes() instead of fill_rectangles() 2021-05-17 17:58:30 +02:00
Daniel Eklöf
b771a28d17
box-drawing: increase brightness of solid shades 2021-05-17 17:58:30 +02:00
Daniel Eklöf
e7109d6b77
config: add tweak.box-drawing-solid-shades=yes|no
When enabled, shades are rendered as solid blocks, using a darker
variant of the current foreground color.

When disabled, shades are instead rendered in a checker box pattern,
using the foreground color unmodified.

Default is enabled.
2021-05-17 17:58:30 +02:00
Daniel Eklöf
c0bd152218
box-drawing: use an a8 buffer when primary font is antialiased
This causes relevant box drawing characters (diagonals, arcs etc) to
be antialiased as well.
2021-05-17 17:58:30 +02:00
Daniel Eklöf
9264d6695c
box-drawing: change_buffer_format: abort on pixman failure 2021-05-17 17:58:30 +02:00
Daniel Eklöf
99a3b034c3
box-drawing: apply antialiasing to LIGHT ARCs
When drawing on an a8 buffer, apply antialiasing to LIGHT ARCs. This
is done by supersampling; draw to a 4 times bigger buffer, then
downsample, where each downsampled pixel is the average of the
corresponding 4x4 pixel from the supersampled buffer.

We also need to take supersampling into account while adjusting the row
and col when pixel aligning the arcs with the regular
horizontal/vertical lines.

The shape of the ARCs can still be improved. Still, this is a much
needed improvement over the current implementation.

Closes #279
2021-05-17 17:58:30 +02:00
Daniel Eklöf
3d97b8c113
box-drawing: draw_pixman_shade(): named struct initialization 2021-05-17 17:58:29 +02:00
Daniel Eklöf
977d37396f
box-drawing: fix typo: missing ‘.’ in struct member initialization 2021-05-17 17:58:29 +02:00
Daniel Eklöf
6937b1add8
box-drawing: shades can now be rendered either using solid color, or checker box
For now, switching is done using a static variable. In the future,
this could be a user option.
2021-05-17 17:58:29 +02:00
Daniel Eklöf
d495da03e1
box-drawing: temporary “fix” for LIGHT ARCs with a8 buffers
We don’t have a method to draw the arcs using pixman yet. Work around
this by replacing the a8 buffer with an a1 buffer, and render the arcs
using our old, non-antialiased, way.
2021-05-17 17:58:29 +02:00
Daniel Eklöf
5dd8a70905
box-drawing: swap amount of shade for LIGHT and DARK shades
The DARK shade is the one most dense, and thus the one that looks
brightest.
2021-05-17 17:58:29 +02:00
Daniel Eklöf
b280928084
box-drawing: draw shades as “antialiased” blocks
When rendering to an a8 surface, render shades using “transparent”
pixman rectangles.

When these glyphs are composited with a color, the resulting look is
the color, but darkened.
2021-05-17 17:58:29 +02:00
Daniel Eklöf
d6898dcc42
box-drawing: use pixman_image_fill_boxes() for rect() 2021-05-17 17:58:29 +02:00
Daniel Eklöf
e05a510a7c
box-drawing: implement LIGHT diagonal lines using pixman
Use trapezoids to rasterize the diagonal lines.
2021-05-17 17:58:29 +02:00
Daniel Eklöf
19fa1b30b8
box-drawing: rect(): implement using pixman
Use pixman_image_fill_rectangles() to render rectangles. Duh!
2021-05-17 17:58:29 +02:00
Daniel Eklöf
155537c2de
box-drawing: {h,v}line: implement using pixman
Use pixman_image_fill_rectangles() to render horizontal and vertical
lines.

Despite the name, this *is* the appropriate function to use, since our
lines *do* have a thickness, and thus *are* rectangles.
2021-05-17 17:58:29 +02:00
Daniel Eklöf
e03257d342
box-drawing: U+256C - BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL: add missing corner
The inner corner, where the upper/left lines meet, were missing
2021-05-17 17:58:29 +02:00
Daniel Eklöf
8d09ba5bd2
box-drawing: include pixman image in the buffer we’re passing around 2021-05-17 17:58:29 +02:00
Daniel Eklöf
9e5d740422
box-drawing: add Unicode 13 U+1FB70 - U+1FB8B
Part of #471
2021-05-04 10:47:36 +02:00
Craig Barnes
e56136ce11 debug: rename assert() to xassert(), to avoid clashing with <assert.h> 2021-01-16 20:16:00 +00:00
Craig Barnes
dad0549f2e box-drawing: use enum constants in draw_sextant() instead of #define
Both are functionally equivalent here, but the former is also properly
scoped, can be naturally indented and has a less repetitive syntax.
2021-01-15 16:07:51 +00:00
Daniel Eklöf
14ce8fd872
box-drawing: line thickness now depends on both DPI and cell size
Cell size is defined as the length of the diagonal of the cell.
2021-01-12 17:31:55 +01:00
Daniel Eklöf
f1b4bf1275
box-drawing: LIGHT ARC: ensure row+col are within range 2021-01-12 17:31:55 +01:00
Daniel Eklöf
4bb056bb4b
box-drawing: {h,v}line() + rect(): ensure *end* row/col is >= 0 2021-01-12 17:31:47 +01:00
Daniel Eklöf
25c2379d5f
box-drawing: x/y offsets: use pre-calculated offset values from term struct 2021-01-11 09:31:09 +01:00
Daniel Eklöf
a6fc8b5da4
config: line-height, letter-spacing: values are in pt by default, but we allow px
If the value is specified without a unit, then the value is assumed to
be in points, subject to DPI scaling.

The value can optionally have a ‘px’ suffix, in which case the value
is treated as a raw pixel count.
2021-01-11 09:31:08 +01:00
Daniel Eklöf
389570b274
box-drawing: compensate for non-zero {horizontal,vertical}-letter-offsets
Box drawing characters should always cover the entire cell. No more,
no less.
2021-01-11 09:31:06 +01:00
Craig Barnes
39b2e46e72 Use wrappers from macros.h instead of bare GCC attributes/pragmas 2021-01-03 08:56:47 +00:00
Daniel Eklöf
0861e8d377
box-drawing: drop ‘pragma GCC optimize(“Os”)’
“The optimize attribute should be used for debugging purposes
  only. It is not suitable in production code.”

Luckily, it seems it really isn’t needed anymore; with all the other
size optimizations that has been done since this was introduced, there
is no longer any difference with or without this pragma.
2021-01-02 17:47:47 +01:00
Daniel Eklöf
c7a611fdf3
box-drawing: codespell: assymetrical -> asymmetrical 2021-01-02 12:35:53 +01:00
Daniel Eklöf
e353edaf41
box-drawing: add macros for {h,v}line_middle_mixed()
Mixed here refers to mixed thickness - the lines thickness doesn’t
match the thickness of an abstract, orthogonal line going through the
middle of the cell.
2021-01-02 12:28:03 +01:00
Daniel Eklöf
5a5134e9bd
box-drawing: LIGHT ARC: simpler way to adjust for asymmetrical arc when mirroring
When mirroring an arc, we need to adjust the mirrored position if the
arc’s position in the cell is asymmetrical. This happens when *either*
the line is odd sized, *or* the cell is. But not when both are.

Thus, we can simply do a ‘thickness % 2 ^ width % 2’ when adjusting
the position.

Describe this in a comment.
2021-01-02 12:09:00 +01:00
Daniel Eklöf
66497cfd4d
box-drawing: LIGHT ARC: use min/max instead of checking range inside loop 2021-01-02 12:08:32 +01:00
Daniel Eklöf
d8e40cf5d4
box-drawing: LIGHT ARC: fix alignment of arcs when thickness is > 1px 2021-01-02 02:26:12 +01:00