From 49465d11fb5e62a976e41768f142ef0fb58c08c3 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Thu, 16 Dec 2004 23:57:31 +0000 Subject: [PATCH] * scm/output-tex.scm (named-glyph): new function. This fixes TeX output. * scm/framework-tex.scm (otf-font-load-command): load subfonts. (tex-font-command-raw): new function. * lily/include/virtual-font-metric.hh (Module): remove file * lily/virtual-font-metric.cc (Module): remove file. * lily/open-type-font.cc (LY_DEFINE): ly:otf-font-glyph-info (get_indexed_char): read bbox from lily table if present. --- ChangeLog | 23 ++++ buildscripts/mf-to-table.py | 21 ++-- lily/include/open-type-font.hh | 8 +- lily/include/stem.hh | 4 +- lily/include/tuplet-bracket.hh | 15 +-- lily/include/virtual-font-metric.hh | 40 ------- lily/open-type-font.cc | 100 +++++++++++----- lily/paper-def.cc | 33 +---- lily/score-engraver.cc | 13 +- lily/stem.cc | 8 +- lily/sustain-pedal.cc | 6 +- lily/text-item.cc | 1 - lily/tuplet-bracket.cc | 24 ++-- lily/virtual-font-metric.cc | 179 ---------------------------- mf/GNUmakefile | 3 + mf/feta-beugel.mf | 18 +-- scm/define-grobs.scm | 4 +- scm/framework-tex.scm | 39 +++--- scm/output-tex.scm | 16 ++- scm/safe-lily.scm | 4 +- 20 files changed, 196 insertions(+), 363 deletions(-) delete mode 100644 lily/include/virtual-font-metric.hh delete mode 100644 lily/virtual-font-metric.cc diff --git a/ChangeLog b/ChangeLog index e6e82d4a31..22db230b14 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,26 @@ +2004-12-17 Han-Wen Nienhuys + + * scm/output-tex.scm (named-glyph): new function. This fixes TeX output. + + * scm/framework-tex.scm (otf-font-load-command): load subfonts. + (tex-font-command-raw): new function. + + * lily/include/virtual-font-metric.hh (Module): remove file + + * lily/virtual-font-metric.cc (Module): remove file. + + + * lily/open-type-font.cc (LY_DEFINE): ly:otf-font-glyph-info + (get_indexed_char): read bbox from lily table if present. + +2004-12-16 Han-Wen Nienhuys + + * mf/GNUmakefile ($(outdir)/aybabtu.subfonts): rule for + aybabtu.subfonts + + * mf/feta-beugel.mf (y): don't number consecutively, instead, use + global glyphname. Enables more than 64 glyphs in the OTF. + 2004-12-16 Jan Nieuwenhuizen * scm/font.scm (add-music-fonts): Load aybabtu iso all separate diff --git a/buildscripts/mf-to-table.py b/buildscripts/mf-to-table.py index e19a96b0ef..97effe82ce 100644 --- a/buildscripts/mf-to-table.py +++ b/buildscripts/mf-to-table.py @@ -63,7 +63,10 @@ font_family = 'feta' def parse_logfile (fn): (autolines, deps) = read_log_file (fn) charmetrics = [] - global_info = {} + + global_info = { + 'filename' : os.path.splitext (os.path.basename (fn))[0] + } group = '' for l in autolines: @@ -171,14 +174,18 @@ def write_character_lisp_table (file, global_info, charmetrics): f = 1.0 s = """(%s . ((bbox . (%f %f %f %f)) + (subfont . "%s") + (subfont-index . %d) (attachment . (%f . %f)))) """ %(charmetric['name'], - -charmetric['breapth'] * f, - -charmetric['depth'] * f, - charmetric['width'] * f, - charmetric['height'] * f, - charmetric['wx'], - charmetric['wy']) + -charmetric['breapth'] * f, + -charmetric['depth'] * f, + charmetric['width'] * f, + charmetric['height'] * f, + global_info['filename'], + charmetric['code'], + charmetric['wx'], + charmetric['wy']) return s diff --git a/lily/include/open-type-font.hh b/lily/include/open-type-font.hh index a369d48494..1f9890e342 100644 --- a/lily/include/open-type-font.hh +++ b/lily/include/open-type-font.hh @@ -15,7 +15,7 @@ #include "font-metric.hh" typedef std::map Index_to_charcode_map; -//typedef std::map Glyph_name_to_charcode_map; +typedef std::map Glyph_name_to_index_map; class Open_type_font : public Font_metric { @@ -25,10 +25,14 @@ class Open_type_font : public Font_metric SCM lily_character_table_; SCM lily_global_table_; Index_to_charcode_map index_to_charcode_map_; - //Glyph_name_to_charcode_map glyph_name_to_charcode_map_; + Glyph_name_to_index_map glyph_name_to_index_map_; Open_type_font (FT_Face); public: + SCM get_subfonts () const; + SCM get_global_table () const; + SCM get_char_table () const; + static SCM make_otf (String); virtual ~Open_type_font(); virtual Offset attachment_point (String) const; diff --git a/lily/include/stem.hh b/lily/include/stem.hh index b9134d120f..fb5acd4374 100644 --- a/lily/include/stem.hh +++ b/lily/include/stem.hh @@ -42,9 +42,9 @@ public: static void set_spacing_hints (Grob *); DECLARE_SCHEME_CALLBACK (print, (SCM)); - DECLARE_SCHEME_CALLBACK (off_callback, (SCM element, SCM axis)); + DECLARE_SCHEME_CALLBACK (offset_callback, (SCM element, SCM axis)); DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM)); - DECLARE_SCHEME_CALLBACK (dim_callback, (SCM smob, SCM axis)); + DECLARE_SCHEME_CALLBACK (width_callback, (SCM smob, SCM axis)); DECLARE_SCHEME_CALLBACK (height, (SCM, SCM)); private: diff --git a/lily/include/tuplet-bracket.hh b/lily/include/tuplet-bracket.hh index 620f6b28cc..e3f460dbb8 100644 --- a/lily/include/tuplet-bracket.hh +++ b/lily/include/tuplet-bracket.hh @@ -10,27 +10,18 @@ #include "lily-guile.hh" #include "lily-proto.hh" -/* - - TODO: quantise, we don't want to collide with staff lines. - (or should we be above staff?) - - todo: handle breaking elegantly. -*/ class Tuplet_bracket { public: + DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM )); + DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM )); DECLARE_SCHEME_CALLBACK (print, (SCM )); + static bool has_interface (Grob*); - static void add_column (Grob*me,Item*); static void add_beam (Grob*me,Grob*); static Grob *parallel_beam (Grob *me, Link_array const&cols, bool *equally_long); static void calc_position_and_height (Grob*,Real*,Real *dy); - - DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM )); - - DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM )); static Stencil make_bracket (Grob *me, Axis protusion_axis, Offset dz, Drul_array height, Interval gap, Drul_array widen, diff --git a/lily/include/virtual-font-metric.hh b/lily/include/virtual-font-metric.hh deleted file mode 100644 index 200c1ff02b..0000000000 --- a/lily/include/virtual-font-metric.hh +++ /dev/null @@ -1,40 +0,0 @@ - -/* -virtual-font-metric.hh -- declare Virtual_font_metric - -source file of the GNU LilyPond music typesetter - -(c) 2002--2004 Han-Wen Nienhuys - - */ - -#ifndef VIRTUAL_FONT_METRIC_HH -#define VIRTUAL_FONT_METRIC_HH - -#include "font-metric.hh" - -class Virtual_font_metric : public Font_metric -{ - SCM font_list_; - -public: - SCM get_font_list () const; - Virtual_font_metric (SCM namelist); - virtual Real design_size () const; - virtual int count () const; - virtual Box get_indexed_char (int ascii) const; - virtual Box get_ascii_char (int ascii) const; - virtual Stencil get_indexed_char_stencil (int ascii) const; - virtual Stencil get_ascii_char_stencil (int ascii) const; - virtual Offset get_indexed_wxwy (int) const; - virtual int name_to_index (String)const; - virtual Stencil find_by_name (String) const; - virtual String coding_scheme () const; - -protected: - virtual void derived_mark () const; -}; - - -#endif /* VIRTUAL_FONT_METRIC_HH */ - diff --git a/lily/open-type-font.cc b/lily/open-type-font.cc index 741db31b43..9d0154a771 100644 --- a/lily/open-type-font.cc +++ b/lily/open-type-font.cc @@ -15,7 +15,7 @@ #include "warn.hh" #include "open-type-font.hh" #include "dimensions.hh" - +#include "modified-font-metric.hh" const Real point_constant = 1 PT; @@ -62,7 +62,7 @@ load_scheme_table (char const *tag_str, FT_Face face) } -Index_to_charcode_map +Index_to_charcode_map make_index_to_charcode_map (FT_Face face) { Index_to_charcode_map m; @@ -75,29 +75,6 @@ make_index_to_charcode_map (FT_Face face) return m; } -#if 0 -Glyph_name_to_charcode_map -make_glyph_name_to_charcode_map (FT_Face face) -{ - Glyph_name_to_charcode_map m; - FT_ULong charcode; - FT_UInt gindex; - char buffer[1024]; - - for (charcode = FT_Get_First_Char (face, &gindex); gindex != 0; - charcode = FT_Get_Next_Char (face, charcode, &gindex)) - { - if (FT_Get_Glyph_Name (face, gindex, buffer, sizeof (buffer) - 1)) - { - programming_error ("no glyph name"); - continue; - } - m[String (buffer)] = charcode; - } - return m; -} -#endif - Open_type_font::~Open_type_font() { FT_Done_Face (face_); @@ -124,7 +101,6 @@ Open_type_font::make_otf (String str) return otf->self_scm (); } - Open_type_font::Open_type_font (FT_Face face) { face_ = face; @@ -136,8 +112,6 @@ Open_type_font::Open_type_font (FT_Face face) lily_global_table_ = alist_to_hashq (load_scheme_table ("LILY", face_)); lily_subfonts_ = load_scheme_table ("LILF", face_); index_to_charcode_map_ = make_index_to_charcode_map (face_); - - //glyph_name_to_charcode_map_ = make_glyph_name_to_charcode_map (face_); } void @@ -159,16 +133,47 @@ Open_type_font::attachment_point (String glyph_name) const return o; SCM char_alist = entry; - - SCM att_scm = scm_cdr (scm_assq (ly_symbol2scm ("attachment"), char_alist)); return point_constant * ly_scm2offset (att_scm); } + Box Open_type_font::get_indexed_char (int signed_idx) const { + if (SCM_HASHTABLE_P (lily_character_table_)) + { + const int len =256; + char name[len]; + int code = FT_Get_Glyph_Name (face_, signed_idx, name, len); + if (code) + { + warning ("FT_Get_Glyph_Name() returned error"); + } + + SCM sym = ly_symbol2scm (name); + SCM alist = scm_hashq_ref (lily_character_table_, sym, SCM_BOOL_F); + + if (alist != SCM_BOOL_F) + { + SCM bbox = scm_cdr (scm_assq (ly_symbol2scm ("bbox"), alist)); + + Box b; + b[X_AXIS][LEFT] = scm_to_double (scm_car (bbox)); + bbox = scm_cdr (bbox); + b[Y_AXIS][LEFT] = scm_to_double (scm_car (bbox)); + bbox = scm_cdr (bbox); + b[X_AXIS][RIGHT] = scm_to_double (scm_car (bbox)); + bbox = scm_cdr (bbox); + b[Y_AXIS][RIGHT] = scm_to_double (scm_car (bbox)); + bbox = scm_cdr (bbox); + + b.scale (point_constant); + return b; + } + } + FT_UInt idx = signed_idx; FT_Load_Glyph (face_, idx, @@ -201,7 +206,7 @@ Open_type_font::index_to_charcode (int i) const #if 0 unsigned -Open_type_font::glyph_name_to_charcode (String glyph_name) const +Open_type_font::glyph_name_to_index (String glyph_name) const { return ((Open_type_font*) this)->glyph_name_to_charcode_map_[glyph_name]; } @@ -233,3 +238,36 @@ LY_DEFINE (ly_font_sub_fonts, "ly:font-sub-fonts", 1, 0, 0, return fm->sub_fonts (); } +LY_DEFINE (ly_otf_font_glyph_info, "ly:otf-font-glyph-info", 2, 0, 0, + (SCM font, SCM glyph), + "Given the font metric @var{font} of an OpenType font, return the " + "information about named glyph @var{glyph} (a string)") +{ + Modified_font_metric * fm + = dynamic_cast (unsmob_metrics (font)); + Open_type_font * otf = dynamic_cast (fm->original_font ()); + SCM_ASSERT_TYPE (otf, font, SCM_ARG1, __FUNCTION__, "OTF font-metric"); + SCM_ASSERT_TYPE (scm_is_string (glyph), glyph, SCM_ARG1, + __FUNCTION__, "string"); + + SCM sym = scm_string_to_symbol (glyph); + return scm_hashq_ref (otf->get_char_table (), sym, SCM_EOL); +} + +SCM +Open_type_font::get_char_table () const +{ + return lily_character_table_; +} + +SCM +Open_type_font::get_subfonts () const +{ + return lily_subfonts_; +} + +SCM +Open_type_font::get_global_table () const +{ + return lily_global_table_; +} diff --git a/lily/paper-def.cc b/lily/paper-def.cc index 401b824f28..6b89f107cb 100644 --- a/lily/paper-def.cc +++ b/lily/paper-def.cc @@ -10,7 +10,6 @@ #include "ly-module.hh" #include "output-def.hh" #include "modified-font-metric.hh" -#include "virtual-font-metric.hh" Real output_scale (Output_def *od) @@ -27,8 +26,6 @@ find_scaled_font (Output_def *mod, Font_metric *f, Real m, return find_scaled_font (mod->parent_, f, m, font_encoding, input_encoding); Real lookup_mag = m; - if (!dynamic_cast (f)) - lookup_mag /= output_scale (mod); SCM font_table = mod->lookup_variable (ly_symbol2scm ("scaled-fonts")); if (scm_hash_table_p (font_table) != SCM_BOOL_T) @@ -47,35 +44,7 @@ find_scaled_font (Output_def *mod, Font_metric *f, Real m, else sizes = SCM_EOL; - /* Hmm. We're chaining font - metrics. Should consider whether to - merge virtual-font and scaled_font. */ - SCM val = SCM_EOL; - if (Virtual_font_metric * vf = dynamic_cast (f)) - { - /* For fontify_atom (), the magnification and name must be known - at the same time. That's impossible for - - Scaled (Virtual_font (Font1,Font2)) - - so we replace by - - Virtual_font (Scaled (Font1), Scaled (Font2)) */ - SCM lst = SCM_EOL; - SCM *t = &lst; - for (SCM s = vf->get_font_list (); scm_is_pair (s); s = scm_cdr (s)) - { - Font_metric *scaled - = find_scaled_font (mod, unsmob_metrics (scm_car (s)), m, - font_encoding, input_encoding); - *t = scm_cons (scaled->self_scm (), SCM_EOL); - t = SCM_CDRLOC (*t); - } - - vf = new Virtual_font_metric (lst); - val = vf->self_scm (); - } - else - val = Modified_font_metric::make_scaled_font_metric (f, lookup_mag, + SCM val = Modified_font_metric::make_scaled_font_metric (f, lookup_mag, font_encoding, input_encoding); diff --git a/lily/score-engraver.cc b/lily/score-engraver.cc index fb97fcf6f2..d44f9d3588 100644 --- a/lily/score-engraver.cc +++ b/lily/score-engraver.cc @@ -102,11 +102,14 @@ Score_engraver::initialize () { Font_metric *fm = all_fonts_global->find_otf (MUSIC_FONT); if (!fm) - error (_f ("cannot find `%s'", MUSIC_FONT ".otf") - + "\n" - + _ ("Music font has not been installed properly.") - + _ ("Aborting")); - + { + error (_f ("cannot find `%s'", MUSIC_FONT ".otf") + + "\n" + + _ ("Music font has not been installed properly.\n") + + _f ("Search path `%s'\n", global_path.to_string ().to_str0()) + + _ ("Aborting")); + } + if (!scm_is_string (ly_kpathsea_find_file (scm_makfrom0str ("ecrm10.pfa"))) && (!scm_is_string (ly_kpathsea_find_file (scm_makfrom0str ("lmr10.pfb"))))) error (_f ("cannot find `%s'", "ecrm10.pfa") diff --git a/lily/stem.cc b/lily/stem.cc index eb8d47ef8f..b098b38af7 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -592,9 +592,9 @@ Stem::flag (Grob *me) return flag; } -MAKE_SCHEME_CALLBACK (Stem,dim_callback,2); +MAKE_SCHEME_CALLBACK (Stem,width_callback,2); SCM -Stem::dim_callback (SCM e, SCM ax) +Stem::width_callback (SCM e, SCM ax) { Axis a = (Axis) scm_to_int (ax); assert (a == X_AXIS); @@ -714,9 +714,9 @@ Stem::print (SCM smob) /* move the stem to right of the notehead if it is up. */ -MAKE_SCHEME_CALLBACK (Stem, off_callback, 2); +MAKE_SCHEME_CALLBACK (Stem, offset_callback, 2); SCM -Stem::off_callback (SCM element_smob, SCM) +Stem::offset_callback (SCM element_smob, SCM) { Grob *me = unsmob_grob (element_smob); Real r = 0.0; diff --git a/lily/sustain-pedal.cc b/lily/sustain-pedal.cc index 5537069fd4..fa81ff3bd8 100644 --- a/lily/sustain-pedal.cc +++ b/lily/sustain-pedal.cc @@ -26,6 +26,10 @@ */ + +/* + FIXME. Need to use markup. + */ struct Sustain_pedal { public: @@ -48,7 +52,7 @@ Sustain_pedal::print (SCM smob) for (int i = 0; i < text.length (); i++) { - String idx ("pedal-"); + String idx ("pedal."); if (text.cut_string (i, 3) == "Ped") { idx += "Ped"; diff --git a/lily/text-item.cc b/lily/text-item.cc index 47cfa06269..6c7b0eff8d 100644 --- a/lily/text-item.cc +++ b/lily/text-item.cc @@ -14,7 +14,6 @@ #include "warn.hh" #include "grob.hh" #include "font-interface.hh" -#include "virtual-font-metric.hh" #include "output-def.hh" #include "modified-font-metric.hh" #include "ly-module.hh" diff --git a/lily/tuplet-bracket.cc b/lily/tuplet-bracket.cc index f074f3a68e..cab2e673ba 100644 --- a/lily/tuplet-bracket.cc +++ b/lily/tuplet-bracket.cc @@ -23,10 +23,17 @@ */ -#include "tuplet-bracket.hh" +/* + + TODO: quantise, we don't want to collide with staff lines. + (or should we be above staff?) + + todo: handle breaking elegantly. +*/ #include +#include "tuplet-bracket.hh" #include "line-interface.hh" #include "beam.hh" #include "warn.hh" @@ -297,12 +304,11 @@ Tuplet_bracket::make_bracket (Grob *me, // for line properties. use first -> last note for slope, and then correct for disturbing notes in between. */ void -Tuplet_bracket::calc_position_and_height (Grob*me,Real *offset, Real * dy) +Tuplet_bracket::calc_position_and_height (Grob*me, Real *offset, Real * dy) { Link_array columns = Pointer_group_interface__extract_grobs (me, (Grob*)0, "note-columns"); - SCM cols = me->get_property ("note-columns"); Grob * commony = common_refpoint_of_list (cols, me, Y_AXIS); Grob * commonx = common_refpoint_of_list (cols, me, X_AXIS); @@ -495,7 +501,7 @@ Tuplet_bracket::after_line_breaking (SCM smob) else if (!scm_is_number (rp) && !scm_is_number (lp)) { lp = scm_make_real (offset); - rp = scm_make_real (offset +dy); + rp = scm_make_real (offset + dy); } me->set_property ("left-position", lp); @@ -537,7 +543,11 @@ Tuplet_bracket::add_column (Grob*me, Item*n) -ADD_INTERFACE (Tuplet_bracket,"tuplet-bracket-interface", - "A bracket with a number in the middle, used for tuplets.", - "note-columns bracket-flare edge-height shorten-pair padding left-position right-position bracket-visibility number-visibility thickness direction"); +ADD_INTERFACE (Tuplet_bracket, + "tuplet-bracket-interface", + "A bracket with a number in the middle, used for tuplets.", + + "note-columns bracket-flare edge-height shorten-pair " + "padding left-position right-position bracket-visibility " + "number-visibility thickness direction"); diff --git a/lily/virtual-font-metric.cc b/lily/virtual-font-metric.cc deleted file mode 100644 index a2fd658558..0000000000 --- a/lily/virtual-font-metric.cc +++ /dev/null @@ -1,179 +0,0 @@ -/* - virtual-font-metric.cc -- implement Virtual_font_metric - -source file of the GNU LilyPond music typesetter - -(c) 2002--2004 Han-Wen Nienhuys - - */ - -#include "virtual-font-metric.hh" - -#include "all-font-metrics.hh" -#include "stencil.hh" -#include "output-def.hh" -#include "warn.hh" - -/* - passing DEF is ughish. Should move into layoutdef? - */ -Virtual_font_metric::Virtual_font_metric (SCM font_list) -{ - font_list_ = SCM_EOL; - SCM *tail = &font_list_; - - SCM mag = SCM_EOL; - SCM name_list = SCM_EOL; - SCM *name_tail = &name_list; - - for (SCM s = font_list; scm_is_pair (s); s = scm_cdr (s)) - { - if (Font_metric *fm = unsmob_metrics (scm_car (s))) - { - *tail = scm_cons (scm_car (s),SCM_EOL); - tail = SCM_CDRLOC (*tail); - - if (!scm_is_number (mag)) - /* Ugh. */ - mag = scm_cdr (fm->description_); - - *name_tail = scm_cons (scm_car (fm->description_), SCM_EOL); - name_tail = SCM_CDRLOC (*name_tail); - } - } - - description_ = scm_cons (name_list, mag); -} - -Real -Virtual_font_metric::design_size () const -{ - return unsmob_metrics (scm_car (font_list_))-> design_size (); -} - -void -Virtual_font_metric::derived_mark ()const -{ - scm_gc_mark (font_list_); -} - -int -Virtual_font_metric::count () const -{ - int k = 0; - for (SCM s = font_list_; scm_is_pair (s); s = scm_cdr (s)) - k += unsmob_metrics (scm_car (s))->count (); - return k; -} - -Stencil -Virtual_font_metric::find_by_name (String glyph) const -{ - Stencil m; - for (SCM s = font_list_; m.is_empty () && scm_is_pair (s); s = scm_cdr (s)) - m = unsmob_metrics (scm_car (s))->find_by_name (glyph); - - return m; -} - -Box -Virtual_font_metric::get_ascii_char (int) const -{ - programming_error ("Virtual font metric cannot be indexed by ASCII."); - return Box (); -} - -Stencil -Virtual_font_metric::get_ascii_char_stencil (int ) const -{ - programming_error ("Virtual font metric cannot be indexed by ASCII."); - return Stencil (); -} - -Offset -Virtual_font_metric::get_indexed_wxwy (int code) const -{ - int total = 0; - for (SCM s = font_list_; scm_is_pair (s); s = scm_cdr (s)) - { - Font_metric *fm = unsmob_metrics (scm_car (s)); - if (code < total + fm->count ()) - return fm->get_indexed_wxwy (code - total); - total += fm->count (); - } - return Offset (0,0); -} - -Box -Virtual_font_metric::get_indexed_char (int code) const -{ - int total = 0; - for (SCM s = font_list_; scm_is_pair (s); s = scm_cdr (s)) - { - Font_metric *fm = unsmob_metrics (scm_car (s)); - if (code < total + fm->count ()) - return fm->get_indexed_char (code - total); - total += fm->count (); - } - return Box (); -} - -int -Virtual_font_metric::name_to_index (String glyph) const -{ - Stencil m; - int total = 0; - for (SCM s = font_list_; m.is_empty () && scm_is_pair (s); s = scm_cdr (s)) - { - Font_metric *m = unsmob_metrics (scm_car (s)); - int k = m->name_to_index (glyph); - if (k >= 0) - return total + k; - - total += m->count (); - } - return -1; -} - -Stencil -Virtual_font_metric::get_indexed_char_stencil (int code) const -{ - Stencil m ; - int total = 0; - - for (SCM s = font_list_; scm_is_pair (s); s = scm_cdr (s)) - { - Font_metric *fm = unsmob_metrics (scm_car (s)); - if (code < total + fm->count ()) - { - /* Ugh. */ - m = fm->get_indexed_char_stencil (code - total); - break; - } - total += fm->count (); - } - return m; -} - - -SCM -Virtual_font_metric::get_font_list () const -{ - return font_list_; -} - -LY_DEFINE (ly_make_virtual_font, "ly:make-virtual-font", 0, 0, 1, - (SCM args), - "Make a virtual font metric from @var{args}, " - "a list of font objects.") -{ - Virtual_font_metric *fm = new Virtual_font_metric (args); - return scm_gc_unprotect_object (fm->self_scm ()); -} - -String -Virtual_font_metric::coding_scheme () const -{ - Font_metric *fm = unsmob_metrics (scm_car (font_list_)); - return fm->coding_scheme (); -} diff --git a/mf/GNUmakefile b/mf/GNUmakefile index 7258626958..2508055660 100644 --- a/mf/GNUmakefile +++ b/mf/GNUmakefile @@ -58,7 +58,10 @@ $(outdir)/%.otf: $(outdir)/%.pe $(outdir)/%.otf-table: $(outdir)/%.lisp cat $< $(subst parmesan,feta,$<) > $@ +$(outdir)/aybabtu.otf: $(outdir)/aybabtu.subfonts +$(outdir)/aybabtu.subfonts: + echo $(subst .mf,,$(wildcard feta-braces-[a-z].mf)) > $@ $(PE_SCRIPTS): $(PYTHON) $(buildscript-dir)/gen-bigcheese-scripts.py --dir=$(outdir) diff --git a/mf/feta-beugel.mf b/mf/feta-beugel.mf index ba5840bfbe..393d6a372d 100644 --- a/mf/feta-beugel.mf +++ b/mf/feta-beugel.mf @@ -25,11 +25,11 @@ mode_setup; -save code; +save code, braces_per_font; code := 64; +braces_per_font := 64; - -def draw_brace (expr height_sharp, width_sharp, slt_sharp) = +def draw_brace (expr height_sharp, width_sharp, slt_sharp, brace_number) = save pendir, height, width, thin, thick, slt; save penangle; @@ -38,8 +38,8 @@ def draw_brace (expr height_sharp, width_sharp, slt_sharp) = slt# := slt_sharp; %% +1 is needed because fet_beginchar increments after dumping the strings. -fet_beginchar ("brace number " & (decimal (code + 1)), - "brace" & decimal code) +fet_beginchar ("brace number " & (decimal (brace_number)), + "brace" & decimal(brace_number)) set_char_box (0, width#, height#/2, height#/2); @@ -79,17 +79,20 @@ y := 10pt#; + for i := 0 step 1 until font_count: %% We can't store more than 64 (65?) height dimensions in a TFM %% file, so we make small files. + save number; + + number := braces_per_font * i; for j := 0 step 1 until 63: % message "l: "&decimal l; % note: define_pixels (x) multiplies x by hppp, % must never get bigger than infinity y := y + increment; - if y > infinity/hppp: message "Resolution and/or magnification is too high"; error please report: ; @@ -103,8 +106,9 @@ for i := 0 step 1 until font_count: increment := x / 10; linethickness := min (0.5pt#, y/150); if i = font_count: - draw_brace (y, x, linethickness); + draw_brace (y, x, linethickness, number); fi + number := number + 1; endfor; endfor diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index 45eaf03288..2adda3e4c4 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -1045,8 +1045,8 @@ ;; The 'extreme case' minima (beamed-extreme-minimum-free-lengths . (2.0 1.25)) - (X-offset-callbacks . (,Stem::off_callback)) - (X-extent-callback . ,Stem::dim_callback) + (X-offset-callbacks . (,Stem::offset_callback)) + (X-extent-callback . ,Stem::width_callback) (Y-extent-callback . ,Stem::height) (Y-offset-callbacks . (,Staff_symbol_referencer::callback)) (meta . ((interfaces . (stem-interface font-interface item-interface )))) diff --git a/scm/framework-tex.scm b/scm/framework-tex.scm index 1d20344a43..58d1bcdf01 100644 --- a/scm/framework-tex.scm +++ b/scm/framework-tex.scm @@ -51,41 +51,40 @@ 'pre "" 'post)) + +(define-public (tex-font-command-raw name magnification) + (string-append + "magfont" + (string-encode-integer + (hash name 1000000)) + "m" + (string-encode-integer + (inexact->exact (round (* 1000 magnification)))))) + +(define-public (tex-font-command font) + (tex-font-command-raw + (ly:font-file-name font) (ly:font-magnification font))) + + (define (otf-font-load-command paper font) (let* - ((sub-fonts (ly:font-sub-fonts font)) - (base-name (tex-font-command font))) + ((sub-fonts (ly:font-sub-fonts font))) (string-append (apply string-append (map (lambda (sub-name) (string-append - "\\font\\" (string-append base-name (digits->letters sub-name)) "=" - sub-name + "\\font\\" (tex-font-command-raw sub-name (ly:font-magnification font)) + "=" sub-name " scaled " (ly:number->string (inexact->exact (round (* 1000 (ly:font-magnification font) (ly:paper-outputscale paper))))) "%\n")) - sub-fonts))) - - "\\def\\" (tex-font-command font) "{" - (apply string-append - (map (lambda (name) - "\\def\\" (string-append base-name (digits->letters name)) - ) - )))) + sub-fonts))))) -(define-public (tex-font-command font) - (string-append - "magfont" - (string-encode-integer - (hashq (ly:font-file-name font) 1000000)) - "m" - (string-encode-integer - (inexact->exact (round (* 1000 (ly:font-magnification font))))))) (define (simple-font-load-command paper font) (let* ((coding-alist (ly:font-encoding-alist font)) diff --git a/scm/output-tex.scm b/scm/output-tex.scm index 0f4f5b4f95..615ca5f36a 100644 --- a/scm/output-tex.scm +++ b/scm/output-tex.scm @@ -91,15 +91,13 @@ (define (named-glyph font name) - (string-append "\\" (tex-font-command font) - "\\" - (string-append -; (digits->letters (ly:font-name font)) - (regexp-substitute/global - #f "[-\\._]" - (digits->letters name) - 'pre "" - 'post)))) + (let* + ((info (ly:otf-font-glyph-info font name))) + + (string-append "\\" (tex-font-command-raw + (assoc-get 'subfont info) + (ly:font-magnification font)) + "\\char" (number->string (assoc-get 'subfont-index info))))) (define (dashed-line thick on off dx dy) (embedded-ps (list 'dashed-line thick on off dx dy))) diff --git a/scm/safe-lily.scm b/scm/safe-lily.scm index 5baaf1c8b7..3ec1c8024f 100644 --- a/scm/safe-lily.scm +++ b/scm/safe-lily.scm @@ -263,9 +263,9 @@ Staff_symbol::print Staff_symbol_referencer::callback Stem::before_line_breaking - Stem::dim_callback + Stem::width_callback Stem::height - Stem::off_callback + Stem::offset_callback Stem::print Stem_tremolo::height Stem_tremolo::print -- 2.39.2