]> git.donarmstrong.com Git - lilypond.git/blob - lily/kpath.cc
9579aae41f89cdf614afbb12b57c44d12e3948ac
[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--2002 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 #define getopt YAKLUDGE
17
18 #if HAVE_KPATHSEA_KPATHSEA_H
19 extern "C" {
20 #include <kpathsea/kpathsea.h>
21 #include <kpathsea/tex-file.h>
22 }
23 #endif
24
25 #include "file-path.hh"
26 #include "string.hh"
27 #include "main.hh"
28 #include "kpath.hh"
29 #include "warn.hh"
30
31 String
32 ly_find_afm (char const * name)
33 {
34 #if (KPATHSEA && HAVE_KPSE_FIND_FILE)
35   char * name_ptr =  kpse_find_file (name, kpse_afm_format, true);
36
37   if(!name_ptr)
38     {
39   /*
40     don't mutter about afms, since we try to find them first, and lots of
41     TFMs don't have AFMs. 
42    */
43       //      warning (_f("kpathsea couldn't find AFM file `%s'", name));
44     }
45   else
46     return name_ptr;
47   
48 #endif
49   return "";
50 }
51
52 String
53 ly_find_tfm (char const * name)
54 {
55   String p = global_path.find (String (name) + ".tfm");
56
57   if (p.length ())
58     return p;
59   
60 #if (KPATHSEA && HAVE_KPSE_FIND_FILE)
61   char * name_ptr =  kpse_find_file (name, kpse_tfm_format, true);
62   if(!name_ptr)
63     {
64       warning (_f("Kpathsea couldn't find TFM file `%s'", name));
65     }
66   else
67     return name_ptr;
68   
69 #endif
70   return "";
71 }
72
73
74 void
75 ly_init_kpath (char *av0)
76 {
77 #if KPATHSEA && HAVE_KPATHSEA_KPATHSEA_H
78   /*
79     We take two pronged approach to tfms:
80
81     * the lilypond tfms (feta*.tfm) are found through our own routines.
82
83     * the TeX tfms are found through vanilla kpathsea.
84
85     (* other TFMs are not found, i.e. don't use them. )
86
87     PRO:
88  
89     - TFM and AFM checksums always match in Lily.
90
91     - less hassle, no kpathsea spaghetti
92
93     CON:
94
95     - feta PK files are often recreated, locally
96     Solution: cache PK files locally?
97
98     - need env. vars to make sure that TeX finds the TFMs
99
100     - Outdated PK (TFM?) font files are not automatically removed,
101     since VERSION is not part of the standard location.
102
103
104     ALTERNATIVE
105
106     we have tried to come up with schemes that leave this kind of work
107     to kpathsea with objective of fixing the CONs, but miserably
108     failed. TeX installations and kpathsea itself form a buggy,
109     inconsistent, and unorderly mess.
110     
111   */
112
113   /*
114    initialize kpathsea
115    */
116   kpse_set_program_name (av0, NULL);
117   kpse_maketex_option ("tfm", TRUE);
118 #endif
119 }
120
121