0

For an 8-bit embedded system that has a small monochrome LCD with black/white pixels (not grayscale), I need an efficient way of storing and displaying fonts. I will probably choose two fixed-width fonts, 4x5 pixels and 5x7 pixels. The resources are very limited: 30k ROM, 2k RAM. The fonts will be written to the buffer with a 1:1 scale, as a one-line string with a given start offset in pixels (char* str, byte x, byte y)

I think I would use 1k of RAM for the buffer. Unless there's a more efficient structure for writing the fonts to, I would have it arranged so it can be written sequentially into the LCD, which would be as follows:

byte buffer[1024];

Where each byte represents a horizontal line of 8 pixels (MSB on the left), and each line of the display is completed from left to right, and in that fashion, top to bottom. (So each line is represented by (128px / 8 =) 16 bytes.)

So my question:

  1. How should the fonts be stored?
  2. What form should the buffer take?
  3. How should the fonts be written to the buffer?

I presume there are some standard algorithms for this, but I can't find anything in searches. Any suggestions would be very helpful (I don't expect anyone to code this for me!!)

Thanks

Jodes
  • 14,118
  • 26
  • 97
  • 156
  • See the question and answer for work done on an Arduino Uno using a 3.5" TFT LCD display, https://stackoverflow.com/questions/67259938/reducing-memory-required-for-kedei-tft-library-used-with-3-5-tft-display-with-a which describes a similar problem along with a solution with a 5 byte per character raster font table containing only the characters space (0x20) through the upper case letter Z (0x5a). It also allows for different sizes of characters by allowing scaling of characters by 2 and by 3. – Richard Chambers May 17 '21 at 01:23

1 Answers1

2

As a first cut, implement bit blit, a primitive with many uses, including drawing characters. This dictates the following answers to your questions.

  1. As bitmaps.
  2. A bitmap.
  3. Bit blit.

The implementation of bit blit itself involves a bunch of bitwise operations repeatedly extracting a byte or combination of two partial bytes from the source bitmap to be combined with the destination byte.

David Eisenstat
  • 64,237
  • 7
  • 60
  • 120