EsoErik

Monday, October 22, 2012

 

Remaking Windows Terminal Blocky Font With Most Codepage 437 Characters in TrueType for Native OS X Applications

I've previously written about using the Windows shell font on Linux and in X11 on OS X.  However, this method was only a stopgap for OS X - the native API (Cocoa) does not support bitmap fonts.  My favorite editor, Slickedit, switched to Qt compiled in Quartz mode and no longer presents its interface through X11.  A native interface is nice for many reasons, although it forces me to finally let go of my beloved vgaoem.fon.

All the monospace TrueType fonts I have been able to find are offensively awful and I reject the implicit suggestion from Apple that I should use them.

Extreme measures were in order.  So, on my trusty Gentoo workstation, I fired up Fontforge, and created a new, empty font.

This all gets a little involved.  I set the EM size to 1200 as I will be working with the 8x12 version of Bitstream Terminal (the font contained in vgaoem.fon).  This produces a convenient 100-1 TrueType spacial unit to bitmap font pixel mapping.  Then, I imported the BDF conversion of vgaoem.fon with the "as background" box checked.  I had to add 50 to the default ascent size and subtract 50 from the descent size at this point in the Element->Font Info dialog and then transform all glyphs by y+50 with the box for transform everything checked.  Furthermore, still with all glyphs selected, I set the right extent to 800 (8x12, remember?).  Next, I selected all glyphs and executed the autotrace command with various arguments until it produced outlines that were completely correct in a small number of cases.  The majority required laborious manual editing.  The following screenshot was taken about halfway through the process of fixing/creating outlines.
After this, I imported codepage 437 to unicode table conveniently available from unicode.org and forced the encoding to it.  After setting a few font properties so that the font will be recognized as monospace, I generated a TTF and imported it into my font library on OS X.  And, as you can see, all went according to plan.
Sweet justice.  Thank the deity, I can finally upgrade Slickedit and close those twenty thousand XTerms in favor of terminal.app.  In case you would like to try it, dear reader, here is the TTF file (in the Google Docs interface, go to File->Download to get the TTF).  FYI, it should be used in 12-point with antialiasing turned off.

Update: I noticed the vertical line spacing was too large.  I edited some arcane fields in the font's TrueType header to fix this.  Here is the updated version.  The following screenshot shows a subtraction between screenshots on OS X and Windows of the same text - the text is now rendered identically.
Note: to disable antialiasing of this font in XCode 4.5 on 10.8, execute
defaults -currentHost write -globalDomain AppleFontSmoothing -int 0
in the terminal.

Archives

July 2009   August 2009   September 2009   October 2009   November 2009   December 2009   January 2010   September 2010   December 2010   January 2011   February 2011   April 2011   June 2011   August 2011   February 2012   June 2012   July 2012   August 2012   October 2012   November 2012   January 2014   April 2014   June 2014   August 2014   September 2014   October 2014   January 2015   March 2015   April 2015   June 2015   November 2015   December 2015   January 2016   June 2016   August 2016   January 2017   March 2017  

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]