|
楼主 |
发表于 2014-5-27 16:06:52
|
显示全部楼层
对应emWin的字符显示函数为:
- void GUI_FontEx_DispChar(U16 c)
- {
- static U8 _cbuf[32*32/8];
- if(GUI_FontEx_IsInFont(GUI_pContext->pAFont, c)){
- const GUI_FONT *pFont = GUI_pContext->pAFont;
- const FontEx_T *pProp = (const FontEx_T *)pFont->p.pFontData;
- if(pProp){
- GUI_DRAWMODE OldDrawMode;
- int xdist = 0;
- U32 offset = 0;
- if(sizeof(_cbuf) < pProp->CharSize){
- // 缓冲区不足以容纳字符位图。
- return;
- }
- // ASCII码。
- if(c < 0x80){
- c -= 0x20;
- xdist = (pProp->ASCInfo[c]).Width;
- // 单字节的ASCII字符偏移为256。
- offset = FONT_CHARMAP_BEGIN + c * pProp->CharSize;
- }
- // GBK汉字码。
- else{
- xdist = pProp->GBKWidth;
- offset = ((c & 0xFF) - 0xa1);
- c >>= 8;
- offset += (c - 0xa1) * 94;
- // 双字节的GBK字符偏移为256+96个ASCII字符总和。
- offset = FONT_CHARMAP_BEGIN + (96 + offset) * pProp->CharSize;
- }
- // 从外部Flash读取一个字符的MAP位图。
- pProp->ReadCharData(_cbuf, offset, pProp->CharSize);
- OldDrawMode = LCD_SetDrawMode(GUI_pContext->TextMode);
- LCD_DrawBitmap( GUI_pContext->DispPosX, GUI_pContext->DispPosY,
- xdist,
- pFont->YDist,
- pFont->XMag,
- pFont->YMag,
- 1, /* Bits per Pixel */
- pProp->CharStride,
- _cbuf,
- GUI_pContext->LCD_pBkColorIndex
- );
- LCD_SetDrawMode(OldDrawMode);
- GUI_pContext->DispPosX += xdist * pFont->XMag;
- }
- }
- }
复制代码 |
|