Author: tkreuzer
Date: Wed Aug 17 08:48:51 2011
New Revision: 53278
URL:
http://svn.reactos.org/svn/reactos?rev=53278&view=rev
Log:
[GDI FONT DRIVER]
- Implement initial "ClearType" support. Currently only bitmap characters are
correctly copied and they can have a color distortion. But its at least readable.
Modified:
branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/copybits.c
branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/glyph.c
Modified: branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/copybits.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/drivers…
==============================================================================
--- branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/copybits.c [iso-8859-1]
(original)
+++ branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/copybits.c [iso-8859-1] Wed
Aug 17 08:48:51 2011
@@ -99,6 +99,68 @@
}
}
+#define CT_OPAQUE 0x2a
+
+static
+VOID
+FtfdCopyBits_S1D8(
+ GLYPHBITS *pgb,
+ FT_Bitmap *ftbitmap)
+{
+ ULONG ulRows, ulSrcDelta;
+ PBYTE pjDstLine, pjSrcLine;
+
+ pjDstLine = pgb->aj;
+
+ pjSrcLine = ftbitmap->buffer;
+ ulSrcDelta = abs(ftbitmap->pitch);
+
+ ulRows = pgb->sizlBitmap.cy;
+ while (ulRows--)
+ {
+ ULONG ulWidth = pgb->sizlBitmap.cx;
+ BYTE j, *pjSrc;
+ pjSrc = pjSrcLine;
+
+ /* Get 8 pixels */
+ j = (*pjSrc++);
+
+ while (ulWidth >= 8)
+ {
+ /* Set 8 pixels */
+ *pjDstLine++ = (j & 128) ? CT_OPAQUE : 0;
+ *pjDstLine++ = (j & 64) ? CT_OPAQUE : 0;
+ *pjDstLine++ = (j & 32) ? CT_OPAQUE : 0;
+ *pjDstLine++ = (j & 16) ? CT_OPAQUE : 0;
+ *pjDstLine++ = (j & 8) ? CT_OPAQUE : 0;
+ *pjDstLine++ = (j & 4) ? CT_OPAQUE : 0;
+ *pjDstLine++ = (j & 2) ? CT_OPAQUE : 0;
+ *pjDstLine++ = (j & 1) ? CT_OPAQUE : 0;
+
+ /* Next 8 pixels */
+ j = (*pjSrc++);
+ ulWidth -= 8;
+ }
+
+ /* Set remaining pixels (max 7) */
+ switch (ulWidth)
+ {
+ case 7: pjDstLine[6] = (j & 2) ? CT_OPAQUE : 0;
+ case 6: pjDstLine[5] = (j & 4) ? CT_OPAQUE : 0;
+ case 5: pjDstLine[4] = (j & 8) ? CT_OPAQUE : 0;
+ case 4: pjDstLine[3] = (j & 16) ? CT_OPAQUE : 0;
+ case 3: pjDstLine[2] = (j & 32) ? CT_OPAQUE : 0;
+ case 2: pjDstLine[1] = (j & 64) ? CT_OPAQUE : 0;
+ case 1: pjDstLine[0] = (j & 128) ? CT_OPAQUE : 0;
+ }
+
+ pjDstLine += ulWidth;
+
+ /* Go to the next source line */
+ pjSrcLine += ulSrcDelta;
+ }
+}
+
static
VOID
FtfdCopyBits_S8D4(
@@ -137,6 +199,47 @@
}
}
+static
+VOID
+FtfdCopyBits_LCD_X(
+ GLYPHBITS *pgb,
+ FT_Bitmap *ftbitmap)
+{
+ ULONG ulRows, ulDstDelta, ulSrcDelta;
+ PBYTE pjDstLine, pjSrcLine;
+
+ pjDstLine = pgb->aj;
+ ulDstDelta = pgb->sizlBitmap.cx;
+
+ pjSrcLine = ftbitmap->buffer;
+ ulSrcDelta = abs(ftbitmap->pitch);
+
+ ulRows = pgb->sizlBitmap.cy;
+ while (ulRows--)
+ {
+ ULONG ulWidth = ulDstDelta;
+ BYTE *pjSrc;
+
+ pjSrc = pjSrcLine;
+ while (ulWidth--)
+ {
+ /* Get the pixel */
+ *pjDstLine++ = (*pjSrc++);
+ }
+
+ /* Go to the next source line */
+ pjSrcLine += ulSrcDelta;
+ }
+}
+
+static
+VOID
+FtfdCopyBits_LCD_Y(
+ GLYPHBITS *pgb,
+ FT_Bitmap *ftbitmap)
+{
+}
+
VOID
NTAPI
FtfdCopyBits(
@@ -157,28 +260,47 @@
{
FtfdCopyBits_S1D1(pgb, ftbitmap);
}
+ else if ((ftbitmap->pixel_mode == FT_PIXEL_MODE_GRAY) &&
+ (ftbitmap->num_grays == 256))
+ {
+ FtfdCopyBits_S8D1(pgb, ftbitmap);
+ }
+ else
+ {
+ WARN("Unsupported pixel format\n");
+ __debugbreak();
+ }
+ }
+ else if (jBppDst == 4)
+ {
+ if (ftbitmap->pixel_mode == FT_PIXEL_MODE_MONO)
+ {
+ FtfdCopyBits_S1D4(pgb, ftbitmap);
+ }
else if (ftbitmap->pixel_mode == FT_PIXEL_MODE_GRAY &&
ftbitmap->num_grays == 256)
{
- FtfdCopyBits_S8D1(pgb, ftbitmap);
+ FtfdCopyBits_S8D4(pgb, ftbitmap);
}
else
{
WARN("Unsupported pixel format\n");
__debugbreak();
}
-
- }
- else if (jBppDst == 4)
- {
- if (ftbitmap->pixel_mode == FT_PIXEL_MODE_MONO)
- {
- FtfdCopyBits_S1D4(pgb, ftbitmap);
- }
- else if (ftbitmap->pixel_mode == FT_PIXEL_MODE_GRAY &&
- ftbitmap->num_grays == 256)
- {
- FtfdCopyBits_S8D4(pgb, ftbitmap);
+ }
+ else if (jBppDst == 8)
+ {
+ if (ftbitmap->pixel_mode == FT_PIXEL_MODE_LCD)
+ {
+ FtfdCopyBits_LCD_X(pgb, ftbitmap);
+ }
+ else if (ftbitmap->pixel_mode == FT_PIXEL_MODE_LCD_V)
+ {
+ FtfdCopyBits_LCD_Y(pgb, ftbitmap);
+ }
+ else if (ftbitmap->pixel_mode == FT_PIXEL_MODE_MONO)
+ {
+ FtfdCopyBits_S1D8(pgb, ftbitmap);
}
else
{
Modified: branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/glyph.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/drivers…
==============================================================================
--- branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/glyph.c [iso-8859-1]
(original)
+++ branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/glyph.c [iso-8859-1] Wed Aug
17 08:48:51 2011
@@ -115,8 +115,11 @@
pfont->ftface = ftface;
- /* Set requested number of bits per pixel */
- pfont->jBpp = pfo->flFontType & FO_GRAY16 ? 4 : 1;
+ /* Set requested number of bits per pixel of the target */
+ if (pfo->flFontType & FO_CLEARTYPE_X) pfont->jBpp = 8;
+ else if (pfo->flFontType & FO_CLEARTYPE_Y) pfont->jBpp = 8;
+ else if (pfo->flFontType & FO_GRAY16) pfont->jBpp = 4;
+ else pfont->jBpp = 1;
/* Get the XFORMOBJ from the font */
pxo = FONTOBJ_pxoGetXform(pfo);
@@ -549,7 +552,13 @@
FT_Error fterror;
FT_Render_Mode mode;
- mode = pfont->jBpp == 1 ? FT_RENDER_MODE_MONO : FT_RENDER_MODE_NORMAL;
+ /* Determine the right render mode */
+ if (pfont->jBpp == 1) mode = FT_RENDER_MODE_MONO;
+ else if (pfont->pfo->flFontType & FO_CLEARTYPE_X) mode =
FT_RENDER_MODE_LCD;
+ else if (pfont->pfo->flFontType & FO_CLEARTYPE_Y) mode =
FT_RENDER_MODE_LCD_V;
+ else mode = FT_RENDER_MODE_NORMAL;
+
+ /* Render the glyph */
fterror = FT_Render_Glyph(pfont->ftface->glyph, mode);
if (fterror)
{