Duane Clark wrote:
It looks like, when printing via CUPS, if the PPD file for an installed printer does not contain entries (usually at the end of the file) like:

*DefaultFont: Courier
*Font AvantGarde-Book: Standard "(001.006S)" Standard ROM
*Font AvantGarde-BookOblique: Standard "(001.006S)" Standard ROM
... (lots more)

...
It seems to me that Wine probably should work in this case. Would it be acceptable to supply the defaults used in Wine's generic PPD file if they are not in the one being used? I could take a shot at trying to code that if it would be acceptable. Otherwise, I could change the error message to perhaps better explain what the problem is.

Attached is a proposed patch that uses *Font entries from Wine's generic.ppd file if the printer PPD file does not have them. Would something along these lines be acceptable?

Index: dlls/wineps.drv/init.c
===================================================================
RCS file: /home/wine/wine/dlls/wineps.drv/init.c,v
retrieving revision 1.3
diff -u -p -b -r1.3 init.c
--- dlls/wineps.drv/init.c	15 Jun 2006 16:08:37 -0000	1.3
+++ dlls/wineps.drv/init.c	15 Jul 2006 17:57:26 -0000
@@ -529,6 +529,7 @@ PRINTERINFO *PSDRV_FindPrinterInfo(LPCST
     const char *ppd = NULL;
     DWORD ppdType;
     char* ppdFileName = NULL;
+    char* generic_ppdFileName = NULL;
     HKEY hkey;
     BOOL using_default_devmode = FALSE;
 
@@ -604,17 +605,18 @@ PRINTERINFO *PSDRV_FindPrinterInfo(LPCST
             res = GetPrinterDataA(hPrinter, "PPD File", &ppdType, (LPBYTE)ppdFileName, needed, &needed);
         }
     }
-    /* Look for a ppd file for this printer in the config file.
+    /* Look for a ppd file for this printer in the registry.
      * First look under that printer's name, and then under 'generic'
      */
     /* @@ Wine registry key: HKCU\Software\Wine\Printing\PPD Files */
     if((res != ERROR_SUCCESS) && !RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\Printing\\PPD Files", &hkey))
     {
         const char* value_name;
+        LONG retval = ERROR_SUCCESS+1;
 
         if (RegQueryValueExA(hkey, name, 0, NULL, NULL, &needed) == ERROR_SUCCESS) {
             value_name=name;
-        } else if (RegQueryValueExA(hkey, "generic", 0, NULL, NULL, &needed) == ERROR_SUCCESS) {
+        } else if ((retval=RegQueryValueExA(hkey, "generic", 0, NULL, NULL, &needed)) == ERROR_SUCCESS) {
             value_name="generic";
         } else {
             value_name=NULL;
@@ -622,10 +624,36 @@ PRINTERINFO *PSDRV_FindPrinterInfo(LPCST
         if (value_name) {
             ppdFileName=HeapAlloc(PSDRV_Heap, 0, needed);
             RegQueryValueExA(hkey, value_name, 0, &ppdType, (LPBYTE)ppdFileName, &needed);
+#ifdef HAVE_CUPS_CUPS_H
+            generic_ppdFileName=HeapAlloc(PSDRV_Heap, 0, needed);
+            if (retval == ERROR_SUCCESS)
+                RegQueryValueExA(hkey, value_name, 0, &ppdType, (LPBYTE)generic_ppdFileName, &needed);
+            else if (RegQueryValueExA(hkey, "generic", 0, NULL, NULL, &needed) == ERROR_SUCCESS)
+                RegQueryValueExA(hkey, value_name, 0, &ppdType, (LPBYTE)generic_ppdFileName, &needed);
+#endif
         }
         RegCloseKey(hkey);
     }
 
+#ifdef HAVE_CUPS_CUPS_H
+    if (!generic_ppdFileName)
+    {
+        const char *data_dir, *filename;
+
+        if ((data_dir = wine_get_data_dir())) filename = "/generic.ppd";
+        else if ((data_dir = wine_get_build_dir())) filename = "/dlls/wineps.drv/generic.ppd";
+        else
+        {
+            res = ERROR_FILE_NOT_FOUND;
+            ERR ("Error %li getting PPD file name for printer '%s'\n", res, name);
+            goto closeprinter;
+        }
+        generic_ppdFileName = HeapAlloc( PSDRV_Heap, 0, strlen(data_dir) + strlen(filename) + 1 );
+        strcpy( generic_ppdFileName, data_dir );
+        strcat( generic_ppdFileName, filename );
+    }
+#endif
+
     if (!ppdFileName)
     {
         const char *data_dir, *filename;
@@ -753,6 +781,20 @@ PRINTERINFO *PSDRV_FindPrinterInfo(LPCST
     pi->next = NULL;
     pi->Fonts = NULL;
 
+#ifdef HAVE_CUPS_CUPS_H
+    /* 
+     * Some manufacturer supplied PPD files do not have the *Font and *DefaultFont sections.
+     * In this case, use the entries from the Wine supplied generic.ppd file.
+     */
+    if (!(pi->ppd->InstalledFonts) && generic_ppdFileName) {
+        PPD *generic_PPD;
+        TRACE("No fonts in supplied PPD. Using fonts from generic PPD.\n");
+        generic_PPD = PSDRV_ParsePPD(generic_ppdFileName);
+        pi->ppd->InstalledFonts = generic_PPD->InstalledFonts;
+        if (!(pi->ppd->DefaultFont))
+            pi->ppd->DefaultFont = generic_PPD->DefaultFont;
+    }
+#endif
     for(font = pi->ppd->InstalledFonts; font; font = font->next) {
         afm = PSDRV_FindAFMinList(PSDRV_AFMFontList, font->Name);
 	if(!afm) {


Reply via email to