From 083a335d7ca1edec4942d12f53673266e19701fd Mon Sep 17 00:00:00 2001
From: Han-Wen Nienhuys <hanwen@xs4all.nl>
Date: Wed, 6 Apr 2005 12:14:41 +0000
Subject: [PATCH] * lily/main.cc (setup_paths): either add mf/out to search
 path or fonts/{otf,type1,etc}

* lily/font-config.cc (init_fontconfig): either add mf/out to
FontConfig or fonts/{otf,type1,etc}

* GNUmakefile.in: don't put mf/ link in share/ dir.

* lily/font-config.cc (init_fontconfig): add operator pacification
message.
---
 ChangeLog           |  8 ++++++++
 GNUmakefile.in      | 27 +++++++++++++++++----------
 lily/font-config.cc | 20 +++++++++++++++-----
 lily/main.cc        | 29 +++++++++++++++++++++++++----
 mf/GNUmakefile      |  3 ++-
 5 files changed, 67 insertions(+), 20 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 07e6c15e3a..b50bd89ba7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2005-04-06  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
+	* lily/main.cc (setup_paths): either add mf/out to search path or 
+	fonts/{otf,type1,etc}
+	
+	* lily/font-config.cc (init_fontconfig): either add mf/out to
+	FontConfig or fonts/{otf,type1,etc}
+
+	* GNUmakefile.in: don't put mf/ link in share/ dir.
+
 	* lily/staff-spacing.cc: move same-direction-correction to note-spacing-interface
 
 	* scm/lily.scm (lilypond-main): use variable argument count for
diff --git a/GNUmakefile.in b/GNUmakefile.in
index 1a5613ff98..e654362a75 100644
--- a/GNUmakefile.in
+++ b/GNUmakefile.in
@@ -110,15 +110,17 @@ $(tree-prefix)/lilypond-force: GNUmakefile
 	mkdir -p $(tree-prefix)/dvips
 	mkdir -p $(tree-prefix)/elisp
 	mkdir -p $(tree-prefix)/fonts
+	mkdir -p $(tree-prefix)/fonts/otf
+	mkdir -p $(tree-prefix)/fonts/tfm
+	mkdir -p $(tree-prefix)/fonts/type1
+	mkdir -p $(tree-prefix)/fonts/svg
+	mkdir -p $(tree-prefix)/fonts/map
+	mkdir -p $(tree-prefix)/fonts/enc
 	mkdir -p $(tree-prefix)/tex
 	cd $(builddir)/lib && \
 		ln -s  ../../../python/$(outconfbase) python
 	cd $(tree-prefix) && \
 		ln -s $(abs-srcdir)/ly ly && \
-		ln -s ../../../mf/$(outconfbase) otf && \
-		ln -s ../../../mf/$(outconfbase) svg && \
-		ln -s ../../../mf/$(outconfbase) tfm && \
-		ln -s $(abs-srcdir)/mf && \
 		ln -s $(abs-srcdir)/ps && \
 		ln -s ../../../python/$(outconfbase) python && \
 		ln -s $(abs-srcdir)/scm && \
@@ -130,14 +132,19 @@ $(tree-prefix)/lilypond-force: GNUmakefile
 		ln -s $(abs-srcdir)/tex source && \
 		ln -s ../../../../tex/$(outconfbase) tex-out && \
 		ln -s ../../../../mf/$(outconfbase) mf-out
