Author: jimtabor
Date: Tue Dec 23 20:23:30 2008
New Revision: 38317
URL: 
http://svn.reactos.org/svn/reactos?rev=38317&view=rev
Log:
- Add IntGetCharDimensions and text metrics for win32k server info.
Modified:
    trunk/reactos/subsystems/win32/win32k/include/text.h
    trunk/reactos/subsystems/win32/win32k/ntuser/winsta.c
    trunk/reactos/subsystems/win32/win32k/objects/font.c
Modified: trunk/reactos/subsystems/win32/win32k/include/text.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/in…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/text.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/include/text.h [iso-8859-1] Tue Dec 23 20:23:30
2008
@@ -106,6 +106,7 @@
 DWORD FASTCALL ftGdiGetKerningPairs(PFONTGDI,DWORD,LPKERNINGPAIR);
 BOOL NTAPI GreExtTextOutW(IN HDC,IN INT,IN INT,IN UINT,IN OPTIONAL LPRECT,
     IN LPWSTR, IN INT, IN OPTIONAL LPINT, IN DWORD);
+DWORD FASTCALL IntGetCharDimensions(HDC, PTEXTMETRICW, PDWORD);
 #define IntLockProcessPrivateFonts(W32Process) \
   ExEnterCriticalRegionAndAcquireFastMutexUnsafe(&W32Process->PrivateFontListLock)
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/winsta.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/winsta.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/winsta.c [iso-8859-1] Tue Dec 23 20:23:30
2008
@@ -294,6 +294,7 @@
 BOOL FASTCALL
 co_IntInitializeDesktopGraphics(VOID)
 {
+   TEXTMETRICW tmw;
    UNICODE_STRING DriverName = RTL_CONSTANT_STRING(L"DISPLAY");
    if (! IntCreatePrimarySurface())
    {
@@ -316,9 +317,13 @@
    IntGdiSetDCOwnerEx( hSystemBM, GDI_OBJ_HMGR_PUBLIC, FALSE);
    // FIXME! Move these to a update routine.
-   gpsi->Planes    = NtGdiGetDeviceCaps(ScreenDeviceContext, PLANES);
-   gpsi->BitsPixel = NtGdiGetDeviceCaps(ScreenDeviceContext, BITSPIXEL);
-   gpsi->BitCount  = gpsi->Planes * gpsi->BitsPixel;
+   gpsi->Planes        = NtGdiGetDeviceCaps(ScreenDeviceContext, PLANES);
+   gpsi->BitsPixel     = NtGdiGetDeviceCaps(ScreenDeviceContext, BITSPIXEL);
+   gpsi->BitCount      = gpsi->Planes * gpsi->BitsPixel;
+   gpsi->dmLogPixels   = NtGdiGetDeviceCaps(ScreenDeviceContext, LOGPIXELSY);
+   // Font is realized and this dc was previously set to internal DC_ATTR.
+   gpsi->cxSysFontChar = IntGetCharDimensions(hSystemBM, &tmw,
&gpsi->cySysFontChar);
+   gpsi->tmSysFont     = tmw;
    return TRUE;
 }
Modified: trunk/reactos/subsystems/win32/win32k/objects/font.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ob…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/font.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/font.c [iso-8859-1] Tue Dec 23 20:23:30
2008
@@ -53,6 +53,49 @@
   }
   return Count;
 }
+
+DWORD
+FASTCALL
+IntGetCharDimensions(HDC hdc, PTEXTMETRICW ptm, PDWORD height)
+{
+  PDC pdc;
+  PDC_ATTR pDc_Attr;
+  PTEXTOBJ TextObj;
+  SIZE sz;
+  TMW_INTERNAL tmwi;
+  BOOL Good;
+
+  static const WCHAR alphabet[] = {
+
'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q',
+
'r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H',
+
'I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',0};
+
+  if(!ftGdiGetTextMetricsW(hdc, &tmwi)) return 0;
+
+  pdc = DC_LockDc(hdc);
+
+  if (!pdc) return 0;
+
+  pDc_Attr = pdc->pDc_Attr;
+  if(!pDc_Attr) pDc_Attr = &pdc->Dc_Attr;
+
+  TextObj = RealizeFontInit(pDc_Attr->hlfntNew);
+  if ( !TextObj )
+  {
+     DC_UnlockDc(pdc);
+     return 0;
+  }
+  Good = TextIntGetTextExtentPoint(pdc, TextObj, alphabet, 52, 0, NULL, 0, &sz);
+  TEXTOBJ_UnlockText(TextObj);
+  DC_UnlockDc(pdc);
+
+  if (!Good) return 0;
+  if (ptm) *ptm = tmwi.TextMetric;
+  if (height) *height = tmwi.TextMetric.tmHeight;
+
+  return (sz.cx / 26 + 1) / 2;
+}
+
 DWORD
 FASTCALL