Char to graphic screen

Go To Last Post
14 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi i have a 128 x 64 all graphic screen with no internal character memory. My question is how do you take a char character & write it to the screen? I imagine you would have to create a table of bitmap characters & somehow reference it against you char in question. Does anybody have some really basic code of how this is done. I can print the code below.

Also doing something like this

const unsigned char E [] = {
0xF8, 0xF8, 0x88, 0x88, 0x88, 0x88, 0x00, 0x00, 0x0F, 0x0F, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00
};

takes up a lot of memory & i think some people have got around it by writing it a different way in memory. How is that done?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You pretty much have it. Now your master table only needs to be arranged so the char can index it directly (or by subtracting an offset first ... Say 0x20)

Writing code is like having sex.... make one little mistake, and you're supporting it for life.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Assuming you're using avr-gcc, you would want to put your table in flash. There's a tutorial on the use a progmem. There's code available for displays like the nokia 6100 that will have the tables already defined for you and code to write the chars. You'll have to modify it to suit.

Warren, no use sending me a pm. It only further delays my response as i have to read the pm.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Take a look at some typical 128x64 code:

http://en.radzio.dxp.pl/ks0108/

See font5x8.h in that.

(not this code actually has a bug - in one place he treats the data as if it is in avr-gcc's "PROGMEM" and in another he does not).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok i am now able to write the data into memory like.

static int C[] PROGMEM = {
0xE0, 0xF0, 0x18, 0x08, 0x08, 0x18, 0x10, 0x00, 0x03, 0x07, 0x0C, 0x08, 0x08, 0x0C, 0x04, 0x00
};

static int H[] PROGMEM = {
0xF8, 0xF8, 0x80, 0x80, 0x80, 0xF8, 0xF8, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00
};

static int A[] PROGMEM = {
0x00, 0xE0, 0xF8, 0x18, 0xF8, 0xE0, 0x00, 0x00, 0x0E, 0x0F, 0x03, 0x02, 0x03, 0x0F, 0x0E, 0x00
};

static int R[] PROGMEM = {
0xF8, 0xF8, 0x88, 0x88, 0x88, 0xF8, 0x70, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x01, 0x07, 0x0E, 0x00
};

static int L[] PROGMEM = {
0x00, 0xF8, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x08, 0x08, 0x08, 0x08, 0x00
};

static int I[] PROGMEM = {
0x00, 0x00, 0x00, 0xF8, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x00
};

static int E[] PROGMEM = {
0xF8, 0xF8, 0x88, 0x88, 0x88, 0x88, 0x00, 0x00, 0x0F, 0x0F, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00
};

but how would i do something like.

LCD_Write("CHARLIE");

I write to the screen like

void LCD_WriteGraphicCharTeam(int h, int v, int* graphic)
{
	uint8_t i = 0;
	for(int x = 0; x < 2; x++)
	{
		if (h < 64)
		{
			for(int y = 0; y < 8; y++)
			{
				LCD_Instruction ((184 + x + v), 1);
				LCD_Instruction ((64 + y + h) ,1);
				LCD_Write(pgm_read_byte(&graphic[i]),1);
				i++;
			}
		}
		else
		{
			for(int y = 0; y < 8; y++)
			{
				LCD_Instruction ((184 + x + v), 2);
				LCD_Instruction ((64 + y + (h - 64)) ,2);
				LCD_Write(pgm_read_byte(&graphic[i]),2);
				i++;
			}
		}
	}
}
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Did you look at the link, clawson suggested? You can either make a big array or a two-dimensional with an offset of e.g. 0x20 (ASCII-code for space).
Why on earth do you declare the font as static int[] PROGMEM instead of static uint8_t[] PROGMEM and waste 50% of the memory?

/Martin.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes i did but the link doesn't work server error.

I have looked at other programs but its so hard to trace where they go. Im just missing the link of how you could access a table or how you could point the C character to the static int C []. Without someone elses basic, easy to read code as an example im stuffed.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This is extracted from the code that Cliff pointed to.

Quote:

//-------------------------------------------------------------------------------------------------
//
//-------------------------------------------------------------------------------------------------
void GLCD_WriteChar(char charToWrite)
{
int i;
charToWrite -= 32;
for(i = 0; i < 5; i++)
GLCD_WriteData(GLCD_ReadByteFromROMMemory((char *)((int)font5x8 + (5 * charToWrite) + i)));
GLCD_WriteData(0x00);
}
//-------------------------------------------------------------------------------------------------
//
//-------------------------------------------------------------------------------------------------
void GLCD_WriteString(char * stringToWrite)
{
while(*stringToWrite)
GLCD_WriteChar(*stringToWrite++);
}

and the font.h file:
// font.h
//
// Tablica czcionek 5x7
//
//#include
static const char /*PROGMEM*/ font5x8[] = {
0x00, 0x00, 0x00, 0x00, 0x00,// (spacja)
0x00, 0x00, 0x5F, 0x00, 0x00,// !
0x00, 0x07, 0x00, 0x07, 0x00,// "
0x14, 0x7F, 0x14, 0x7F, 0x14,// #
0x24, 0x2A, 0x7F, 0x2A, 0x12,// $
0x23, 0x13, 0x08, 0x64, 0x62,// %
0x36, 0x49, 0x55, 0x22, 0x50,// &
0x00, 0x05, 0x03, 0x00, 0x00,// '
0x00, 0x1C, 0x22, 0x41, 0x00,// (
0x00, 0x41, 0x22, 0x1C, 0x00,// )
0x08, 0x2A, 0x1C, 0x2A, 0x08,// *
0x08, 0x08, 0x3E, 0x08, 0x08,// +
0x00, 0x50, 0x30, 0x00, 0x00,// ,
0x08, 0x08, 0x08, 0x08, 0x08,// -
0x00, 0x30, 0x30, 0x00, 0x00,// .
0x20, 0x10, 0x08, 0x04, 0x02,// /
0x3E, 0x51, 0x49, 0x45, 0x3E,// 0
0x00, 0x42, 0x7F, 0x40, 0x00,// 1
0x42, 0x61, 0x51, 0x49, 0x46,// 2
0x21, 0x41, 0x45, 0x4B, 0x31,// 3
0x18, 0x14, 0x12, 0x7F, 0x10,// 4
0x27, 0x45, 0x45, 0x45, 0x39,// 5
0x3C, 0x4A, 0x49, 0x49, 0x30,// 6
0x01, 0x71, 0x09, 0x05, 0x03,// 7
0x36, 0x49, 0x49, 0x49, 0x36,// 8
0x06, 0x49, 0x49, 0x29, 0x1E,// 9
0x00, 0x36, 0x36, 0x00, 0x00,// :
0x00, 0x56, 0x36, 0x00, 0x00,// ;
0x00, 0x08, 0x14, 0x22, 0x41,// <
0x14, 0x14, 0x14, 0x14, 0x14,// =
0x41, 0x22, 0x14, 0x08, 0x00,// >
0x02, 0x01, 0x51, 0x09, 0x06,// ?
0x32, 0x49, 0x79, 0x41, 0x3E,// @
0x7E, 0x11, 0x11, 0x11, 0x7E,// A
0x7F, 0x49, 0x49, 0x49, 0x36,// B
0x3E, 0x41, 0x41, 0x41, 0x22,// C
0x7F, 0x41, 0x41, 0x22, 0x1C,// D
0x7F, 0x49, 0x49, 0x49, 0x41,// E
0x7F, 0x09, 0x09, 0x01, 0x01,// F
0x3E, 0x41, 0x41, 0x51, 0x32,// G
0x7F, 0x08, 0x08, 0x08, 0x7F,// H
0x00, 0x41, 0x7F, 0x41, 0x00,// I
0x20, 0x40, 0x41, 0x3F, 0x01,// J
0x7F, 0x08, 0x14, 0x22, 0x41,// K
0x7F, 0x40, 0x40, 0x40, 0x40,// L
0x7F, 0x02, 0x04, 0x02, 0x7F,// M
0x7F, 0x04, 0x08, 0x10, 0x7F,// N
0x3E, 0x41, 0x41, 0x41, 0x3E,// O
0x7F, 0x09, 0x09, 0x09, 0x06,// P
0x3E, 0x41, 0x51, 0x21, 0x5E,// Q
0x7F, 0x09, 0x19, 0x29, 0x46,// R
0x46, 0x49, 0x49, 0x49, 0x31,// S
0x01, 0x01, 0x7F, 0x01, 0x01,// T
0x3F, 0x40, 0x40, 0x40, 0x3F,// U
0x1F, 0x20, 0x40, 0x20, 0x1F,// V
0x7F, 0x20, 0x18, 0x20, 0x7F,// W
0x63, 0x14, 0x08, 0x14, 0x63,// X
0x03, 0x04, 0x78, 0x04, 0x03,// Y
0x61, 0x51, 0x49, 0x45, 0x43,// Z
0x00, 0x00, 0x7F, 0x41, 0x41,// [
0x02, 0x04, 0x08, 0x10, 0x20,// "\"
0x41, 0x41, 0x7F, 0x00, 0x00,// ]
0x04, 0x02, 0x01, 0x02, 0x04,// ^
0x40, 0x40, 0x40, 0x40, 0x40,// _
0x00, 0x01, 0x02, 0x04, 0x00,// `
0x20, 0x54, 0x54, 0x54, 0x78,// a
0x7F, 0x48, 0x44, 0x44, 0x38,// b
0x38, 0x44, 0x44, 0x44, 0x20,// c
0x38, 0x44, 0x44, 0x48, 0x7F,// d
0x38, 0x54, 0x54, 0x54, 0x18,// e
0x08, 0x7E, 0x09, 0x01, 0x02,// f
0x08, 0x14, 0x54, 0x54, 0x3C,// g
0x7F, 0x08, 0x04, 0x04, 0x78,// h
0x00, 0x44, 0x7D, 0x40, 0x00,// i
0x20, 0x40, 0x44, 0x3D, 0x00,// j
0x00, 0x7F, 0x10, 0x28, 0x44,// k
0x00, 0x41, 0x7F, 0x40, 0x00,// l
0x7C, 0x04, 0x18, 0x04, 0x78,// m
0x7C, 0x08, 0x04, 0x04, 0x78,// n
0x38, 0x44, 0x44, 0x44, 0x38,// o
0x7C, 0x14, 0x14, 0x14, 0x08,// p
0x08, 0x14, 0x14, 0x18, 0x7C,// q
0x7C, 0x08, 0x04, 0x04, 0x08,// r
0x48, 0x54, 0x54, 0x54, 0x20,// s
0x04, 0x3F, 0x44, 0x40, 0x20,// t
0x3C, 0x40, 0x40, 0x20, 0x7C,// u
0x1C, 0x20, 0x40, 0x20, 0x1C,// v
0x3C, 0x40, 0x30, 0x40, 0x3C,// w
0x44, 0x28, 0x10, 0x28, 0x44,// x
0x0C, 0x50, 0x50, 0x50, 0x3C,// y
0x44, 0x64, 0x54, 0x4C, 0x44,// z
0x00, 0x08, 0x36, 0x41, 0x00,// {
0x00, 0x00, 0x7F, 0x00, 0x00,// |
0x00, 0x41, 0x36, 0x08, 0x00,// }
0x08, 0x08, 0x2A, 0x1C, 0x08,// ->
0x08, 0x1C, 0x2A, 0x08, 0x08 // <-
};
//

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes that looks better, i couldn't get the that page probably due to the crap internet provider. Something is beginning to click & i think i have an idea what is happening in GLCD_ReadByteFromROMMemory. but can you post that as well?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

warren1 wrote:
Yes that looks better, i couldn't get the that page probably due to the crap internet provider. Something is beginning to click & i think i have an idea what is happening in GLCD_ReadByteFromROMMemory. but can you post that as well?

unsigned char GLCD_ReadByteFromROMMemory(char * ptr)
{
return pgm_read_byte(ptr);
}

/Martin.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks martin I guessed right on how that was done. To me it seems a silly way to do it but what would I know. Ok I am able to read a font table but only if each char is say a perfect 8x8. I have seen in font editors that some fonts take up less or more than 8bits wide e.g comparing ! & w characters for instance. If this is the case & different characters have different widths how is it possible to tell where each font starts & ends? Can someone fill me in on how its done?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Written for an 8051 a decade ago, not for an AVR - but maybe it gives you an idea:

typedef unsigned char byte;             /*  8 Bit */

typedef struct {
  byte *font;
  byte  width;
} FONTvariable8;

/* font 8 pixel high, variable width */
/* the spacing between the characters is not stored in this font! */

static code byte ASCII032 [] = { 0x00, 0x00, 0x00 };
static code byte ASCII033 [] = { 0xFC };
static code byte ASCII034 [] = { 0x06, 0x00, 0x06 };
static code byte ASCII035 [] = { 0xE8, 0x3E, 0xE8, 0x3E };
static code byte ASCII036 [] = { 0x26, 0x49, 0xFF, 0x49, 0x32 };
static code byte ASCII037 [] = { 0x00, 0x02, 0x05, 0x72, 0x2E, 0x51, 0x20 };
static code byte ASCII038 [] = { 0x30, 0x4E, 0x49, 0x59, 0x27, 0x50 };
static code byte ASCII039 [] = { 0x03 };
static code byte ASCII040 [] = { 0x7C, 0x82 };
static code byte ASCII041 [] = { 0x81, 0x7E };
static code byte ASCII042 [] = { 0x14, 0x0C, 0x14 };
static code byte ASCII043 [] = { 0x10, 0x10, 0x7C, 0x10, 0x10 };
static code byte ASCII044 [] = { 0x00, 0x80, 0x40 };
static code byte ASCII045 [] = { 0x10, 0x10 };
static code byte ASCII046 [] = { 0x00, 0x40 };
static code byte ASCII047 [] = { 0x60, 0x1C, 0x03 };
static code byte ASCII048 [] = { 0x3E, 0x41, 0x41, 0x3E };
static code byte ASCII049 [] = { 0x00, 0x02, 0x7F };
static code byte ASCII050 [] = { 0x42, 0x61, 0x59, 0x46 };
static code byte ASCII051 [] = { 0x22, 0x41, 0x49, 0x36 };
static code byte ASCII052 [] = { 0x18, 0x14, 0x12, 0x7F, 0x10 };
static code byte ASCII053 [] = { 0x2F, 0x45, 0x45, 0x39 };
static code byte ASCII054 [] = { 0x3E, 0x45, 0x45, 0x3A };
static code byte ASCII055 [] = { 0x01, 0x71, 0x0D, 0x03 };
static code byte ASCII056 [] = { 0x36, 0x49, 0x49, 0x36 };
static code byte ASCII057 [] = { 0x2E, 0x51, 0x51, 0x3E };
static code byte ASCII058 [] = { 0x44 };
static code byte ASCII059 [] = { 0xC4 };
static code byte ASCII060 [] = { 0x08, 0x14, 0x22 };
static code byte ASCII061 [] = { 0x14, 0x14, 0x14, 0x14 };
static code byte ASCII062 [] = { 0x22, 0x14, 0x08 };
static code byte ASCII063 [] = { 0x02, 0x01, 0x59, 0x09, 0x06 };
static code byte ASCII064 [] = { 0x3C, 0x42, 0xBE, 0xA5, 0x95, 0xAD, 0x72 };
static code byte ASCII065 [] = { 0x40, 0x38, 0x16, 0x11, 0x16, 0x38, 0x40 };
static code byte ASCII066 [] = { 0x00, 0x7F, 0x49, 0x49, 0x3E };
static code byte ASCII067 [] = { 0x00, 0x3E, 0x41, 0x41, 0x41, 0x22 };
static code byte ASCII068 [] = { 0x00, 0x7F, 0x41, 0x41, 0x41, 0x3E };
static code byte ASCII069 [] = { 0x00, 0x7F, 0x49, 0x49, 0x49, 0x49 };
static code byte ASCII070 [] = { 0x00, 0x7F, 0x09, 0x09, 0x01 };
static code byte ASCII071 [] = { 0x00, 0x3E, 0x41, 0x41, 0x49, 0x3A };
static code byte ASCII072 [] = { 0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F };
static code byte ASCII073 [] = { 0x00, 0x7F };
static code byte ASCII074 [] = { 0x60, 0x40, 0x40, 0x3F };
static code byte ASCII075 [] = { 0x00, 0x7F, 0x08, 0x14, 0x22, 0x41 };
static code byte ASCII076 [] = { 0x00, 0x7F, 0x40, 0x40, 0x40 };
static code byte ASCII077 [] = { 0x7F, 0x06, 0x38, 0x40, 0x38, 0x06, 0x7F };
static code byte ASCII078 [] = { 0x00, 0x7F, 0x06, 0x08, 0x30, 0x7F };
static code byte ASCII079 [] = { 0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E };
static code byte ASCII080 [] = { 0x00, 0x7F, 0x09, 0x09, 0x0F };
static code byte ASCII081 [] = { 0x00, 0x3E, 0x41, 0x41, 0x61, 0x5E };
static code byte ASCII082 [] = { 0x00, 0x7F, 0x09, 0x09, 0x19, 0x66 };
static code byte ASCII083 [] = { 0x00, 0x26, 0x49, 0x49, 0x32 };
static code byte ASCII084 [] = { 0x01, 0x01, 0x7F, 0x01, 0x01 };
static code byte ASCII085 [] = { 0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F };
static code byte ASCII086 [] = { 0x03, 0x0C, 0x30, 0x40, 0x30, 0x0C, 0x03 };
static code byte ASCII087 [] = { 0x03, 0x3C, 0x40, 0x3E, 0x01, 0x3E, 0x40, 0x3C, 0x03 };
static code byte ASCII088 [] = { 0x41, 0x36, 0x08, 0x36, 0x41 };
static code byte ASCII089 [] = { 0x00, 0x01, 0x06, 0x78, 0x06, 0x01 };
static code byte ASCII090 [] = { 0x61, 0x51, 0x49, 0x45, 0x43, 0x41 };
static code byte ASCII091 [] = { 0x00, 0xFF, 0x81 };
static code byte ASCII092 [] = { 0x03, 0x1C, 0x60 };
static code byte ASCII093 [] = { 0x81, 0xFF };
static code byte ASCII094 [] = { 0x06, 0x01, 0x06 };
static code byte ASCII095 [] = { 0x80, 0x80, 0x80, 0x80, 0x80 };
static code byte ASCII096 [] = { 0x01, 0x02 };
static code byte ASCII097 [] = { 0x64, 0x54, 0x54, 0x7C };
static code byte ASCII098 [] = { 0x7F, 0x44, 0x44, 0x38 };
static code byte ASCII099 [] = { 0x38, 0x44, 0x44, 0x28 };
static code byte ASCII100 [] = { 0x38, 0x44, 0x44, 0x7F };
static code byte ASCII101 [] = { 0x38, 0x54, 0x54, 0x58 };
static code byte ASCII102 [] = { 0x04, 0x7E, 0x05 };
static code byte ASCII103 [] = { 0x5C, 0xA2, 0xA2, 0x7E };
static code byte ASCII104 [] = { 0x7F, 0x04, 0x04, 0x78 };
static code byte ASCII105 [] = { 0x7D };
static code byte ASCII106 [] = { 0xFD };
static code byte ASCII107 [] = { 0x7F, 0x10, 0x38, 0x44 };
static code byte ASCII108 [] = { 0x7F };
static code byte ASCII109 [] = { 0x7C, 0x04, 0x04, 0x7C, 0x04, 0x04, 0x78 };
static code byte ASCII110 [] = { 0x7C, 0x04, 0x04, 0x78 };
static code byte ASCII111 [] = { 0x38, 0x44, 0x44, 0x38 };
static code byte ASCII112 [] = { 0xFE, 0x22, 0x22, 0x1C };
static code byte ASCII113 [] = { 0x1C, 0x22, 0x22, 0xFE };
static code byte ASCII114 [] = { 0x7C, 0x04, 0x04 };
static code byte ASCII115 [] = { 0x48, 0x54, 0x54, 0x24 };
static code byte ASCII116 [] = { 0x7E, 0x44 };
static code byte ASCII117 [] = { 0x3C, 0x40, 0x40, 0x7C };
static code byte ASCII118 [] = { 0x04, 0x38, 0x40, 0x38, 0x04 };
static code byte ASCII119 [] = { 0x3C, 0x40, 0x3C, 0x40, 0x3C };
static code byte ASCII120 [] = { 0x44, 0x38, 0x38, 0x44 };
static code byte ASCII121 [] = { 0x04, 0x38, 0xC0, 0x38, 0x04 };
static code byte ASCII122 [] = { 0x64, 0x64, 0x4C };

static code FONTvariable8 FONTnx8 [] = {
  { ASCII032, sizeof (ASCII032) },
  { ASCII033, sizeof (ASCII033) },
  { ASCII034, sizeof (ASCII034) },
  { ASCII035, sizeof (ASCII035) },
  { ASCII036, sizeof (ASCII036) },
  { ASCII037, sizeof (ASCII037) },
  { ASCII038, sizeof (ASCII038) },
  { ASCII039, sizeof (ASCII039) },
  { ASCII040, sizeof (ASCII040) },
  { ASCII041, sizeof (ASCII041) },
  { ASCII042, sizeof (ASCII042) },
  { ASCII043, sizeof (ASCII043) },
  { ASCII044, sizeof (ASCII044) },
  { ASCII045, sizeof (ASCII045) },
  { ASCII046, sizeof (ASCII046) },
  { ASCII047, sizeof (ASCII047) },
  { ASCII048, sizeof (ASCII048) },
  { ASCII049, sizeof (ASCII049) },
  { ASCII050, sizeof (ASCII050) },
  { ASCII051, sizeof (ASCII051) },
  { ASCII052, sizeof (ASCII052) },
  { ASCII053, sizeof (ASCII053) },
  { ASCII054, sizeof (ASCII054) },
  { ASCII055, sizeof (ASCII055) },
  { ASCII056, sizeof (ASCII056) },
  { ASCII057, sizeof (ASCII057) },
  { ASCII058, sizeof (ASCII058) },
  { ASCII059, sizeof (ASCII059) },
  { ASCII060, sizeof (ASCII060) },
  { ASCII061, sizeof (ASCII061) },
  { ASCII062, sizeof (ASCII062) },
  { ASCII063, sizeof (ASCII063) },
  { ASCII064, sizeof (ASCII064) },
  { ASCII065, sizeof (ASCII065) },
  { ASCII066, sizeof (ASCII066) },
  { ASCII067, sizeof (ASCII067) },
  { ASCII068, sizeof (ASCII068) },
  { ASCII069, sizeof (ASCII069) },
  { ASCII070, sizeof (ASCII070) },
  { ASCII071, sizeof (ASCII071) },
  { ASCII072, sizeof (ASCII072) },
  { ASCII073, sizeof (ASCII073) },
  { ASCII074, sizeof (ASCII074) },
  { ASCII075, sizeof (ASCII075) },
  { ASCII076, sizeof (ASCII076) },
  { ASCII077, sizeof (ASCII077) },
  { ASCII078, sizeof (ASCII078) },
  { ASCII079, sizeof (ASCII079) },
  { ASCII080, sizeof (ASCII080) },
  { ASCII081, sizeof (ASCII081) },
  { ASCII082, sizeof (ASCII082) },
  { ASCII083, sizeof (ASCII083) },
  { ASCII084, sizeof (ASCII084) },
  { ASCII085, sizeof (ASCII085) },
  { ASCII086, sizeof (ASCII086) },
  { ASCII087, sizeof (ASCII087) },
  { ASCII088, sizeof (ASCII088) },
  { ASCII089, sizeof (ASCII089) },
  { ASCII090, sizeof (ASCII090) },
  { ASCII091, sizeof (ASCII091) },
  { ASCII092, sizeof (ASCII092) },
  { ASCII093, sizeof (ASCII093) },
  { ASCII094, sizeof (ASCII094) },
  { ASCII095, sizeof (ASCII095) },
  { ASCII096, sizeof (ASCII096) },
  { ASCII097, sizeof (ASCII097) },
  { ASCII098, sizeof (ASCII098) },
  { ASCII099, sizeof (ASCII099) },
  { ASCII100, sizeof (ASCII100) },
  { ASCII101, sizeof (ASCII101) },
  { ASCII102, sizeof (ASCII102) },
  { ASCII103, sizeof (ASCII103) },
  { ASCII104, sizeof (ASCII104) },
  { ASCII105, sizeof (ASCII105) },
  { ASCII106, sizeof (ASCII106) },
  { ASCII107, sizeof (ASCII107) },
  { ASCII108, sizeof (ASCII108) },
  { ASCII109, sizeof (ASCII109) },
  { ASCII110, sizeof (ASCII110) },
  { ASCII111, sizeof (ASCII111) },
  { ASCII112, sizeof (ASCII112) },
  { ASCII113, sizeof (ASCII113) },
  { ASCII114, sizeof (ASCII114) },
  { ASCII115, sizeof (ASCII115) },
  { ASCII116, sizeof (ASCII116) },
  { ASCII117, sizeof (ASCII117) },
  { ASCII118, sizeof (ASCII118) },
  { ASCII119, sizeof (ASCII119) },
  { ASCII120, sizeof (ASCII120) },
  { ASCII121, sizeof (ASCII121) },
  { ASCII122, sizeof (ASCII122) }
};

static void cputc (byte ch)
{
  byte i;

  if (ch >= 32 && ch <= 122) {
    ch -= 32;
    for (i = 0; i < FONTnx8 [ch].width; i++) {
      cputcol (FONTnx8 [ch].font [i]);
    }
    cputcol (0x00);
  }
}

/Martin.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A structure with the adress of the beginning of a character and its width, for each character , could work.

But if you want to use varying width fonts, you should be aware that some fonts are context dependent (i.e. : if you want very classical typographic rules, ff should have the first f linked with the second : (la)teX could cope with such typographical rules, but it is very rare -and does not exist in modern books-...).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'd stick to fixed width fonts (think Courier on Windows or even the [code] font here). While proportional are do able by keeping widths with characters consider how complex things can get if you want to give the user the ability to edit text input!