better stub for EnumFonts (fixed license agreement in ClamWin installer)
[reactos.git] / reactos / lib / gdi32 / objects / font.c
index 7ac049f..3051921 100644 (file)
@@ -183,10 +183,10 @@ IntEnumFontFamilies(HDC Dc, LPLOGFONTW LogFont, PVOID EnumProc, LPARAM lParam,
                     BOOL Unicode)
 {
   int FontFamilyCount;
-  unsigned FontFamilySize;
+  int FontFamilySize;
   PFONTFAMILYINFO Info;
   int Ret = 0;
-  unsigned i;
+  int i;
   ENUMLOGFONTEXA EnumLogFontExA;
   NEWTEXTMETRICEXA NewTextMetricExA;
 
@@ -231,7 +231,7 @@ IntEnumFontFamilies(HDC Dc, LPLOGFONTW LogFont, PVOID EnumProc, LPARAM lParam,
         }
       else
         {
-          RosRtlLogFontW2A(&EnumLogFontExA.elfLogFont, &Info[i].EnumLogFontEx.elfLogFont);
+          LogFontW2A(&EnumLogFontExA.elfLogFont, &Info[i].EnumLogFontEx.elfLogFont);
           WideCharToMultiByte(CP_THREAD_ACP, 0, Info[i].EnumLogFontEx.elfFullName, -1,
                               (LPSTR)EnumLogFontExA.elfFullName, LF_FULLFACESIZE, NULL, NULL);
           WideCharToMultiByte(CP_THREAD_ACP, 0, Info[i].EnumLogFontEx.elfStyle, -1,
@@ -292,7 +292,7 @@ EnumFontFamiliesExA (HDC hdc, LPLOGFONTA lpLogfont, FONTENUMPROCA lpEnumFontFamE
 {
   LOGFONTW LogFontW;
 
-  RosRtlLogFontA2W(&LogFontW, lpLogfont);
+  LogFontA2W(&LogFontW, lpLogfont);
 
   /* no need to convert LogFontW back to lpLogFont b/c it's an [in] parameter only */
   return IntEnumFontFamilies(hdc, &LogFontW, lpEnumFontFamExProc, lParam, FALSE);
@@ -404,10 +404,10 @@ GetCharacterPlacementW(
     /* Treat the case where no special handling was requested in a fastpath way */
     /* copy will do if the GCP_REORDER flag is not set */
     if(lpResults->lpOutString)
-      strncpyW( lpResults->lpOutString, lpString, nSet );
+      lstrcpynW( lpResults->lpOutString, lpString, nSet );
 
     if(lpResults->lpGlyphs)
-      strncpyW( lpResults->lpGlyphs, lpString, nSet );
+      lstrcpynW( lpResults->lpGlyphs, lpString, nSet );
 
     if(lpResults->lpOrder)
     {
@@ -532,7 +532,7 @@ CreateFontIndirectA(
 {
   LOGFONTW tlf;
 
-  RosRtlLogFontA2W(&tlf, lplf);
+  LogFontA2W(&tlf, lplf);
 
   return NtGdiCreateFontIndirect(&tlf);
 }
@@ -782,3 +782,110 @@ RemoveFontResourceA(
 
   return rc;
 }
+
+/***********************************************************************
+ *           GdiGetCharDimensions
+ *
+ * Gets the average width of the characters in the English alphabet.
+ *
+ * PARAMS
+ *  hdc    [I] Handle to the device context to measure on.
+ *  lptm   [O] Pointer to memory to store the text metrics into.
+ *  height [O] On exit, the maximum height of characters in the English alphabet.
+ *
+ * RETURNS
+ *  The average width of characters in the English alphabet.
+ *
+ * NOTES
+ *  This function is used by the dialog manager to get the size of a dialog
+ *  unit. It should also be used by other pieces of code that need to know
+ *  the size of a dialog unit in logical units without having access to the
+ *  window handle of the dialog.
+ *  Windows caches the font metrics from this function, but we don't and
+ *  there doesn't appear to be an immediate advantage to do so.
+ *
+ * SEE ALSO
+ *  GetTextExtentPointW, GetTextMetricsW, MapDialogRect.
+ *
+ * Despite most of MSDN insisting that the horizontal base unit is
+ * tmAveCharWidth it isn't.  Knowledge base article Q145994
+ * "HOWTO: Calculate Dialog Units When Not Using the System Font",
+ * says that we should take the average of the 52 English upper and lower
+ * case characters.
+ */
+/*
+ * @implemented
+ */
+DWORD
+STDCALL
+GdiGetCharDimensions(HDC hdc, LPTEXTMETRICW lptm, DWORD *height)
+{
+    SIZE sz;
+    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(lptm && !GetTextMetricsW(hdc, lptm)) return 0;
+
+    if(!GetTextExtentPointW(hdc, alphabet, 52, &sz)) return 0;
+
+    if (height) *height = sz.cy;
+    return (sz.cx / 26 + 1) / 2;
+}
+
+
+/*
+ * @unimplemented
+ */
+int
+STDCALL
+EnumFontsW(
+       HDC  hDC,
+       LPCWSTR lpFaceName,
+       FONTENUMPROCW  FontFunc,
+       LPARAM  lParam
+       )
+{
+#if 0
+  return NtGdiEnumFonts ( hDC, lpFaceName, FontFunc, lParam );
+#else
+  return EnumFontFamiliesW( hDC, lpFaceName, FontFunc, lParam );
+#endif
+}
+
+/*
+ * @unimplemented
+ */
+int
+STDCALL
+EnumFontsA (
+       HDC  hDC,
+       LPCSTR lpFaceName,
+       FONTENUMPROCA  FontFunc,
+       LPARAM  lParam
+       )
+{
+#if 0
+  NTSTATUS Status;
+  LPWSTR lpFaceNameW;
+  int rc = 0;
+
+  Status = HEAP_strdupA2W ( &lpFaceNameW, lpFaceName );
+  if (!NT_SUCCESS (Status))
+    SetLastError (RtlNtStatusToDosError(Status));
+  else
+    {
+      rc = NtGdiEnumFonts ( hDC, lpFaceNameW, FontFunc, lParam );
+
+      HEAP_free ( lpFaceNameW );
+    }
+  return rc;
+#else
+  return EnumFontFamiliesA( hDC, lpFaceName, FontFunc, lParam );
+#endif
+}
+
+
+
+