Text-mode apps (Was :Who are the "spacists"?)

Chris Angelico rosuav at gmail.com
Sun Mar 26 13:29:30 EDT 2017


On Mon, Mar 27, 2017 at 3:57 AM, Mikhail V <mikhailwas at gmail.com> wrote:
> On 26 March 2017 at 17:37, Chris Angelico <rosuav at gmail.com> wrote:
>> On Mon, Mar 27, 2017 at 2:17 AM, Mikhail V <mikhailwas at gmail.com> wrote:
>>>>> Why? IIRC I can do good pseudographics on linux only with extended
>>>>> unicode character sets, so yes it is possible, is that what you mean?
>>>>
>>>> No.  The same ASCII character set that was available in DOS is
>>>> available in Linux without unicode.
>>>
>>> Ok, now I have read that one can change the encoding in the terminal
>>> to get same table drawing characters (if one does not want to use
>>> unicode).
>>
>> Just use Unicode. Everything else, these days, is a subset of Unicode
>> anyway. Unless you're stuck on the default Windows shell/terminal, you
>> should be able to use UTF-8 everywhere and have the entire Unicode
>> range available.
>
> Yes I am 'stuck' on Windows console, and I use it for what it is
> made for - running command line tools.

Not really stuck; even if you can't get off Windows, you should be
able to move off the ancient terminal that you get by default.

> On Win 7 and 10, I can see UTF-8 chars everywhere.
> To be precise, to see entire range of chars, you need a _font_
> in which someone have drawn those chars according to their
> understanding how those glyphs must look, nothing more.

Duh? If you want characters to display, you need a font.... yes...?

> No need to say, that even for text only, monospaced cannot
> represent them even close to satisfying, and for Arabic for example they
> look ass ugly in monospaced.
> IOW, even a console-like apps would use proportional fonts in the future.

Arabic text is written right-to-left. It's a lot more complicated than
just whether your font is monospaced or not, particularly when you mix
strongly-directional characters, weakly-directional characters,
non-directional characters, and explicit directionality markers. If
you mix RTL and LTR text, is the RTL text aligned to the right of the
page, or the left? There is a LOT more than just your font to take
care of here. If you want perfect handling of international text, you
basically need to use a Unicode-compliant text renderer - and
fortunately, most graphical engines these days come with exactly that.

>>> And more important: can one use binary (bitmap) fonts in default modern
>>> linux console? If yes, can one patch them with custom tiles at
>>> the application start?
>>
>> If you really need something completely custom, it's not text any
>> more.
>
> Obvious fact, but if I need e.g. rounded corners in table drawing
> characters? Or I just want to fix some characters which look especially ugly?
> Create a new TTF? No, thanks, this would be worst nightmare to
> do without a special tool (which have prices with several zeros, otherwise
> just don't work and can even break things system-wide)

Rounded corners?

╭─┬─╮
├─┼─┤
╰─┴─╯

A good font should show this as a rounded box with cross-lines through
it. The characters here are:

U+256D BOX DRAWINGS LIGHT ARC DOWN AND RIGHT
U+2500 BOX DRAWINGS LIGHT HORIZONTAL
U+252C BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
U+2500 BOX DRAWINGS LIGHT HORIZONTAL
U+256E BOX DRAWINGS LIGHT ARC DOWN AND LEFT
U+000A LINE FEED
U+251C BOX DRAWINGS LIGHT VERTICAL AND RIGHT
U+2500 BOX DRAWINGS LIGHT HORIZONTAL
U+253C BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
U+2500 BOX DRAWINGS LIGHT HORIZONTAL
U+2524 BOX DRAWINGS LIGHT VERTICAL AND LEFT
U+000A LINE FEED
U+2570 BOX DRAWINGS LIGHT ARC UP AND RIGHT
U+2500 BOX DRAWINGS LIGHT HORIZONTAL
U+2534 BOX DRAWINGS LIGHT UP AND HORIZONTAL
U+2500 BOX DRAWINGS LIGHT HORIZONTAL
U+256F BOX DRAWINGS LIGHT ARC UP AND LEFT
U+000A LINE FEED

And if you think that some characters look ugly, you can create a font
with just those characters in it. Thanks to font substitution, your
font should be used for the characters it defines, but anything it
doesn't will fall back on some other font, so you don't have to create
representations for hundreds of thousands of Unicode characters.

>> More likely, you don't truly need something custom - what you need is
>> a different subset of characters (maybe you need to mix Latin, Greek,
>> and Hebrew letters, in order to show interlinear translation of the
>> Bible). Instead of messing around with character sets, you can just
>> use Unicode and have all of them available.
>
> If I was to deal with multiple language charsets in _my own_ rendering
> app, I would still use discrete encoding for inner algorithms.
> i.e. I would place separate charsets on separate code ranges.
> And for own standalone app, I would not use any TTF or
> anything vector-based font, since why?

Separate code ranges? You mean like allocating U+03xx to Greek, U+04xx
to Cyrillic (Russian and friends), U+06xx to Arabic, etc? Sounds like
a good plan....

>> Yeah; if my memory serves me, this was an IBM BIOS feature, so all
>> versions of DOS would be equally able to do it. But it's basically a
>> form of tile graphics, not text. Given how easily graphical programs
>> can be built these days, I would strongly recommend that, rather than
>> abusing pseudo-text as pseudo-graphics. Pick up Tk or GTK or wxWindows
>> or something, or build your app to run in a web browser, or something
>> like that.
>
> Exactly, that is why I do so, and even if one wants to play around
> with console hacking, there is not so many documented
> ways to do it. In Windows, I can manually select raster fonts,
> so in pure theory, one could hack it with custom tiles, but
> since it is much easier to use a graphical library today,
> too few people are interested in it.

It's easier AND better. Why mess around with the console config when
you can just draw what you need?

ChrisA


More information about the Python-list mailing list