Remote-Url: https://hpjansson.org/blag/2021/09/16/chafa-1-8-terminal-graphics-with-a-side-of-everything/ Retrieved-at: 2021-09-19 18:00:40.603261+00:00 TheChafachangelog was growing long again, owing to about half a year's worth of slow accretion. Hence,a release. Here's some stuff that happened.High-end protocolsWith existing choices of the old text mode standby and its friend, the most unreasonably efficient sixel encoder known to man, I threwKittyandiTerm2on the pile, bringing our total number of output formats to four. I think that's all the terminal graphics anyone could want (unless you wantReGIS; in which case, tough tty).Moar terminalsModern terminal emulators are generally less fickle than their pre-y2k ancestors. However, sometimes it takes a little sleuthing to figure out which extended features might be hiding behind e.g. some mysteriousxterm-256colorfaçade so we can do the right thing.Luckily, Chafa has a steadily improving handle on terminals of the Unix/GNU/Linux world. A few examples:Of course, this is forever a work in progress and an area where I receive regular, highly appreciated contributions*chef's kiss – somehow still not an actual emoji*.Funky lo-fi featuresØyvind Kolås(ofGIMPandGEGLfame) swooped in with new builtins for the legacy computing block, meaning Chafa is nowPETSCIIReady™ – or as ready as you can be with Unicode 13.0: The standard has a few annoying issues, such as not declaring any code points for the four permutations of black triangle, relying instead on existing code points in the geometric shapes block (U+25E2..U+25E5) which are typically represented by fonts as sitting on the baseline surrounded by empty space and therefore useless next to the legacy computing and block elements blocks.Still, it's got a sweet 2×3 dot matrix (--symbols sextant) and all those nifty wedge shapes (--symbols wedge).Øyvind also added an 8-color mode. Used together (-c 8 --symbols legacy+space), these features enable visual emulation ofTeletextLevel 1 and similar systems widely deployed in the late 1970s until roughly 1990 (technicallyinto the present, albeit perhaps not so widely anymore).Somewhere along the way I discovered that Øyvindhas a Patreon page– and if you're a GIMP user and/or care about the free software graphics ecosystem, you may want to readthis articleand consider its implications.A bit of background austerityI followed up in the retro vein with a foreground-only (--fg-only) modifier, which allows emulation of vintage systems that could only specify a single color per cell against a uniform background color. A popular example is the Commodore 64'sstandard character mode. It's also useful in terminals where block symbols don't render correctly (for example due to missing font support), since it prevents background color variation from drowning out details in low-coverage symbols used in their place. The Linux consoletends to be among thesedue to hardware and font limitations that are somehow still in play today.This is also how many classic ASCII art packages did things; so I guess I am once again asking you to party like it's 1999 (…and stay up all night trying to make your Napster killer render withAAlib).When used with--fg-only, the existing--bgoption has a greater impact than usual; in addition to being the fade color for alpha blending, it determines the relationship between symbols and blank space, including symbols where the background color "wins" part of a cell. A dark image on a bright background will have more high-coverage symbols that cover up the background as much as possible.If your terminal has a bright background color,--invertis a shortcut to inverting the sense of--fgand--bg; the white-on-black default then becomes black-on-white.Since foreground-only mode leaves the background color alone, you can easily experiment with setting it yourself, e.g:echo -e '\033[41m'; \ chafa -c 16 --symbols ascii --fg-only --bg darkred birbs.pngWeird and wonderful forum art reduxIf you read Steam reviews, you may be familiar with this guy:There are layers to this, but I'll keep it brief and simply observe that people seem to like braille. Braille is popular in this context for at least four reasons. It has:A luxurious 2×4 dot matrix at your fingertips.Widespread font support.Consistent glyph width even in variable-width fonts.A special blank symbol (U+2800 BRAILLE PATTERN BLANK) for consistent spacing.Chafa's supported this kind of output for a long time (-c none --symbols braille), but in some circumstances it could replace cells having identical foreground and background colors with a hardcoded U+0020 as an optimization. This could result in inconsistent spacing, making braille (and probably other symbol combinations) less useful. Fortunately the issue is now a thing of the past; the latest version will instead use a visually blank symbol from the user's symbol set, falling back to the lowest-coverage symbol it can find.The GPL doesn't regulate netiquette: Please use for good, or in extreme cases, awesome.The ever elusive practical application in the wildIt's good to be useful.Neofetchwas the first project to avail itself of Chafa's incredible power, and the latest isHarfBuzz'hb-view. And – er – I think that's all of them. For now!⠀⠀⠀⠀⠀⠀⠀⠀⢠⣿⣶⣄⣀⡀⠀⠀⠀⠀⠀⠀⢀⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⣦⣄⣀⡀⣠⣾⡇⠀⠀⠀⠀⠀⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⢀⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠿⢿⣿⣿⡇⣶⣿⣦⣜⣿⣿⣿⡟⠻⣿⣿⣿⣿⣿⣿⣿⡿⢿⡏⣴⣺⣦⣙⣿⣷⣄⣯⡇⣻⣿⣿⣿⣿⣷⣾⣿⣬⣥⣭⣽⣿⣿⣧⣼⡇⣯⣇⣹⣿⣿⣿⣿⠹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠸⣿⣿⣿⣿⣿⣿