hpjansson / chafa

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

chafa8x8.py tuning/polishing #29

Open hpjansson opened 5 years ago

hpjansson commented 5 years ago

@cdluminate

This is probably not a showstopper, but may be worth looking into anyway:

When I run chafa8x8.py GenA, it prints the following:

$ ./chafa8x8.py GenA
 -> number of centers: 4414
=> Result saved to chafa8x8.json
Number of glyphs: 4414
I'm sorry this file is too complex for me to understand (or is erroneous)

The last one looks like an error message from fontforge. The resulting TTF seems ok from a quick look with ttfdump, though, so it's likely mostly cosmetic.

cdluminate commented 5 years ago

I was always ignoring that error message but nothing went wrong actually.

cdluminate commented 1 year ago

Maybe I should write a PCF font exporter instead of using fontforge?

hpjansson commented 1 year ago

PCF would be nice. I don't know how much work it is, though. It might be possible to do bitmap embeddings in TTF too.

The problem I'm seeing right now is that VTE puts vertical space between the characters, and mlterm adds horizontal space for some reason. So maybe the font dimensions/kerning is underspecified somehow.

hpjansson commented 1 year ago

I had to do this:

diff --git a/tools/fontgen/chafa8x8.py b/tools/fontgen/chafa8x8.py
index 2905f30..344499e 100755
--- a/tools/fontgen/chafa8x8.py
+++ b/tools/fontgen/chafa8x8.py
@@ -293,8 +293,6 @@ def mainGenFont(argv: List[str]):
             glyph.importOutlines('chafa8x8_svg/%d.svg' % i)
             glyph.left_side_bearing = 0
             glyph.right_side_bearing = 0
-            glyph.width = 0
-            glyph.vwidth = 0
         # font.save('chafa8x8.sfd')
         font.generate(ag.ttf)
         font.close()

to make the font loader work correctly. Otherwise it gets the glyph x size wrong. I don't know why it's there, though.

cdluminate commented 1 year ago

I had to do this:

diff --git a/tools/fontgen/chafa8x8.py b/tools/fontgen/chafa8x8.py
index 2905f30..344499e 100755
--- a/tools/fontgen/chafa8x8.py
+++ b/tools/fontgen/chafa8x8.py
@@ -293,8 +293,6 @@ def mainGenFont(argv: List[str]):
             glyph.importOutlines('chafa8x8_svg/%d.svg' % i)
             glyph.left_side_bearing = 0
             glyph.right_side_bearing = 0
-            glyph.width = 0
-            glyph.vwidth = 0
         # font.save('chafa8x8.sfd')
         font.generate(ag.ttf)
         font.close()

to make the font loader work correctly. Otherwise it gets the glyph x size wrong. I don't know why it's there, though.

Me neither -- I've forgotten the reason why the width is set as 0. But I remember back at that time I had a difficult time working around the character kerning/spacing issue in different terminals. They must be some workarounds that worked for the issue at that time.

cdluminate commented 1 year ago

Just for record. The above weird zero width issue is fixed in https://github.com/hpjansson/chafa/commit/e1e9f723acbbe2b6460469b1ce9e976f9d20752c That is a temporary hack to mitigate vertical/horizontal gaps in VTE terminals. We can improve it in the future.

clort81 commented 1 year ago

Fwiw i find bdf format convenient, allows text editing. And converting to pcf with xfonts-utils: /usr/bin/bdftopcf

cdluminate commented 1 year ago

The BDF font writer is here: https://github.com/hpjansson/chafa/commit/48f57019fd56e21e5cbdec91e7f95af3c5779649 But it seems that Unicode support range is an issue:

$ bdftopcf -o chafa8x8.pcf chafa8x8.bdf
[...]
BDF Error on line 105340: char 'U+0x101075' has encoding too large (1052789)
BDF Error on line 105365: char 'U+0x101076' has encoding too large (1052790)
BDF Error on line 105390: char 'U+0x101077' has encoding too large (1052791)
BDF Error on line 105415: char 'U+0x101078' has encoding too large (1052792)
BDF Error on line 105440: char 'U+0x101079' has encoding too large (1052793)
BDF Warning on line 105463: No characters with valid encodings
cdluminate commented 1 year ago

chafa8x8.bdf.zip

Fontforge can correctly read the resulting file. But the 0x100000 range is not supported for this format...

hpjansson commented 1 year ago

Could one of the lower PUA ranges work?