30 #include <kpathsea/expand.h>
31 #include <kpathsea/pathsearch.h>
60 #define MAP_HASH_SIZE 57
61 #define ENC_HASH_SIZE 31
62 #define PSMAP_HASH_SIZE 57
66 #define ENCNAME_HASH_SIZE 131
79 "Gamma",
"Delta",
"Theta",
"Lambda",
"Xi",
"Pi",
"Sigma",
"Upsilon",
80 "Phi",
"Psi",
"Omega",
"arrowup",
"arrowdown",
"quotesingle",
81 "exclamdown",
"questiondown",
"dotlessi",
"dotlessj",
"grave",
82 "acute",
"caron",
"breve",
"macron",
"ring",
"cedilla",
83 "germandbls",
"ae",
"oe",
"oslash",
"AE",
"OE",
"Oslash",
"space",
84 "exclam",
"quotedbl",
"numbersign",
"dollar",
"percent",
85 "ampersand",
"quoteright",
"parenleft",
"parenright",
"asterisk",
86 "plus",
"comma",
"hyphen",
"period",
"slash",
"zero",
"one",
"two",
87 "three",
"four",
"five",
"six",
"seven",
"eight",
"nine",
"colon",
88 "semicolon",
"less",
"equal",
"greater",
"question",
"at",
"A",
"B",
89 "C",
"D",
"E",
"F",
"G",
"H",
"I",
"J",
"K",
"L",
"M",
"N",
"O",
90 "P",
"Q",
"R",
"S",
"T",
"U",
"V",
"W",
"X",
"Y",
"Z",
91 "bracketleft",
"backslash",
"bracketright",
"circumflex",
92 "underscore",
"quoteleft",
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
93 "i",
"j",
"k",
"l",
"m",
"n",
"o",
"p",
"q",
"r",
"s",
"t",
"u",
94 "v",
"w",
"x",
"y",
"z",
"braceleft",
"bar",
"braceright",
"tilde",
95 "dieresis", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
96 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
97 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
98 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
99 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
100 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
128 if(fstat(fileno(in), &st) < 0) {
133 st.st_size -= enc->
offset;
136 enc->
private = (
char *)malloc(st.st_size + 1);
143 fseek(in, enc->
offset, SEEK_SET);
145 if(fread(enc->
private, st.st_size, 1, in) != 1) {
157 for(line = enc->
private; *line && curr < 256; line = next) {
161 if(
STRNEQ(line,
"def", 3))
164 name =
getword(line,
" \t\n", &next);
171 while(*next && *next !=
'\n')
178 if(*next) *next++ = 0;
184 if(!
STREQ(name,
".notdef")) {
197 enc->
vector[curr++] = NULL;
209 if(enc == default_encoding) {
214 if(enc != tex_text_encoding) {
246 if(encodings.
count) {
255 filename = kpse_find_file(basefile,
256 kpse_program_text_format, 0);
260 filename = kpse_find_file(basefile,
261 kpse_tex_ps_header_format, 0);
263 filename = kpse_find_file(basefile,
264 kpse_dvips_config_format, 0);
270 in = fopen(filename,
"rb");
279 while((line =
dgets(&input, in)) != NULL) {
280 if(
STRNEQ(line,
"Encoding=", 9)) {
281 name =
getword(line + 9,
" \t", &line);
282 if(*line) *line++ = 0;
284 }
else if(*line ==
'/') {
299 if(name == NULL || *name == 0) {
301 "%s: could not determine name of encoding\n",
309 if(enc == tex_text_encoding) {
314 if(enc == default_encoding)
315 default_encoding = NULL;
327 if(enc == default_encoding) {
328 default_encoding = NULL;
348 if(default_encoding == NULL)
349 default_encoding = enc;
356 basefile, enc->
name));
365 DEBUG((
DBG_FMAP,
"%s: encoding not found, returning default `%s'\n",
366 name, default_encoding->
name));
370 if(enc == tex_text_encoding)
381 for(i = 0; i < 256; i++) {
382 if(enc->
vector[i] == NULL)
396 if(enc == tex_text_encoding)
398 if(!enc->
links || --enc->
links > 0 || !should_free)
428 arg =
getword(spec,
" \t", &spec);
429 if(*spec) *spec++ = 0;
430 command =
getword(spec,
" \t", &spec);
431 if(*spec) *spec++ = 0;
434 if(
STREQ(command,
"SlantFont")) {
435 double x = 10000 * strtod(arg, 0);
439 }
else if(
STREQ(command,
"ExtendFont")) {
440 double x = 10000 * strtod(arg, 0);
443 }
else if(
STREQ(command,
"ReEncodeFont")) {
454 printf(
"Entry for `%s':\n", ent->
fontname);
455 printf(
" PS name: %s\n", ent->
psname ? ent->
psname :
"(none)");
459 printf(
" Extend: %ld\n", ent->
extend);
460 printf(
" Slant: %ld\n", ent->
slant);
475 ptr = kpse_find_file(file, kpse_program_text_format, 0);
477 ptr = kpse_find_file(file, kpse_tex_ps_header_format, 0);
479 ptr = kpse_find_file(file, kpse_dvips_config_format, 0);
481 in = fopen(file,
"rb");
483 in = fopen(ptr,
"rb");
492 last_encoding = NULL;
495 while((ptr =
dgets(&input, in)) != NULL) {
507 if(*ptr <=
' ' || *ptr ==
'*' || *ptr ==
'#' ||
508 *ptr ==
';' || *ptr ==
'%')
524 char *hdr_name = NULL;
526 while(*ptr && *ptr <=
' ')
537 }
else if(*ptr ==
'<') {
541 else if(*ptr ==
'[') {
561 if(is_encoding || (ext &&
STRCEQ(ext,
"enc")))
564 font_file = hdr_name;
581 if(!last_encfile || !
STREQ(last_encfile, ent->
encfile)) {
590 _(
"%s: %d: [%s] requested encoding `%s' does not match vector `%s'\n"),
629 for(ent = head; ent; ent = next) {
657 encoding->
name =
"TeXTextEncoding";
662 for(i = 0; i < 256; i++) {
677 tex_text_encoding = encoding;
688 if(enc == default_encoding)
696 default_encoding = enc;
697 if(old != tex_text_encoding)
725 config = kpse_cnf_get(
"mdvi-config");
729 file = kpse_find_file(config, kpse_program_text_format, 0);
731 in = fopen(config,
"rb");
733 in = fopen(file,
"rb");
739 while((line =
dgets(&input, in)) != NULL) {
740 char *arg, *map_file;
743 if(*line <
' ' || *line ==
'#' || *line ==
'%')
745 if(
STRNEQ(line,
"fontmap", 7)) {
748 arg =
getstring(line + 7,
" \t", &line); *line = 0;
752 map_file = kpse_find_file(arg, kpse_fontmap_format, 0);
760 "%s: installing fontmap\n", arg));
764 }
else if(
STRNEQ(line,
"encoding", 8)) {
765 arg =
getstring(line + 8,
" \t", &line); *line = 0;
768 }
else if(
STRNEQ(line,
"default-encoding", 16)) {
769 arg =
getstring(line + 16,
" \t", &line); *line = 0;
773 }
else if(
STRNEQ(line,
"psfontpath", 10)) {
774 arg =
getstring(line + 11,
" \t", &line); *line = 0;
780 }
else if(
STRNEQ(line,
"pslibpath", 9)) {
781 arg =
getstring(line + 10,
" \t", &line); *line = 0;
787 }
else if(
STRNEQ(line,
"psfontmap", 9)) {
788 arg =
getstring(line + 9,
" \t", &line); *line = 0;
798 count, fontmaps.
count));
849 if((enc != tex_text_encoding && enc->
links) || enc->
links > 1) {
887 kppath = getenv(
"GS_LIB");
888 kfpath = getenv(
"GS_FONTPATH");
891 pslibdir = kpse_path_expand(kppath);
911 fullname = kpse_path_search(
pslibdir, name, 1);
913 fullname = (
char *)name;
914 in = fopen(fullname,
"rb");
922 while((line =
dgets(&dstr, in)) != NULL) {
935 name =
getword(line + 1,
" \t", &line);
936 if(*line) *line++ = 0;
937 mapname =
getword(line,
" \t", &line);
938 if(*line) *line++ = 0;
940 if(!name || !mapname || !*name)
942 if(*mapname ==
'(') {
946 for(end = mapname; *end && *end !=
')'; end++);
954 if(ext &&
STREQ(ext,
"gsf")) {
964 "(ps) replacing font `%s' (%s) by `%s'\n",
988 DEBUG((
DBG_FMAP,
"(ps) %s: %d PostScript fonts registered\n",
1026 int recursion_limit = 32;
1039 while(recursion_limit-- > 0 && smap && *smap->
mapname ==
'/')
1043 if(recursion_limit == 0)
1045 "(ps) %s: possible loop in PS font map\n",
1097 DEBUG((
DBG_FMAP,
"(ps) %s: looking for metric data\n", fontname));
1113 basefile =
strrchr(psfont,
'/');
1114 if(basefile == NULL)
1116 baselen = strlen(basefile);
1120 if(baselen + 4 < 64)
1121 afmfile = &buffer[0];
1124 strcpy(afmfile, basefile);
1125 strcpy(afmfile + baselen,
".afm");
1129 fontname, afmfile));
1131 psfont = kpse_path_search(
psfontdir, afmfile, 1);
1133 if(afmfile != &buffer[0])
1135 if(psfont != NULL) {
1149 #define DROUND(x) ((x) >= 0 ? floor((x) + 0.5) : ceil((x) - 0.5))
1150 #define TRANSFORM(x,y) DROUND(efactor * (x) + sfactor * (y))
1152 efactor = (double)map.
extend / 10000.0;
1153 sfactor = (
double)map.
slant / 10000.0;
1157 nc = info->
hic - info->
loc + 1;
1158 for(ch = info->
chars; ch < info->chars + nc; ch++) {