Author: tkreuzer
Date: Thu May 19 21:57:49 2011
New Revision: 51825

URL: http://svn.reactos.org/svn/reactos?rev=51825&view=rev
Log:
[GDI FONT DRIVER]
- Allow to use non-unicode charsets (Marlett for example only has a symbol 
charset embedded)
- Use a char bias when dealing with other charsets
- Fixes Marlett based nonclient buttons, when used as default driver in Windows

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/tttables.c

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=51825&r1=51824&r2=51825&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] Thu May 19 21:57:49 2011
@@ -138,7 +138,6 @@
     pifi->rclFontBox.top = ftface->bbox.yMax;
     pifi->rclFontBox.bottom = ftface->bbox.yMin;
 
-    pifi->cKerningPairs = 0;
     pifi->ulPanoseCulture = FM_PANOSE_CULTURE_LATIN;
 
     /* Try to get OS/2 TrueType or OpenType metrics */
@@ -182,8 +181,8 @@
         pifi->fwdStrikeoutPosition = pifi->fwdMacAscender / 3;
         pifi->fwdAveCharWidth = CalculateAveCharWidth(ftface);
 
-        /* Special characters (first and last char are already enumerated) */
-        pifi->wcDefaultChar = 0x0020;
+        /* Special characters */
+        pifi->wcDefaultChar = 0x001F;
         pifi->wcBreakChar = 0x0020;
 
         pifi->panose.bFamilyType = PAN_FAMILY_TEXT_DISPLAY;
@@ -199,6 +198,14 @@
 
         *(DWORD*)&pifi->achVendId = 'nknU';
     }
+
+    /* Copy unicode values to ansi values */
+    pifi->chDefaultChar = (CHAR)pifi->wcDefaultChar;
+    pifi->chBreakChar = (CHAR)pifi->wcBreakChar;
+    pifi->chFirstChar = (CHAR)pifi->wcFirstChar;
+    if (pifi->wcFirstChar > 0xff) pifi->chFirstChar = 0xff;
+    pifi->chLastChar = (CHAR)pifi->wcLastChar;
+    if (pifi->wcLastChar > 0xff) pifi->chLastChar = 0xff;
 
     /* Try to get type1 info from freetype */
     fterror = FT_Get_PS_Font_Info(pface->ftface, &fontinfo);
@@ -334,7 +341,7 @@
         {
             /* Add a new WCRUN */
             cRuns++;
-            pGlyphSet->awcrun[cRuns - 1].wcLow = wcCurrent;
+            pGlyphSet->awcrun[cRuns - 1].wcLow = wcCurrent - pface->wcCharBias;
             pGlyphSet->awcrun[cRuns - 1].cGlyphs = 1;
             pGlyphSet->awcrun[cRuns - 1].phg = &phglyphs[i];
         }
@@ -399,9 +406,33 @@
 {
     PFTFD_FACE pface;
     FT_Error fterror;
-    ULONG ulAccumCharWidth = 0;
+    ULONG ulEncoding, ulAccumCharWidth = 0;
     WCHAR wcCurrent, wcPrev;
     FT_UInt index;
+
+    /* Try to load a unicode charmap */
+    ulEncoding = FT_ENCODING_UNICODE;
+    fterror = FT_Select_Charmap(ftface, ulEncoding);
+    if (fterror)
+    {
+        /* Check if we have any charmaps at all */
+        if (ftface->num_charmaps == 0)
+        {
+            WARN("There are no charmaps available!\n");
+            return NULL;
+        }
+
+        /* Load first charmap instead */
+        ulEncoding = ftface->charmaps[0]->encoding;
+        fterror = FT_Select_Charmap(ftface, ulEncoding);
+        if (fterror)
+        {
+            WARN("Could not load a charmap\n");
+            return NULL;
+        }
+
+        TRACE("Loaded charmap with encoding %.4s\n", &ulEncoding);
+    }
 
     pface = EngAllocMem(FL_ZERO_MEMORY, sizeof(FTFD_FACE), 'dftF');
     if (!pface)
@@ -415,17 +446,13 @@
     pface->iFace = iFace;
     pface->ftface = ftface;
     pface->cGlyphs = ftface->num_glyphs;
+    pface->ulEncoding = ulEncoding;
+
+    /* Set char bias, FIXME: use lCharBias? other encodings? */
+    pface->wcCharBias = ulEncoding == FT_ENCODING_MS_SYMBOL ? 0xf000 : 0;
 
     /* Get the font format */
     pface->ulFontFormat = FtfdGetFontFormat(ftface);
-
-    /* Load a unicode charmap */
-    fterror = FT_Select_Charmap(ftface, FT_ENCODING_UNICODE);
-    if (fterror)
-    {
-        WARN("Could not load unicode charmap\n");
-        return NULL;
-    }
 
     /* Start with 0 runs and 0 mappings */
     pface->cMappings = 0;
@@ -433,7 +460,7 @@
 
     /* Loop through all character mappings */
     wcPrev = wcCurrent = (WCHAR)FT_Get_First_Char(ftface, &index);
-    pface->ifiex.ifi.wcFirstChar = wcCurrent;
+    pface->ifiex.ifi.wcFirstChar = wcCurrent - pface->wcCharBias;;
     while (index)
     {
         /* Count the mapping */
@@ -448,7 +475,7 @@
     }
 
     /* Save the last character */
-    pface->ifiex.ifi.wcLastChar = wcPrev;
+    pface->ifiex.ifi.wcLastChar = wcPrev - pface->wcCharBias;;
 
     /* Initialize IFIMETRICS */
     FtfdInitIfiMetrics(pface);

Modified: branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/ftfd.h
URL: 
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/ftfd.h?rev=51825&r1=51824&r2=51825&view=diff
==============================================================================
--- 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] Thu May 19 21:57:49 2011
@@ -94,6 +94,8 @@
     ULONG cMappings;
     ULONG cRuns;
     ULONG ulFontRevision;
+    ULONG ulEncoding;
+    WCHAR wcCharBias;
     PWCHAR pwcReverseTable;
     FD_GLYPHSET *pGlyphSet;
     FD_KERNINGPAIR *pKerningPairs;

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=51825&r1=51824&r2=51825&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] Thu May 19 21:57:49 2011
@@ -253,13 +253,15 @@
     //pifi->fwdUnderscorePosition;
     pifi->fwdStrikeoutSize = GETW(&pOs2->yStrikeoutSize);
     pifi->fwdStrikeoutPosition = GETW(&pOs2->yStrikeoutPosition);
+    *(DWORD*)pifi->achVendId = *(DWORD*)pOs2->achVendID;
+    //pifi->ulPanoseCulture;
+    pifi->panose = *(PANOSE*)pOs2->panose;
+
+    /* Get special characters */
     pifi->wcFirstChar = GETW(&pOs2->usFirstCharIndex);
     pifi->wcLastChar = GETW(&pOs2->usLastCharIndex);
     pifi->wcDefaultChar = GETW(&pOs2->usDefaultChar);
     pifi->wcBreakChar = GETW(&pOs2->usBreakChar);
-    *(DWORD*)pifi->achVendId = *(DWORD*)pOs2->achVendID;
-    //pifi->ulPanoseCulture;
-    pifi->panose = *(PANOSE*)pOs2->panose;
 
     return TRUE;
 }


Reply via email to