Monday, September 27, 2021

gVim Font Fixes and Other Tangents

Okay, I fixed something that has been irking me for a very long time: why gVim in Windows cannot use my favourite pan-Unicode font, Unifont in it despite being distinctively monospaced in nature as compared to the regular proportional fonts.

As it turns out, the TTF marks it as ``Even Width'' instead of ``Monospaced'', which explains why despite having the font installed, I simply could not select/set it in gVim via the .vimrc file.

The solution then is to grab Fontforge (I already have it installed some time back), and go through the annoying process of setting the correct marked information. I'm replicating the steps here in case the information goes away:
  1. Fire up Fontforge and load the relevant TTF file.
  2. Once loaded, go ``Element''→``Font Info''→``OS/2''→``Panrose'' and set ``Proportion'' to ``Monospaced''.
  3. Head to ``PS Names'' and update the various fields to not clash with the existings ones for Unifont (I just shoved a capital `H' in front for ``Hacked'', so my hacked font is now ``HUnifont'').
  4. After dismissing all the dialogue boxes, head to ``File''→``Generate Fonts'' and just follow through to generate some new TTF, ignoring warnings/errors.
  5. Install the generated TTF and we are done.
And from that, we've got a ``monospaced'' version of Unifont that can be activated in gVim. The multi-cellular span of some double-width characters (like CJK ideograms) are rendered correctly, as is the navigation through them, so all in all, I call this a success.

On a semi-related note, after getting back into QuickBASIC on my retro-programming tour, I've fallen back in love with the stupidity that is the 9×16 VGA character font. You see, when I was writing FilePak for LED2-20, I used the iconic QuickBASIC IDE with its glorious 80×25 text mode display with blue background and light gray characters in full-screen, and that really made my eyeballs feel so at home, despite these days trying my best to avoid dealing with blue light [at night] in general.

So nostalgic.

Anyway, someone has gone through the trouble and created modern equivalents of the old school text-mode fonts, with the added proportion adjustments to ensure that what is rendered is closer to the true physical proportions from back in the day.

And this brings up a different aspect of the old days. Programmers these days are spoiled for a few reasons:
  1. Physical screen aspect ratios have been synchronised with logical screen aspect ratios, leading to square pixels; and
  2. Screen resolutions are high enough that a pixel is much closer to the ideal of a dimensionless point than before.
For the first point, things have largely been determined through the HDMI standard that unifies computer screens and television screens, defining important features for video formats that get back-ported into regular computer displays. In yonder days of computing, the computer display being solely analogue meant that the actual output signal from the DAC to the display had little to do with how the screen was logically handled, which led to interesting problems like having a 4:3 (aspect ratio 1.3+) monitor trying to display a 320×200 (aspect ratio 1.6) screen. This meant that each logical pixel had a physical form that was some squished version. This led to interesting ``adjustments'' to draw things like circles, as seen in this official documentation in QuickBASIC's help file:
I can only imagine how complex the various early versions of CAD programs were just to accomodate the myriads of odd-shaped displays while still using the logical CGA/EGA/VGA/VESA standards.

By a fluke of history, what was originally complicated aspect ratio wrangling in the past for 320×200 resolutions is completely nullified with the modern screens having exactly the 1.6 aspect ratio. It makes old programs that tried to compensate for that look wrong now, but it makes lazy programmer me who didn't see the need to mess with all these physical stuff that I cannot control very happy to see that circles that I kept logically correct is now physically correct as well. And this is likely to keep being the same since 4:3 monitors are not making a come back any more. Rumour has it that the reason for the 4:3 aspect ratio came from how it introduced less variance in the curvature of the CRT (cathode ray tube you faux ``woke'' bugger) between the centre and the edges since it was closest to being ``circular''---I don't know if it is true, nor do I really care as much.

As for the second point, it means that more details can be added to the graphics in a brute-force sort of way, as opposed to many of the tricks that had to be employed to work with the big-ass rectangle pixels that we used to see. There's no real problem with this, just that it really makes graphics related design that much easier since it relies more on fundamentals than on advanced trickery that is tailored to the hardware of the time.

I think that's about it. Maybe I should create a new tag in addition to technical for these retro-programming stuff.

Maybe.

Till the next update then.

No comments: