Byte codes for pixel maps for Ascii characters?
Asked Answered
E

7

8

Anyone who ever had to draw text in a graphics application for pre-windows operating systems (i.e. Dos) will know what I'm asking for.

Each ASCII character can be represented by an 8x8 pixel matrix. Each matrix can be represented by an 8 byte code (each byte used as a bit mask for each line of the matrix, 1 bit representing a white pixel, each 0 a black pixel).

Does anyone know where I can find the byte codes for the basic ASCII characters?

Thanks,
BW

Eleanoraeleanore answered 29/1, 2010 at 16:32 Comment(5)
IBM DOS and MS-DOS used a charset in the BIOS where each character was 8x16 pixels, not 8x8Palmirapalmistry
@mads: this I wasn't aware of, thanks. I had 8x8 inmind because I drew my own 8x8 characters for a project back in gulp 1991Eleanoraeleanore
Here's a useful Wikipedia article: en.wikipedia.org/wiki/Code_page_437Palmirapalmistry
Google finds github.com/dhepper/font8x8Perennial
@Pi: Add that as an answer and I'll accept it.Eleanoraeleanore
E
3

Self answering because user P i hasn't (they posted it in a comment on the question).

This github repo is exactly what I was looking for

dhepper/font8x8

From the read me . . .


8x8 monochrome bitmap font for rendering

A collection of header files containing a 8x8 bitmap font.

font8x8.h contains all available characters font8x8_basic.h contains unicode points U+0000 - U+007F font8x8_latin.h contains unicode points U+0000 - U+00FF

Author: Daniel Hepper [email protected] License: Public Domain

Encoding

Every character in the font is encoded row-wise in 8 bytes.

The least significant bit of each byte corresponds to the first pixel in a row.

The character 'A' (0x41 / 65) is encoded as { 0x0C, 0x1E, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x00}

0x0C => 0000 1100 => ..XX....
0X1E => 0001 1110 => .XXXX...
0x33 => 0011 0011 => XX..XX..
0x33 => 0011 0011 => XX..XX..
0x3F => 0011 1111 => xxxxxx..
0x33 => 0011 0011 => XX..XX..
0x33 => 0011 0011 => XX..XX..
0x00 => 0000 0000 => ........

To access the nth pixel in a row, right-shift by n.

                     . . X X . . . .
                     | | | | | | | |
(0x0C >> 0) & 1 == 0-+ | | | | | | |
(0x0C >> 1) & 1 == 0---+ | | | | | |
(0x0C >> 2) & 1 == 1-----+ | | | | |
(0x0C >> 3) & 1 == 1-------+ | | | |
(0x0C >> 4) & 1 == 0---------+ | | |
(0x0C >> 5) & 1 == 0-----------+ | |
(0x0C >> 6) & 1 == 0-------------+ |
(0x0C >> 7) & 1 == 0---------------+
Eleanoraeleanore answered 3/6, 2022 at 8:38 Comment(0)
P
4

Would this do?

Hope this helps.

Petra answered 29/1, 2010 at 16:43 Comment(0)
H
3

There are some good ones here; maybe not 8x8, but still easy parse

tektite

fixed

Honestly answered 29/1, 2010 at 16:37 Comment(0)
E
3

Self answering because user P i hasn't (they posted it in a comment on the question).

This github repo is exactly what I was looking for

dhepper/font8x8

From the read me . . .


8x8 monochrome bitmap font for rendering

A collection of header files containing a 8x8 bitmap font.

font8x8.h contains all available characters font8x8_basic.h contains unicode points U+0000 - U+007F font8x8_latin.h contains unicode points U+0000 - U+00FF

Author: Daniel Hepper [email protected] License: Public Domain

Encoding

Every character in the font is encoded row-wise in 8 bytes.

The least significant bit of each byte corresponds to the first pixel in a row.

The character 'A' (0x41 / 65) is encoded as { 0x0C, 0x1E, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x00}

