]> git.donarmstrong.com Git - lilypond.git/blob - lily/kpath.cc
patch::: 1.3.152.jcn3
[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 #include "string.hh"
14
15 #define popen REALLYUGLYKLUDGE
16 #define pclose ANOTHERREALLYUGLYKLUDGE
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 "kpath.hh"
26 #include "lily-version.hh"
27
28
29 char *
30 ly_find_afm (char const * name)
31 {
32 #if (KPATHSEA && HAVE_KPSE_FIND_FILE)
33   return kpse_find_file (name, kpse_afm_format, true);
34 #endif
35   return 0;
36 }
37
38 char *
39 ly_find_tfm (char const * name)
40 {
41 #if (KPATHSEA && HAVE_KPSE_FIND_FILE)
42   return kpse_find_file (name, kpse_tfm_format, true);
43 #endif
44   return 0;
45 }
46
47
48 void
49 ly_init_kpath (char *av0)
50 {
51 #if KPATHSEA && HAVE_KPATHSEA_KPATHSEA_H
52
53   /*
54     Remove the setting for TFMFONTS if we have kpathsea, because
55     kpathsea can find TFM fonts anyway.
56
57     If we don't lily will want to make tfms for cmr fonts, even if
58     there is a :: entry in the TFMFONTS path.
59
60     This will fail if a user has special fonts (outside of feta) that
61     can not be found by kpath.
62
63     If TFMFONTS is unset, TFMs of feta will be generated on the
64     fly. The risk is that this will cause checksum mismatch errors,
65     but MF is reasonably deterministic (so we hope not).
66
67     The advantage is that the PK font will also be generated under
68     /var/texmf/fonts, reducing clutter and compilation time.
69     
70   */
71 #ifndef __CYGWIN__  /* mktextfm/mktexpk does not work on windows */
72   unsetenv ("TFMFONTS");
73 #endif
74
75   /*
76    initialize kpathsea
77    */
78   kpse_set_program_name (av0, NULL);
79   kpse_maketex_option ("tfm", TRUE);
80
81   String my_tfm = "$VARTEXFONTS/tfm/lilypond/";
82   my_tfm += version_str () + "/";
83
84   char * mypath = kpse_expand (my_tfm.ch_C ());
85   String prog = "mktextfm --destdir ";
86   prog += mypath;
87   
88   kpse_format_info[kpse_tfm_format].program = strdup (prog.ch_C ());
89   kpse_format_info[kpse_tfm_format].client_path = mypath;
90 #endif
91 }
92
93