Hi
Sorry about my poor English.
I am trying to build an Arabic font library for Nokia 5110 LCD.
I start by #include <PCD8544.h>, and successfully show some bitmaps on LCD.
I move next to make glyphs processing logic.
In font.h, i write:
#ifdef __cplusplus
extern "C" {
#endif
#define byte unsigned char
#define NOT_JOINED 0x00
#define PRV_JOINED 0x01
#define NXT_JOINED 0x02
typedef struct ArabicGlyphsTable {
int utf32Code;
byte widths[4];
byte flags;//NOT_JOINED,PRV_JOINED,NXT_JOINED
byte *isolatedBitmap;
byte *prvJoinedBitmap;
byte *nxtJoinedBitmap;
byte *bthJoinedBitmap;
}ARABICGLYPHSTABLE;
extern ARABICGLYPHSTABLE font8_arabicglyphstable[];
byte *getArabicGlyph(int utf32code,bool bPrvJoined,bool bNxtJoined,byte *pwidth);
#ifdef __cplusplus
}
#endif
and in font.c (40K bytes file), i write:
#include "font.h"
byte font8_Iso_C8_Bitmap[] = {
//........
//........
//........
//........
//........
//........
//........
//........
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
//.#....##
//.#.....#
//.#######
//........
//........
//....##..
//........
//........
0x00,0x07,0x04,0x04,0x24,0x24,0x05,0x07
};
byte font8_Nxt_C8_Bitmap[] = {
//....
//....
//....
//....
//....
//....
//....
//..#.
0x00,0x00,0x80,0x00,
//..##
//...#
//####
//....
//....
//###.
//....
//....
0x24,0x24,0x25,0x07
};
byte font8_Prv_C8_Bitmap[] = {
//.......
//.......
//.......
//.......
//.......
//.......
//.......
//.......
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
//#....##
//#.....#
//#######
//.......
//.......
//....##.
//.......
//.......
0x07,0x04,0x04,0x04,0x24,0x25,0x07
};
byte font8_Bth_C8_Bitmap[] = {
//....
//....
//....
//....
//....
//....
//....
//..#.
0x00,0x00,0x80,0x00,
//..##
//...#
//####
//....
//....
//.##.
//....
//....
0x04,0x24,0x25,0x07
};
//same as above for other 32 characters
ARABICGLYPHSTABLE font8_arabicglyphstable[] = {
{0x0628,[8,7,4,4],NEXT_JOINED|PREVIOUS_JOINED,font8_Iso_C8_Bitmap,font8_Prv_C8_Bitmap,font8_Nxt_C8_Bitmap,font8_Bth_C8_Bitmap},
...
//next 32 entries for each character
};
byte *getArabicGlyph(int utf32code,bool bPrvJoined,bool bNxtJoined,byte *pwidth)
{
int items = sizeof(font8_arabicglyphstable)/sizeof(font8_arabicglyphstable[0]);
for (int i = 0; i < items; i++)
{
if(utf32code == font8_arabicglyphstable[i].utf32Code)//<-- this line freez program/serial monitor execution
{
if(bPrvJoined && bNxtJoined)
{
*pwidth = font8_arabicglyphstable[i].widths[3];
return font8_arabicglyphstable[i].bothJoinedBitmap;
}
else if(bPrvJoined)
{
*pwidth = font8_arabicglyphstable[i].widths[1];
return font8_arabicglyphstable[i].previousJoinedBitmap;
}
else if(bNxtJoined)
{
*pwidth = font8_arabicglyphstable[i].widths[2];
return font8_arabicglyphstable[i].nextJoinedBitmap;
}
else
{
*pwidth = font8_arabicglyphstable[i].widths[0];
return font8_arabicglyphstable[i].isolatedBitmap;
}
}
}
*pwidth = 0;
return NULL;
}
The indicated line stops program execution and freezes serial monitor output.
To check for out-of-boundary index error,I commented out "for(...)" statement, and the program works well for all array indexes (0 to 32).
byte *getArabicGlyph(int utf32code,bool bPrvJoined,bool bNxtJoined,byte ,byte *pwidth)
{
int items = sizeof(font8_arabicglyphstable)/sizeof(font8_arabicglyphstable[0]);
//for (int i = 0; i < items; i++)
//{
if(utf32code == font8_arabicglyphstable[0].utf32Code)//hard coded index, from 0 to 32 works well
{
if(bPrvJoined && bNxtJoined)
{
*pwidth = font8_arabicglyphstable[0].widths[3];
return font8_arabicglyphstable[0].bothJoinedBitmap;
}
else if(bPrvJoined)
{
*pwidth = font8_arabicglyphstable[0].widths[1];
return font8_arabicglyphstable[0].previousJoinedBitmap;
}
else if(bNxtJoined)
{
*pwidth = font8_arabicglyphstable[0].widths[2];
return font8_arabicglyphstable[0].nextJoinedBitmap;
}
else
{
*pwidth = font8_arabicglyphstable[0].widths[0];
return font8_arabicglyphstable[0].isolatedBitmap;
}
}
//}
*pwidth = 0;
return NULL;
}
i cannot find the problem.
i appreciate your help.