PATCH: afm loader

Marcus Meissner marcus at jet.franken.de
Sat Feb 3 12:11:50 CST 2001


Hi,

Tnis adds .afm loading from different wellknown places, so we do not 
need to specify all afm files in the config directory.
I left the teTeX load if'ed out since it takes like 5 seconds on my P2-600 :/

Also included is 1 NULL pointercheck as bugfix.

Ciao, Marcus

Changelog:
	Fixed one parser problem (added NULL check).
	Load all .afm files from several known locations (ghostscript,a2ps,
	enscript,X11).


Index: afm.c
===================================================================
RCS file: /home/wine/wine/dlls/wineps/afm.c,v
retrieving revision 1.4
diff -u -r1.4 afm.c
--- afm.c	2001/01/02 20:30:16	1.4
+++ afm.c	2001/02/03 18:09:19
@@ -8,6 +8,8 @@
 
 #include <string.h>
 #include <stdio.h>
+#include <sys/stat.h>
+#include <dirent.h>
 #include "winnt.h" /* HEAP_ZERO_MEMORY */
 #include "psdrv.h"
 #include "options.h"
@@ -57,6 +59,7 @@
 	    while(isspace(*item))
 	        item++;
 	    value = strpbrk(item, " \t");
+	    if (!value) { ERR("No whitespace found.\n");return;}
 	    while(isspace(*value))
 	        value++;
 	    cp = endpos = strchr(value, ';');
@@ -418,15 +421,86 @@
  * Only exported function in this file. Parses all afm files listed in
  * [afmfiles] of wine.conf .
  */
+
+static void PSDRV_ReadAFMDir(const char* afmdir) {
+    DIR *dir;
+    AFM	*afm;
+
+    dir = opendir(afmdir);
+    if (dir) {
+	struct dirent *dent;
+	while ((dent=readdir(dir))) {
+	    if (strstr(dent->d_name,".afm")) {
+		char afmfn[256];
+		strcpy(afmfn,afmdir);
+		strcat(afmfn,dent->d_name);
+		TRACE("loading AFM %s\n",afmfn);
+		afm = PSDRV_AFMParse(afmfn);
+		if (afm) {
+		    if(afm->EncodingScheme && 
+		       !strcmp(afm->EncodingScheme,"AdobeStandardEncoding")) {
+			PSDRV_ReencodeCharWidths(afm);
+		    }
+		    PSDRV_AddAFMtoList(&PSDRV_AFMFontList, afm);
+		}
+	    }
+	}
+	closedir(dir);
+    }
+}
+
 BOOL PSDRV_GetFontMetrics(void)
 {
     int idx = 0;
     char key[256];
     char value[256];
+    char path[256];
+    DIR *dir;
+
+    /* some packages with afm files in that directory */
+    PSDRV_ReadAFMDir("/usr/share/ghostscript/fonts/");
+    PSDRV_ReadAFMDir("/usr/share/a2ps/afm/");
+    PSDRV_ReadAFMDir("/usr/share/enscript/");
+    PSDRV_ReadAFMDir("/usr/X11R6/lib/X11/fonts/Type1/");
+
+#if 0
+    /* this takes rather long to load :/ */
+    /* teTeX has a 3level directory storage of afm files */
+    strcpy(path,"/opt/teTeX/share/texmf/fonts/afm/");
+    dir = opendir(path);
+    if (dir) {
+	struct dirent *dent;
+
+	while ((dent=readdir(dir))) {
+	    DIR *dir2;
+	    char path2[256],path3[256];
+
+	    if (dent->d_name[0]=='.')
+		continue;
+	    strcpy(path2,path);
+	    strcat(path2,dent->d_name);
+	    strcat(path2,"/");
+	    dir2 = opendir(path2);
+	    if (dir2) {
+		while ((dent=readdir(dir2))) {
+		    if (dent->d_name[0]=='.')
+			continue;
+		    strcpy(path3,path2);
+		    strcat(path3,dent->d_name);
+		    strcat(path3,"/");
+		    PSDRV_ReadAFMDir(path3);
+		}
+		closedir(dir2);
+	    } else
+		PSDRV_ReadAFMDir(path2);
+	}
+	closedir(dir);
+    }
+#endif
 
     while (PROFILE_EnumWineIniString( "afmfiles", idx++, key, sizeof(key), value, sizeof(value)))
     {
-        AFM *afm = PSDRV_AFMParse(value);
+        AFM* afm = PSDRV_AFMParse(value);
         if (afm)
         {
             if(afm->EncodingScheme && 



More information about the wine-patches mailing list