[ros-diffs] [jimtabor] 37201: - Update Font types. Finish GetKerningPairs. Minor code cleanup.

jimtabor at svn.reactos.org jimtabor at svn.reactos.org
Wed Nov 5 14:02:16 CET 2008


Author: jimtabor
Date: Wed Nov  5 07:02:15 2008
New Revision: 37201

URL: http://svn.reactos.org/svn/reactos?rev=37201&view=rev
Log:
- Update Font types. Finish GetKerningPairs. Minor code cleanup.

Modified:
    trunk/reactos/dll/win32/gdi32/include/gdi32p.h
    trunk/reactos/include/reactos/win32k/ntgdihdl.h
    trunk/reactos/subsystems/win32/win32k/objects/font.c
    trunk/reactos/subsystems/win32/win32k/objects/freetype.c

Modified: trunk/reactos/dll/win32/gdi32/include/gdi32p.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdi32/include/gdi32p.h?rev=37201&r1=37200&r2=37201&view=diff
==============================================================================
--- trunk/reactos/dll/win32/gdi32/include/gdi32p.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/gdi32/include/gdi32p.h [iso-8859-1] Wed Nov  5 07:02:15 2008
@@ -102,6 +102,11 @@
   WCHAR           String[188];
 } UMPDEV, *PUMPDEV;
 
+#define LOCALFONT_COUNT 10
+typedef struct _LOCALFONT
+{
+  FONT_ATTR  lfa[LOCALFONT_COUNT];
+} LOCALFONT, *PLOCALFONT;
 
 /* FUNCTIONS *****************************************************************/
 

Modified: trunk/reactos/include/reactos/win32k/ntgdihdl.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/win32k/ntgdihdl.h?rev=37201&r1=37200&r2=37201&view=diff
==============================================================================
--- trunk/reactos/include/reactos/win32k/ntgdihdl.h [iso-8859-1] (original)
+++ trunk/reactos/include/reactos/win32k/ntgdihdl.h [iso-8859-1] Wed Nov  5 07:02:15 2008
@@ -330,8 +330,8 @@
 
 typedef struct _FONT_ATTR
 {
-    DWORD dwUnknown;
-    void *pCharWidthData;
+    BOOL    bSlowWidths;
+    PCFONT  pCharWidthData;
 } FONT_ATTR, *PFONT_ATTR;
 
 

