WPF app to convert TT Fonts to Meadow.Foundation C# Fonts
TrueType and OpenType fonts on windows are vector based fonts, designed to be displayed on high resolution displays. For the Meadow F7 we have small displays that need bitmap fonts. The Graphics Library only supports 1bit fonts.
The approach is to select a font that is installed on windows, and then draw each character in white on a black 12x20 bitmap. These bitmaps use 4 bytes per pixel (and are rendered with anti-aliasing), so we will average the colour channels to get 1 byte per pixel greyscale. Then using a threshhold we can decide if each pixel should be white or black.
The difficulty for a WPF app, is that the WriteableBitmaps do not have a drawstring method. Instead we have to share the bitmap, and write to it using GDI+.
The application does not read or write any files.
- Pick a font from the dropdown at the top - Monospaced fonts may work better, but there is no indication of which are monospaced.
- Mouse over the character (4 btyes per pixel) to see how the pixels will be interpretted for it. @ is on, . is off. The & is used for pixels that may become @ if you move the slider to the left.
- The Threshhold slider sets where black becomes white. Typically move it to the left to fill in fonts, move to the right to open up close spots.
- The 14pt setting should fill the 12x20 box for most fonts. it can be adjusted up or down if necessary
- The x and y position shift the image within the box. look at characters with descenders and see if they are cut off. See if there is too much space on the left or right.
- Once you think you have a font that is legible, double click on the code at the bottom. it should all be selected.
- right click on the selected text to copy, and then paste it into a new class file in your meadow app.
Fonts generated by this application are available in this project: Meadow Font Test