Author: tkreuzer Date: Sat May 7 23:08:15 2011 New Revision: 51636
URL: http://svn.reactos.org/svn/reactos?rev=51636&view=rev Log: [GDI FONT DRIVER] - Implement calculation of normalized base vectors for the FD_DEVICEMETRICS structure
Modified: branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/ftfd.h branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/glyph.c
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] Sat May 7 23:08:15 2011 @@ -16,6 +16,7 @@ #include FT_XFREE86_H #include FT_TYPE1_TABLES_H #include FT_MULTIPLE_MASTERS_H +#include FT_TRIGONOMETRY_H
extern FT_Library gftlibrary;
@@ -126,6 +127,8 @@ FT_Face ftface; FD_XFORM fdxQuantized; FTFD_DEVICEMETRICS metrics; + POINTE pteBase; + POINTE pteSide; ULONG xScale; HGLYPH hgSelected; ULONG cjSelected;
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] Sat May 7 23:08:15 2011 @@ -16,6 +16,55 @@
#define GLYPHBITS_SIZE(cx, cy, bpp) \ (FIELD_OFFSET(GLYPHBITS, aj) + BITMAP_SIZE(cx, cy, bpp)) + +static +VOID +FtfdComputeBaseVector( + POINTE *ppte, + FLOATOBJ foX, + FLOATOBJ foY) +{ + FT_Vector ftvector; + LONG lLength; + FLOATOBJ fo, foLength; + + /* Optimization for scaling transformations */ + if (foX.ul1 == 0 && foX.ul2 == 0) + { + ppte->x = 0; + ppte->y = FLOATL_1; + return; + } + if (foY.ul1 == 0 && foY.ul2 == 0) + { + ppte->x = FLOATL_1; + ppte->y = 0; + return; + } + + /* Convert the point into a 8.24 format freetype vector */ + fo = foX; + FLOATOBJ_MulLong(&fo, 0x01000000); + ftvector.x = FLOATOBJ_GetLong(&fo); + fo = foY; + FLOATOBJ_MulLong(&fo, 0x01000000); + ftvector.y = FLOATOBJ_GetLong(&fo); + + /* Get the length of the freetype vector */ + lLength = FT_Vector_Length(&ftvector); + + /* Convert the 8.24 fixpoint back into a FLOATOBJ */ + FLOATOBJ_SetLong(&foLength, lLength); + FLOATOBJ_DivLong(&foLength, 0x01000000); + + /* Now divide the vector by the length */ + FLOATOBJ_Div(&foX, &foLength); + FLOATOBJ_Div(&foY, &foLength); + + /* Finally convert to FLOATL */ + ppte->x = FLOATOBJ_GetFloat(&foX); + ppte->y = FLOATOBJ_GetFloat(&foY); +}
PFTFD_FONT NTAPI @@ -69,16 +118,25 @@ pxo = FONTOBJ_pxoGetXform(pfo); if (!pxo) { - // unhandled yet - __debugbreak(); - } + WARN("Error there is no XFORMOBJ!\n"); + EngFreeMem(pfont); + return NULL; + } + + // FIXME: quantize to 16.16 fixpoint + XFORMOBJ_iGetXform(pxo, &xform); + pfont->fdxQuantized.eXX = xform.eM11; + pfont->fdxQuantized.eXY = xform.eM12; + pfont->fdxQuantized.eYX = xform.eM21; + pfont->fdxQuantized.eYY = xform.eM22;
/* Get a FLOATOBJ_XFORM matrix */ iComplexity = XFORMOBJ_iGetFloatObjXform(pxo, &foxform); - if (iComplexity == DDI_ERROR) - { - __debugbreak(); - } + ASSERT(iComplexity != DDI_ERROR); + + /* Compute normalized base vectors */ + FtfdComputeBaseVector(&pfont->pteBase, foxform.eM11, foxform.eM21); + FtfdComputeBaseVector(&pfont->pteSide, foxform.eM12, foxform.eM22);
/* Check if there is rotation / shearing (cannot use iComplexity!?) */ if (foxform.eM12.ul1 != 0 || foxform.eM12.ul2 != 0 || @@ -128,9 +186,9 @@ { /* Failure! */ WARN("Error setting face size\n"); + EngFreeMem(pfont); return NULL; } - }
/* Check if there is a design vector */ @@ -144,16 +202,10 @@ { /* Failure! */ WARN("Failed to set design vector\n"); + EngFreeMem(pfont); return NULL; } } - - // FIXME: quantize to 16.16 fixpoint - XFORMOBJ_iGetXform(pxo, &xform); - pfont->fdxQuantized.eXX = xform.eM11; - pfont->fdxQuantized.eXY = xform.eM12; - pfont->fdxQuantized.eYX = xform.eM21; - pfont->fdxQuantized.eYY = xform.eM22;
/* Prepare required coordinates in font space */ pmetrics = &pfont->metrics; @@ -175,15 +227,17 @@ /* Transform all coordinates into device space */ if (!XFORMOBJ_bApplyXform(pxo, XF_LTOL, 7, pmetrics->aptl, pmetrics->aptl)) { - __debugbreak(); + WARN("Failed apply coordinate transformation.\n"); + EngFreeMem(pfont); + return NULL; }
/* Fixup some minimum values */ if (pmetrics->ptlULThickness.y <= 0) pmetrics->ptlULThickness.y = 1; if (pmetrics->ptlSOThickness.y <= 0) pmetrics->ptlSOThickness.y = 1;
-TRACE("Created font with %ld (%ld)\n", yScale, (yScale+32)/64); -//__debugbreak(); + TRACE("Created font of size %ld (%ld)\n", yScale, (yScale+32)/64); + //__debugbreak();
/* Set the pvProducer member of the fontobj */ pfo->pvProducer = pfont; @@ -222,6 +276,7 @@
if (pfddm) { + /* Verify parameter */ if (cjSize < sizeof(FD_DEVICEMETRICS)) { /* Not enough space, fail */ @@ -235,17 +290,8 @@ /* Accelerator flags (ignored atm) */ pfddm->flRealizedType = 0;
- /* Baseline vectors */ - pfddm->pteBase.x = FLOATL_1; - pfddm->pteBase.y = 0; - pfddm->pteSide.x = 0; - pfddm->pteSide.y = 0xbf800000; //-FLOATL_1; - - /* Transform the baseline vectors */ - //XFORMOBJ_bApplyXformToFloat(pxo, 2, &pfddm->pteBase); - /* Fixed width advance */ - if (ftface->face_flags & FT_FACE_FLAG_FIXED_WIDTH) + if (FT_IS_FIXED_WIDTH(ftface)) pfddm->lD = ftface->max_advance_width; else pfddm->lD = 0; @@ -259,6 +305,8 @@ pfddm->ptlSOThickness = pfont->metrics.ptlSOThickness; pfddm->cxMax = pfont->metrics.sizlMax.cx; pfddm->cyMax = pfont->metrics.sizlMax.cy; + pfddm->pteBase = pfont->pteBase; + pfddm->pteSide = pfont->pteSide;
/* cjGlyphMax is the full size of the GLYPHBITS structure */ pfddm->cjGlyphMax = GLYPHBITS_SIZE(pfddm->cxMax, pfddm->cyMax, 4);