File: vfontmap.c

package info (click to toggle)
xdvik-ja 22.15-j1.04-4
  • links: PTS
  • area: main
  • in suites: woody
  • size: 7,588 kB
  • ctags: 9,283
  • sloc: ansic: 79,680; sh: 9,526; makefile: 665; sed: 271; awk: 35
file content (178 lines) | stat: -rw-r--r-- 4,262 bytes parent folder | download
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/*
     Copyright (C) 1996 - 1997  Masahito Yamaga (yamaga@ipc.chiba-u.ac.jp)
*/

#include "xdvi-config.h"
#include <sys/param.h>	/* for MAXPATHLEN */

struct vfontmap *first_ptr = NULL;

#ifdef PTEX
void addfontmap(s1,s2,tate)
	char *s1,*s2;
	int tate;
#else
void addfontmap(s1,s2)
	char *s1,*s2;
#endif
{
	struct vfontmap *new_ptr;

	new_ptr = (struct vfontmap *)
			malloc(sizeof(struct vfontmap));

	new_ptr->jfmname = (char *)xmalloc(strlen(s1)+1);
	new_ptr->vfname  = (char *)xmalloc(strlen(s2)+1);
	(void)strcpy(new_ptr->jfmname, s1);
	(void)strcpy(new_ptr->vfname,  s2);
	new_ptr->flag = -1;
#ifdef PTEX
	new_ptr->tate = tate;
#endif

	new_ptr->next_ptr = first_ptr;
	first_ptr = new_ptr;
}

#define	MAX_VFONTS	255
#define	MAX_VFONTNAME	255

read_VFontmap()
{
	FILE *map;
	char vfontmapf[MAXPATHLEN], line[BUFSIZ];
	char jfmname[MAX_VFONTNAME+1], vfname[MAX_VFONTNAME+1];
	int i, n, tate;
	int min, nmin, tmin, goth, ngoth, tgoth, dm, dg;

	min = nmin = tmin = goth = ngoth = tgoth = dm = dg = 0;

#if defined(USE_ZEIT) && defined(USE_VFONTMAP)

#ifndef	DEFAULT_FONTMAP
#define	DEFAULT_FONTMAP	"/usr/local/share/texmf/xdvi/vfontmap"
#endif

	if (!(map = fopen("vfontmap", "r"))) {
		if (strcmp(resource.vfontmap,DEFAULT_FONTMAP))
			strcpy(vfontmapf, resource.vfontmap);
		else
		if (getenv("VFONTMAP"))
			strcpy(vfontmapf, getenv("VFONTMAP"));
		else
			strcpy(vfontmapf, DEFAULT_FONTMAP);

		if (!(map =  fopen(vfontmapf, "r"))) {
		     Fprintf(stderr,"Warning: Can't open \"%s\"\n",vfontmapf);
		     Fprintf(stderr,"         Default Values are Used.\n");
		}
	}

	if (map) {
		while(fgets(line, BUFSIZ, map)){
		  i = n = tate = 0;

		  while (line[i] == ' '&& line[i] == '\t')
		    i += 1;
		  if (line[i] == '\n' || line[i] == '#')
		    continue;

		  while (line[i] != ' ' && line[i] != '\t' && line[i] != '\n')
		    jfmname[n++] = line[i++];
		  jfmname[n] = '\0';

		  if (line[i] == '\n')
		    {
		      Fprintf(stderr,
			      "No specified Vector Font name for \"%s\"\n",
			      jfmname);
		      continue;
		    }

		  if (debug & DBG_PK)
		    Fprintf(stderr,
			    "JFM name is \"%s\"\n",
			    jfmname);
		  
		  while (line[i] == ' ' || line[i] == '\t')
		    i += 1;
		  if (line[i] == '\n' || line[i] == '#')
		    continue;

		  n = 0;
		  while (line[i] != ' ' && line[i] != '\t' && line[i] != '\n')
		    vfname[n++] = line[i++];
		  vfname[n] = '\0';

		  if (debug & DBG_PK)
		    Fprintf(stderr,
			    "Font name of VFlib is \"%s\"\n",
			    vfname);

#ifdef PTEX
		  while (line[i] == ' ' || line[i] == '\t')
		    i += 1;

		  if (line[i] != '\n' && line[i] != '#')
		    {
		      while (line[i] != ' ' && line[i] != '\t' &&
			     line[i] != '\n')
			i += 1;
		      
		      while (line[i] == ' '&& line[i] == '\t')
			i += 1;
		      
		      if (line[i] != '\n' && line[i] != '#')
			{
fprintf(stderr, "%s\n", line);
			  Fprintf(stderr,
				  "There is too much argument.\n");
			  continue;
			}
		      tate = 1;
		    }
		  if (debug & DBG_PK)
		    Fprintf(stderr,
			    "Font of VFlib is \"%s\"\n",
			    tate ? "TATE font" : "TRANS...font");

		  addfontmap(jfmname,vfname,tate);
#else
			addfontmap(jfmname,vfname);
#endif

			if (!strcmp(jfmname,"dg"   )) dg = 1;
			if (!strcmp(jfmname,"dm"   )) dm = 1;

			if (!strcmp(jfmname,"ngoth")) ngoth = 1;
			if (!strcmp(jfmname,"tgoth")) tgoth = 1;
			if (!strcmp(jfmname,"goth" )) goth  = 1;
			if (!strcmp(jfmname,"nmin" )) nmin  = 1;
			if (!strcmp(jfmname,"tmin" )) tmin  = 1;
			if (!strcmp(jfmname,"min"  )) min   = 1;
		}
	}
#endif /* USE_ZEIT && USE_VFONTMAP */

#ifdef PTEX
	if (!dg)	addfontmap("dg"   ,"goth",0);
	if (!dm)	addfontmap("dm"   ,"min" ,0);

	if (!ngoth)	addfontmap("ngoth","goth",0);
	if (!tgoth)	addfontmap("tgoth","goth",0);
	if (!goth)	addfontmap("goth" ,"goth",0);
	if (!nmin)	addfontmap("nmin" ,"min" ,0);
	if (!tmin)	addfontmap("tmin" ,"min" ,0);
	if (!min) 	addfontmap("min"  ,"min" ,0);
#else
	if (!dg)	addfontmap("dg"   ,"goth");
	if (!dm)	addfontmap("dm"   ,"min" );

	if (!ngoth)	addfontmap("ngoth","goth");
	if (!tgoth)	addfontmap("tgoth","goth");
	if (!goth)	addfontmap("goth" ,"goth");
	if (!nmin)	addfontmap("nmin" ,"min" );
	if (!tmin)	addfontmap("tmin" ,"min" );
	if (!min) 	addfontmap("min"  ,"min" );
#endif
}