Author: tkreuzer
Date: Tue May 17 22:54:19 2011
New Revision: 51817

URL: http://svn.reactos.org/svn/reactos?rev=51817&view=rev
Log:
[GDI FONT DRIVER]
- Calculate some fallback metrics differently
- set default vendor id to 'Unkn'
- Calculate the windows family from the PANOSE data instead of from the class 
ids (remove GetWinFamily)
- Implement enumeration of char sets

Modified:
    branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/font.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/video/font/ftfd/font.c?rev=51817&r1=51816&r2=51817&view=diff
==============================================================================
--- 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] Tue May 17 22:54:19 2011
@@ -96,10 +96,6 @@
 
     pifi->lEmbedId = 0;
     pifi->lCharBias = 0;
-
-    /* Set pitch */
-    pifi->jWinPitchAndFamily = FT_IS_FIXED_WIDTH(ftface) ? FIXED_PITCH :
-                                                           VARIABLE_PITCH;
 
     /* Feature flags */
     pifi->flInfo = FM_INFO_RETURNS_BITMAPS | FM_INFO_1BPP | FM_INFO_4BPP;
@@ -127,14 +123,12 @@
     pifi->fwdMacLineGap = 0;
     pifi->fwdMaxCharInc = ftface->max_advance_width;
     pifi->fwdUnderscoreSize = ftface->underline_thickness;
-    pifi->fwdUnderscorePosition = ftface->underline_position; // FIXME: off by 
10
-    pifi->fwdStrikeoutSize = pifi->fwdUnitsPerEm / 20;
-    pifi->fwdStrikeoutPosition = pifi->fwdUnitsPerEm / 4;
+    pifi->fwdUnderscorePosition = ftface->underline_position;
 
     pifi->ptlBaseline.x = 1; // FIXME
     pifi->ptlBaseline.y = 0; // FIXME
-    pifi->ptlAspect.x = 0x3e9; // FIXME
-    pifi->ptlAspect.y = 0x3e9; // FIXME
+    pifi->ptlAspect.x = 1;
+    pifi->ptlAspect.y = 1;
     pifi->ptlCaret.x = 0; // FIXME
     pifi->ptlCaret.y = 1; // FIXME
 
@@ -173,9 +167,9 @@
         pifi->fwdWinDescender = -(ftface->descender * 213) / 170;
         pifi->fwdTypoAscender = ftface->ascender;
         pifi->fwdTypoDescender = ftface->descender;
-        pifi->fwdTypoLineGap = ftface->units_per_EM / 10;
-        pifi->fwdCapHeight = 0;
-        pifi->fwdXHeight = 0;
+        pifi->fwdTypoLineGap = pifi->fwdUnitsPerEm / 10;
+        pifi->fwdCapHeight = pifi->fwdUnitsPerEm / 2;
+        pifi->fwdXHeight = pifi->fwdUnitsPerEm / 4;
         pifi->fwdSubscriptXSize = 0;
         pifi->fwdSubscriptYSize = 0;
         pifi->fwdSubscriptXOffset = 0;
@@ -184,6 +178,8 @@
         pifi->fwdSuperscriptYSize = 0;
         pifi->fwdSuperscriptXOffset = 0;
         pifi->fwdSuperscriptYOffset = 0;
+        pifi->fwdStrikeoutSize = pifi->fwdUnderscoreSize;
+        pifi->fwdStrikeoutPosition = pifi->fwdMacAscender / 3;
         pifi->fwdAveCharWidth = CalculateAveCharWidth(ftface);
 
         /* Special characters (first and last char are already enumerated) */
@@ -201,7 +197,7 @@
         pifi->panose.bMidline = PAN_ANY;
         pifi->panose.bXHeight = PAN_ANY;
 
-        *(DWORD*)&pifi->achVendId = '0000';
+        *(DWORD*)&pifi->achVendId = 'nknU';
     }
 
     /* Try to get type1 info from freetype */
@@ -216,6 +212,22 @@
         /* Set fallback values */
         pifi->lItalicAngle = 0;
     }
+
+    /* Get the win family */
+    if (pifi->panose.bFamilyType == PAN_FAMILY_SCRIPT)
+        pifi->jWinPitchAndFamily = FF_SCRIPT;
+    else if (pifi->panose.bFamilyType == PAN_FAMILY_DECORATIVE)
+        pifi->jWinPitchAndFamily = FF_DECORATIVE;
+    else if (pifi->panose.bProportion == PAN_PROP_MODERN)
+        pifi->jWinPitchAndFamily = FF_MODERN;
+    else if (pifi->panose.bSerifStyle <= PAN_SERIF_ROUNDED)
+        pifi->jWinPitchAndFamily = FF_SWISS;
+    else
+        pifi->jWinPitchAndFamily = FF_ROMAN;
+
+    /* Set pitch */
+    pifi->jWinPitchAndFamily |= FT_IS_FIXED_WIDTH(ftface) ? FIXED_PITCH :
+                                                            VARIABLE_PITCH;
 
     /* Convert the special characters from unicode to ansi */
     EngUnicodeToMultiByteN(&pifi->chFirstChar, 4, NULL, &pifi->wcFirstChar, 8);

