views:

130

answers:

1

Hi!

I am looking at the code for the font file here: http://www.openobject.org/opensourceurbanism/Bike_POV_Beta_4

The code starts like this:

const byte font[][5] = {
  {0x00,0x00,0x00,0x00,0x00},   //   0x20 32
  {0x00,0x00,0x6f,0x00,0x00},   // ! 0x21 33
  {0x00,0x07,0x00,0x07,0x00},   // " 0x22 34
  {0x14,0x7f,0x14,0x7f,0x14},   // # 0x23 35
  {0x00,0x07,0x04,0x1e,0x00},   // $ 0x24 36
  {0x23,0x13,0x08,0x64,0x62},   // % 0x25 37
  {0x36,0x49,0x56,0x20,0x50},   // & 0x26 38
  {0x00,0x00,0x07,0x00,0x00},   // ' 0x27 39
  {0x00,0x1c,0x22,0x41,0x00},   // ( 0x28 40
  {0x00,0x41,0x22,0x1c,0x00},   // ) 0x29 41
  {0x14,0x08,0x3e,0x08,0x14},   // * 0x2a 42
  {0x08,0x08,0x3e,0x08,0x08},   // + 0x2b 43

and so on...

I am very confused as to how this code works - can someone explain it to me please?

Thanks,

Majd

+1  A: 

Each array of 5 bytes = 40 bits which map to the 7x5 = 35 pixels in the character grid (there are 5 unused bits presumably).

When you want to display a character you copy the corresponding 5 byte bitmap for that character to the appropriate memory location. E.g. to display the character X you would copy the data from font['X'].

Paul R
let's look at character 33, the "!": {0x00,0x00,0x6f,0x00,0x00}, // ! 0x21 33what does the 0x6f part stand for?
majdal
`0x6f` = `0 1 1 0 1 1 1 1` - turn that on its side and you have `!`
Paul R
beautiful! thank you!
majdal