0x0C => 0000 1100 => ..XX....
0X1E => 0001 1110 => .XXXX...
0x33 => 0011 0011 => XX..XX..
0x33 => 0011 0011 => XX..XX..
0x3F => 0011 1111 => xxxxxx..
0x33 => 0011 0011 => XX..XX..
0x33 => 0011 0011 => XX..XX..
0x00 => 0000 0000 => ........

To access the nth pixel in a row, right-shift by n.

                     . . X X . . . .
                     | | | | | | | |
(0x0C >> 0) & 1 == 0-+ | | | | | | |
(0x0C >> 1) & 1 == 0---+ | | | | | |
(0x0C >> 2) & 1 == 1-----+ | | | | |
(0x0C >> 3) & 1 == 1-------+ | | | |
(0x0C >> 4) & 1 == 0---------+ | | |
(0x0C >> 5) & 1 == 0-----------+ | |
(0x0C >> 6) & 1 == 0-------------+ |
(0x0C >> 7) & 1 == 0---------------+
Eleanoraeleanore answered 3/6, 2022 at 8:38 Comment(0)
J
2

5 x 7 typeface would cost less space than 8 x 8.

Do you need any characters that are missing from this?

ascii charset

Jaimiejain answered 5/7, 2021 at 18:53 Comment(0)
T
1

Bitmap?http://cone3d.gamedev.net/cone3d/gfxsdl/tut4-2.gif

you could parse/process this bitmap and get the byte matrixes (matrices?) from this

Tacky answered 29/1, 2010 at 16:38 Comment(2)
<humor> I could do that . . . I could also do my own dentristy with piece of string, some razor blades and a pliers . . . but strangely I dont that</humor> :)Eleanoraeleanore
Yes Yes Yes! A million upvotes, but I may cast but one.Perennial
C
1

It depends on the font. Search Google for 8x8 pixel fonts and you'll find a lot of different ones.

Converting from an image to a byte code table is trivial. Loop through each image 8x8 block at at time, reading the pixels and setting the bytes.

Casie answered 29/1, 2010 at 16:43 Comment(1)
Do that, post the byte codes and the correct answer goes to you. I don't have a fortune of time to spend on this. Thanks.Eleanoraeleanore
L
0

The byte codes for a 5x8 type face can be obtained from:

https://github.com/adafruit/micropython-adafruit-bitmap-font

The most human-readable form is in the font_to_bin.py file in over there:

FONT = bytes((
    0x00, 0x00, 0x00, 0x00, 0x00,
    0x3E, 0x5B, 0x4F, 0x5B, 0x3E, […]

There are examples in the repository for making scrolling displays, but I didn't try them. However, I succeeded in extracting the complete alphabet from it by reading the bytes. Here are 5 from the 256 characters:

    ▓▓      ▓▓▓▓▓▓▓▓      ▓▓▓▓▓▓    ▓▓▓▓▓▓▓▓    ▓▓▓▓▓▓▓▓▓▓
  ▓▓  ▓▓    ▓▓      ▓▓  ▓▓      ▓▓  ▓▓      ▓▓  ▓▓        
▓▓      ▓▓  ▓▓      ▓▓  ▓▓          ▓▓      ▓▓  ▓▓        
▓▓      ▓▓  ▓▓▓▓▓▓▓▓    ▓▓          ▓▓      ▓▓  ▓▓▓▓▓▓▓▓  
▓▓▓▓▓▓▓▓▓▓  ▓▓      ▓▓  ▓▓          ▓▓      ▓▓  ▓▓        
▓▓      ▓▓  ▓▓      ▓▓  ▓▓      ▓▓  ▓▓      ▓▓  ▓▓        
▓▓      ▓▓  ▓▓▓▓▓▓▓▓      ▓▓▓▓▓▓    ▓▓▓▓▓▓▓▓    ▓▓▓▓▓▓▓▓▓▓
Laryngoscope answered 2/5 at 8:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.