X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fkpath.cc;h=62e0186c0596f68cf2129c6d4be00596f20049fe;hb=6eb2e2f71f9895b58a01693a94ea84a432bb3766;hp=8f6f8193434e9fcd1cb86881c74ea828a7039dd7;hpb=125c505b0b8e664b9df2f11718fa6ffca6806060;p=lilypond.git diff --git a/lily/kpath.cc b/lily/kpath.cc index 8f6f819343..62e0186c05 100644 --- a/lily/kpath.cc +++ b/lily/kpath.cc @@ -1,16 +1,15 @@ /* -kpath.cc -- glue kpathsea to lily. Need some ugly kludges for gcc 2.96 + kpath.cc -- glue kpathsea to lily. Need some ugly kludges for gcc 2.96 -source file of the GNU LilyPond music typesetter + source file of the GNU LilyPond music typesetter -(c) 2000--2001 Han-Wen Nienhuys - - */ + (c) 2000--2001 Han-Wen Nienhuys +*/ #include +#include #include "config.h" -#include "string.hh" #define popen REALLYUGLYKLUDGE #define pclose ANOTHERREALLYUGLYKLUDGE @@ -22,24 +21,53 @@ extern "C" { } #endif +#include "file-path.hh" +#include "string.hh" +#include "main.hh" #include "kpath.hh" -#include "version.hh" - +#include "lily-version.hh" +#include "warn.hh" -char * ly_find_afm (char const * name) +String +ly_find_afm (char const * name) { #if (KPATHSEA && HAVE_KPSE_FIND_FILE) - return kpse_find_file (name, kpse_afm_format, true); + char * name_ptr = kpse_find_file (name, kpse_afm_format, true); + + if(!name_ptr) + { + /* + don't mutter about afms, since we try to find them first, and lots of + TFMs don't have AFMs. + */ + // warning (_f("kpathsea couldn't find AFM file `%s'", name)); + } + else + return name_ptr; + #endif - return 0; + return ""; } -char * ly_find_tfm (char const * name) +String +ly_find_tfm (char const * name) { + String p = global_path.find (String (name) + ".tfm"); + + if (p.length_i ()) + return p; + #if (KPATHSEA && HAVE_KPSE_FIND_FILE) - return kpse_find_file (name, kpse_tfm_format, true); + char * name_ptr = kpse_find_file (name, kpse_tfm_format, true); + if(!name_ptr) + { + warning (_f("Kpathsea couldn't find TFM file `%s'", name)); + } + else + return name_ptr; + #endif - return 0; + return ""; } @@ -48,24 +76,45 @@ ly_init_kpath (char *av0) { #if KPATHSEA && HAVE_KPATHSEA_KPATHSEA_H /* - initialize kpathsea - */ - kpse_set_program_name(av0, NULL); - kpse_maketex_option("tfm", TRUE); + We take two pronged approach to tfms: + + * the lilypond tfms (feta*.tfm) are found through our own routines. + + * the TeX tfms are found through vanilla kpathsea. + + (* other TFMs are not found, i.e. don't use them. ) + + PRO: + + - TFM and AFM checksums always match in Lily. + + - less hassle, no kpathsea spaghetti + + CON: + + - feta PK files are often recreated, locally + Solution: cache PK files locally? + + - need env. vars to make sure that TeX finds the TFMs + + - Outdated PK (TFM?) font files are not automatically removed, + since VERSION is not part of the standard location. + + + ALTERNATIVE + + we have tried to come up with schemes that leave this kind of work + to kpathsea with objective of fixing the CONs, but miserably + failed. TeX installations and kpathsea itself form a buggy, + inconsistent, and unorderly mess. + + */ /* - ugh: apparently the program_args is non-functional. + initialize kpathsea */ -#define VERSION MAJOR_VERSION "." MINOR_VERSION "." PATCH_LEVEL - -#define MY_TFMPATH "$VARTEXFONTS/tfm/lilypond/" VERSION "/" - - char * mypath = kpse_expand (MY_TFMPATH); - String prog = "mktextfm --destdir "; - prog += mypath; - - kpse_format_info[kpse_tfm_format].program = strdup (prog.ch_C()); - kpse_format_info[kpse_tfm_format].client_path = mypath; + kpse_set_program_name (av0, NULL); + kpse_maketex_option ("tfm", TRUE); #endif }