BOOL DrawText(HDC hDC, LPSTR lpString, int nCount, LPRECT lpRect, UINT uFormat)
{
int i, j;
int x, y;
int nUnderLineHei;
BOOL bRet;
PFT2FONT pFont;
if((NULL == hDC) || (NULL == hDC->hFont) || (NULL == lpString) || ('\0' == lpString) || (NULL == lpRect))
return FALSE;
pFont = (PFT2FONT)hDC->hFont;
bRet = FreeType2_GetFontData(pFont, lpString);
if(bRet)
{
if((pFont->nRealWid > 0) && (pFont->nRealHei > 0))
{
int nDy;
COLORREF clrD;
BYTE dr, dg, db, mr, mg, mb;
BYTE sr = fb_r(hDC->clrPen);
BYTE sg = fb_g(hDC->clrPen);
BYTE sb = fb_b(hDC->clrPen);
x = lpRect->left;
y = lpRect->top;
nUnderLineHei = 0;
if(pFont->bUnderline)
nUnderLineHei = pFont->nRealHei / 10;
switch(uFormat & 0xf0)
{
case DT_RIGHT:
x += lpRect->right - pFont->nRealWid;
break;
case DT_HCENTER:
x = (lpRect->left + lpRect->right - pFont->nRealWid) / 2;
break;
}
nDy = pFont->bUnderline ? (nUnderLineHei + 1) : 0;
switch(uFormat & 0x0f)
{
case DT_VCENTER:
y = (lpRect->top + lpRect->bottom - (pFont->nRealHei + nDy)) / 2;
break;
case DT_BOTTOM:
y += lpRect->bottom - (pFont->nRealHei + nDy);
break;
}
if(x <= lpRect->left)
x = lpRect->left;
if(y <= lpRect->top)
y = lpRect->top;
RequestPaint();
for(i=0; i
nRealHei; i++)
{
for(j=0; jnRealWid; j++)
{
if((x+j < lpRect->right) && (y+i < lpRect->bottom))
{
if(*(pFont->pucData + i*pFont->nRealWid + j) != 0xff)
{
clrD = xgui_getpixel(x+j, y+i);
mr = fb_r(clrD);
mg = fb_g(clrD);
mb = fb_b(clrD);
if(!*(pFont->pucData + i*pFont->nRealWid + j))
{
dr = sr;
dg = sg;
db = sb;
}
else
{
dr = (*(pFont->pucData + i*pFont->nRealWid + j)*(mr - sr) >> 8) + sr;
dg = (*(pFont->pucData + i*pFont->nRealWid + j)*(mg - sg) >> 8) + sg;
db = (*(pFont->pucData + i*pFont->nRealWid + j)*(mb - sb) >> 8) + sb;
}
xgui_setpixel(hDC, x+j, y+i, fb_rgb(dr, dg, db));
}
}
}
}
if(pFont->bUnderline)
{
y += pFont->nRealHei + 1;
for(i=0; i
{
for(j=0; jnRealWid; j++)
{
if((x+j < lpRect->right) && (y+i < lpRect->bottom))
xgui_setpixel(hDC, x+j, y+i, hDC->clrPen);
}
}
}
CompletePaint();
}
}
return TRUE;
}
阅读(687) | 评论(0) | 转发(0) |