Author: tkreuzer
Date: Fri May 20 19:04:57 2011
New Revision: 51828
URL:
http://svn.reactos.org/svn/reactos?rev=51828&view=rev
Log:
[GDI FONT DRIVER]
- Due to the ret^Z^Z^Z unfavourable behaviour of FT_Get_Advances to return either font
units or fractional pixels without a way to distinguish, use FT_Get_Advances only for the
fast case (in this case we always get font units) und implement the slow version
seperately.
- fast version is if 0ed, since conversion is missing yet
- If used in Windows, the driver now provides proper metrics
- set lNonLinearExtLeading and lNonLinearIntLeading to 0x80000000, this seems to be some
default value, needs more investigation
Modified:
branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/glyph.c
branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/tttables.c
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] Fri May
20 19:04:57 2011
@@ -150,7 +150,7 @@
* space to device space. Since we use FT_Set_Char_Size, which allows
* higher precision than FT_Set_Pixel_Sizes, we need to convert into
* points. So we multiply our scaling coefficients with 72 divided by
- * the device resolution. We also need a 26.4 fixpoint value, so we
+ * the device resolution. We also need a 26.6 fixpoint value, so we
* multiply with 64. */
FLOATOBJ_MulLong(&efScaleX, 64 * pface->ifiex.ifi.fwdUnitsPerEm * 72);
FLOATOBJ_DivLong(&efScaleX, pfo->sizLogResPpi.cx);
@@ -176,7 +176,7 @@
/* Check if there is rotation / skewing (cannot use iComplexity!?) */
if (!FLOATOBJ_bIsNull(&fxform.eM12) || !FLOATOBJ_bIsNull(&fxform.eM21))
{
- __debugbreak();
+ //__debugbreak();
/* Create a transformation matrix that is applied after the character
* scaling. We simply use the normalized base vectors and convert them
@@ -330,8 +330,8 @@
/* Copy the quantized matrix from the font structure */
pfddm->fdxQuantized = pfont->fdxQuantized;
- pfddm->lNonLinearExtLeading = 0x00000000;
- pfddm->lNonLinearIntLeading = 0x00000080; // FIXME
+ pfddm->lNonLinearExtLeading = 0x80000000;
+ pfddm->lNonLinearIntLeading = 0x80000000; // FIXME
pfddm->lNonLinearMaxCharWidth = 0x80000000;
pfddm->lNonLinearAvgCharWidth = 0x80000000;
@@ -341,7 +341,8 @@
}
TRACE("pfddm->fxMaxAscender=%ld, yScale=%ld, height=%ld\n",
- pfddm->fxMaxAscender, pfont->sizlScale.cy,
(pfont->sizlScale.cy+32)/64);
+ pfddm->fxMaxAscender, pfont->sizlScale.cy,
+ (pfont->sizlScale.cy+32)/64);
//__debugbreak();
/* Return the size of the structure */
@@ -686,28 +687,53 @@
//TRACE("FtfdQueryAdvanceWidths\n");
- // FIXME: layout horizontal/vertical
- fl = (iMode == QAW_GETEASYWIDTHS) ? FT_ADVANCE_FLAG_FAST_ONLY : 0;
-// | (ftface->face_flags & FT_FACE_FLAG_VERTICAL) ? FT_LOAD_VERTICAL_LAYOUT :
0;
-fl = 0;
-
- /* Loop all requested glyphs */
- for (i = 0; i < cGlyphs; i++)
- {
- /* Query advance width */
- fterror = FT_Get_Advance(ftface, (FT_UInt)phg[i], fl, &advance);
- if (fterror || advance > 0x0FFFF000)
+ /* The selected glyph will be changed */
+ pfont->hgSelected = -1;
+
+ /* Check if fast version is requested */
+ if (0 && iMode == QAW_GETEASYWIDTHS)
+ {
+ fl = FT_ADVANCE_FLAG_FAST_ONLY;
+
+ /* Check if the font layout is vertical */
+ if (ftface->face_flags & FT_FACE_FLAG_VERTICAL)
{
- WARN("Failed to query advance width hg=%lx, fl=0x%lx\n",
- phg[i], fl);
- pusWidths[i] = 0xffff;
- bResult = FALSE;
+ fl |= FT_LOAD_VERTICAL_LAYOUT;
}
- else
+
+ /* Loop all requested glyphs */
+ for (i = 0; i < cGlyphs; i++)
{
- /* Transform from 16.16 points to 28.4 pixels */
- pusWidths[i] = (USHORT)((advance * 72 / pfo->sizLogResPpi.cx) >>
12);
- //TRACE("Got advance width: hg=%lx, adv=%lx->%ld\n", phg[i],
advance, pt.x);
+ /* Query advance width */
+ fterror = FT_Get_Advances(ftface, (FT_UInt)phg[i], 1, fl, &advance);
+ if (fterror || advance > 0xFFFF)
+ {
+ pusWidths[i] = 0xffff;
+ bResult = FALSE;
+ }
+ else
+ {
+ pusWidths[i] = (USHORT)(advance >> 2);
+ //TRACE("Got advance width: hg=%lx, adv=%lx->%ld\n", phg[i],
advance, pt.x);
+ }
+ }
+ }
+ else
+ {
+ /* Loop all requested glyphs */
+ for (i = 0; i < cGlyphs; i++)
+ {
+ /* Load the glyph */
+ fterror = FT_Load_Glyph(ftface, (FT_UInt)phg[i], 0);
+ if (fterror)
+ {
+ pusWidths[i] = 0xffff;
+ bResult = FALSE; // FIXME: return FALSE or DDI_ERROR?
+ }
+ else
+ {
+ pusWidths[i] = (USHORT)ftface->glyph->advance.x >> 2;
+ }
}
}
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] Fri
May 20 19:04:57 2011
@@ -273,11 +273,13 @@
FD_KERNINGPAIR *pkp2)
{
ULONG ul1, ul2;
+
+ /* Calculate the values for the 2 kerning pairs */
ul1 = pkp1->wcFirst + 65536 * pkp1->wcSecond;
ul2 = pkp2->wcFirst + 65536 * pkp2->wcSecond;
- if (ul1 < ul2) return -1;
- if (ul1 > ul2) return 1;
- return 0;
+
+ /* Return the comparison result */
+ return (ul1 < ul2) ? -1 : ((ul1 > ul2) ? 1 : 0);
}
@@ -314,7 +316,6 @@
nTables = GETW(&pKernTable->nTables);
ulLastAddress = (ULONG_PTR)pKernTable + cjSize;
-
/* Loop all subtables */
pSubTable = &pKernTable->subtable;
for (i = 0; i < nTables; i++)
@@ -322,7 +323,7 @@
/* Check if the subtable is accessible */
if ((ULONG_PTR)pSubTable + sizeof(TT_KERNING_SUBTABLE) > ulLastAddress)
{
- __debugbreak();
+ WARN("kern table outside the file\n");
return;
}
@@ -330,7 +331,7 @@
cjSize = GETW(&pSubTable->usLength);
if ((ULONG_PTR)pSubTable + cjSize > ulLastAddress)
{
- __debugbreak();
+ WARN("kern table exceeds size of the file\n");
return;
}
@@ -341,7 +342,7 @@
cPairs += GETW(&pSubTable->format0.nPairs);
if ((ULONG_PTR)&pSubTable->format0.akernpair[cPairs] >
ulLastAddress)
{
- __debugbreak();
+ WARN("Number of kerning pairs too large for table size\n");
return;
}
}