1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
#include "config.h"
#include <string.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
int stat();
char *path_segment();
bool
findfile(path,n,fontmag,name)
char path[STRSIZE]; /* PIXEL path */
char n[STRSIZE]; /* name of font */
long fontmag; /* magnification */
char name[STRSIZE]; /* full name of PXL file (returned) */
{
char local_path[STRSIZE];
char *pathpt;
struct stat s;
int rc = -1;
int resolution, i;
resolution = (int)(fontmag/5.0 +0.5) ;
for(i=0; (pathpt=path_segment((bool)(i==0),path,local_path))!=NULL;i++)
{
#ifdef USEPXL
sprintf(name,"%s/%d/%s.pk",pathpt,resolution,n);
if ((rc = stat(name,&s))!=0)
{
sprintf(name,"%s/%d/%s.pxl",pathpt,resolution,n);
if ((rc = stat(name,&s))!=0)
{
sprintf(name,"%s.pk",n);
if ((rc = stat(name,&s))!=0)
{
sprintf(name,"%s.pxl",n);
if ((rc = stat(name,&s))!=0)
{
sprintf(name,"%s/%ld/%s.pk",pathpt,fontmag,n);
if ((rc = stat(name,&s))!=0)
{
sprintf(name,"%s/%ld/%s.pxl",pathpt,fontmag,n);
if ((rc = stat(name,&s))!=0)
{
#ifndef MSDOS
sprintf(name,"%s/%d/%s.pk",pathpt,resolution,n);
if ((rc = stat(name,&s))!=0)
{
sprintf(name,"%s/%d/%s.pxl",pathpt,resolution,n);
if ((rc = stat(name,&s))!=0)
{
#endif
sprintf(name,"%s/%d/%s.",pathpt,resolution,n);
rc = stat(name,&s);
#ifndef MSDOS
}
}
#endif
}
}
}
}
}
}
#else
sprintf(name,"%s/%d/%s.gf",pathpt,resolution,n);
if ((rc = stat(name,&s))!=0)
{
sprintf(name,"%s/%ld/%s.gf",pathpt,fontmag,n);
rc = stat(name,&s);
}
#endif
if (rc==0) return(TRUE);
};
#ifdef FUTURE
for(i=0; (pathpt=path_segment((bool)(i==0),VFPATH,local_path))!=NULL;i++) {
sprintf(name,"%s/%s.vfm",pathpt,n);
printf("searching virtual font <%s>\n",name);
if (stat(name,&s) == 0) return(TRUE);
}
#endif
#ifdef USEPXL
/* return error messaage */
sprintf(name,"font not found: <%s>/<%d;%ld>/%s.gf",
path,resolution,fontmag,n);
#else
sprintf(name,"font not found: <%s>/<%d;%ld>/%s.<pk;pxl>",
path,resolution,fontmag,n);
#endif
return(FALSE);
}
char *
path_segment(first,full_path,local_path)
bool first;
char *full_path, *local_path;
{
static char *pppt;
char *pathpt;
if (first) pathpt = strcpy(local_path,full_path);
else pathpt = pppt;
if (pathpt != NULL) {
#ifdef unix
pppt = strchr(pathpt , ':' );
#else
pppt = strchr(pathpt , ';' );
#endif
#ifdef MSDOS
pppt = strchr(pathpt , ';' );
#endif
if (pppt != NULL) {
*pppt = '\0';
pppt++;
}
}
return pathpt;
}
|