aboutsummaryrefslogtreecommitdiff
path: root/box-drawing.c (follow)
Commit message (Collapse)AuthorAgeLines
* box-drawing: fenv.h: remove, not needed anymoreDaniel Eklöf2025-12-26-1/+0
|
* box-drawings: handle architecture with soft-floatThomas Bonnefille2025-02-05-3/+1
| | | | | | | | | | | | 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>
* box-drawings: implement octantsDaniel Eklöf2024-12-08-10/+440
|
* Don't use fancy Unicode quotes, stick to ASCIIDaniel Eklöf2024-02-06-1/+1
|
* term: cache font baselineDaniel Eklöf2023-10-10-1/+1
| | | | | No need to redo the calculation for every single cell we render, every frame...
* render: apply new baseline calculation everywhereDaniel Eklöf2023-07-25-1/+1
| | | | | | | | * URL jump labels * Scrollback position indicator * Line/box drawings characters Closes #1430
* Use circles for rendering light arc box-drawing characters.L3MON4D32022-04-03-114/+214
| | | | | | Ellipses can look weird when the font is narrow. Closes #988
* fcft: adapt to API changes in fcft-3.xDaniel Eklöf2022-02-05-16/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* box-drawing: LIGHT ARC: check for sqrt() failuresDaniel Eklöf2022-02-04-0/+12
| | | | Closes #914
* term: only scale using DPI if *all* monitors have a scaling factor or oneDaniel Eklöf2021-09-24-2/+2
| | | | | | | | | | | | | | | | | | | | 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
* box-drawing: repair debug logsDaniel Eklöf2021-09-19-4/+3
|
* box-drawing: braille: prefer increasing spacing over dot widthDaniel Eklöf2021-09-14-17/+20
| | | | | | | | 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.
* box-drawing: NOINLINE brailleDaniel Eklöf2021-09-12-1/+1
|
* box-drawing: add braille charactersDaniel Eklöf2021-09-12-0/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* pt-or-px: heed the dpi-aware settingDaniel Eklöf2021-08-13-28/+34
| | | | | | | | | | | | | | | | | | | | | | | | 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
* box-drawing: fix compiler warningDaniel Eklöf2021-08-06-1/+1
| | | | | | | | | | ../../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; | ^~
* box-drawing: re-align sextants and wedgesDaniel Eklöf2021-08-06-47/+62
| | | | | Improve the visual quality of sextants (and wedges) when the cell height isn’t a multiple of three.
* box-drawing: don’t inline functions called for multiple codepointsDaniel Eklöf2021-08-05-5/+5
| | | | | In several cases, this expanded to multiple calls, and when inlined, resulted in much larger code size.
* box-drawing: wedges: pre-load x_halfs[] and y_thirds[]Daniel Eklöf2021-08-05-64/+71
| | | | This reduces the number of loads in the rest of the function.
* box-drawing: wedges: avoid floating point mathDaniel Eklöf2021-08-05-68/+66
| | | | | Re-use the pre-calculated offsets used by the sextants. This is the correct thing to do since wedges *should* align with sextants.
* box-drawing: pre-calculate sextant x,y offsetsDaniel Eklöf2021-08-05-6/+19
| | | | | | | | 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.
* box-drawing: deal with quads in the same as sextantsDaniel Eklöf2021-08-05-79/+42
| | | | | | 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”.
* box-drawing: don’t inline horizontal-one-eighth-block-NDaniel Eklöf2021-08-05-1/+1
|
* box-drawing: don’t inline light diagionalDaniel Eklöf2021-08-05-2/+2
|
* box-drawing: wedges: fix alignment of inverted wedgesDaniel Eklöf2021-08-05-33/+109
| | | | | | | | | | | | | 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.
* box-drawing: wedges: don’t group similar cases togetherDaniel Eklöf2021-08-05-48/+100
| | | | | Since they’re not exactly alike, we still need branches within each case. Better to split them up - one case per codepoint.
* box-drawing: add U+1FB3C-U+1FB6F, U+1FB9A and U+1FB9BDaniel Eklöf2021-08-05-4/+217
| | | | | | These are the “wedges” from the Unicode 13 “Legacy Computing” symbols. Closes #474
* box-drawing: big-endian support when setting bits manuallyDaniel Eklöf2021-07-14-6/+16
|
* box-drawing: pre-calculate the LIGHT and HEAVY thicknessesDaniel Eklöf2021-05-17-4/+16
|
* box-drawing: always pass ‘buf’ as the first parameterDaniel Eklöf2021-05-17-6/+6
| | | | | This way, the compiler doesn’t have to waste instructions on re-ordering the parameters
* box-drawing: don’t inline _thickness()Daniel Eklöf2021-05-17-1/+1
| | | | | It results in quite a lot of floating point instructions being emitted in almost every box drawing function we have...
* box-drawing: use fill_boxes() instead of fill_rectangles()Daniel Eklöf2021-05-17-30/+20
|
* box-drawing: increase brightness of solid shadesDaniel Eklöf2021-05-17-3/+3
|
* config: add tweak.box-drawing-solid-shades=yes|noDaniel Eklöf2021-05-17-10/+11
| | | | | | | | | | 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.
* box-drawing: use an a8 buffer when primary font is antialiasedDaniel Eklöf2021-05-17-1/+3
| | | | | This causes relevant box drawing characters (diagonals, arcs etc) to be antialiased as well.
* box-drawing: change_buffer_format: abort on pixman failureDaniel Eklöf2021-05-17-0/+6
|
* box-drawing: apply antialiasing to LIGHT ARCsDaniel Eklöf2021-05-17-40/+73
| | | | | | | | | | | | | | | | 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
* box-drawing: draw_pixman_shade(): named struct initializationDaniel Eklöf2021-05-17-1/+1
|
* box-drawing: fix typo: missing ‘.’ in struct member initializationDaniel Eklöf2021-05-17-1/+1
|
* box-drawing: shades can now be rendered either using solid color, or checker boxDaniel Eklöf2021-05-17-21/+51
| | | | | For now, switching is done using a static variable. In the future, this could be a user option.
* box-drawing: temporary “fix” for LIGHT ARCs with a8 buffersDaniel Eklöf2021-05-17-1/+22
| | | | | | 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.
* box-drawing: swap amount of shade for LIGHT and DARK shadesDaniel Eklöf2021-05-17-2/+2
| | | | | The DARK shade is the one most dense, and thus the one that looks brightest.
* box-drawing: draw shades as “antialiased” blocksDaniel Eklöf2021-05-17-18/+36
| | | | | | | | 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.
* box-drawing: use pixman_image_fill_boxes() for rect()Daniel Eklöf2021-05-17-10/+2
|
* box-drawing: implement LIGHT diagonal lines using pixmanDaniel Eklöf2021-05-17-30/+52
| | | | Use trapezoids to rasterize the diagonal lines.
* box-drawing: rect(): implement using pixmanDaniel Eklöf2021-05-17-7/+15
| | | | Use pixman_image_fill_rectangles() to render rectangles. Duh!
* box-drawing: {h,v}line: implement using pixmanDaniel Eklöf2021-05-17-14/+20
| | | | | | | | 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.
* box-drawing: U+256C - BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL: add missing cornerDaniel Eklöf2021-05-17-1/+1
| | | | The inner corner, where the upper/left lines meet, were missing
* box-drawing: include pixman image in the buffer we’re passing aroundDaniel Eklöf2021-05-17-2/+6
|
* box-drawing: add Unicode 13 U+1FB70 - U+1FB8BDaniel Eklöf2021-05-04-2/+227
| | | | Part of #471
* debug: rename assert() to xassert(), to avoid clashing with <assert.h>Craig Barnes2021-01-16-8/+8
|
* box-drawing: use enum constants in draw_sextant() instead of #defineCraig Barnes2021-01-15-6/+8
| | | | | Both are functionally equivalent here, but the former is also properly scoped, can be naturally indented and has a less repetitive syntax.
* box-drawing: line thickness now depends on both DPI and cell sizeDaniel Eklöf2021-01-12-11/+21
| | | | Cell size is defined as the length of the diagonal of the cell.
* box-drawing: LIGHT ARC: ensure row+col are within rangeDaniel Eklöf2021-01-12-8/+12
|
* box-drawing: {h,v}line() + rect(): ensure *end* row/col is >= 0Daniel Eklöf2021-01-12-3/+3
|
* box-drawing: x/y offsets: use pre-calculated offset values from term structDaniel Eklöf2021-01-11-12/+2
|
* config: line-height, letter-spacing: values are in pt by default, but we allow pxDaniel Eklöf2021-01-11-2/+12
| | | | | | | | 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.
* box-drawing: compensate for non-zero {horizontal,vertical}-letter-offsetsDaniel Eklöf2021-01-11-2/+3
| | | | | Box drawing characters should always cover the entire cell. No more, no less.
* Use wrappers from macros.h instead of bare GCC attributes/pragmasCraig Barnes2021-01-03-7/+2
|
* box-drawing: drop ‘pragma GCC optimize(“Os”)’Daniel Eklöf2021-01-02-4/+0
| | | | | | | | | “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.
* box-drawing: codespell: assymetrical -> asymmetricalDaniel Eklöf2021-01-02-2/+2
|
* box-drawing: add macros for {h,v}line_middle_mixed()Daniel Eklöf2021-01-02-24/+28
| | | | | | 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.
* box-drawing: LIGHT ARC: simpler way to adjust for asymmetrical arc when mirroringDaniel Eklöf2021-01-02-4/+31
| | | | | | | | | | | 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.
* box-drawing: LIGHT ARC: use min/max instead of checking range inside loopDaniel Eklöf2021-01-02-10/+5
|
* box-drawing: LIGHT ARC: fix alignment of arcs when thickness is > 1pxDaniel Eklöf2021-01-02-29/+58
|
* box-drawing: LIGHT ARC: test using a circle equation instead of a bezier curveDaniel Eklöf2021-01-01-73/+35
|
* box-drawing: guard GCC pragma with #if defined(__GNUC__)Daniel Eklöf2021-01-01-1/+3
|
* box-drawing: do not inline any of the utility functionsDaniel Eklöf2021-01-01-21/+21
|
* box-drawing: dedicated functions to draw a full horizontal/vertical lineDaniel Eklöf2021-01-01-88/+60
|
* box-drawing: convert {h,v}line_middle_{left,right,up,down}() macros to functionsDaniel Eklöf2021-01-01-53/+56
| | | | This greatly reduces the size of the foot binary
* box-drawing: sextants: convert sextant_*() macros to functionsDaniel Eklöf2021-01-01-12/+41
| | | | While this doesn’t really reduce foot’s size, it is cleaner
* box-drawing: quadrants: convert quad_*() macros to functionsDaniel Eklöf2021-01-01-25/+44
| | | | | | | | | This reduces the size of the foot binary by ~4K; all the quad macros called ceil() and floor() twice per macro, which caused many float -> int -> float conversions in the expanded code. By using functions instead, there’s no expansion - the conversion only happens in one (well, four) places.
* box-drawing: reduce number of function argumentsDaniel Eklöf2021-01-01-579/+589
| | | | | | | | | We were using so many function arguments that a lot of the emitted code was just stack push and pops to pass around arguments. Bundle the buffer data, width, height, stride, and current DPI, into a single ‘buf’ argument. This greatly reduces the number of arguments to all functions.
* box-drawing: force minsize optimizationDaniel Eklöf2021-01-01-0/+2
|
* box-drawing: disable debug outputDaniel Eklöf2021-01-01-1/+1
|
* box-drawing: LIGHT DIAGONALsDaniel Eklöf2021-01-01-6/+50
| | | | | | * U+2571 * U+2572 * U+2573
* box-drawing: silence variable-may-not-be-initialized warningsDaniel Eklöf2021-01-01-2/+2
|
* box-drawing: LIGHT/HEAVY DOUBLE/TRIPLE/QUADRUPLE VERTICALDaniel Eklöf2021-01-01-72/+138
| | | | | | | | | | | Also combine the HORIZONTAL versions into a single draw function. * U+2506 * U+2507 * U+250A * U+250B * U+254E * U+254F
* box-drawing: LIGHT/HEAVY DOUBLE/TRIPLE/QUADRUPLE HORIZONTALDaniel Eklöf2021-01-01-6/+130
| | | | | | | | | *U+2504 *U+2505 *U+2508 *U+2509 *U+254C *U+254D
* box-drawing: LIGHT ARC: improve symmetry when cell width is evenDaniel Eklöf2021-01-01-4/+24
|
* box-drawing: LIGHT ARC: no need to do floating point since we’re truncatingDaniel Eklöf2021-01-01-4/+4
|
* box-drawing: LIGHT ARC: pixel-perfectDaniel Eklöf2021-01-01-24/+26
| | | | At least in odd-sized cells, with a thickness of 1 pixel.
* box-drawing: wip: LIGHT ARC: U+256d-U+2570Daniel Eklöf2021-01-01-6/+95
|
* box-drawing: {h,v}line(): handle both start/end point being too small *and* too largeDaniel Eklöf2021-01-01-2/+8
|
* box-drawing: thickness(): ensure thickness is *at least* 1pxDaniel Eklöf2021-01-01-1/+1
|
* box-drawing: make sure we never walk outside the (image) bufferDaniel Eklöf2021-01-01-13/+14
|
* box-drawing: wrap {h,v}hline() functions in macros, to shorten argument listDaniel Eklöf2021-01-01-94/+98
| | | | | | | | Rename the *function* {h,v}line() to _{h,v}line(), and add two new macros: hline() and vline(). This allows us to shorten the argument list by removing the ‘buf’ and ‘stride’ arguments.
* box-drawing: SEXTANTS, U+1fb00-1fb3bDaniel Eklöf2021-01-01-0/+135
|
* box-drawing: oops - remove accidental ‘x’Daniel Eklöf2021-01-01-1/+1
|
* box-drawing: remove LOG_WARN from U+259x range - all codepoints have been implementedDaniel Eklöf2021-01-01-4/+1
|
* box_drawing(): mark function as ‘cold’Daniel Eklöf2021-01-01-1/+1
|
* box-drawing: remove __attribute__((__const__)) from thickness()Daniel Eklöf2021-01-01-1/+1
| | | | thickness() is a static function and thus ‘const’ is not necessary.
* box-drawing: make ‘term’ parameter constDaniel Eklöf2021-01-01-1/+1
|
* box-drawing: DOUBLE lines, U+2550-U+256CDaniel Eklöf2021-01-01-31/+418
|
* box-drawing: LIGHT/MEDIUM/DARK SHADEDaniel Eklöf2021-01-01-3/+39
| | | | | | * U+2591 * U+2592 * U+2593
* box-drawing: QUADRANTs: ensure all quads have equal width and hightDaniel Eklöf2021-01-01-4/+4
| | | | | If the cell width/height is odd, the previous implementation would result in uneven quads.
* box-drawing: QUADRANTsDaniel Eklöf2021-01-01-10/+86
| | | | | | | | | | | | | * U+2596 * U+2597 * U+2598 * U+2599 * U+259A * U+259B * U+259C * U+259D * U+259E * U+259F
* box-drawing: RIGHT HALF, UPPER ONE EIGHTH and RIGHT ONE EIGTHDaniel Eklöf2021-01-01-3/+21
| | | | | | * U+2590 * U+2594 * U+2595
* box-drawing: use floating point math, and round(), when drawing block elementsDaniel Eklöf2021-01-01-15/+15
| | | | | This is especially important for the LEFT xxx BLOCK characters, since cells can be quite narrow, and one eighth is not a lot...
* box-drawing: first half of the block elements, U+2580-U+258FDaniel Eklöf2021-01-01-18/+126
|