[ros-diffs] [tkreuzer] 53238: [GDI FONT DRIVER] - Set FM_INFO_OPTICALLY_FIXED_PITCH for fixed width fonts - Fix calculation of fixed width. Fixes display of fixed width fonts, like Lucida Console

tkreuzer at svn.reactos.org tkreuzer at svn.reactos.org
Sun Aug 14 20:27:27 UTC 2011


Author: tkreuzer
Date: Sun Aug 14 20:27:26 2011
New Revision: 53238

URL: http://svn.reactos.org/svn/reactos?rev=53238&view=rev
Log:
[GDI FONT DRIVER]
- Set FM_INFO_OPTICALLY_FIXED_PITCH for fixed width fonts
- Fix calculation of fixed width. Fixes display of fixed width fonts, like Lucida Console

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

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=53238&r1=53237&r2=53238&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] Sun Aug 14 20:27:26 2011
@@ -111,6 +111,8 @@
         pifi->flInfo |= FM_INFO_NOT_CONTIGUOUS;
     if (pface->ulFontFormat != FMT_FNT)
         pifi->flInfo |= /*FM_INFO_RETURNS_OUTLINES |*/ FM_INFO_ARB_XFORMS;
+    if (ftface->face_flags & FT_FACE_FLAG_FIXED_WIDTH)
+        pifi->flInfo |= FM_INFO_OPTICALLY_FIXED_PITCH;
     pifi->flInfo |= FM_INFO_RIGHT_HANDED; // FIXME: how to determine?
 
     /* Font resolution */

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=53238&r1=53237&r2=53238&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] Sun Aug 14 20:27:26 2011
@@ -138,7 +138,7 @@
     FLOATOBJ y;
 } POINTEF, *PPOINTEF;
 
-typedef struct
+typedef struct _FTFD_FONT
 {
     FONTOBJ *pfo;
     PFTFD_FILE pfile;

Modified: branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/glyph.c
URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/glyph.c?rev=53238&r1=53237&r2=53238&view=diff
==============================================================================
--- 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] Sun Aug 14 20:27:26 2011
@@ -305,6 +305,34 @@
     return pfont;
 }
 
+static
+BOOL
+FtfdLoadGlyph(
+    PFTFD_FONT pfont,
+    HGLYPH hg,
+    ULONG iFormat) // 0 = bitmap, 1 = outline
+{
+    FT_Error fterror;
+
+    /* Check if the glyph needs to be updated */
+    if (pfont->hgSelected != hg)
+    {
+        /* Load the glyph into the freetype face slot */
+        fterror = FT_Load_Glyph(pfont->ftface, hg, 0);
+        if (fterror)
+        {
+            WARN("Couldn't load glyph 0x%lx\n", hg);
+            pfont->hgSelected = -1;
+            return FALSE;
+        }
+
+        /* Update the selected glyph */
+        pfont->hgSelected = hg;
+    }
+
+    return TRUE;
+}
+
 ULONG
 NTAPI
 FtfdQueryMaxExtents(
@@ -331,11 +359,28 @@
         /* Accelerator flags (ignored atm) */
         pfddm->flRealizedType = 0;
 
-        /* Set fixed width advance */
+        /* Check for fixed width font */
         if (FT_IS_FIXED_WIDTH(ftface))
-            pfddm->lD = ftface->max_advance_width;
+        {
+            /* Make sure a glyph is loaded */
+            if ((pfont->hgSelected != -1) ||
+                FtfdLoadGlyph(pfont, 0, 0))
+            {
+                /* Convert advance from 26.6 fixpoint to pixel format */
+                pfddm->lD = pface->ftface->glyph->advance.x >> 6;
+            }
+            else
+            {
+                /* Fall back to dynamic pitch */
+                WARN("Couldn't load a glyph\n");
+                pfddm->lD = 0;
+            }
+        }
         else
+        {
+            /* Variable pitch */
             pfddm->lD = 0;
+        }
 
         /* Copy some values from the font structure */
         pfddm->fxMaxAscender = pfont->metrics.fxMaxAscender;
@@ -380,33 +425,6 @@
     return sizeof(FD_DEVICEMETRICS);
 }
 
-static
-BOOL
-FtfdLoadGlyph(
-    PFTFD_FONT pfont,
-    HGLYPH hg,
-    ULONG iFormat) // 0 = bitmap, 1 = outline
-{
-    FT_Error fterror;
-
-    /* Check if the glyph needs to be updated */
-    if (pfont->hgSelected != hg)
-    {
-        /* Load the glyph into the freetype face slot */
-        fterror = FT_Load_Glyph(pfont->ftface, hg, 0);
-        if (fterror)
-        {
-            WARN("Couldn't load glyph 0x%lx\n", hg);
-            pfont->hgSelected = -1;
-            return FALSE;
-        }
-
-        /* Update the selected glyph */
-        pfont->hgSelected = hg;
-    }
-
-    return TRUE;
-}
 
 static
 VOID
@@ -436,8 +454,8 @@
         pgd->fxAB = pgd->fxA + ftglyph->metrics.height;
     }
 
-    /* D is the glyph advance width */
-    pgd->fxD = ftglyph->advance.x / 4; // FIXME: should be projected on the x-axis
+    /* D is the glyph advance width. Convert it from 26.6 to 28.4 fixpoint format */
+    pgd->fxD = ftglyph->advance.x >> 2; // FIXME: should be projected on the x-axis
 
     /* Get the bitnmap size */
     sizlBitmap.cx = ftglyph->bitmap.width;




More information about the Ros-diffs mailing list