From 35442451531b25bd35ae9a12c26efe926f053937 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Mon, 13 Dec 2004 23:02:38 +0000 Subject: [PATCH] * buildscripts/gen-bigcheese-scripts.py (i): load .subfonts table. * lily/open-type-font.cc (LY_DEFINE): new function ly:font-sub-fonts * lily/include/font-metric.hh (struct Font_metric): new method sub_fonts() --- ChangeLog | 8 +++++ buildscripts/gen-bigcheese-scripts.py | 15 ++++++++ buildscripts/mf-to-table.py | 2 -- lily/font-metric.cc | 8 ++++- lily/include/font-metric.hh | 1 + lily/include/modified-font-metric.hh | 1 + lily/include/open-type-font.hh | 2 ++ lily/modified-font-metric.cc | 6 ++++ lily/open-type-font.cc | 49 ++++++++++++++++----------- scm/output-tex.scm | 27 +++++++++++++-- 10 files changed, 94 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index ab0ea7a7ec..beff39089b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2004-12-13 Han-Wen Nienhuys + * buildscripts/gen-bigcheese-scripts.py (i): load .subfonts table. + + * lily/open-type-font.cc (LY_DEFINE): new function + ly:font-sub-fonts + + * lily/include/font-metric.hh (struct Font_metric): new method + sub_fonts() + * lily/vaticana-ligature-engraver.cc (transform_heads): replace . with - in add.stem. diff --git a/buildscripts/gen-bigcheese-scripts.py b/buildscripts/gen-bigcheese-scripts.py index 01a1cc5b8e..8d590fe0e3 100644 --- a/buildscripts/gen-bigcheese-scripts.py +++ b/buildscripts/gen-bigcheese-scripts.py @@ -3,6 +3,7 @@ import sys import getopt import re import os +import string (options, files) = \ getopt.getopt (sys.argv[1:], @@ -59,6 +60,7 @@ endloop MergeFonts("feta-alphabet%(design_size)d.pfa"); MergeKern("feta-alphabet%(design_size)d.tfm"); +LoadTableFromFile("LILF", "%(name)s%(design_size)d.subfonts") LoadTableFromFile("LILC", "feta%(design_size)d.otf-table") LoadTableFromFile("LILY", "feta%(design_size)d.otf-gtable") @@ -68,6 +70,19 @@ Generate("%(name)s%(design_size)d.cff");''' % vars() path = os.path.join (outdir, name + '%d' % design_size + '.pe') open (path, 'w').write (script) + + subfonts = ['feta%(design_size)d', + 'parmesan%(design_size)d', + 'feta-alphabet%(design_size)d'] + + ns = [] + for s in subfonts: + ns.append (s % vars()) + + subfonts_str = string.join (ns) + + open (os.path.join (outdir, '%(name)s%(design_size)d.subfonts' % vars()), 'w').write (subfonts_str) + path = os.path.join (outdir, name + '%d' % design_size + '.dep') deps = r'''%(name)s%(design_size)d.otf: $(outdir)/feta%(design_size)d.pfa \ diff --git a/buildscripts/mf-to-table.py b/buildscripts/mf-to-table.py index 163f48d111..e19a96b0ef 100644 --- a/buildscripts/mf-to-table.py +++ b/buildscripts/mf-to-table.py @@ -153,8 +153,6 @@ def write_afm_metric (file, global_info, charmetrics): def write_tex_defs (file, global_info, charmetrics): - nm = global_info['font - ## nm = global_info['FontFamily'] nm = font_family for m in charmetrics: diff --git a/lily/font-metric.cc b/lily/font-metric.cc index e334548fbb..55084aad4d 100644 --- a/lily/font-metric.cc +++ b/lily/font-metric.cc @@ -183,7 +183,7 @@ LY_DEFINE (ly_font_index_to_charcode, "ly:font-index-to-charcode", SCM_ASSERT_TYPE (fm, font, SCM_ARG1, __FUNCTION__, "font-metric"); SCM_ASSERT_TYPE (scm_is_integer (index), index, SCM_ARG2, __FUNCTION__, "index"); - return scm_from_unsigned_integer (fm->index_to_charcode (ly_scm2int (index))); + return scm_from_unsigned_integer (fm->index_to_charcode (scm_to_int (index))); } LY_DEFINE (ly_font_glyph_name_to_charcode, "ly:font-glyph-name-to-charcode", @@ -329,3 +329,9 @@ Font_metric::attachment_point (String) const { return Offset (0, 0); } + +SCM +Font_metric::sub_fonts () const +{ + return SCM_EOL; +} diff --git a/lily/include/font-metric.hh b/lily/include/font-metric.hh index ad56d8f931..183815d42d 100644 --- a/lily/include/font-metric.hh +++ b/lily/include/font-metric.hh @@ -33,6 +33,7 @@ public: virtual Stencil get_indexed_char_stencil (int k) const; virtual Stencil get_ascii_char_stencil (int k) const; virtual String coding_scheme () const; + virtual SCM sub_fonts () const; DECLARE_SMOBS (Font_metric,); diff --git a/lily/include/modified-font-metric.hh b/lily/include/modified-font-metric.hh index 277d61f894..2d6215fc57 100644 --- a/lily/include/modified-font-metric.hh +++ b/lily/include/modified-font-metric.hh @@ -39,6 +39,7 @@ protected: Modified_font_metric (Font_metric *fm, Real magnification, String font_encoding, String input_encoding); + virtual SCM sub_fonts () const; virtual Real design_size () const; virtual void derived_mark () const; virtual Box get_indexed_char (int) const; diff --git a/lily/include/open-type-font.hh b/lily/include/open-type-font.hh index fddb9b2ce8..a369d48494 100644 --- a/lily/include/open-type-font.hh +++ b/lily/include/open-type-font.hh @@ -21,6 +21,7 @@ class Open_type_font : public Font_metric { FT_Face face_; /* handle to face object */ + SCM lily_subfonts_; SCM lily_character_table_; SCM lily_global_table_; Index_to_charcode_map index_to_charcode_map_; @@ -36,6 +37,7 @@ public: //virtual unsigned glyph_name_to_charcode (String) const; virtual unsigned index_to_charcode (int) const; virtual void derived_mark () const; + virtual SCM sub_fonts () const; #if 0 virtual int count () const; virtual int index_to_ascii (int) const; diff --git a/lily/modified-font-metric.cc b/lily/modified-font-metric.cc index bac7d43993..a28ae42a60 100644 --- a/lily/modified-font-metric.cc +++ b/lily/modified-font-metric.cc @@ -333,3 +333,9 @@ LY_DEFINE (ly_font_encoding, "ly:font-encoding", return ly_symbol2scm (fm->original_font ()->coding_scheme ().to_str0 ()); } +SCM +Modified_font_metric::sub_fonts () const +{ + return orig_->sub_fonts(); +} + diff --git a/lily/open-type-font.cc b/lily/open-type-font.cc index 4c5c9e24f1..36eeafb522 100644 --- a/lily/open-type-font.cc +++ b/lily/open-type-font.cc @@ -55,13 +55,13 @@ load_scheme_table (char const *tag_str, FT_Face face) String contents ((Byte const*)buffer, length); contents = "(quote (" + contents + "))"; - SCM alist = scm_c_eval_string (contents.to_str0 ()); - tab = alist_to_hashq (alist); + SCM expr = scm_c_eval_string (contents.to_str0 ()); free (buffer); } - return tab; + return expr; } + Index_to_charcode_map make_index_to_charcode_map (FT_Face face) { @@ -98,18 +98,6 @@ make_glyph_name_to_charcode_map (FT_Face face) } #endif -Open_type_font::Open_type_font (FT_Face face) -{ - face_ = face; - lily_character_table_ = SCM_EOL; - lily_global_table_ = SCM_EOL; - - lily_character_table_ = load_scheme_table ("LILC", face_); - lily_global_table_ = load_scheme_table ("LILY", face_); - index_to_charcode_map_ = make_index_to_charcode_map (face_); - //glyph_name_to_charcode_map_ = make_glyph_name_to_charcode_map (face_); -} - Open_type_font::~Open_type_font() { FT_Done_Face (face_); @@ -136,15 +124,19 @@ Open_type_font::make_otf (String str) return otf->self_scm (); } -Open_type_font::Open_type_font(FT_Face face) + +Open_type_font::Open_type_font (FT_Face face) { face_ = face; lily_character_table_ = SCM_EOL; lily_global_table_ = SCM_EOL; + + lily_character_table_ = alist_to_hashq (load_scheme_table ("LILC", 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_); - lily_character_table_ = load_scheme_table ("LILC", face_); - lily_global_table_ = load_scheme_table ("LILY", face_); - index_to_charcode_map_ = make_index_to_charcode_map (face_); + //glyph_name_to_charcode_map_ = make_glyph_name_to_charcode_map (face_); } void @@ -152,6 +144,7 @@ Open_type_font::derived_mark () const { scm_gc_mark (lily_character_table_); scm_gc_mark (lily_global_table_); + scm_gc_mark (lily_subfonts_); } Offset @@ -220,3 +213,21 @@ Open_type_font::design_size () const ly_symbol2scm ("staffsize"), SCM_BOOL_F); return scm_to_double (entry); } + + +SCM +Open_type_font::sub_fonts () const +{ + return lily_subfonts_; +} + +LY_DEFINE (ly_font_magnification, "ly:font-sub-fonts", 1, 0, 0, + (SCM font), + "Given the font metric @var{font}, return the " + "magnification, relative to the current outputscale.") +{ + Font_metric *fm = unsmob_metrics (font); + SCM_ASSERT_TYPE (fm, font, SCM_ARG1, __FUNCTION__, "font-metric"); + return scm_cdr (fm->description_); +} + diff --git a/scm/output-tex.scm b/scm/output-tex.scm index c8ac8ec04e..e4aab9f613 100644 --- a/scm/output-tex.scm +++ b/scm/output-tex.scm @@ -29,7 +29,7 @@ beam bracket dashed-slur - char + named-glyph dashed-line zigzag-line ez-ball @@ -89,9 +89,30 @@ (define (dashed-slur thick dash l) (embedded-ps (list 'dashed-slur thick dash `(quote ,l)))) -(define (char font i) +(define (digits->letters str) + (regexp-substitute/global + #f "([0-9])" str + 'pre + (lambda (match) + (make-string + 1 + (integer->char + (+ (char->integer #\A) + (- (char->integer #\0)) + (char->integer (string-ref (match:substring match 1) 0))) + ))) + 'post)) + +(define (named-glyph font name) (string-append "\\" (tex-font-command font) - "\\char" (ly:inexact->string i 10) " ")) + "\\" + (string-append +; (digits->letters (ly:font-name font)) + (regexp-substitute/global + #f "[\\._]" + (digits->letters name) + 'pre "" + 'post)))) (define (dashed-line thick on off dx dy) (embedded-ps (list 'dashed-line thick on off dx dy))) -- 2.39.2