Author: tkreuzer Date: Mon May 16 17:40:41 2011 New Revision: 51794
URL: http://svn.reactos.org/svn/reactos?rev=51794&view=rev Log: [GDI FONT DRIVER] - Get font revision and lowest ppem from 'head' true type table - use font revision to create the unique name
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/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] Mon May 16 17:40:41 2011 @@ -51,6 +51,7 @@ } }
+ /* Return the average glyph width */ return (FWORD)(ulAccumCharWidth / cGlyphs); }
@@ -85,7 +86,7 @@ pifi->dpCharSets = FIELD_OFFSET(FTFD_IFIMETRICS, ajCharSet); pifi->dpFontSim = 0;
- /* Charsets */ + /* Initialize charsets */ pifi->jWinCharSet = ANSI_CHARSET; pifiex->ajCharSet[0] = pifi->jWinCharSet; for (i = 1; i < 16; i++) @@ -118,7 +119,7 @@
/* Font resolution */ pifi->fwdUnitsPerEm = ftface->units_per_EM; - pifi->fwdLowestPPEm = 3; // FIXME + pifi->fwdLowestPPEm = 3;
/* Font metrics */ pifi->fwdMacAscender = ftface->ascender; @@ -242,15 +243,13 @@ strnlen(ftface->family_name, MAX_PATH));
/* Create a unique name */ - wcscpy(pifiex->awcUniqueName, L"1.000;ABCD;"); + wcscpy(pifiex->awcUniqueName, L"1.000;????;"); wcsncat(pifiex->awcUniqueName, pifiex->awcFamilyName, LF_FACESIZE); - pifiex->awcUniqueName[0] = L'1'; // + version? - pifiex->awcUniqueName[2] = L'0'; // + version? - EngMultiByteToUnicodeN(pifiex->awcUniqueName + 6, - 4, - NULL, - pifi->achVendId, - 4); + pifiex->awcUniqueName[0] = L'0' + HIWORD(pface->ulFontRevision) % 10; + pifiex->awcUniqueName[2] = L'0' + (LOWORD(pface->ulFontRevision) / 100) % 10; + pifiex->awcUniqueName[3] = L'0' + (LOWORD(pface->ulFontRevision) / 10) % 10; + pifiex->awcUniqueName[4] = L'0' + LOWORD(pface->ulFontRevision) % 10; + EngMultiByteToUnicodeN(pifiex->awcUniqueName+6, 4, NULL, pifi->achVendId, 4);
//__debugbreak(); return TRUE; @@ -279,7 +278,6 @@ WARN("EngAllocMem() failed.\n"); return NULL; } -
/* Calculate FD_GLYPHSET size (incl. HGLYPH array!) */ cjSize = FIELD_OFFSET(FD_GLYPHSET, awcrun) @@ -437,6 +435,7 @@ wcCurrent = (WCHAR)FT_Get_Next_Char(ftface, wcCurrent, &index); }
+ /* Save the last character */ pface->ifiex.ifi.wcLastChar = wcPrev;
/* Initialize IFIMETRICS */
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] Mon May 16 17:40:41 2011 @@ -93,6 +93,7 @@ ULONG cGlyphs; ULONG cMappings; ULONG cRuns; + ULONG ulFontRevision; PWCHAR pwcReverseTable; FD_GLYPHSET *pGlyphSet; FD_KERNINGPAIR *pKerningPairs;
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] Mon May 16 17:40:41 2011 @@ -263,10 +263,8 @@ { PFTFD_FONT pfont = pfo->pvProducer;
- if (!pfont) - { - pfont = FtfdCreateFontInstance(pfo); - } + /* Create a font instance if neccessary */ + if (!pfont) pfont = FtfdCreateFontInstance(pfo);
/* Return the font instance */ return pfont; @@ -302,7 +300,7 @@ /* Accelerator flags (ignored atm) */ pfddm->flRealizedType = 0;
- /* Fixed width advance */ + /* Set fixed width advance */ if (FT_IS_FIXED_WIDTH(ftface)) pfddm->lD = ftface->max_advance_width; else @@ -362,7 +360,7 @@ /* Check if the glyph needs to be updated */ if (pfont->hgSelected != hg) { - /* Load the glypg into the freetype face slot */ + /* Load the glyph into the freetype face slot */ fterror = FT_Load_Glyph(pfont->ftface, hg, 0); if (fterror) { @@ -406,7 +404,7 @@ }
/* D is the glyph advance width */ - pgd->fxD = ftglyph->advance.x / 4; // should be projected on the x-axis + pgd->fxD = ftglyph->advance.x / 4; // FIXME: should be projected on the x-axis
/* This is the box in which the bitmap fits */ pgd->rclInk.left = ftglyph->bitmap_left; @@ -418,7 +416,7 @@ pgd->fxInkBottom = (-pgd->rclInk.bottom) << 4; pgd->fxInkTop = pgd->rclInk.top << 4;
- /* Make the bitmap at least 1x1 pixel */ + /* Make the bitmap at least 1x1 pixel large */ if (ftglyph->bitmap.width == 0) pgd->rclInk.right++; if (ftglyph->bitmap.rows == 0) pgd->rclInk.bottom++;
@@ -668,7 +666,7 @@ FT_Error fterror; FT_Fixed advance;
- TRACE("FtfdQueryAdvanceWidths\n"); + //TRACE("FtfdQueryAdvanceWidths\n");
// FIXME: layout horizontal/vertical fl = (iMode == QAW_GETEASYWIDTHS) ? FT_ADVANCE_FLAG_FAST_ONLY : 0;
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] Mon May 16 17:40:41 2011 @@ -312,13 +312,26 @@ { PFTFD_FILE pfile = pface->pfile; PVOID pvView = pfile->pvView; - PTT_OS2_DATA pOs2; + PTT_TABLE_OS2 pOs2; + PTT_TABLE_HEAD pHead; + + /* Get the head table for the face */ + pHead = FtfdFindTrueTypeTable(pvView, pfile->cjView, pface->iFace, 'daeh', NULL); + if (!pHead) + { + WARN("Couldn't find 'head' table\n"); + return FALSE; + } + + /* Get lowest PPEm */ + pifi->fwdLowestPPEm = GETW(&pHead->lowestRecPPEM); + pface->ulFontRevision = GETD(&pHead->fontRevision);
/* Get the OS/2 table for the face */ pOs2 = FtfdFindTrueTypeTable(pvView, pfile->cjView, pface->iFace, '2/SO', NULL); if (!pOs2) { - WARN("Couldn't find OS/2 table\n"); + WARN("Couldn't find 'OS/2' table\n"); return FALSE; }
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] Mon May 16 17:40:41 2011 @@ -66,7 +66,7 @@ SHORT glyphDataFormat; } TT_TABLE_HEAD, *PTT_TABLE_HEAD;
-typedef struct _TT_OS2_DATA +typedef struct _TT_TABLE_OS2 { USHORT version; // // 0x00 SHORT xAvgCharWidth; @@ -113,7 +113,7 @@ USHORT usDefaultChar; USHORT usBreakChar; USHORT usMaxContext; -} TT_OS2_DATA, *PTT_OS2_DATA; +} TT_TABLE_OS2, *PTT_TABLE_OS2;
typedef struct _TT_KERNPAIR {