Before explaining about the font, let’s first talk about sub-pixel rendering. Sub-pixel rendering is the process of drawing on the screen by taking advantage of the fact that a single pixel on screen is actually made up of 3 separate coloured pixels.
In an LCD screen, these three sub-pixels, coloured red, green and blue, are laid out horizontally, repeating for each whole pixel on-screen, as indicated below.
By using one of these three individual colours we can then draw onscreen at resolutions higher than a whole pixel. This technique is used to create the 1x5 pixel font. Using the sub-pixel rendering, we are able to create a font which, in effect, is 3 pixels wide and 5 pixels high, while only using 1 physical pixel width.
The version of the font demonstrated on Distractionware was written in C++, so I borrowed the idea, and wrote a C# version of the font using the same technique. Below we can see the result.
As you can see, the results are (just barely) readable. It is not the most practical of fonts, but the technique does produce results surprisingly more legible than you would expect.
using System.Collections.Generic ;
namespace MicroFont
{
public class FontDefinition
{
public Dictionary < char , int [, ]> Characters ;
public FontDefinition ()
{
Characters = new Dictionary < char , int [, ]> ();
Characters . Add ( 'A' , new int [ 5 , 3 ] { { 1 , 1 , 1 }, { 1 , 0 , 1 }, { 1 , 1 , 1 }, { 1 , 0 , 1 }, { 1 , 0 , 1 } });
Characters . Add ( 'B' , new int [ 5 , 3 ] { { 1 , 1 , 1 }, { 1 , 0 , 1 }, { 1 , 1 , 0 }, { 1 , 0 , 1 }, { 1 , 1 , 1 } });
Characters . Add ( 'C' , new int [ 5 , 3 ] { { 1 , 1 , 1 }, { 1 , 0 , 0 }, { 1 , 0 , 0 }, { 1 , 0 , 0 }, { 1 , 0 , 1 } });
Characters . Add ( 'D' , new int [ 5 , 3 ] { { 1 , 1 , 0 }, { 1 , 0 , 1 }, { 1 , 0 , 1 }, { 1 , 0 , 1 }, { 1 , 0 , 0 } });
Characters . Add ( 'E' , new int [ 5 , 3 ] { { 1 , 1 , 1 }, { 1 , 0 , 0 }, { 1 , 1 , 0 }, { 1 , 0 , 0 }, { 1 , 0 , 1 } });
Characters . Add ( 'F' , new int [ 5 , 3 ] { { 1 , 1 , 1 }, { 1 , 0 , 0 }, { 1 , 1 , 0 }, { 1 , 0 , 0 }, { 1 , 0 , 0 } });
Characters . Add ( 'G' , new int [ 5 , 3 ] { { 1 , 1 , 1 }, { 1 , 0 , 0 }, { 1 , 0 , 1 }, { 1 , 0 , 1 }, { 1 , 1 , 1 } });
Characters . Add ( 'H' , new int [ 5 , 3 ] { { 1 , 0 , 1 }, { 1 , 0 , 1 }, { 1 , 1 , 1 }, { 1 , 0 , 1 }, { 1 , 0 , 1 } });
Characters . Add ( 'I' , new int [ 5 , 3 ] { { 1 , 1 , 1 }, { 0 , 1 , 0 }, { 0 , 1 , 0 }, { 0 , 1 , 0 }, { 1 , 1 , 1 } });
Characters . Add ( 'J' , new int [ 5 , 3 ] { { 1 , 1 , 1 }, { 0 , 1 , 0 }, { 0 , 1 , 0 }, { 0 , 1 , 0 }, { 1 , 1 , 0 } });
Characters . Add ( 'K' , new int [ 5 , 3 ] { { 1 , 0 , 0 }, { 1 , 0 , 1 }, { 1 , 1 , 0 }, { 1 , 0 , 1 }, { 1 , 0 , 1 } });
Characters . Add ( 'L' , new int [ 5 , 3 ] { { 1 , 0 , 0 }, { 1 , 0 , 0 }, { 1 , 0 , 0 }, { 1 , 0 , 0 }, { 1 , 1 , 1 } });
Characters . Add ( 'M' , new int [ 5 , 3 ] { { 1 , 0 , 1 }, { 1 , 1 , 1 }, { 1 , 1 , 1 }, { 1 , 0 , 1 }, { 1 , 0 , 1 } });
Characters . Add ( 'N' , new int [ 5 , 3 ] { { 1 , 0 , 1 }, { 1 , 1 , 1 }, { 1 , 1 , 1 }, { 1 , 1 , 1 }, { 1 , 0 , 1 } });
Characters . Add ( 'O' , new int [ 5 , 3 ] { { 1 , 1 , 1 }, { 1 , 0 , 1 }, { 1 , 0 , 1 }, { 1 , 0 , 1 }, { 1 , 1 , 1 } });
Characters . Add ( 'P' , new int [ 5 , 3 ] { { 1 , 1 , 1 }, { 1 , 0 , 1 }, { 1 , 1 , 1 }, { 1 , 0 , 0 }, { 1 , 0 , 0 } });
Characters . Add ( 'Q' , new int [ 5 , 3 ] { { 1 , 1 , 1 }, { 1 , 0 , 1 }, { 1 , 0 , 1 }, { 1 , 1 , 1 }, { 1 , 1 , 1 } });
Characters . Add ( 'R' , new int [ 5 , 3 ] { { 1 , 1 , 1 }, { 1 , 0 , 1 }, { 1 , 1 , 0 }, { 1 , 0 , 1 }, { 1 , 0 , 1 } });
Characters . Add ( 'S' , new int [ 5 , 3 ] { { 1 , 1 , 1 }, { 1 , 0 , 0 }, { 1 , 1 , 1 }, { 0 , 0 , 1 }, { 1 , 1 , 1 } });
Characters . Add ( 'T' , new int [ 5 , 3 ] { { 1 , 1 , 1 }, { 0 , 1 , 0 }, { 0 , 1 , 0 }, { 0 , 1 , 0 }, { 0 , 1 , 0 } });
Characters . Add ( 'U' , new int [ 5 , 3 ] { { 1 , 0 , 1 }, { 1 , 0 , 1 }, { 1 , 0 , 1 }, { 1 , 0 , 1 }, { 0 , 1 , 0 } });
Characters . Add ( 'V' , new int [ 5 , 3 ] { { 1 , 0 , 1 }, { 1 , 0 , 1 }, { 1 , 0 , 1 }, { 0 , 1 , 0 }, { 0 , 1 , 0 } });
Characters . Add ( 'W' , new int [ 5 , 3 ] { { 1 , 0 , 1 }, { 1 , 0 , 1 }, { 1 , 1 , 1 }, { 1 , 1 , 1 }, { 1 , 0 , 1 } });
Characters . Add ( 'X' , new int [ 5 , 3 ] { { 1 , 0 , 1 }, { 1 , 0 , 1 }, { 0 , 1 , 0 }, { 1 , 0 , 1 }, { 1 , 0 , 1 } });
Characters . Add ( 'Y' , new int [ 5 , 3 ] { { 1 , 0 , 1 }, { 1 , 0 , 1 }, { 1 , 1 , 1 }, { 0 , 1 , 0 }, { 0 , 1 , 0 } });
Characters . Add ( 'Z' , new int [ 5 , 3 ] { { 1 , 1 , 1 }, { 0 , 0 , 1 }, { 0 , 1 , 0 }, { 1 , 0 , 0 }, { 1 , 1 , 1 } });
Characters . Add ( '1' , new int [ 5 , 3 ] { { 0 , 1 , 0 }, { 0 , 1 , 0 }, { 0 , 1 , 0 }, { 0 , 1 , 0 }, { 1 , 1 , 1 } });
Characters . Add ( '2' , new int [ 5 , 3 ] { { 1 , 1 , 1 }, { 0 , 0 , 1 }, { 0 , 1 , 1 }, { 1 , 1 , 0 }, { 1 , 1 , 1 } });
Characters . Add ( '3' , new int [ 5 , 3 ] { { 1 , 1 , 1 }, { 0 , 0 , 1 }, { 0 , 1 , 1 }, { 0 , 0 , 1 }, { 1 , 1 , 1 } });
Characters . Add ( '4' , new int [ 5 , 3 ] { { 1 , 0 , 0 }, { 1 , 0 , 0 }, { 1 , 1 , 0 }, { 1 , 1 , 1 }, { 0 , 1 , 0 } });
Characters . Add ( '5' , new int [ 5 , 3 ] { { 1 , 1 , 1 }, { 1 , 0 , 0 }, { 1 , 1 , 0 }, { 0 , 0 , 1 }, { 1 , 1 , 0 } });
Characters . Add ( '6' , new int [ 5 , 3 ] { { 1 , 1 , 1 }, { 1 , 0 , 0 }, { 1 , 1 , 1 }, { 1 , 0 , 1 }, { 1 , 1 , 1 } });
Characters . Add ( '7' , new int [ 5 , 3 ] { { 1 , 1 , 1 }, { 0 , 0 , 1 }, { 0 , 0 , 1 }, { 0 , 0 , 1 }, { 0 , 0 , 1 } });
Characters . Add ( '8' , new int [ 5 , 3 ] { { 1 , 1 , 1 }, { 1 , 0 , 1 }, { 1 , 1 , 1 }, { 1 , 0 , 1 }, { 1 , 1 , 1 } });
Characters . Add ( '9' , new int [ 5 , 3 ] { { 1 , 1 , 1 }, { 1 , 0 , 1 }, { 1 , 1 , 1 }, { 0 , 0 , 1 }, { 0 , 0 , 1 } });
Characters . Add ( '0' , new int [ 5 , 3 ] { { 0 , 1 , 0 }, { 1 , 0 , 1 }, { 1 , 0 , 1 }, { 1 , 0 , 1 }, { 0 , 1 , 0 } });
Characters . Add ( '!' , new int [ 5 , 3 ] { { 0 , 1 , 0 }, { 0 , 1 , 0 }, { 0 , 1 , 0 }, { 0 , 0 , 0 }, { 0 , 1 , 0 } });
Characters . Add ( '\"' , new int [ 5 , 3 ] { { 1 , 0 , 1 }, { 1 , 0 , 1 }, { 0 , 0 , 0 }, { 0 , 0 , 0 }, { 0 , 0 , 0 } });
Characters . Add ( '#' , new int [ 5 , 3 ] { { 1 , 0 , 1 }, { 1 , 1 , 1 }, { 1 , 0 , 1 }, { 1 , 1 , 1 }, { 1 , 0 , 1 } });
Characters . Add ( '$' , new int [ 5 , 3 ] { { 1 , 1 , 1 }, { 1 , 1 , 0 }, { 1 , 1 , 1 }, { 0 , 1 , 1 }, { 1 , 1 , 1 } });
Characters . Add ( '%' , new int [ 5 , 3 ] { { 1 , 0 , 1 }, { 0 , 0 , 1 }, { 0 , 1 , 0 }, { 1 , 0 , 0 }, { 1 , 0 , 1 } });
Characters . Add ( '&' , new int [ 5 , 3 ] { { 0 , 1 , 0 }, { 1 , 0 , 1 }, { 1 , 1 , 1 }, { 1 , 0 , 1 }, { 1 , 1 , 1 } });
Characters . Add ( '\'' , new int [ 5 , 3 ] { { 0 , 1 , 0 }, { 0 , 1 , 0 }, { 0 , 0 , 0 }, { 0 , 0 , 0 }, { 0 , 0 , 0 } });
Characters . Add ( '(' , new int [ 5 , 3 ] { { 0 , 1 , 1 }, { 1 , 0 , 0 }, { 1 , 0 , 0 }, { 1 , 0 , 0 }, { 0 , 1 , 1 } });
Characters . Add ( ')' , new int [ 5 , 3 ] { { 1 , 1 , 0 }, { 0 , 0 , 1 }, { 0 , 0 , 1 }, { 0 , 0 , 1 }, { 1 , 1 , 0 } });
Characters . Add ( '*' , new int [ 5 , 3 ] { { 0 , 0 , 0 }, { 0 , 1 , 0 }, { 1 , 1 , 1 }, { 0 , 1 , 0 }, { 1 , 0 , 1 } });
Characters . Add ( '+' , new int [ 5 , 3 ] { { 0 , 0 , 0 }, { 0 , 1 , 0 }, { 1 , 1 , 1 }, { 0 , 1 , 0 }, { 0 , 0 , 0 } });
Characters . Add ( ',' , new int [ 5 , 3 ] { { 0 , 0 , 0 }, { 0 , 0 , 0 }, { 0 , 0 , 0 }, { 0 , 1 , 1 }, { 1 , 1 , 0 } });
Characters . Add ( '.' , new int [ 5 , 3 ] { { 0 , 0 , 0 }, { 0 , 0 , 0 }, { 0 , 0 , 0 }, { 0 , 1 , 1 }, { 0 , 1 , 1 } });
Characters . Add ( ':' , new int [ 5 , 3 ] { { 0 , 0 , 0 }, { 0 , 1 , 0 }, { 0 , 0 , 0 }, { 0 , 1 , 0 }, { 0 , 0 , 0 } });
Characters . Add ( ';' , new int [ 5 , 3 ] { { 0 , 0 , 0 }, { 0 , 1 , 0 }, { 0 , 0 , 0 }, { 0 , 1 , 0 }, { 1 , 0 , 0 } });
Characters . Add ( '<' , new int [ 5 , 3 ] { { 0 , 0 , 1 }, { 0 , 1 , 0 }, { 1 , 0 , 0 }, { 0 , 1 , 0 }, { 0 , 0 , 1 } });
Characters . Add ( '>' , new int [ 5 , 3 ] { { 1 , 0 , 0 }, { 0 , 1 , 0 }, { 0 , 0 , 1 }, { 0 , 1 , 0 }, { 1 , 0 , 0 } });
Characters . Add ( '?' , new int [ 5 , 3 ] { { 1 , 1 , 1 }, { 0 , 0 , 1 }, { 0 , 1 , 0 }, { 0 , 0 , 0 }, { 0 , 1 , 0 } });
Characters . Add ( '@' , new int [ 5 , 3 ] { { 1 , 1 , 1 }, { 1 , 0 , 1 }, { 1 , 0 , 1 }, { 1 , 1 , 1 }, { 1 , 1 , 1 } });
Characters . Add ( '=' , new int [ 5 , 3 ] { { 0 , 0 , 0 }, { 1 , 1 , 1 }, { 0 , 0 , 0 }, { 1 , 1 , 1 }, { 0 , 0 , 0 } });
Characters . Add ( '[' , new int [ 5 , 3 ] { { 1 , 1 , 0 }, { 1 , 0 , 0 }, { 1 , 0 , 0 }, { 1 , 0 , 0 }, { 1 , 1 , 0 } });
Characters . Add ( ']' , new int [ 5 , 3 ] { { 0 , 1 , 1 }, { 0 , 0 , 1 }, { 0 , 0 , 1 }, { 0 , 0 , 1 }, { 0 , 1 , 1 } });
Characters . Add ( '-' , new int [ 5 , 3 ] { { 0 , 0 , 0 }, { 0 , 0 , 0 }, { 1 , 1 , 1 }, { 0 , 0 , 0 }, { 0 , 0 , 0 } });
Characters . Add ( ' ' , new int [ 5 , 3 ] { { 0 , 0 , 0 }, { 0 , 0 , 0 }, { 0 , 0 , 0 }, { 0 , 0 , 0 }, { 0 , 0 , 0 } });
}
}
}