- Deactivate unneeded debug prints, change DbgPrint to DPRINTx, remove unused perform...
[reactos.git] / reactos / dll / win32 / gdi32 / objects / font.c
index c826254..7450294 100644 (file)
@@ -108,7 +108,7 @@ static LPWSTR FONT_mbtowc(HDC hdc, LPCSTR str, INT count, INT *plenW, UINT *pCP)
     lenW = MultiByteToWideChar(cp, 0, str, count, NULL, 0);
     strW = HeapAlloc(GetProcessHeap(), 0, lenW*sizeof(WCHAR));
     MultiByteToWideChar(cp, 0, str, count, strW, lenW);
-    DPRINT1("mapped %s -> %S\n", str, strW);
+    DPRINT("mapped %s -> %S\n", str, strW);
     if(plenW) *plenW = lenW;
     if(pCP) *pCP = cp;
     return strW;
@@ -325,8 +325,8 @@ IntEnumFontFamilies(HDC Dc, LPLOGFONTW LogFont, PVOID EnumProc, LPARAM lParam,
       if (Unicode)
         {
           Ret = ((FONTENUMPROCW) EnumProc)(
-            &Info[i].EnumLogFontEx,
-            &Info[i].NewTextMetricEx,
+            (VOID*)&Info[i].EnumLogFontEx,
+            (VOID*)&Info[i].NewTextMetricEx,
             Info[i].FontType, lParam);
         }
       else
@@ -341,8 +341,8 @@ IntEnumFontFamilies(HDC Dc, LPLOGFONTW LogFont, PVOID EnumProc, LPARAM lParam,
           NewTextMetricExW2A(&NewTextMetricExA,
                              &Info[i].NewTextMetricEx);
           Ret = ((FONTENUMPROCA) EnumProc)(
-            &EnumLogFontExA,
-            &NewTextMetricExA,
+            (VOID*)&EnumLogFontExA,
+            (VOID*)&NewTextMetricExA,
             Info[i].FontType, lParam);
         }
     }