+	cd $(tree-prefix)/fonts/type1 && \
+		ln -s ../../../../../mf/$(outconfbase)/*.pfa .
+	cd $(tree-prefix)/fonts/otf && \
+		ln -s ../../../../../mf/$(outconfbase)/*.otf .
+	cd $(tree-prefix)/fonts/svg && \
+		ln -s ../../../../../mf/$(outconfbase)/*.svg .
+	cd $(tree-prefix)/fonts/tfm && \
+		ln -s ../../../../../mf/$(outconfbase)/*.tfm .
+	cd $(tree-prefix)/fonts/enc && \
+		ln -s ../../../../../mf/$(outconfbase)/*.enc .
 	cd $(tree-prefix)/fonts && \
 		ln -s $(abs-srcdir)/mf source && \
-		ln -s ../../../../tex/$(outconfbase) enc && \
-		ln -s ../../../../mf/$(outconfbase) map && \
-		ln -s ../../../../mf/$(outconfbase) otf && \
-		ln -s ../../../../mf/$(outconfbase) tfm && \
-		ln -s ../../../../mf/$(outconfbase) svg && \
-		ln -s ../../../../mf/$(outconfbase) type1
+		true
 	cd $(tree-prefix)/elisp && \
 		ln -sf ../../../../../elisp/$(outconfbase)/lilypond-words.el . && \
 		ln -s $(abs-srcdir)/elisp/*.el .
diff --git a/lily/font-config.cc b/lily/font-config.cc
index 08378da3a7..eb8b4f80c0 100644
--- a/lily/font-config.cc
+++ b/lily/font-config.cc
@@ -28,12 +28,22 @@ init_fontconfig ()
   FcConfig *fcc = FcConfigGetCurrent ();
 
   Array<String> dirs;
-  dirs.push (prefix_directory + "/mf/out/");
-  
-  dirs.push (prefix_directory + "/fonts/otf/");
-  dirs.push (prefix_directory + "/fonts/type1/");
-  dirs.push (prefix_directory + "/fonts/cff/");
 
+
+  struct stat statbuf; 
+  String builddir = prefix_directory + "/mf/out/";
+  if (stat (builddir.to_str0 (), &statbuf) != 0)
+    {
+      dirs.push (builddir.to_str0 ());
+    }
+  else
+    {
+      dirs.push (prefix_directory + "/fonts/otf/");
+      dirs.push (prefix_directory + "/fonts/type1/");
+      dirs.push (prefix_directory + "/fonts/cff/");
+      dirs.push (prefix_directory + "/fonts/svg/");
+  }
+  
   for (int i = 0; i < dirs.size (); i++)
     {
       String dir = dirs[i];
diff --git a/lily/main.cc b/lily/main.cc
index 80095fa9af..ef8f60679f 100644
--- a/lily/main.cc
+++ b/lily/main.cc
@@ -16,6 +16,7 @@
 #include <pwd.h>
 #include <grp.h>
 #include <sys/types.h>
+#include <sys/stat.h>
 
 #include "config.hh"
 
@@ -234,15 +235,35 @@ setup_paths ()
 
   /* Adding mf/out make lilypond unchanged source directory, when setting
      LILYPONDPREFIX to lilypond-x.y.z */
-  char *suffixes[] = {"ly", "fonts/cff", "fonts/otf", "mf/out", "scm",
-		      "fonts/tfm", "ps", "fonts/svg",
-		      0};
+  char *suffixes[] = {"ly", "ps", "scm", 0 };
 
+  Array<String> dirs;
   for (char **s = suffixes; *s; s++)
     {
       String path = prefix_directory + to_string ('/') + String (*s);
-      global_path.prepend (path);
+      dirs.push (path);
     }
+
+  /*
+    ugh. C&P font-config.cc
+  */
+  struct stat statbuf; 
+  String builddir = prefix_directory + "/mf/out/";
+  if (stat (builddir.to_str0 (), &statbuf) == 0)
+    {
+      dirs.push (builddir.to_str0 ());
+    }
+  else
+    {
+      dirs.push (prefix_directory + "/fonts/otf/");
+      dirs.push (prefix_directory + "/fonts/type1/");
+      dirs.push (prefix_directory + "/fonts/cff/");
+      dirs.push (prefix_directory + "/fonts/svg/");
+      dirs.push (prefix_directory + "/fonts/cff/");
+    }
+
+  for (int i = 0; i < dirs.size (); i++)
+    global_path.prepend (dirs[i]);  
 }
   
 static void
diff --git a/mf/GNUmakefile b/mf/GNUmakefile
index bd4e0ab3e6..f0d455656e 100644
--- a/mf/GNUmakefile
+++ b/mf/GNUmakefile
@@ -59,6 +59,7 @@ MFTRACE_FLAGS=$(if $(ENCODING_FILE),--encoding $(ENCODING_FILE),) --no-afm
 $(outdir)/%.cff.ps $(outdir)/PFA%.pfa $(outdir)/%.cff $(outdir)/%.otf $(outdir)/%.svg: $(outdir)/%.pe
 	(cd $(outdir) && $(FONTFORGE) -script $(notdir $<))
 	$(PYTHON) $(buildscript-dir)/ps-embed-cff.py $(basename $<).cff `cat $(basename $<).fontname` $(basename $<).cff.ps
+	-rm $(outdir)/*.scale.pfa
 
 
 $(outdir)/%.otf-table: $(outdir)/%.lisp $(if $(findstring brace,$<),,$(subst feta,parmesan,$<)) 
@@ -174,7 +175,7 @@ $(outdir)/%.lisp $(outdir)/%.otf-gtable $(outdir)/%.enc  $(outdir)/%.tex $(outdi
 fontdir: $(addprefix $(outdir)/, lilypond.map lilypond.sfd private-fonts fonts.scale fonts.dir Fontmap.lily)
 
 
-$(outdir)/lilypond.map: $(AFM_FILES)
+$(outdir)/lilypond.map:
 	for i in $(FETA_FONTS); do echo $$i $$i '<'$$i.pfa; done > $@
 	for i in $(STAFF_SIZES); \
 		do echo "Emmentaler-$$i Emmentaler-$$i <emmentaler-$$i.cff.ps" ; done \
-- 
2.39.5