Modified: branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/todo.txt
URL: 
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/todo.txt?rev=51817&r1=51816&r2=51817&view=diff
==============================================================================
--- 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] Tue May 17 22:54:19 2011
@@ -36,16 +36,15 @@
     - dpwszUniqueName: get from 'name' table
     - dpFontSim: implement
     - dpCharSets: implement
-    - fwdMacLineGap: implement
+    - fwdMacLineGap: from hhea table
     - fwdMaxCharInc: check/fix
     - fwdCapHeight: check/fix
     - fwdUnderscorePosition: fix
     - chFirstChar, chLastChar, chDefaultChar, chBreakChar: fix
     - wcDefaultChar, wcBreakChar: fix
     - ptlBaseline: fix
-    - ptlAspect: fix
-    - ptlCaret: fix
-    - jWinPitchandFamily: check, improve (Apolonia: 0,0->0x12)
+    - ptlCaret: use hhea table caretSlopeRun, caretSlopeRise
+    - Put most important charset into slot 0
 
 - FtfdInitGlyphSet: 100% done
 - FtfdInitKerningPairs: 90% done

Modified: branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/tttables.c
URL: 
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/tttables.c?rev=51817&r1=51816&r2=51817&view=diff
==============================================================================
--- 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] Tue May 17 22:54:19 2011
@@ -149,170 +149,30 @@
     return NULL;
 }
 
