TrueType - array C

I am writing a low C application and I plan to use an array to store my fonts.

The problem is that the font I would like to use is in TrueType format. Like me:

  • Convert TTF to format B, W, bitmap font without any AA (not strict programming) associated with);

  • Parse the B & W font bitmap into a byte array C.

What format should be used for bitmap? It should be simple enough so that I, a novice programmer with a little over a year of experience, could write a parser to save it in the specified array.

I do not want to use external libraries, and I would like to keep C Std. Lib. use to a minimum. This is for a college project, and I want to write everything myself.

+4
source share
3 answers

This is not the most professional or clean, but here is what I would do in your situation:

  • Choose a monospace font and size where each character is an integer number of pixels.
  • Open GIMP (or your favorite image editing program) and make the image with font_width wide and font_height*96 high.
  • Make the text element anchored in the upper left corner containing <space> <newline> ! <newline> " <newline> # <newline> <space> <newline> ! <newline> " <newline> # <newline> ... (i.e. all ASCII characters).
  • Save it as an uncompressed image format that is easy to process, such as PNM.
  • Load it into an array of type uint8_t [96][font_height][font_width] .
+3
source

Use Win32 GDI APIs to write bitmaps: create a bitmap, print a letter, use GetPixel to read it. Serialize the .c file.

+1
source

Try Freetype . It can provide you with data that you can use to create a bitmap.

+1
source

All Articles