From f525f992e5dbeb579981153775cc9ee10b78cb3f Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sat, 11 Dec 2004 12:54:04 +0000 Subject: [PATCH] * mf/merge.pe: new file. * 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. --- ChangeLog | 14 +++++++++ config.make.in | 6 ++-- configure.in | 4 ++- lily/afm.cc | 2 +- lily/all-font-metrics.cc | 50 ++++++++++++++++++++++++++++++-- lily/freetype.cc | 25 ++++++++++++++++ lily/include/all-font-metrics.hh | 3 ++ lily/include/freetype.hh | 20 +++++++++++++ lily/include/lily-proto.hh | 1 + lily/main.cc | 1 - lily/open-type-font.cc | 34 ++++++++++++++++++++++ lily/time-signature.cc | 2 +- ly/engraver-init.ly | 12 ++++---- mf/GNUmakefile | 9 ++++-- mf/merge.pe | 16 ++++++++++ mf/parmesan-timesig.mf | 44 ++++++++++++++-------------- scripts/convert-ly.py | 1 + 17 files changed, 204 insertions(+), 40 deletions(-) create mode 100644 lily/freetype.cc create mode 100644 lily/include/freetype.hh create mode 100644 lily/open-type-font.cc create mode 100644 mf/merge.pe diff --git a/ChangeLog b/ChangeLog index ba16420e3c..53fe7fa7b8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2004-12-11 Han-Wen Nienhuys + + * 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 * configure.in (PKG_CONFIG_PATH): Remove stray `i'. Check for diff --git a/config.make.in b/config.make.in index 55ff72debc..ade4f410e2 100644 --- a/config.make.in +++ b/config.make.in @@ -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@ diff --git a/configure.in b/configure.in index 80fc829506..a2d1125427 100644 --- a/configure.in +++ b/configure.in @@ -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]) diff --git a/lily/afm.cc b/lily/afm.cc index 6f9fe444e1..27a284d0a6 100644 --- a/lily/afm.cc +++ b/lily/afm.cc @@ -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 (); } diff --git a/lily/all-font-metrics.cc b/lily/all-font-metrics.cc index 4540994a3a..63658d6be3 100644 --- a/lily/all-font-metrics.cc +++ b/lily/all-font-metrics.cc @@ -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 (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 index 0000000000..a966bf3bf9 --- /dev/null +++ b/lily/freetype.cc @@ -0,0 +1,25 @@ +/* + freetype.cc -- implement Freetype routines. + + source file of the GNU LilyPond music typesetter + + (c) 2004 Han-Wen Nienhuys + +*/ + +#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"); + } +} + diff --git a/lily/include/all-font-metrics.hh b/lily/include/all-font-metrics.hh index bb690d66e7..0ea6294573 100644 --- a/lily/include/all-font-metrics.hh +++ b/lily/include/all-font-metrics.hh @@ -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 index 0000000000..2be35459c6 --- /dev/null +++ b/lily/include/freetype.hh @@ -0,0 +1,20 @@ +/* + freetype.hh -- declare Freetype global settings. + + source file of the GNU LilyPond music typesetter + + (c) 2004 Han-Wen Nienhuys + +*/ + +#ifndef FREETYPE_HH +#define FREETYPE_HH + +#include +#include FT_FREETYPE_H + +void init_freetype(); +extern FT_Library freetype2_library; + +#endif /* FREETYPE_HH */ + diff --git a/lily/include/lily-proto.hh b/lily/include/lily-proto.hh index 778dbf01bf..1ceb002c6f 100644 --- a/lily/include/lily-proto.hh +++ b/lily/include/lily-proto.hh @@ -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; diff --git a/lily/main.cc b/lily/main.cc index 71c45cfa25..f0a209bbde 100644 --- a/lily/main.cc +++ b/lily/main.cc @@ -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 index 0000000000..c08e897759 --- /dev/null +++ b/lily/open-type-font.cc @@ -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 + +*/ +#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_); +} diff --git a/lily/time-signature.cc b/lily/time-signature.cc index c048ae522c..ba2a32cf33 100644 --- a/lily/time-signature.cc +++ b/lily/time-signature.cc @@ -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); diff --git a/ly/engraver-init.ly b/ly/engraver-init.ly index c901b285e0..e056216422 100644 --- a/ly/engraver-init.ly +++ b/ly/engraver-init.ly @@ -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 diff --git a/mf/GNUmakefile b/mf/GNUmakefile index d0736af0c0..fdd7f503fb 100644 --- a/mf/GNUmakefile +++ b/mf/GNUmakefile @@ -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 index 0000000000..e0fe623406 --- /dev/null +++ b/mf/merge.pe @@ -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"); + diff --git a/mf/parmesan-timesig.mf b/mf/parmesan-timesig.mf index cf03e8f77b..cc7f939a0e 100644 --- a/mf/parmesan-timesig.mf +++ b/mf/parmesan-timesig.mf @@ -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") diff --git a/scripts/convert-ly.py b/scripts/convert-ly.py index 82a0394609..5cab61bfe6 100644 --- a/scripts/convert-ly.py +++ b/scripts/convert-ly.py @@ -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 -- 2.39.5