]> git.donarmstrong.com Git - lilypond.git/blob - lily/kpath.cc
patch::: 1.4.0.jcn4
[lilypond.git] / lily / kpath.cc
1 /*   
2   kpath.cc -- glue kpathsea to lily. Need some ugly kludges for gcc 2.96
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2000--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include <stdio.h>
10 #include <string.h>
11
12 #include "config.h"
13
14 #define popen REALLYUGLYKLUDGE
15 #define pclose ANOTHERREALLYUGLYKLUDGE
16
17 #if HAVE_KPATHSEA_KPATHSEA_H
18 extern "C" {
19 #include <kpathsea/kpathsea.h>
20 #include <kpathsea/tex-file.h>
21 }
22 #endif
23
24 #include "file-path.hh"
25 #include "string.hh"
26 #include "main.hh"
27 #include "kpath.hh"
28 #include "lily-version.hh"
29
30
31 char *
32 ly_find_afm (char const * name)
33 {
34 #if (KPATHSEA && HAVE_KPSE_FIND_FILE)
35   return kpse_find_file (name, kpse_afm_format, true);
36 #endif
37   return 0;
38 }
39
40 String
41 ly_find_tfm (char const * name)
42 {
43   String p = global_path.find (String (name) + ".tfm");
44
45   if (p.length_i ())
46     return p;
47   
48 #if (KPATHSEA && HAVE_KPSE_FIND_FILE)
49   return kpse_find_file (name, kpse_tfm_format, true);
50 #endif
51   return "";
52 }
53
54
55 void
56 ly_init_kpath (char *av0)
57 {
58 #if KPATHSEA && HAVE_KPATHSEA_KPATHSEA_H
59   /*
60     We take two pronged approach to tfms:
61
62     * the lilypond tfms (feta*.tfm) are found through our own routines.
63
64     * the TeX tfms are found through vanilla kpathsea.
65
66     (* other TFMs are not found, i.e. don't use them. )
67
68     PRO:
69  
70     - TFM and AFM checksums always match in Lily.
71
72     - less hassle, no kpathsea spaghetti
73
74     CON:
75
76     - feta PK files are often recreated, locally
77     Solution: cache PK files locally?
78
79     - need env. vars to make sure that TeX finds the TFMs
80
81     - Outdated PK (TFM?) font files are not automatically removed,
82     since VERSION is not part of the standard location.
83
84
85     ALTERNATIVE
86
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.
91     
92   */
93
94   /*
95    initialize kpathsea
96    */
97   kpse_set_program_name (av0, NULL);
98   kpse_maketex_option ("tfm", TRUE);
99
100 #if  0
101
102
103   /*
104     
105     Remove the setting for TFMFONTS if we have kpathsea, because
106     kpathsea can find TFM fonts anyway.
107
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.
110
111     This will fail if a user has special fonts (outside of feta) that
112     can not be found by kpath.
113
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).
117
118     The advantage is that the PK font will also be generated under
119     /var/texmf/fonts, reducing clutter and compilation time.
120
121    */
122
123 #ifndef __CYGWIN__  /* mktextfm/mktexpk does not work on windows */
124   unsetenv ("TFMFONTS");
125 #endif
126
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
133
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 ());
139                            
140   String prog = "mktextfm --destdir ";
141   prog += mypath;
142   
143   kpse_format_info[kpse_tfm_format].program = strdup (prog.ch_C ());
144 #endif
145 #endif
146 #endif
147   
148 }
149
150