Author: tkreuzer Date: Wed May 11 19:47:49 2011 New Revision: 51675
URL: http://svn.reactos.org/svn/reactos?rev=51675&view=rev Log: [GDI FONT DRIVER] - Implement basics of 1bpp vs 4bpp bitmap handling - Fix special ansi characters - Fix direction of normalized base vectors (inverted y axis) - Fix ptqD member in GLYPHDATA structure
Modified: branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/font.c branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/ftfd.h branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/glyph.c branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/todo.txt branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/tttables.c branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/tttables.h
Modified: branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/font.c URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/drivers/... ============================================================================== --- branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/font.c [iso-8859-1] (original) +++ branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/font.c [iso-8859-1] Wed May 11 19:47:49 2011 @@ -217,7 +217,10 @@ }
/* Convert the special characters from unicode to ansi */ - EngUnicodeToMultiByteN(&pifi->chFirstChar, 4, NULL, &pifi->wcFirstChar, 3); + EngUnicodeToMultiByteN(&pifi->chFirstChar, 4, NULL, &pifi->wcFirstChar, 8); + + /* This one seems to be hardcoded to 0xff */ + pifi->chLastChar = 0xff;
/* Convert names to unicode */ EngMultiByteToUnicodeN(pifiex->awcFamilyName, @@ -249,6 +252,7 @@ pifi->achVendId, 4);
+ //__debugbreak(); return TRUE; }
@@ -486,6 +490,8 @@ PFTFD_FILE pfile = NULL;
TRACE("FtfdLoadFontFile()\n"); +//__debugbreak(); +//return 0;
/* Check parameters */ if (cFiles != 1)
Modified: branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/ftfd.h URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/drivers/... ============================================================================== --- branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/ftfd.h [iso-8859-1] (original) +++ branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/ftfd.h [iso-8859-1] Wed May 11 19:47:49 2011 @@ -146,6 +146,7 @@ ULONG xScale; HGLYPH hgSelected; ULONG cjSelected; + UCHAR jBpp; } FTFD_FONT, *PFTFD_FONT;
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 May 11 19:47:49 2011 @@ -37,7 +37,7 @@ if (FLOATOBJ_bIsNull(&pptef->x)) { efLength = pptef->y; - FLOATOBJ_SetLong(&pptef->y, 1); + FLOATOBJ_SetLong(&pptef->y, -1); return efLength; }
@@ -59,6 +59,9 @@ /* Now divide the vector by the length */ FLOATOBJ_Div(&pptef->x, &efLength); FLOATOBJ_Div(&pptef->y, &efLength); + + /* y axis is inverted! */ + FLOATOBJ_Neg(&pptef->y);
/* Return the former length of the vector */ return efLength; @@ -110,6 +113,9 @@ }
pfont->ftface = ftface; + + /* Set requested number of bits per pixel */ + pfont->jBpp = pfo->flFontType & FO_GRAY16 ? 4 : 1;
/* Get the XFORMOBJ from the font */ pxo = FONTOBJ_pxoGetXform(pfo); @@ -316,13 +322,15 @@ pfddm->pteSide.y = FLOATOBJ_GetFloat(&pfont->ptefSide.y);
/* cjGlyphMax is the full size of the GLYPHBITS structure */ - pfddm->cjGlyphMax = GLYPHBITS_SIZE(pfddm->cxMax, pfddm->cyMax, 4); + pfddm->cjGlyphMax = GLYPHBITS_SIZE(pfddm->cxMax, + pfddm->cyMax, + pfont->jBpp);
/* Copy the quantized matrix from the font structure */ pfddm->fdxQuantized = pfont->fdxQuantized;
pfddm->lNonLinearExtLeading = 0x00000000; - pfddm->lNonLinearIntLeading = 0x00000010; + pfddm->lNonLinearIntLeading = 0x00000080; // FIXME pfddm->lNonLinearMaxCharWidth = 0x80000000; pfddm->lNonLinearAvgCharWidth = 0x80000000;
@@ -405,17 +413,28 @@ if (ftglyph->bitmap.width == 0) pgd->rclInk.right++; if (ftglyph->bitmap.rows == 0) pgd->rclInk.bottom++;
- pgd->ptqD.x.LowPart = 0x000000fd; // ftglyph->advance.x + // FIXME: + pgd->ptqD.x.LowPart = pgd->fxD; pgd->ptqD.x.HighPart = 0; - pgd->ptqD.y.LowPart = 0x000000a0; // ftglyph->advance.y + pgd->ptqD.y.LowPart = 0; pgd->ptqD.y.HighPart = 0; //pgd->ptqD.x.QuadPart = 0; //pgd->ptqD.y.QuadPart = 0; //__debugbreak(); }
+static VOID -FtfdCopyBitmap( +FtfdCopyBitmap1Bpp( + BYTE *pjDest, + FT_Bitmap *ftbitmap) +{ + __debugbreak(); +} + +static +VOID +FtfdCopyBitmap4Bpp( BYTE *pjDest, FT_Bitmap *ftbitmap) { @@ -469,7 +488,9 @@ pgb->sizlBitmap.cx = ftglyph->bitmap.width; pgb->sizlBitmap.cy = ftglyph->bitmap.rows;
- cjBitmapSize = BITMAP_SIZE(pgb->sizlBitmap.cx, pgb->sizlBitmap.cy, 4); + cjBitmapSize = BITMAP_SIZE(pgb->sizlBitmap.cx, + pgb->sizlBitmap.cy, + pfont->jBpp); if (cjBitmapSize + FIELD_OFFSET(GLYPHBITS, aj) > cjSize) { WARN("Buffer too small, got %ld, need %ld\n", @@ -479,13 +500,14 @@ }
/* Copy the bitmap */ - FtfdCopyBitmap(pgb->aj, &ftglyph->bitmap); - - //RtlCopyMemory(pgb->aj, ftglyph->bitmap.buffer, cjBitmapSize); + if (pfont->jBpp == 4) + FtfdCopyBitmap4Bpp(pgb->aj, &ftglyph->bitmap); + else + FtfdCopyBitmap1Bpp(pgb->aj, &ftglyph->bitmap);
TRACE("QueryGlyphBits hg=%lx, (%ld,%ld) cjSize=%ld, need %ld\n", hg, pgb->sizlBitmap.cx, pgb->sizlBitmap.cy, cjSize, - GLYPHBITS_SIZE(pgb->sizlBitmap.cx, pgb->sizlBitmap.cy, 4)); + GLYPHBITS_SIZE(pgb->sizlBitmap.cx, pgb->sizlBitmap.cy, pfont->jBpp));
}
@@ -504,8 +526,10 @@ PFTFD_FONT pfont) { FT_Error fterror; - - fterror = FT_Render_Glyph(pfont->ftface->glyph, FT_RENDER_MODE_NORMAL); + FT_Render_Mode mode; + + mode = pfont->jBpp == 1 ? FT_RENDER_MODE_MONO : FT_RENDER_MODE_NORMAL; + fterror = FT_Render_Glyph(pfont->ftface->glyph, mode); if (fterror) { WARN("Cound't render glyph\n"); @@ -553,7 +577,7 @@ /* Return the size for a 1bpp bitmap */ return GLYPHBITS_SIZE(pfont->ftface->glyph->bitmap.width, pfont->ftface->glyph->bitmap.rows, - 4); + pfont->jBpp);
case QFD_GLYPHANDOUTLINE: TRACE("QFD_GLYPHANDOUTLINE\n");
Modified: branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/todo.txt URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/drivers/... ============================================================================== --- branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/todo.txt [iso-8859-1] (original) +++ branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/todo.txt [iso-8859-1] Wed May 11 19:47:49 2011 @@ -34,8 +34,11 @@ - FtfdInitIfiMetrics: 70% done - handle other font types than TTF/OTF - fix fwdLowestPPEm, fwdMacLineGap, ptlBaseline, ptlAspect, ptlCaret - - cKerningPairs, ulPanoseCulture + - cKerningPairs from atmfd is bigger, ulPanoseCulture - check fwdMacAscender, fwdMacDescender + - Check jWinPitchandFamily (from OS/2 table, Apolonia: 0,0->0x12) + - chLastChar: hardcoded 0xff ? + - fix fwdUnderscorePosition
- FtfdInitGlyphSet: 100% done - FtfdInitKerningPairs: unimplemented, later @@ -50,9 +53,14 @@ - hande accelerator flags for bitmap / outline - FtfdQueryGlyphData: 70% done - handle vertical layout - - handle ptqD + - handle ptqD for rotation / skewing
-- FtfdQueryGlyphBits: 40% +- FtfdQueryGlyphBits: 50% depends on FtfdCopyBitmap4Bpp and FtfdCopyBitmap1Bpp - handle 1bpp bitmaps
- FtfdQueryGlyphOutline: unimplemented +- FtfdCopyBitmap4Bpp: 90 % + - add rounding + - Could need optimization +- FtfdCopyBitmap1Bpp: unimplemented +
Modified: branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/tttables.c URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/drivers/... ============================================================================== --- branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/tttables.c [iso-8859-1] (original) +++ branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/tttables.c [iso-8859-1] Wed May 11 19:47:49 2011 @@ -152,7 +152,7 @@ switch (jClassId) { case 0: // Class ID = 0 No Classification - return FF_SWISS; + return FF_ROMAN;//FF_SWISS;
case 1: // Class ID = 1 Oldstyle Serifs switch (jSubclassId)
Modified: branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/tttables.h URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/drivers/... ============================================================================== --- branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/tttables.h [iso-8859-1] (original) +++ branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/tttables.h [iso-8859-1] Wed May 11 19:47:49 2011 @@ -47,7 +47,7 @@
typedef struct _TT_OS2_DATA { - USHORT version; // 0x0004 + USHORT version; // // 0x00 SHORT xAvgCharWidth; USHORT usWeightClass; USHORT usWidthClass; @@ -55,14 +55,14 @@ SHORT ySubscriptXSize; SHORT ySubscriptYSize; SHORT ySubscriptXOffset; - SHORT ySubscriptYOffset; + SHORT ySubscriptYOffset; // 0x10 SHORT ySuperscriptXSize; SHORT ySuperscriptYSize; SHORT ySuperscriptXOffset; SHORT ySuperscriptYOffset; SHORT yStrikeoutSize; SHORT yStrikeoutPosition; - union // 0x30 + union // 0x1e { struct {