Commit graph

116 commits

Author SHA1 Message Date
Thomas Bonnefille
9443ac7e29
box-drawings: handle architecture with soft-float
Currently, architecture using soft-floats doesn't support instructions
FE_INVALID, FE_DIVBYZERO, FE_OVERFLOW and FE_UNDERFLOW and so building
on those architectures results with a build error.
As the sqrt math function should set errno to EDOM if an error occurs,
fetestexcept shouldn't be mandatory.

This commit removes the float environment error handling.

Signed-off-by: Thomas Bonnefille <thomas.bonnefille@bootlin.com>
2025-02-05 13:31:46 +01:00
Daniel Eklöf
9a1b59adae
box-drawings: implement octants 2024-12-08 12:55:57 +01:00
Daniel Eklöf
7999975016
Don't use fancy Unicode quotes, stick to ASCII 2024-02-06 12:36:45 +01:00
Daniel Eklöf
4449177517
term: cache font baseline
No need to redo the calculation for every single cell we render,
every frame...
2023-10-10 14:23:33 +02:00
Daniel Eklöf
a36f67cbe3
render: apply new baseline calculation everywhere
* URL jump labels
* Scrollback position indicator
* Line/box drawings characters

Closes #1430
2023-07-25 15:53:29 +02:00
L3MON4D3
d6dab2f2ba
Use circles for rendering light arc box-drawing characters.
Ellipses can look weird when the font is narrow.

Closes #988
2022-04-03 18:49:47 +02:00
Daniel Eklöf
e0227266ca
fcft: adapt to API changes in fcft-3.x
Fcft no longer uses wchar_t, but plain uint32_t to represent
codepoints.

Since we do a fair amount of string operations in foot, it still makes
sense to use something that actually _is_ a string (or character),
rather than an array of uint32_t.

For this reason, we switch out all wchar_t usage in foot to
char32_t. We also verify, at compile-time, that char32_t used
UTF-32 (which is what fcft expects).

Unfortunately, there are no string functions for char32_t. To avoid
having to re-implement all wcs*() functions, we add a small wrapper
layer of c32*() functions.

These wrapper functions take char32_t arguments, but then simply call
the corresponding wcs*() function.

For this to work, wcs*() must _also_ be UTF-32 compatible. We can
check for the presence of the  __STDC_ISO_10646__ macro. If set,
wchar_t is at least 4 bytes and its internal representation is UTF-32.

FreeBSD does *not* define this macro, because its internal wchar_t
representation depends on the current locale. It _does_ use UTF-32
_if_ the current locale is UTF-8.

Since foot enforces UTF-8, we simply need to check if __FreeBSD__ is
defined.

Other fcft API changes:

* fcft_glyph_rasterize() -> fcft_codepoint_rasterize()
* font.space_advance has been removed
* ‘tags’ have been removed from fcft_grapheme_rasterize()
* ‘fcft_log_init()’ removed
* ‘fcft_init()’ and ‘fcft_fini()’ must be explicitly called
2022-02-05 17:00:54 +01:00
Daniel Eklöf
e97e873b9e
box-drawing: LIGHT ARC: check for sqrt() failures
Closes #914
2022-02-04 18:15:35 +01:00
Daniel Eklöf
fb77637eb9
term: only scale using DPI if *all* monitors have a scaling factor or one
With dpi-aware=auto (the default), scale fonts using DPI *only*
if *all* available monitors have a scaling factor of one.

The idea is this: if a user, with multiple monitors, have enabled
scaling on *at least* one monitor, he/she has most likely done so to
match the size of his/hers other monitors.

For example, if the user has one monitor with a scaling factor of one,
and another one with a scaling factor of two, he/she expects things to
be twice as large on the second monitor.

If we (foot) scale using DPI on the first monitor, and using the
scaling factor on the second monitor, foot will *not* look twice as
big on the second monitor (this was the old behavior of
dpi-aware=auto).

Part of #714
2021-09-24 22:07:47 +02:00
Daniel Eklöf
705b5d786c
box-drawing: repair debug logs 2021-09-19 11:49:49 +02:00
Daniel Eklöf
e426e77b1d
box-drawing: braille: prefer increasing spacing over dot width
Too large dots make them harder to distinguish, when the spacing
between them is small.

Prefer increasing the spacing, instead of increasing the dot
size. This looks better at small font sizes in particular.
2021-09-14 10:20:07 +02:00
Daniel Eklöf
ac2091f107
box-drawing: NOINLINE braille 2021-09-12 19:22:14 +02:00
Daniel Eklöf
b4c759e2de
box-drawing: add braille characters
Render braille ourselves, instead of using font glyphs. Decoding a
braille character is easy enough; there are 256 codepoints,
represented by an 8-bit integer (i.e. subtract the Unicode codepoint
offset, 0x2800, and you’re left with an integer in the range 0-255).

Each bit corresponds to a dot. The first 6 bits represent the upper 6
dots, while the two last bits represent the fourth (and last) row of
dots.

The hard part is sizing the dots and the spacing between them.

The aim is to have the spacing between the dots be the same size as
the dots themselves, and to have the margins on each side be half the
size of the dots.

In a perfectly sized cell, this means two braille characters next to
each other will be evenly spaced.

This is however almost never the case. The layout logic currently:

* Set dot size to either the width / 4, or height / 8, depending on
  which one is smallest.

* Horizontal spacing is initialized to the width / 4

* Vertical spacing is initialized to the height / 8

* Horizontal margins are initialized to the horizontal spacing / 2

* Vertical margins are initialized to the vertical spacing / 2.

Next, we calculate the number of “remaining” pixels. That is, if we
add the left margin, two dots and the spacing between, how many pixels
are left on the horizontal axis?

These pixels are distributed in the following order (we “stop” as soon
as we run out of pixels):

* If the dot size is 0 (happens for very small font sizes), increase
  it to 1.
* If the margins are 0, increase them to 1.
* If we have enough pixels (need at 2 horizontal and 4 vertical),
  increase the dot size.
* Increase spacing.
* Increase margins.

Closes #702
2021-09-12 19:22:12 +02:00
Daniel Eklöf
f6f8f2b35e
pt-or-px: heed the dpi-aware setting
Before this patch, pt-or-px values, like letter-spacing, were *always*
scaled using the current DPI value.

This is wrong; if the fonts are scaled using the output’s scaling
factor, then so should all other point values.

This also fixes an issue where e.g. letter-spacing would use one DPI
value at startup, but then when increasing/decreasing or resetting the
font size, would be re-calculated using a different DPI value, leading
to completely different spacing.

This happened when there were multiple monitors, with different DPI
values, and foot guessed the initial DPI value wrong. Normally, foot
would correct itself as soon as the window was mapped, and the
“correct” DPI value known. But if the fonts were scaled using the
scaling factor, it was possible that the font reload never happened.

This patch also updates the thickness calculation (for LIGHT and HEAVY
box drawing characters) to use the scaling factor when appropriate.

Closes #680
2021-08-13 17:38:56 +02:00
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