-/*! \name GetWinFamily
- *  \brief Translates IBM font class IDs into a Windows family bitfield
- *  \param jClassId
- *  \param jSubclassId
- *  \ref http://www.microsoft.com/typography/otspec/ibmfc.htm
- */
-static
-BYTE
-GetWinFamily(BYTE jClassId, BYTE jSubclassId)
-{
-    switch (jClassId)
-    {
-        case 0: // Class ID = 0 No Classification
-            return FF_ROMAN;//FF_SWISS;
-
-        case 1: // Class ID = 1 Oldstyle Serifs
-            switch (jSubclassId)
-            {
-                case 0: // Subclass ID = 0 : No Classification
-                case 1: // Subclass ID = 1 : IBM Rounded Legibility
-                case 2: // Subclass ID = 2 : Garalde
-                case 3: // Subclass ID = 3 : Venetian
-                case 4: // Subclass ID = 4 : Modified Venetian
-                case 5: // Subclass ID = 5 : Dutch Modern
-                case 6: // Subclass ID = 6 : Dutch Traditional
-                case 7: // Subclass ID = 7 : Contemporary
-                case 8: // Subclass ID = 8 : Calligraphic
-                case 15: // Subclass ID = 15 : Miscellaneous
-                default: // Subclass ID = 9-14 : (reserved for future use)
-                    break;
-            }
-
-        case 2: // Class ID = 2 Transitional Serifs
-            switch (jSubclassId)
-            {
-                case 15: return FF_ROMAN; // 15: Miscellaneous
-                case 0: // Subclass ID = 0 : No Classification
-                case 1: // Subclass ID = 1 : Direct Line
-                case 2: // Subclass ID = 2 : Script
-                default: // Subclass ID = 3-14 : (reserved for future use)
-                    break;
-            }
-
-        case 3: // Class ID = 3 Modern Serifs
-            switch (jSubclassId)
-            {
-                case 0: // Subclass ID = 0 : No Classification
-                case 1: // Subclass ID = 1 : Italian
-                case 2: // Subclass ID = 2 : Script
-                case 15: // Subclass ID = 15 : Miscellaneous
-                default: // Subclass ID = 3-14 : (reserved for future use)
-                    break;
-            }
-
-        case 4: // Class ID = 4 Clarendon Serifs
-            switch (jSubclassId)
-            {
-                case 0: // Subclass ID = 0 : No Classification
-                case 1: // Subclass ID = 1 : Clarendon
-                case 2: // Subclass ID = 2 : Modern
-                case 3: // Subclass ID = 3 : Traditional
-                case 4: // Subclass ID = 4 : Newspaper
-                case 5: // Subclass ID = 5 : Stub Serif
-                case 6: // Subclass ID = 6 : Monotone
-                case 7: // Subclass ID = 7 : Typewriter
-                case 15: // Subclass ID = 15 : Miscellaneous
-                default: // Subclass ID = 8-14: (reserved for future use)
-                    break;
-            }
-
-        case 5: // Class ID = 5 Slab Serifs
-            switch (jSubclassId)
-            {
-                case 0: // Subclass ID = 0 : No Classification
-                case 1: // Subclass ID = 1 : Monotone
-                case 2: // Subclass ID = 2 : Humanist
-                case 3: // Subclass ID = 3 : Geometric
-                case 4: // Subclass ID = 4 : Swiss
-                case 5: // Subclass ID = 5 : Typewriter
-                case 15: // Subclass ID = 15 : Miscellaneous
-                default: // Subclass ID = 6-14 : (reserved for future use)
-                    break;
-            }
-
-        case 7: // Class ID = 7 Freeform Serifs
-            switch (jSubclassId)
-            {
-                case 0: // Subclass ID = 0 : No Classification
-                case 1: // Subclass ID = 1 : Modern
-                case 15: // Subclass ID = 15 : Miscellaneous
-                default: // Subclass ID = 2-14 : (reserved for future use)
-                    break;
-            }
-
-        case 8: // Class ID = 8 Sans Serif
-            switch (jSubclassId)
-            {
-                case 0: return FF_SWISS; // 0: No Classification
-                case 5: return FF_SWISS; // 5: Neo-grotesque Gothic
-                case 15: return FF_SWISS|FF_ROMAN; // 15: Miscellaneous
-
-                case 1: // Subclass ID = 1 : IBM Neo-grotesque Gothic
-                case 2: // Subclass ID = 2 : Humanist
-                case 3: // Subclass ID = 3 : Low-x Round Geometric
-                case 4: // Subclass ID = 4 : High-x Round Geometric
-                case 6: // Subclass ID = 6 : Modified Neo-grotesque Gothic
-                case 9: // Subclass ID = 9 : Typewriter Gothic
-                case 10: // Subclass ID = 10 : Matrix
-                default: // Subclass ID = 7-8, 11-14 : (reserved for future 
use)
-                    break;
-            }
-
-        case 9: // Class ID = 9 Ornamentals
-            switch (jSubclassId)
-            {
-                case 0: // Subclass ID = 0 : No Classification
-                case 1: // Subclass ID = 1 : Engraver
-                case 2: // Subclass ID = 2 : Black Letter
-                case 3: // Subclass ID = 3 : Decorative
-                case 4: // Subclass ID = 4 : Three Dimensional
-                case 15: // Subclass ID = 15 : Miscellaneous
-                default: // Subclass ID = 5-14 : (reserved for future use)
-                    break;
-            }
-
-        case 10: // Class ID = 10 Scripts
-            switch (jSubclassId)
-            {
-                case 0: // Subclass ID = 0 : No Classification
-                case 1: // Subclass ID = 1 : Uncial
-                case 2: // Subclass ID = 2 : Brush Joined
-                case 3: // Subclass ID = 3 : Formal Joined
-                case 4: // Subclass ID = 4 : Monotone Joined
-                case 5: // Subclass ID = 5 : Calligraphic
-                case 6: // Subclass ID = 6 : Brush Unjoined
-                case 7: // Subclass ID = 7 : Formal Unjoined
-                case 8: // Subclass ID = 8 : Monotone Unjoined
-                case 15: // Subclass ID = 15 : Miscellaneous
-                default: // Subclass ID = 9-14 : (reserved for future use)
-                    break;
-            }
-
-        case 12: // Class ID = 12 Symbolic
-            switch (jSubclassId)
-            {
-                case 0: // Subclass ID = 0 : No Classification
-                case 3: // Subclass ID = 3 : Mixed Serif
-                case 6: // Subclass ID = 6 : Oldstyle Serif
-                case 7: // Subclass ID = 7 : Neo-grotesque Sans Serif
-                case 15: // Subclass ID = 15 : Miscellaneous
-                default: // Subclass ID = 1-2,4-5,8-14  : (reserved for future 
use)
-                    break;
-            }
-
-        case 13: // Class ID = 13 Reserved
-        case 14: // Class ID = 14 Reserved
-        default: // Class ID = 6,11 (reserved for future use)
-            break;
-    }
-
-    WARN("Unhandled class: jClassId=%d, jSubclassId=%d\n", jClassId, 
jSubclassId);
-//__debugbreak();
-    return FF_SWISS;
-}
+static BYTE
+gajlCodePage1[32] =
+{
+    /* 0 */ ANSI_CHARSET,
+    /* 1 */ EASTEUROPE_CHARSET,
+    /* 2 */ RUSSIAN_CHARSET,
+    /* 3 */ GREEK_CHARSET,
+    /* 4 */ TURKISH_CHARSET,
+    /* 5 */ HEBREW_CHARSET,
+    /* 6 */ ARABIC_CHARSET,
+    /* 7 */ BALTIC_CHARSET,
+    /* 8 */ VIETNAMESE_CHARSET,
+    /* 9-15 */ 0, 0, 0, 0, 0, 0, 0,
+    /* 16 */ THAI_CHARSET,
+    /* 17 */ SHIFTJIS_CHARSET,
+    /* 18 */ GB2312_CHARSET,
+    /* 19 */ HANGEUL_CHARSET, // Korean Wansung, is this correct?
+    /* 20 */ CHINESEBIG5_CHARSET,
+    /* 21 */ JOHAB_CHARSET,
+    /* 22-28 */ 0, 0, 0, 0, 0, 0, 0,
+    /* 29 */ MAC_CHARSET,
+    /* 30 */ OEM_CHARSET,
+    /* 31 */ SYMBOL_CHARSET,
+};
 
 BOOL
 NTAPI
