1 //========================================================================
5 // Copyright 1996 Derek B. Noonburg
7 //========================================================================
19 char **fontPath = NULL;
20 static int fontPathLen, fontPathSize;
22 DevFontMapEntry *devFontMap = NULL;
23 static int devFontMapLen, devFontMapSize;
25 void initParams(char *configFile) {
31 // initialize font path and font map
32 fontPath = (char **)gmalloc((fontPathSize = 8) * sizeof(char *));
33 fontPath[fontPathLen = 0] = NULL;
34 devFontMap = (DevFontMapEntry *)gmalloc((devFontMapSize = 8) *
35 sizeof(DevFontMapEntry));
36 devFontMap[devFontMapLen = 0].pdfFont = NULL;
39 fileName = appendToPath(getHomeDir(), configFile);
40 if ((f = fopen(fileName->getCString(), "r"))) {
41 while (fgets(buf, sizeof(buf)-1, f)) {
42 buf[sizeof(buf)-1] = '\0';
43 p = strtok(buf, " \t\n\r");
44 if (p && !strcmp(p, "fontpath")) {
45 if (fontPathLen+1 >= fontPathSize)
47 grealloc(fontPath, (fontPathSize += 8) * sizeof(char *));
48 p = strtok(NULL, " \t\n\r");
49 fontPath[fontPathLen++] = copyString(p);
50 } else if (p && !strcmp(p, "fontmap")) {
51 if (devFontMapLen+1 >= devFontMapSize)
52 devFontMap = (DevFontMapEntry *)
54 (devFontMapSize += 8) * sizeof(DevFontMapEntry));
55 p = strtok(NULL, " \t\n\r");
56 devFontMap[devFontMapLen].pdfFont = copyString(p);
57 p = strtok(NULL, "\t\n\r");
60 for (q = p + strlen(p) - 1; q >= p && *q == ' '; --q) ;
62 devFontMap[devFontMapLen++].devFont = copyString(p);
66 fontPath[fontPathLen] = NULL;
67 devFontMap[devFontMapLen].pdfFont = NULL;
76 for (i = 0; i < fontPathLen; ++i)
81 for (i = 0; i < devFontMapLen; ++i) {
82 gfree(devFontMap[i].pdfFont);
83 gfree(devFontMap[i].devFont);