lilypond-1.5.1
[lilypond.git] / lily / kpath.cc
blobf42c5fd1f6fcbadb101c1d692932af28cd19020c
1 /*
2 kpath.cc -- glue kpathsea to lily. Need some ugly kludges for gcc 2.96
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
9 #include <stdio.h>
10 #include <string.h>
12 #include "config.h"
14 #define popen REALLYUGLYKLUDGE
15 #define pclose ANOTHERREALLYUGLYKLUDGE
17 #if HAVE_KPATHSEA_KPATHSEA_H
18 extern "C" {
19 #include <kpathsea/kpathsea.h>
20 #include <kpathsea/tex-file.h>
22 #endif
24 #include "file-path.hh"
25 #include "string.hh"
26 #include "main.hh"
27 #include "kpath.hh"
28 #include "lily-version.hh"
31 char *
32 ly_find_afm (char const * name)
34 #if (KPATHSEA && HAVE_KPSE_FIND_FILE)
35 return kpse_find_file (name, kpse_afm_format, true);
36 #endif
37 return 0;
40 String
41 ly_find_tfm (char const * name)
43 String p = global_path.find (String (name) + ".tfm");
45 if (p.length_i ())
46 return p;
48 #if (KPATHSEA && HAVE_KPSE_FIND_FILE)
49 return kpse_find_file (name, kpse_tfm_format, true);
50 #endif
51 return "";
55 void
56 ly_init_kpath (char *av0)
58 #if KPATHSEA && HAVE_KPATHSEA_KPATHSEA_H
60 We take two pronged approach to tfms:
62 * the lilypond tfms (feta*.tfm) are found through our own routines.
64 * the TeX tfms are found through vanilla kpathsea.
66 (* other TFMs are not found, i.e. don't use them. )
68 PRO:
70 - TFM and AFM checksums always match in Lily.
72 - less hassle, no kpathsea spaghetti
74 CON:
76 - feta PK files are often recreated, locally
77 Solution: cache PK files locally?
79 - need env. vars to make sure that TeX finds the TFMs
81 - Outdated PK (TFM?) font files are not automatically removed,
82 since VERSION is not part of the standard location.
85 ALTERNATIVE
87 we have tried to come up with schemes that leave this kind of work
88 to kpathsea with objective of fixing the CONs, but miserably
89 failed. TeX installations and kpathsea itself form a buggy,
90 inconsistent, and unorderly mess.
95 initialize kpathsea
97 kpse_set_program_name (av0, NULL);
98 kpse_maketex_option ("tfm", TRUE);
100 #if 0
105 Remove the setting for TFMFONTS if we have kpathsea, because
106 kpathsea can find TFM fonts anyway.
108 If we don't lily will want to make tfms for cmr fonts, even if
109 there is a :: entry in the TFMFONTS path.
111 This will fail if a user has special fonts (outside of feta) that
112 can not be found by kpath.
114 If TFMFONTS is unset, TFMs of feta will be generated on the
115 fly. The risk is that this will cause checksum mismatch errors,
116 but MF is reasonably deterministic (so we hope not).
118 The advantage is that the PK font will also be generated under
119 /var/texmf/fonts, reducing clutter and compilation time.
123 #ifndef __CYGWIN__ /* mktextfm/mktexpk does not work on windows */
124 unsetenv ("TFMFONTS");
125 #endif
127 #ifdef DEBIAN
128 String my_tfm = "$VARTEXFONTS/tfm/public/lilypond";
129 #else
130 String my_tfm = "$VARTEXFONTS/tfm/lilypond/";
131 my_tfm += version_str () + "/";
132 #endif
134 #ifdef DEBIAN
135 char * mypath = strdup ((my_tfm + ":").ch_C());
136 kpse_format_info[kpse_tfm_format].client_path = mypath;
137 #else
138 char * mypath = kpse_expand (my_tfm.ch_C ());
140 String prog = "mktextfm --destdir ";
141 prog += mypath;
143 kpse_format_info[kpse_tfm_format].program = strdup (prog.ch_C ());
144 #endif
145 #endif
146 #endif