点阵是由8x16数组构成,字符的点阵是由字符的asci码X16来索引其对应的点阵,所以大于0x80就不是asiic
#include <config.h>
#include <fonts_manager.h>
#define FONTDATAMAX 4096
static int ASCIIFontInit(char *pcFontFile, unsigned int dwFontSize);
static int ASCIIGetFontBitmap(unsigned int dwCode, PT_FontBitMap ptFontBitMap);
static T_FontOpr g_tASCIIFontOpr = {
.name = "ascii",
.FontInit = ASCIIFontInit,
.GetFontBitmap = ASCIIGetFontBitmap,
};
static int ASCIIFontInit(char *pcFontFile, unsigned int dwFontSize)
{
if (dwFontSize != 16)
{
//DBG_PRINTF("ASCII can't support %d font size\n", dwFontSize);
return -1;
}
return 0;
}
static int ASCIIGetFontBitmap(unsigned int dwCode, PT_FontBitMap ptFontBitMap)
{
int iPenX = ptFontBitMap->iCurOriginX;
int iPenY = ptFontBitMap->iCurOriginY;
if (dwCode > (unsigned int)0x80)
{
//DBG_PRINTF("don't support this code : 0x%x\n", dwCode);
return -1;
}
//由卡尔坐标转换为lcd坐标,笛卡尔原点在左下角,lcd原点在左上角
ptFontBitMap->iXLeft = iPenX;
ptFontBitMap->iYTop = iPenY - 16;
ptFontBitMap->iXMax = iPenX + 8;
ptFontBitMap->iYMax = iPenY;
ptFontBitMap->iBpp = 1;
ptFontBitMap->iPitch = 1;
//有索引找到对应的点阵
ptFontBitMap->pucBuffer = (unsigned char *)&fontdata_8x16[dwCode * 16];;
//Y不变,x增加
ptFontBitMap->iNextOriginX = iPenX + 8;
ptFontBitMap->iNextOriginY = iPenY;
return 0;
}
int ASCIIInit(void)
{
return RegisterFontOpr(&g_tASCIIFontOpr);//添加到链表
}