@@ -324,6 +184,8 @@
     PVOID pvView = pfile->pvView;
     PTT_TABLE_OS2 pOs2;
     PTT_TABLE_HEAD pHead;
+    PBYTE pjCharset;
+    ULONG ulCharset, ulBit, ulCodePageRange1;
 
     /* Get the head table for the face */
     pHead = FtfdFindTrueTypeTable(pvView, pfile->cjView, pface->iFace, 'daeh', 
NULL);
@@ -345,10 +207,26 @@
         return FALSE;
     }
 
+    /* Get a pointer to the charsets */
+    pjCharset = (PBYTE)pifi + pifi->dpCharSets;
+
+    /* Loop bits of ulCodePageRange1 */
+    ulCodePageRange1 = GETD(&pOs2->ulCodePageRange1);
+    for (ulBit = 0, ulCharset = 0; ulBit < 32 && ulCharset < 15; ulBit++)
+    {
+        /* Check if the unicode range is present */
+        if (ulCodePageRange1 & (1 << ulBit))
+        {
+            /* Save the win charset */
+            pjCharset[ulCharset++] = gajlCodePage1[ulBit];
+        }
+    }
+
+    /* Copy the first charset */
+    pifi->jWinCharSet = pjCharset[0];
+
     //pifi->lEmbedId;
     //pifi->lCharBias;
-    //pifi->jWinCharSet;
-    pifi->jWinPitchAndFamily |= GetWinFamily(pOs2->jClassId, 
pOs2->jSubClassId);
     pifi->usWinWeight = GETW(&pOs2->usWeightClass);
     pifi->fsSelection = GETW(&pOs2->fsSelection);
     pifi->fsType = GETW(&pOs2->fsType);

Modified: branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/tttables.h
URL: 
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/tttables.h?rev=51817&r1=51816&r2=51817&view=diff
==============================================================================
--- 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] Tue May 17 22:54:19 2011
@@ -92,21 +92,21 @@
         };
         SHORT  sFamilyClass;
     };
-    BYTE       panose[10];
-    ULONG      ulUnicodeRange1; //     Bits 0-31
-    ULONG      ulUnicodeRange2; //     Bits 32-63
-    ULONG      ulUnicodeRange3; //     Bits 64-95
-    ULONG      ulUnicodeRange4; //     Bits 96-127
-    CHAR       achVendID[4];
-    USHORT     fsSelection;
-    USHORT     usFirstCharIndex;
-    USHORT     usLastCharIndex;
-    SHORT      sTypoAscender;
+    BYTE       panose[10]; // 0x20
+    ULONG      ulUnicodeRange1; // 0x2A        Bits 0-31
+    ULONG      ulUnicodeRange2; // 0x2E        Bits 32-63
+    ULONG      ulUnicodeRange3; // 0x32        Bits 64-95
+    ULONG      ulUnicodeRange4; // 0x36        Bits 96-127
+    CHAR       achVendID[4]; // 0x3a
+    USHORT     fsSelection; // 0x3e
+    USHORT     usFirstCharIndex; // 0x40
+    USHORT     usLastCharIndex; // 0x42
+    SHORT      sTypoAscender; // 0x44
     SHORT      sTypoDescender;
     SHORT      sTypoLineGap;
     USHORT     usWinAscent;
     USHORT     usWinDescent;
-    ULONG      ulCodePageRange1; //    Bits 0-31
+    ULONG      ulCodePageRange1; // 0x4e       Bits 0-31
     ULONG      ulCodePageRange2; //    Bits 32-63
     SHORT      sxHeight;
     SHORT      sCapHeight;


Reply via email to