hpjansson / chafa

📺🗿 Terminal graphics for the 21st century.
https://hpjansson.org/chafa/
GNU Lesser General Public License v3.0
2.71k stars 57 forks source link

Support limiting symbols to a particular vintage character set #110

Open kimslawson opened 1 year ago

kimslawson commented 1 year ago

It would be a nice addition to chafa to support restricting the characters used to a subset corresponding to a particular computer's character set (for example, PETSCII, ATASCII, Apple II, etc.) While the vintage class to symbols and fill is nice, it's not specific enough... If I'm making ATASCII art, I don't want it to include characters that aren't supported by the Atari's limited character set.

I'd like to see classes corresponding to the individual computer/terminal types, so as to limit the output to that particular character set. (for example --symbols=ATASCII, --fill=PETSCII)

Specifically, characters from each supported character set class would need to be mapped to the appropriate unicode points, and those sets assigned to individual symbol classes. Unscii is a font that might help with this endeavour, as well as displaying the output in a terminal, as it faithfully tries to recreate the pixelated character sets of many retro platforms.

(Related closed issue here)

hpjansson commented 1 year ago

Yes! I actually want to implement a --preset (-P) option for this with built-in presets for vintage platforms. I've made rudimentary starts for C64 and IBM/VGA/cp437. A little more groundwork needs to be laid so it can also emulate the various color palettes.

kimslawson commented 1 year ago

Awesome!

Screen Shot 2022-09-16 at 11 43 32

This is what I get when I test using unscii-8 right now, but for example ATASCII has no support for many of those glyphs.

hpjansson commented 1 year ago

Nice Workbench 1.3 vibes :-)

By the way, you can specify individual glyphs by passing their hex codes to --symbols, e.g. --symbols 20,30..39, but it's obviously pretty tedious.

kimslawson commented 1 year ago

Nice Workbench 1.3 vibes :-)

Ha. I was going for Atari mode 0 but I got the luminance wrong.

kimslawson commented 1 year ago

This is what I get when I test using unscii-8 right now, but for example ATASCII has no support for many of those glyphs.

Screen Shot 2022-09-16 at 12 29 13

of course I haven't had enough coffee, because I got that command wrong. THIS is what it should look like with it restricted to legacy (I had it mixed up with "vintage" which is a nonexistent class)

Relevant still is that some of those are not supported by certain systems. So the point still stands :)

hpjansson commented 1 year ago

Indeed.

I'd love to have some help with the research. For instance, I'd accept a PR with an ATASCII table similar to the ones I did for C64/cp437. Or maybe there needs to be more than one table -- I'm not sure what the differences are between the Atari 400 and later models.

kimslawson commented 1 year ago

similar to the ones I did for C64/cp437

I had a look around the code and docs, but didn't see this. Can you point me in the right direction?

hpjansson commented 1 year ago

Ah sorry, I linked to the source files in https://github.com/hpjansson/chafa/issues/110#issuecomment-1249519684. They're not used for anything yet, but it's useful to keep adding those so I can integrate them later.

clort81 commented 1 year ago

This is what I get when I test using unscii-8 right now, but for example ATASCII has no support for many of those glyphs.

Screen Shot 2022-09-16 at 12 29 13

of course I haven't had enough coffee, because I got that command wrong. THIS is what it should look like with it restricted to legacy (I had it mixed up with "vintage" which is a nonexistent class)

Relevant still is that some of those are not supported by certain systems. So the point still stands :)

Amazingly, Viznut failed to add the eight glyphs that would be needed to emulate PETSCII triangles in half-width (common aspect ratio) monospace fonts. For that I made 8 glyphs with double-wide triangles, so that Blapinus has glyphs with 45 degree angle triangles.

clort81 commented 1 year ago

A HUGE THANK YOU to hpjansson for now restricting chosen glyphs to those contained in the --glyph-file !

/usr/local/bin/chafa --color-space=din99d --color-extractor=median -p on --symbols all --glyph-file /usr/share/fonts/X11/misc/blapetscii-12.pcf.gz -w 8 -s 80 redcrab-ihasfloppy.png

Now i can limit the glyphs used from my real font (blapinus) by creating a font containing only the glyphs I want! But... that's a lot of work to create and install a font just to limit the glyphs chafa pulls from!

Would anyone consider a patch that reads-in a list of glyph codepoints from a text file, and ONLY uses those?

Without the --glyph-file it is impossible for me to set the range that I want explicitly on the command line, using, for example

chafa --symbols none,+u2580+u2584+u258c+u2590+u2595+u25AE+uE000..uE07F+uEB4D..uEB92+uEC15..uEC18  redcrab-ihasfloppy.png

Fails to include the codepoints I add. It seems to select a few... (?). But none in the PUA range?

There ought to be a way for user to specify the exact codepoint ranges to use upon invocation and not get overriden by inscrutable internal program range-selection logic, without creating an entire new font every time he wants to adapt the selection of glyphs...