Hacker News new | ask | show | jobs
by vidarh 16 days ago
No, you don't need to pick a fixed width font for that. You will get the best results with one, but rescaling the glyphs works just fine. I've written a font renderer. It's not hard.

In fact my terminal, using said font renderer, rescales glyphs by default because even a lot of "fixed width" fonts are buggy and not truly fixed, and so enforcing the grid alignment and scaling to fit was the easiest way to ensure consistency.

Mixing and matching fonts for full coverage works fine, especially for wide characters.

1 comments

I thought this discussion is more about somehow aligning pipes over multiple lines in existing console emulators(impossible), than about implementing a complete custom graphical text rendering system specific to your app that butcher font files to put glyphs wherever you want?

That feels like cheating since you're not rendering provided font at that point. Besides you might as well just use SVG for diagrams than pretending to be text only.

> I thought this discussion is more about somehow aligning pipes over multiple lines in existing console emulators(impossible)

I am aligning pipes over multiple lines in my existing console emulator. It's not just not impossible, but near trivial.

> than about implementing a complete custom graphical text rendering system specific to your app that butcher font files to put glyphs wherever you want?

It's not butchering anything. It is using the font data to render them in the way that fits the constraints of the output.

> That feels like cheating since you're not rendering provided font at that point.

Any font renderer makes just adjustments to make the font look as good as possible. That is the entire point of providing a scalable font instead of a bitmap font: That you can render the provided glyphs at any scale suitable.

Fitting the bounding box of the glyph to the bounding box of the cell the text is rendering into is entirely reasonable and the lesser of two evils when faced with a glyph that does not fit the cell, which is a relatively common occurrence, when the alternative is to clip.

It looks awful if you were to render e.g. latin script with a proportional font in a fixed grid, but for many scripts with more uniform widths the variation is a lot less, and so it's butchering things far less than rendering fallback glyphs for missing code points.