textual
textual copied to clipboard
Improve cosmetics on Linux vconsole
Textual works, but doesn't look good on the Linux virtual console environment. I am about to deploy an in company solution that uses textual on read-only Linux ISOs, where the textual app is launched as the default shell. It all works, but the box drawing looks poor, and you can see the problem by running any textual demo in the console environment. All the graphical elements that should have edges have rows of diamonds (or whatever the missing glyph is shown as for that font). The available colors are limited, and the scroll bars have no contrast, but that could presumably be fixed with some CSS.
Ironically, if you provoke a traceback, the box drawing in the traceback looks great.
The Linux console has some limitations, inherited from VGA hardware text mode. There are at most 256 glyphs, or 512 if you give up bright colors. A standard install ships with about 120 font files, which differ in both glyph shape and size, and the mapping of character index to glyph shape, to cover a range of languages. I have looked at quite a lot of the Latin ones, and all the ones I checked have the basic, single-line box drawing characters and some shading chars, round 0xB0 to 0xB5 and 0xC0 to 0xC6.
There are supposedly some psfu fonts, which do some extended Unicode mapping to the limited set of available glyphs, and these might include some or all of the Unicode box drawing area round 2500 that Textual uses. None of my installs have psfu files, but I could chase that if it one that works was known.
I don't want to solutioneer, but I can see two options.
- Either, a better font is found (or made).
- Or, an alternate box drawing mode that uses the existing single line glyphs. Ideally, this would auto-detect, but if we had to pass a parameter in, perhaps to the app object, that would be fine. Looking at the source code, I think changes could be largely localised to the box drawing module.
Happy to help, but I don't want to start changing things on a clone in a way you would never accept.
Thank you for your issue. Give us a little time to review it.
PS. You might want to check the FAQ if you haven't done so already.
This is an automated reply, generated by FAQtory
I will investigate, but it looks like the zap fonts include more box drawing chars, and map the Unicode 2500 range, so might be an option. See https://www.zap.org.au/projects/console-fonts-zap/.
Textual is quite configurable, so it would be quite doable to find a set of styles that work well on the Linux console.
We have an update in the pipeline to allow for ansi-colors. I suspect that most of the poor visuals are due to downsampling truecolor RGB to 256 / 156 colors. We could also have a mode to pick characters for borders that work better.
In short, there is a lot that could be done.
Can I ask who you are working for?
I work at QinetiQ, in the UK, although we have branches round the world.
On Wed, 18 Sept 2024, 09:48 Will McGugan, @.***> wrote:
Textual is quite configurable, so it would be quite doable to find a set of styles that work well on the Linux console.
We have an update in the pipeline to allow for ansi-colors. I suspect that most of the poor visuals are due to downsampling truecolor RGB to 256 / 156 colors. We could also have a mode to pick characters for borders that work better.
In short, there is a lot that could be done.
Can I ask who you are working for?
— Reply to this email directly, view it on GitHub https://github.com/Textualize/textual/issues/5011#issuecomment-2357871384, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC4N6MFYDH76PHFPTTHIS4TZXE47JAVCNFSM6AAAAABOJWCFJOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNJXHA3TCMZYGQ . You are receiving this because you authored the thread.Message ID: @.***>
QinetiQ Im going to check them out.
Further observations. I have tried the ansi_colors switch from version 0.80.0 onwards, and it doesn't help with my specific problems.
I can improve things a lot by fiddling with the styling, for example by setting the scrollbar-color to something in the VGA color set, it is at least visible - used yellow, which looks weird, but at least has contrast.
My guess that the problem is to do with line drawing characters is wrong; the unicode mappings on the two fonts I tried are good enough that setting border: solid works. If I use zap-light18, I can even mix border: double and border: single as distinct.
Many of the cosmetic glitches can then be improved by setting border: solid on a variety of widgets. My residual glitches come down to the fact that the block drawing characters of different heights and widths are not in any of the console fonts I have tried. This means that border: tall, which is used at the top and bottom of buttons in the default style, comes up as missing glyphs. Setting a border: solid on Button draws an outline, which looks OK, except for variant buttons where the background extends outside the border.
There is a similar problem with the scrollbar, which uses the variable height or width blocks in search of extra position resolution for the thumb. This is hardcoded as class variables in scrollbar.py.
As this is python, I could presumably replace the existing values with my own array, and trade smooth scrolling for reduced artefacts.
Beyond that, maybe one of 512 glyph fonts from the Zap people has more of the block characters, which might solve things at the expense of loosing bright / normal colour distinctions. Alternatively, and this is heading into the realm of fantasy land, are there ansi sequences for switching between fonts? Could one use a special font loaded with blocks and the like for rendering the cosmetics, and swap back to normal font for the Latin characters?
The 512 glyph Zap fonts have lots more accented, Greek and Cyrillic characters, not block drawing. I have found a PSF font with block drawing; psf-unifont. It is primarily intended to support APL (oddball langauge, originally from IBM, with single character operators for vector, matrix and tensor operations). It doesn't have many accented characters, but probably enough western europen languages. The downside is that because it is a 512 glyph font, you only get 8 colors, and that really messes up the rendering for light mode! In dark mode, it mostly looks OK. I still need to set scrollbar-color to something, but that is the only thing.
So my suggestion is a documentation fix in the short term: Where you discuss using various terminals, and their short comings, suggest the psf-unifont package for the Linux console, and that because there are only 8 colors, you need to make some harsh style choices, and in particular to set scrollbar-color to something different from the background. Going forward, when theming is a thing, an eight color theme would give some of this out of the box.
I'd certainly like to see some improvements here myself. My use-case is similar. I'm writing an application that also runs off of an ISO. In my case, it's a post system install wizard that runs in the virtual terminal so the users can configure things. Currently, our application is built on urwid... which is... kind of... not so great. But, it somehow manages to look better than textual currently does, which really hurts me to say... especially after putting about 120 hours into converting our application to textual. I probably should have tested in the console sooner.
I think the practical solution is a custom PCF font. Textual needs 16 colour support, so no more than 256 glyphs, and it needs a full set of the line drawing and block drawing glyphs. The APL font has everything we need, but is a 512 glyph font, so only has 8 colours, which really messes the rendering up.
There are open source tools for working with PCF fonts, and we need somebody to make one that fits those constraints. Any voliunteers? I don't think you would need to design any new shapes - just starting with say the APL font and slimming it down to 256 would do (License conditions permitting!) - or one of the existing 256 glyph fonts and substituting block drawing glyphs for some other ones. Many of the 256 glyph fonts have enough line drawing characters, but usually lack block drawing.
Honestly I have no idea what a PCF font is, but wouldn't an "ASCII-only" mode be a simpler solution...?
- https://github.com/Textualize/textual/issues/3086
PCF fonts are used by the Linux console. Strict ASCII only mode loses nice features like button outlines and scroll bars. It looks fairly ugly, and obviously can not support languages with accented characters. You can improve cosmetics a lot by playing with css, but the lack of block drawing means scrollbars are not good.
On Fri, 27 Jun 2025, 19:48 TomJGooding, @.***> wrote:
TomJGooding left a comment (Textualize/textual#5011) https://github.com/Textualize/textual/issues/5011#issuecomment-3014067808
Honestly I have no idea what a PCF font is, but wouldn't an "ASCII-only" mode be a simpler solution...?
— Reply to this email directly, view it on GitHub https://github.com/Textualize/textual/issues/5011#issuecomment-3014067808, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC4N6MC67XXJQUSLT4GHOPD3FWGZFAVCNFSM6AAAAACAB6RMXKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTAMJUGA3DOOBQHA . You are receiving this because you authored the thread.Message ID: @.***>