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