Modified: trunk/reactos/subsystems/win32/win32k/objects/font.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/objects/font.c?rev=37201&r1=37200&r2=37201&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/font.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/font.c [iso-8859-1] Wed Nov  5 07:02:15 2008
@@ -402,8 +402,69 @@
                      ULONG  NumPairs,
                      LPKERNINGPAIR  krnpair)
 {
-  UNIMPLEMENTED;
-  return 0;
+  PDC dc;
+  PDC_ATTR Dc_Attr;
+  PTEXTOBJ TextObj;
+  PFONTGDI FontGDI;
+  DWORD Count;
+  KERNINGPAIR *pKP;
+  NTSTATUS Status = STATUS_SUCCESS;
+
+  dc = DC_LockDc(hDC);
+  if (!dc)
+  {
+     SetLastWin32Error(ERROR_INVALID_HANDLE);
+     return 0;
+  }
+
+  Dc_Attr = dc->pDc_Attr;
+  if(!Dc_Attr) Dc_Attr = &dc->Dc_Attr;
+  TextObj = RealizeFontInit(Dc_Attr->hlfntNew);
+  DC_UnlockDc(dc);
+
+  if (!TextObj)
+  {
+     SetLastWin32Error(ERROR_INVALID_HANDLE);
+     return 0;
+  }
+
+  FontGDI = ObjToGDI(TextObj->Font, FONT);
+  TEXTOBJ_UnlockText(TextObj);
+
+  Count = ftGdiGetKerningPairs(FontGDI,0,NULL);
+
+  if ( Count && krnpair )
+  {
+     if (Count > NumPairs)
+     {
+        SetLastWin32Error(ERROR_INSUFFICIENT_BUFFER);
+        return 0;
+     }
+     pKP = ExAllocatePoolWithTag(PagedPool, Count * sizeof(KERNINGPAIR), TAG_GDITEXT);
+     if (!pKP)
+     {
+        SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
+        return 0;
+     }
+     ftGdiGetKerningPairs(FontGDI,Count,pKP);
+     _SEH_TRY
+     {
+        ProbeForWrite(krnpair, Count * sizeof(KERNINGPAIR), 1);
+        RtlCopyMemory(krnpair, pKP, Count * sizeof(KERNINGPAIR));
+     }
+     _SEH_HANDLE
+     {
+        Status = _SEH_GetExceptionCode();
+     }
+     _SEH_END
+     if (!NT_SUCCESS(Status))
+     {
+        SetLastWin32Error(ERROR_INVALID_PARAMETER);
+        Count = 0;
+     }     
+     ExFreePoolWithTag(pKP,TAG_GDITEXT);
+  }
+  return Count;
 }
 
 /*
@@ -424,7 +485,7 @@
   HFONT hFont = 0;
   ULONG Size;
   OUTLINETEXTMETRICW *potm;
-  NTSTATUS Status;
+  NTSTATUS Status = STATUS_SUCCESS;
 
   dc = DC_LockDc(hDC);
   if (!dc)
@@ -460,12 +521,21 @@
   IntGetOutlineTextMetrics(FontGDI, Size, potm);
   if (otm)
   {
-     Status = MmCopyToCaller(otm, potm, Size);
-     if (! NT_SUCCESS(Status))
+     _SEH_TRY
+     {
+         ProbeForWrite(otm, Size, 1);
+         RtlCopyMemory(otm, potm, Size);
+     }
+     _SEH_HANDLE
+     {
+         Status = _SEH_GetExceptionCode();
+     }
+     _SEH_END
+
+     if (!NT_SUCCESS(Status))
      {
         SetLastWin32Error(ERROR_INVALID_PARAMETER);
-        ExFreePoolWithTag(potm,TAG_GDITEXT);
-        return 0;
+        Size = 0;
      }
   }
   ExFreePoolWithTag(potm,TAG_GDITEXT);

Modified: trunk/reactos/subsystems/win32/win32k/objects/freetype.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/objects/freetype.c?rev=37201&r1=37200&r2=37201&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/freetype.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/freetype.c [iso-8859-1] Wed Nov  5 07:02:15 2008
@@ -2208,8 +2208,7 @@
   TT_OS2 *pOS2;
   FT_Face Face;
   CHARSETINFO csi;
-  DWORD cp;
-  DWORD fs0;
+  DWORD cp, fs0;
   USHORT usACP, usOEM;
 
   Dc_Attr = Dc->pDc_Attr;
@@ -2942,6 +2941,7 @@
   return TRUE;
 }
 
+
 DWORD
 FASTCALL
 ftGdiGetKerningPairs( PFONTGDI Font,
@@ -2949,22 +2949,20 @@
                       LPKERNINGPAIR pKerningPair)
 {
   DWORD Count = 0;
-  FT_Face face;
-
-  face = Font->face;
+  INT i = 0;
+  FT_Face face = Font->face;
 
   if (FT_HAS_KERNING(face) && face->charmap->encoding == FT_ENCODING_UNICODE)
   {
      FT_UInt previous_index = 0, glyph_index = 0;
      FT_ULong char_code, char_previous;
      FT_Vector delta;
-     int i;
         
      char_previous = char_code = FT_Get_First_Char(face, &glyph_index);
 
      IntUnLockFreeType;
 
-     for (i = 0; i < face->num_glyphs; i++)
+     while (glyph_index)
      {
          if (previous_index && glyph_index)
          {
@@ -2975,6 +2973,8 @@
                pKerningPair[i].wFirst      = char_previous;
                pKerningPair[i].wSecond     = char_code;
                pKerningPair[i].iKernAmount = delta.x;
+               i++;
+               if (i == cPairs) break;
             }
             Count++;
          }



More information about the Ros-diffs mailing list