@@ -355,7 +355,7 @@ IntEnumFontFamilies(HDC Dc, LPLOGFONTW LogFont, PVOID EnumProc, LPARAM lParam,
 /*
  * @implemented
  */
-int STDCALL
+int WINAPI
 EnumFontFamiliesExW(HDC hdc, LPLOGFONTW lpLogfont, FONTENUMPROCW lpEnumFontFamExProc,
                     LPARAM lParam, DWORD dwFlags)
 {
@@ -366,7 +366,7 @@ EnumFontFamiliesExW(HDC hdc, LPLOGFONTW lpLogfont, FONTENUMPROCW lpEnumFontFamEx
 /*
  * @implemented
  */
-int STDCALL
+int WINAPI
 EnumFontFamiliesW(HDC hdc, LPCWSTR lpszFamily, FONTENUMPROCW lpEnumFontFamProc,
                   LPARAM lParam)
 {
@@ -376,6 +376,7 @@ EnumFontFamiliesW(HDC hdc, LPCWSTR lpszFamily, FONTENUMPROCW lpEnumFontFamProc,
   LogFont.lfCharSet = DEFAULT_CHARSET;
   if (NULL != lpszFamily)
     {
+      if (!*lpszFamily) return 1;
       lstrcpynW(LogFont.lfFaceName, lpszFamily, LF_FACESIZE);
     }
 
@@ -386,7 +387,7 @@ EnumFontFamiliesW(HDC hdc, LPCWSTR lpszFamily, FONTENUMPROCW lpEnumFontFamProc,
 /*
  * @implemented
  */
-int STDCALL
+int WINAPI
 EnumFontFamiliesExA (HDC hdc, LPLOGFONTA lpLogfont, FONTENUMPROCA lpEnumFontFamExProc,
                      LPARAM lParam, DWORD dwFlags)
 {
@@ -407,7 +408,7 @@ EnumFontFamiliesExA (HDC hdc, LPLOGFONTA lpLogfont, FONTENUMPROCA lpEnumFontFamE
 /*
  * @implemented
  */
-int STDCALL
+int WINAPI
 EnumFontFamiliesA(HDC hdc, LPCSTR lpszFamily, FONTENUMPROCA lpEnumFontFamProc,
                   LPARAM lParam)
 {
@@ -417,6 +418,7 @@ EnumFontFamiliesA(HDC hdc, LPCSTR lpszFamily, FONTENUMPROCA lpEnumFontFamProc,
   LogFont.lfCharSet = DEFAULT_CHARSET;
   if (NULL != lpszFamily)
     {
+      if (!*lpszFamily) return 1;
       MultiByteToWideChar(CP_THREAD_ACP, 0, lpszFamily, -1, LogFont.lfFaceName, LF_FACESIZE);
     }
 
@@ -427,7 +429,7 @@ EnumFontFamiliesA(HDC hdc, LPCSTR lpszFamily, FONTENUMPROCA lpEnumFontFamProc,
  * @implemented
  */
 DWORD
-STDCALL
+WINAPI
 GetCharacterPlacementW(
        HDC hdc,
        LPCWSTR lpString,
@@ -510,7 +512,7 @@ GetCharacterPlacementW(
  *
  */
 BOOL
-STDCALL
+WINAPI
 GetCharABCWidthsFloatW(HDC hdc,
                        UINT FirstChar,
                        UINT LastChar,
@@ -535,7 +537,7 @@ GetCharABCWidthsFloatW(HDC hdc,
  *
  */
 BOOL
-STDCALL
+WINAPI
 GetCharWidthFloatW(HDC hdc,
                    UINT iFirstChar,
                    UINT iLastChar,
@@ -560,7 +562,7 @@ GetCharWidthFloatW(HDC hdc,
  *
  */
 BOOL
-STDCALL
+WINAPI
 GetCharWidthW(HDC hdc,
               UINT iFirstChar,
               UINT iLastChar,
@@ -585,7 +587,7 @@ GetCharWidthW(HDC hdc,
  *
  */
 BOOL
-STDCALL
+WINAPI
 GetCharWidth32W(HDC hdc,
                UINT iFirstChar,
                UINT iLastChar,
@@ -611,7 +613,7 @@ GetCharWidth32W(HDC hdc,
  *
  */
 BOOL
-STDCALL
+WINAPI
 GetCharABCWidthsW(HDC hdc,
                   UINT FirstChar,
                   UINT LastChar,
@@ -635,7 +637,7 @@ GetCharABCWidthsW(HDC hdc,
  * @implemented
  */
 BOOL
-STDCALL
+WINAPI
 GetCharWidthA(
        HDC     hdc,
        UINT    iFirstChar,
@@ -683,7 +685,7 @@ GetCharWidthA(
  * @implemented
  */
 BOOL
-STDCALL
+WINAPI
 GetCharWidth32A(
        HDC     hdc,
        UINT    iFirstChar,
@@ -860,7 +862,7 @@ GetCharABCWidthsFloatA(
  * @implemented
  */
 BOOL
-STDCALL
+WINAPI
 GetCharABCWidthsI(HDC hdc,
                   UINT giFirst,
                   UINT cgi,
@@ -880,7 +882,7 @@ GetCharABCWidthsI(HDC hdc,
  * @implemented
  */
 BOOL
-STDCALL
+WINAPI
 GetCharWidthI(HDC hdc,
               UINT giFirst,
               UINT cgi,
@@ -907,19 +909,31 @@ GetCharWidthI(HDC hdc,
  * @implemented
  */
 DWORD
-STDCALL
+WINAPI
 GetFontLanguageInfo(
        HDC     hDc
        )
 {
-  return GetDCDWord(hDc, GdiGetFontLanguageInfo, GCP_ERROR); 
+  DWORD Gcp = 0, Ret = 0;
+  if (gbLpk)
+  {
+     Ret = NtGdiGetTextCharsetInfo(hDc, NULL, 0);
+     if ((Ret == ARABIC_CHARSET) || (Ret == HEBREW_CHARSET))
+        Ret = (GCP_KASHIDA|GCP_DIACRITIC|GCP_LIGATE|GCP_GLYPHSHAPE|GCP_REORDER);
+  }
+  Gcp = GetDCDWord(hDc, GdiGetFontLanguageInfo, GCP_ERROR); 
+  if ( Gcp == GCP_ERROR)
+     return Gcp;
+  else
+     Ret = Gcp | Ret;
+  return Ret;
 }
 
 /*
  * @implemented
  */
 DWORD
-STDCALL
+WINAPI
 GetGlyphIndicesA(
         HDC hdc,
         LPCSTR lpstr,
@@ -942,7 +956,7 @@ GetGlyphIndicesA(
  * @implemented
  */
 DWORD
-STDCALL
+WINAPI
 GetGlyphOutlineA(
        HDC             hdc,
        UINT            uChar,
@@ -957,7 +971,7 @@ GetGlyphOutlineA(
     LPWSTR p = NULL;
     DWORD ret;
     UINT c;
-    DPRINT1("GetGlyphOutlineA  uChar %x\n", uChar);
+    DPRINT("GetGlyphOutlineA uChar %x\n", uChar);
     if(!(uFormat & GGO_GLYPH_INDEX)) {
         int len;
         char mbchs[2];
@@ -970,7 +984,7 @@ GetGlyphOutlineA(
             mbchs[0] = (uChar & 0xff);
         }
         p = FONT_mbtowc(hdc, mbchs, len, NULL, NULL);
-       c = p[0];
+        c = p[0];
     } else
         c = uChar;
     ret = NtGdiGetGlyphOutline(hdc, c, uFormat, lpgm, cbBuffer, lpvBuffer, (CONST LPMAT2)lpmat2, TRUE);
@@ -983,7 +997,7 @@ GetGlyphOutlineA(
  * @implemented
  */
 DWORD
-STDCALL
+WINAPI
 GetGlyphOutlineW(
        HDC             hdc,
        UINT            uChar,
@@ -994,7 +1008,7 @@ GetGlyphOutlineW(
        CONST MAT2      *lpmat2
        )
 {
-  DPRINT("GetGlyphOutlineW  uChar %x\n", uChar);
+  DPRINT("GetGlyphOutlineW uChar %x\n", uChar);
   if (!lpgm & !lpmat2) return GDI_ERROR;
   if (!lpvBuffer) cbBuffer = 0;
   return NtGdiGetGlyphOutline ( hdc, uChar, uFormat, lpgm, cbBuffer, lpvBuffer, (CONST LPMAT2)lpmat2, TRUE);
@@ -1175,7 +1189,7 @@ GetOutlineTextMetricsW(
  * @implemented
  */
 DWORD
-STDCALL
+WINAPI
 GetKerningPairsW(HDC hdc,
                  ULONG cPairs,
                  LPKERNINGPAIR pkpDst)
@@ -1195,7 +1209,7 @@ GetKerningPairsW(HDC hdc,
  * @implemented
  */
 DWORD
-STDCALL
+WINAPI
 GetKerningPairsA( HDC hDC,
              DWORD cPairs,
  LPKERNINGPAIR kern_pairA )
@@ -1273,7 +1287,7 @@ GetKerningPairsA( HDC hDC,
  * @implemented
  */
 HFONT
-STDCALL
+WINAPI
 CreateFontIndirectExA(const ENUMLOGFONTEXDVA *elfexd)
 {
   if (elfexd)
@@ -1297,7 +1311,7 @@ CreateFontIndirectExA(const ENUMLOGFONTEXDVA *elfexd)
  * @implemented
  */
 HFONT
-STDCALL
+WINAPI
 CreateFontIndirectExW(const ENUMLOGFONTEXDVW *elfexd)
 {
   /* Msdn: Note, this function ignores the elfDesignVector member in
@@ -1315,7 +1329,7 @@ CreateFontIndirectExW(const ENUMLOGFONTEXDVW *elfexd)
  * @implemented
  */
 HFONT
-STDCALL
+WINAPI
 CreateFontIndirectA(
        CONST LOGFONTA          *lplf
        )
@@ -1335,7 +1349,7 @@ CreateFontIndirectA(
  * @implemented
  */
 HFONT
-STDCALL
+WINAPI
 CreateFontIndirectW(
        CONST LOGFONTW          *lplf
        )
@@ -1368,7 +1382,7 @@ CreateFontIndirectW(
  * @implemented
  */
 HFONT
-STDCALL
+WINAPI
 CreateFontA(
        int     nHeight,
        int     nWidth,
@@ -1418,7 +1432,7 @@ CreateFontA(
  * @implemented
  */
 HFONT
-STDCALL
+WINAPI
 CreateFontW(
        int     nHeight,
        int     nWidth,
@@ -1472,7 +1486,7 @@ CreateFontW(
  * @unimplemented
  */
 BOOL
-STDCALL
+WINAPI
 CreateScalableFontResourceA(
        DWORD           fdwHidden,
        LPCSTR          lpszFontRes,
@@ -1488,7 +1502,7 @@ CreateScalableFontResourceA(
  * @implemented
  */
 int
-STDCALL
+WINAPI
 AddFontResourceExW ( LPCWSTR lpszFilename, DWORD fl, PVOID pvReserved )
 {
     if (fl & ~(FR_PRIVATE | FR_NOT_ENUM))
@@ -1505,7 +1519,7 @@ AddFontResourceExW ( LPCWSTR lpszFilename, DWORD fl, PVOID pvReserved )
  * @implemented
  */
 int
-STDCALL
+WINAPI
 AddFontResourceExA ( LPCSTR lpszFilename, DWORD fl, PVOID pvReserved )
 {
     NTSTATUS Status;
@@ -1535,7 +1549,7 @@ AddFontResourceExA ( LPCSTR lpszFilename, DWORD fl, PVOID pvReserved )
  * @implemented
  */
 int
-STDCALL
+WINAPI
 AddFontResourceA ( LPCSTR lpszFilename )
 {
     NTSTATUS Status;
@@ -1561,7 +1575,7 @@ AddFontResourceA ( LPCSTR lpszFilename )
  * @implemented
  */
 int
-STDCALL
+WINAPI
 AddFontResourceW ( LPCWSTR lpszFilename )
 {
     return GdiAddFontResourceW ( lpszFilename, 0, 0 );
@@ -1572,7 +1586,7 @@ AddFontResourceW ( LPCWSTR lpszFilename )
  * @implemented
  */
 BOOL
-STDCALL
+WINAPI
 RemoveFontResourceW(LPCWSTR lpFileName)
 {
     return RemoveFontResourceExW(lpFileName,0,0);
@@ -1583,7 +1597,7 @@ RemoveFontResourceW(LPCWSTR lpFileName)
  * @implemented
  */
 BOOL
-STDCALL
+WINAPI
 RemoveFontResourceA(LPCSTR lpFileName)
 {
     return RemoveFontResourceExA(lpFileName,0,0);
@@ -1593,7 +1607,7 @@ RemoveFontResourceA(LPCSTR lpFileName)
  * @unimplemented
  */
 BOOL
-STDCALL
+WINAPI
 RemoveFontResourceExA(LPCSTR lpFileName,
                       DWORD fl,
                       PVOID pdv
@@ -1622,7 +1636,7 @@ RemoveFontResourceExA(LPCSTR lpFileName,
  * @unimplemented
  */
 BOOL
-STDCALL
+WINAPI
 RemoveFontResourceExW(LPCWSTR lpFileName,
                       DWORD fl,
                       PVOID pdv)
@@ -1668,7 +1682,7 @@ RemoveFontResourceExW(LPCWSTR lpFileName,
  * @implemented
  */
 DWORD
-STDCALL
+WINAPI
 GdiGetCharDimensions(HDC hdc, LPTEXTMETRICW lptm, LONG *height)
 {
     SIZE sz;
@@ -1707,7 +1721,7 @@ GdiGetCharDimensions(HDC hdc, LPTEXTMETRICW lptm, LONG *height)
  * @unimplemented
  */
 BOOL
-STDCALL
+WINAPI
 TranslateCharsetInfo(
   LPDWORD lpSrc, /* [in]
        if flags == TCI_SRCFONTSIG: pointer to fsCsb of a FONTSIGNATURE
@@ -1741,7 +1755,7 @@ TranslateCharsetInfo(
  * @implemented
  */
 DWORD
-STDCALL
+WINAPI
 SetMapperFlags(
        HDC     hDC,
        DWORD   flags
@@ -1795,7 +1809,7 @@ SetMapperFlags(
  * @unimplemented
  */
 int
-STDCALL
+WINAPI
 EnumFontsW(
        HDC  hDC,
        LPCWSTR lpFaceName,
@@ -1814,7 +1828,7 @@ EnumFontsW(
  * @unimplemented
  */
 int
-STDCALL
+WINAPI
 EnumFontsA (
        HDC  hDC,
        LPCSTR lpFaceName,
@@ -1845,7 +1859,7 @@ EnumFontsA (
 #define EfdFontFamilies 3
 
 INT
-STDCALL
+WINAPI
 NewEnumFontFamiliesExW(
     HDC hDC,
     LPLOGFONTW lpLogfont,
@@ -1903,8 +1917,8 @@ NewEnumFontFamiliesExW(
     {
         PNTMW_INTERNAL pNtmwi = (PNTMW_INTERNAL)((ULONG_PTR)pEfdw + pEfdw->ulNtmwiOffset);
 
-        ret = lpEnumFontFamExProcW(&pEfdw->elfexdv.elfEnumLogfontEx,
-                                   &pNtmwi->ntmw,
+        ret = lpEnumFontFamExProcW((VOID*)&pEfdw->elfexdv.elfEnumLogfontEx,
+                                   (VOID*)&pNtmwi->ntmw,
                                    pEfdw->dwFontType,
                                    lParam);