]> git.donarmstrong.com Git - lilypond.git/commitdiff
* mf/merge.pe: new file.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sat, 11 Dec 2004 12:54:04 +0000 (12:54 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sat, 11 Dec 2004 12:54:04 +0000 (12:54 +0000)
* lily/freetype.cc: new file.

* lily/include/freetype.hh: new file.

* lily/open-type-font.cc: new file.

* lily/all-font-metrics.cc (find_otf): new function.

17 files changed:
ChangeLog
config.make.in
configure.in
lily/afm.cc
lily/all-font-metrics.cc
lily/freetype.cc [new file with mode: 0644]
lily/include/all-font-metrics.hh
lily/include/freetype.hh [new file with mode: 0644]
lily/include/lily-proto.hh
lily/main.cc
lily/open-type-font.cc [new file with mode: 0644]
lily/time-signature.cc
ly/engraver-init.ly
mf/GNUmakefile
mf/merge.pe [new file with mode: 0644]
mf/parmesan-timesig.mf
scripts/convert-ly.py

index ba16420e3c7cc284a3ac141714928ab347ebbf17..53fe7fa7b8147a40308f3164b1c1c5973bce46de 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2004-12-11  Han-Wen Nienhuys  <hanwen@xs4all.nl>
+
+       * mf/merge.pe: new file.
+
+       * lily/freetype.cc: new file.
+
+       * lily/include/open-type-font.hh (class Open_type_font): new file.
+
+       * lily/include/freetype.hh: new file.
+
+       * lily/open-type-font.cc: new file.
+
+       * lily/all-font-metrics.cc (find_otf): new function.
+
 2004-12-11  Jan Nieuwenhuizen  <janneke@gnu.org>
 
        * configure.in (PKG_CONFIG_PATH): Remove stray `i'.  Check for
index 55ff72debc02ca391d033f8cd6a31043ea07e436..ade4f410e208732b941485ca4e7f195c3873aca6 100644 (file)
@@ -7,10 +7,10 @@ MISSING_REQUIRED = @REQUIRED@
 
 package-depth = @package_depth@
 
-USER_CFLAGS = @CFLAGS@ @CPPFLAGS@ @GUILE_CFLAGS@ @PANGO_CFLAGS@
-USER_CXXFLAGS = @CXXFLAGS@ @CPPFLAGS@ @GUILE_CFLAGS@ @PANGO_CFLAGS@
+USER_CFLAGS = @CFLAGS@ @CPPFLAGS@ @GUILE_CFLAGS@ @PANGO_CFLAGS@ @FREETYPE2_CFLAGS@
+USER_CXXFLAGS = @CXXFLAGS@ @CPPFLAGS@ @GUILE_CFLAGS@ @PANGO_CFLAGS@ @FREETYPE2_CFLAGS@
 USER_LDFLAGS = @LDFLAGS@ @GUILE_LDFLAGS@
-EXTRA_LIBES = @EXTRA_LIBES@ @LIBS@ @PANGO_LIBS@
+EXTRA_LIBES = @EXTRA_LIBES@ @LIBS@ @PANGO_LIBS@ @FREETYPE2_LIBS@
 
 PACKAGE = @PACKAGE@
 package = @package@
index 80fc82950679c9fbe9de98e75a19ed6ed7b6a088..a2d1125427fa8af5472c1d6f9797d989df707328 100644 (file)
@@ -55,7 +55,9 @@ STEPMAKE_PYTHON_DEVEL(REQUIRED)
 STEPMAKE_PROGS(MFTRACE, mftrace, REQUIRED, 1.0.27)
 
 # mftrace for generating pfa's, pfb's
-STEPMAKE_PROGS(FONTFORGE, fontforge, REQUIRED, 20041208)
+STEPMAKE_PROGS(FONTFORGE, fontforge, REQUIRED)
+
+# version:  20041208)
 
 
 AC_CHECK_HEADERS([assert.h sys/stat.h])
index 6f9fe444e16fa9f2ca73eb429f6f8cdf56c16d7e..27a284d0a699b950f7ca541a845d407cfb5555c9 100644 (file)
@@ -48,7 +48,7 @@ Adobe_font_metric::make_afm (AFM_Font_info *fi,
 {
   Adobe_font_metric *fm = new Adobe_font_metric (fi);
   fm->checksum_ = checksum;
-  fm->design_size_ = design_size;
+  fm->design_size_ = design_size; 
   return fm->self_scm ();    
 }
 
index 4540994a3a2831800eb78bef4689dd51aa1efcb6..63658d6be34b3f5d901102653551db02b25fe439 100644 (file)
@@ -8,6 +8,7 @@
 
 #include "all-font-metrics.hh"
 
+#include "open-type-font.hh"
 #include "config.hh"
 #include "main.hh"
 #include "warn.hh"
@@ -22,6 +23,7 @@ All_font_metrics::All_font_metrics (String path)
 {
   afm_p_dict_ = new Scheme_hash_table;
   tfm_p_dict_ = new Scheme_hash_table;
+  otf_p_dict_ = new Scheme_hash_table;
   
   search_path_.parse_path (path);
 }
@@ -30,6 +32,11 @@ All_font_metrics::~All_font_metrics ()
 {
   scm_gc_unprotect_object (afm_p_dict_->self_scm ());
   scm_gc_unprotect_object (tfm_p_dict_->self_scm ());
+  scm_gc_unprotect_object (otf_p_dict_->self_scm ());
+}
+
+All_font_metrics::All_font_metrics (All_font_metrics const&)
+{
 }
 
 /*
@@ -114,6 +121,40 @@ All_font_metrics::find_afm (String name)
 }
 
 
+Open_type_font*
+All_font_metrics::find_otf (String name)
+{
+  SCM sname = ly_symbol2scm (name.to_str0 ());
+  SCM name_string = scm_makfrom0str (name.to_str0 ());
+  SCM val;
+  if (!otf_p_dict_->try_retrieve (sname, &val))
+    {
+      String file_name;
+      
+      if (file_name.is_empty ())
+       file_name = search_path_.find (name  + ".otf");
+      if (file_name.is_empty ())
+       return 0;
+
+      if (verbose_global_b)
+       progress_indication ("[" + file_name);
+      
+      val = Open_type_font::make_otf (file_name);
+
+      if (verbose_global_b)
+       progress_indication ("]");
+
+      unsmob_metrics (val)->file_name_ = file_name;
+      unsmob_metrics (val)->description_ = scm_cons (name_string,
+                                                    scm_make_real (1.0));
+      otf_p_dict_->set (sname, val);
+      scm_gc_unprotect_object (val);
+    }
+
+  return dynamic_cast<Open_type_font*> (unsmob_metrics (val));
+}
+
+
 Tex_font_metric*
 All_font_metrics::find_tfm (String name)
 {
@@ -159,8 +200,11 @@ All_font_metrics::find_tfm (String name)
 Font_metric*
 All_font_metrics::find_font (String name)
 {
-  Font_metric *f = 0;
-  if ((name.left_string (4) == "feta")
+  Font_metric *f = find_otf (name);
+
+  
+  if (!f &&
+      (name.left_string (4) == "feta")
       || (name.left_string (8) == "parmesan")
       || (name.left_string (2) == "lm"))
     {
@@ -168,7 +212,7 @@ All_font_metrics::find_font (String name)
       if (!f)
        f = find_tfm (name);
     }
-  else
+  else if (!f)
     {
       f = find_tfm (name);
       if (!f)
diff --git a/lily/freetype.cc b/lily/freetype.cc
new file mode 100644 (file)
index 0000000..a966bf3
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+  freetype.cc --  implement Freetype routines.
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 2004 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+*/
+
+#include "freetype.hh"
+#include "warn.hh"
+
+FT_Library freetype2_library;
+
+
+void
+init_freetype()
+{
+  int errorcode = FT_Init_FreeType( &freetype2_library );
+  if (errorcode)
+    {
+      error("Could  not initialize freetype");
+    }
+}
+
index bb690d66e74a6e8d9b80436dadf441dcff06719f..0ea6294573f749efb652539aa07e3559511c2780 100644 (file)
@@ -20,8 +20,10 @@ class All_font_metrics
 {
   Scheme_hash_table *afm_p_dict_;
   Scheme_hash_table *tfm_p_dict_;
+  Scheme_hash_table *otf_p_dict_;
   File_path search_path_;
 
+  All_font_metrics (All_font_metrics const&);
 public:
   All_font_metrics (String search_path);
   ~All_font_metrics ();
@@ -29,6 +31,7 @@ public:
   Adobe_font_metric *find_afm (String name);
   Tex_font_metric *find_tfm (String);
   Font_metric *find_font (String name);  
+  Open_type_font *find_otf (String name);  
   SCM font_descriptions () const;
 };
 
diff --git a/lily/include/freetype.hh b/lily/include/freetype.hh
new file mode 100644 (file)
index 0000000..2be3545
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+  freetype.hh -- declare Freetype global settings.
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 2004 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+*/
+
+#ifndef FREETYPE_HH
+#define FREETYPE_HH
+
+#include <ft2build.h>
+#include FT_FREETYPE_H 
+
+void init_freetype();
+extern FT_Library freetype2_library;
+
+#endif /* FREETYPE_HH */
+
index 778dbf01bf809dcd9c178a45b991bae0a86f61a9..1ceb002c6f21012b518db7397e83e378610fabd8 100644 (file)
@@ -112,6 +112,7 @@ class Output_def;
 class Object_key;
 class Object_key_dumper;
 class Object_key_undumper;
+class Open_type_font;
 class Output_property;
 class Page;
 class Paper_book;
index 71c45cfa259a670603e64dbf6425cc11b06dd26e..f0a209bbde09ec0c772a5f49ca32ac11382857a3 100644 (file)
@@ -312,7 +312,6 @@ main_with_guile (void *, int, char **)
 
   ly_c_init_guile ();
   call_constructors ();
-  
   init_global_tweak_registry ();
   
   determine_output_options ();  
diff --git a/lily/open-type-font.cc b/lily/open-type-font.cc
new file mode 100644 (file)
index 0000000..c08e897
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+  open-type-font.cc --  implement Open_type_font
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 2004 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+*/
+#include "warn.hh"
+#include "open-type-font.hh"
+
+SCM
+Open_type_font::make_otf (String str)
+{
+  Open_type_font * otf = new Open_type_font;
+  int error_code = FT_New_Face( freetype2_library, str.to_str0(),
+                      0, &(otf->face_));
+  
+  if (error_code == FT_Err_Unknown_File_Format)
+    {
+      error("Unsupported font format");
+    }
+  else if (error_code)
+    {
+      error ("Unknown error reading font file.");
+    }
+
+  return otf->self_scm ();
+}
+
+Open_type_font::~Open_type_font()
+{
+  FT_Done_Face (face_);
+}
index c048ae522cf85a35a9a1221f49636363cc7d1f26..ba2a32cf3370d51d1ea33089db0f6b86fd1842fa 100644 (file)
@@ -77,7 +77,7 @@ Time_signature::special_time_signature (Grob *me, SCM scm_style, int n, int d)
        }
     }
 
-  String char_name = style + to_string (n) + "/" + to_string (d);
+  String char_name = style + to_string (n) + to_string (d);
   me->set_property ("font-encoding", ly_symbol2scm ("fetaMusic"));
   Stencil out = Font_interface::get_default_font (me)
     ->find_by_name ("timesig." + char_name);
index c901b285e0ec4b1a012a23eaccc8d584d2c420f8..e056216422b8329a2406463d4df20ecf08ab0bba 100644 (file)
@@ -76,7 +76,7 @@
     \denies Voice
     \accepts DrumVoice
 
-    clefGlyph = #"clefs-percussion"
+    clefGlyph = #"clefs.percussion"
     clefPosition = #0
     \override Script #'staff-padding = #0.75 
 }
@@ -446,7 +446,7 @@ AncientRemoveEmptyStaffContext = \context {
     
     melismaBusyProperties = #default-melisma-properties
     
-    clefGlyph = #"clefs-G"
+    clefGlyph = #"clefs.G"
     clefPosition = #-2
     middleCPosition = #-6
     
@@ -519,7 +519,7 @@ AncientRemoveEmptyStaffContext = \context {
     chordNameExceptionsPartial = #partialJazzExceptions
     
 
-    bassStaffProperties = #'((assign clefGlyph "clefs-F")
+    bassStaffProperties = #'((assign clefGlyph "clefs.F")
       (assign clefPosition 2)
       (assign middleCPosition 6))
     %% tablature:
@@ -643,7 +643,7 @@ EasyNotation = \context {   % TODO: why \context override?
       \remove "Key_engraver"
       \remove "String_number_engraver"
       % Special "TAB" clef
-      clefGlyph = #"clefs-tab"
+      clefGlyph = #"clefs.tab"
       clefPosition = #0
 }
 
@@ -718,7 +718,7 @@ EasyNotation = \context {   % TODO: why \context override?
   % \override StaffSymbol #'width = #60.0
 
   % Choose vaticana do clef on 3rd line as default.
-  clefGlyph = #"clefs-vaticana-do"
+  clefGlyph = #"clefs.vaticana.do"
   middleCPosition = #1
   clefPosition = #1
   clefOctavation = #0
@@ -819,7 +819,7 @@ EasyNotation = \context {   % TODO: why \context override?
   % \override StaffSymbol #'width = #60.0
 
   % Choose petrucci g clef on 2nd line as default.
-  clefGlyph = #"clefs-petrucci-g"
+  clefGlyph = #"clefs.petrucci.g"
   middleCPosition = #-6
   clefPosition = #-2
   clefOctavation = #0
index d0736af0c00858f49295a59b780a875cdda10e18..fdd7f503fba8705dd4e33b7ded9b914b11da7bf3 100644 (file)
@@ -44,8 +44,13 @@ foe:
        echo $(TEXMF)
        kpsewhich exbase.mf
 
-$(outdir)/feta20.otf: merge.pe
-       (cd $(outdir) ; fontforge -s merge.pe ) 
+
+$(outdir)/feta20.otf-table:
+       cat $(outdir)/feta20.lisp $(outdir)/parmesan20.lisp > $@
+
+$(outdir)/feta20.otf: merge.pe $(outdir)/feta20.otf-table
+# FIXME: srcdir build. 
+       (cd $(outdir) ; fontforge -script ../merge.pe ) 
 
 
 ## use separate package sauter-fonts-mftraced.
diff --git a/mf/merge.pe b/mf/merge.pe
new file mode 100644 (file)
index 0000000..e0fe623
--- /dev/null
@@ -0,0 +1,16 @@
+#!/usr/bin/env fontforge
+New();
+
+// TODO: set version
+// TODO: GPL?
+SetFontNames("Feta", "LilyPond", "", "", "This font is in the public domain.", "");
+
+MergeFonts("feta20.pfa");
+MergeFonts("parmesan20.pfa");
+MergeFonts("feta-nummer10.pfa");
+MergeFonts("feta-din14.pfa");
+MergeKern("feta-din14.tfm");
+LoadTableFromFile("LILC", "feta20.otf-table")
+Generate("feta20.otf");
+Generate("feta20.t42");
+
index cf03e8f77b011da6abfc81d5881647247021335e..cc7f939a0e27eda56f7c1de3ffc8233402211a10 100644 (file)
@@ -94,47 +94,47 @@ def mensural_timesig (expr verbose_name, internal_name, ly_name,
 enddef;
 
 %% tempus imperfectum cum prolatione imperfecta
-mensural_timesig ("Mensural 4/4 meter", "mensural4/4", "mensuralfourfourmeter",
+mensural_timesig ("Mensural 4/4 meter", "mensural44", "mensuralfourfourmeter",
                  false, false, false, false);
 
 %% tempus imperfectum cum prolatione imperfecta proportio dupla
-mensural_timesig ("Mensural 2/2 meter", "mensural2/2", "mensuralallabreve",
+mensural_timesig ("Mensural 2/2 meter", "mensural22", "mensuralallabreve",
                  false, false, true, false);
 
 %% tempus perfectum cum prolatione imperfecta
-mensural_timesig ("Mensural 3/2 meter", "mensural3/2", "mensuralthreetwometer",
+mensural_timesig ("Mensural 3/2 meter", "mensural32", "mensuralthreetwometer",
                  true, false, false, false);
 
 %% tempus imperfectum cum prolatione perfecta
-mensural_timesig ("Mensural 6/4 meter", "mensural6/4", "mensuralsixfourmeter",
+mensural_timesig ("Mensural 6/4 meter", "mensural64", "mensuralsixfourmeter",
                  false, false, false, true);
 
 %% tempus perfectum cum prolatione perfecta
-mensural_timesig ("Mensural 9/4 meter", "mensural9/4", "mensuralninefourmeter",
+mensural_timesig ("Mensural 9/4 meter", "mensural94", "mensuralninefourmeter",
                  true, false, false, true);
 
 %% tempus perfectum cum prolatione imperfecta proportio dupla
-mensural_timesig ("Mensural 3/4 meter", "mensural3/4", "mensuralthreefourmeter",
+mensural_timesig ("Mensural 3/4 meter", "mensural34", "mensuralthreefourmeter",
                  true, false, true, false);
 
 %% tempus imperfectum cum prolatione perfecta proportio dupla
-mensural_timesig ("Mensural 6/8 meter", "mensural6/8", "mensuralsixeightmeter",
+mensural_timesig ("Mensural 6/8 meter", "mensural68", "mensuralsixeightmeter",
                  false, false, true, true);
 
 %% tempus perfectum cum prolatione perfecta proportio dupla
-mensural_timesig ("Mensural 9/8 meter", "mensural9/8", "mensuralnineeight",
+mensural_timesig ("Mensural 9/8 meter", "mensural98", "mensuralnineeight",
                  true, false, true, true);
        
 %% tempus imperfectum cum prolatione imperfecta diminutio simplex
-mensural_timesig ("Mensural 4/8 meter", "mensural4/8", "mensuralfoureightmeter",
+mensural_timesig ("Mensural 4/8 meter", "mensural48", "mensuralfoureightmeter",
                  false, true, false, false);
 
 %% tempus imperfectum cum prolatione perfecta diminutio simplex
-mensural_timesig ("Mensural 6/8 meter", "mensural6/8alt", "mensuralsixeightmeteralt",
+mensural_timesig ("Mensural 6/8 meter", "mensural68alt", "mensuralsixeightmeteralt",
                  false, true, false, true);
 
 %% tempus imperfectum cum prolatione imperfecta diminutio duplex
-mensural_timesig ("Mensural 2/4 meter", "mensural2/4", "mensuraltwofourmeter",
+mensural_timesig ("Mensural 2/4 meter", "mensural24", "mensuraltwofourmeter",
                  false, true, true, false);
 
 %%%%%%%%
@@ -188,47 +188,47 @@ def neomensural_timesig (expr verbose_name, internal_name, ly_name,
 enddef;
 
 %% tempus imperfectum cum prolatione imperfecta
-neomensural_timesig ("Mensural 4/4 meter", "neomensural4/4", "neomensuralfourfourmeter",
+neomensural_timesig ("Mensural 4/4 meter", "neomensural44", "neomensuralfourfourmeter",
                        false, false, false, false);
 
 %% tempus imperfectum cum prolatione imperfecta proportio dupla
-neomensural_timesig ("Mensural 2/2 meter", "neomensural2/2", "neomensuralallabreve",
+neomensural_timesig ("Mensural 2/2 meter", "neomensural22", "neomensuralallabreve",
                        false, false, true, false);
 
 %% tempus perfectum cum prolatione imperfecta
-neomensural_timesig ("Mensural 3/2 meter", "neomensural3/2", "neomensuralthreetwometer",
+neomensural_timesig ("Mensural 3/2 meter", "neomensural32", "neomensuralthreetwometer",
                        true, false, false, false);
 
 %% tempus imperfectum cum prolatione perfecta
-neomensural_timesig ("Mensural 6/4 meter", "neomensural6/4", "neomensuralsixfourmeter",
+neomensural_timesig ("Mensural 6/4 meter", "neomensural64", "neomensuralsixfourmeter",
                        false, false, false, true);
 
 %% tempus perfectum cum prolatione perfecta
-neomensural_timesig ("Mensural 9/4 meter", "neomensural9/4", "neomensuralninefourmeter",
+neomensural_timesig ("Mensural 9/4 meter", "neomensural94", "neomensuralninefourmeter",
                        true, false, false, true);
 
 %% tempus perfectum cum prolatione imperfecta proportio dupla
-neomensural_timesig ("Mensural 3/4 meter", "neomensural3/4", "neomensuralthreefourmeter",
+neomensural_timesig ("Mensural 3/4 meter", "neomensural34", "neomensuralthreefourmeter",
                        true, false, true, false);
 
 %% tempus imperfectum cum prolatione perfecta proportio dupla
-neomensural_timesig ("Mensural 6/8 meter", "neomensural6/8", "neomensuralsixeightmeter",
+neomensural_timesig ("Mensural 6/8 meter", "neomensural68", "neomensuralsixeightmeter",
                        false, false, true, true);
 
 %% tempus perfectum cum prolatione perfecta proportio dupla
-neomensural_timesig ("Mensural 9/8 meter", "neomensural9/8", "neomensuralnineeight",
+neomensural_timesig ("Mensural 9/8 meter", "neomensural98", "neomensuralnineeight",
                        true, false, true, true);
        
 %% tempus imperfectum cum prolatione imperfecta diminutio simplex
-neomensural_timesig ("Mensural 4/8 meter", "neomensural4/8", "neomensuralfoureightmeter",
+neomensural_timesig ("Mensural 4/8 meter", "neomensural48", "neomensuralfoureightmeter",
                        false, true, false, false);
 
 %% tempus imperfectum cum prolatione perfecta diminutio simplex
-neomensural_timesig ("Mensural 6/8 meter", "neomensural6/8alt", "neomensuralsixeightmeteralt",
+neomensural_timesig ("Mensural 6/8 meter", "neomensural68alt", "neomensuralsixeightmeteralt",
                        false, true, false, true);
 
 %% tempus imperfectum cum prolatione imperfecta diminutio duplex
-neomensural_timesig ("Mensural 2/4 meter", "neomensural2/4", "neomensuraltwofourmeter",
+neomensural_timesig ("Mensural 2/4 meter", "neomensural24", "neomensuraltwofourmeter",
                        false, true, true, false);
 
 fet_endgroup ("timesig")
index 82a039460960b9382f953d76878e5349761b541d..5cab61bfe6855119a9f9b1300fbc167665039069 100644 (file)
@@ -2292,6 +2292,7 @@ def conv (str):
 conversions.append (((2, 5, 2),
                     conv,
                     '\markup .. < .. > .. -> \markup .. { .. } ..'))
+
 def conv (str):
        str = re.sub ('ly:find-glyph-by-name', 'ly:font-get-glyph', str)
        return str