From 277bf60e1ab493b9567ebc666e0baa1096924421 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sun, 12 Dec 2004 22:27:35 +0000 Subject: [PATCH] * lily/open-type-font.cc (attachment_point): new function. (load_table): read LILC table * buildscripts/gen-bigcheese-scripts.py (Module): new file. Generate FF scripts. --- buildscripts/gen-bigcheese-scripts.py | 4 +++- buildscripts/mf-to-table.py | 31 ++++++++++++++++++++---- lily/include/open-type-font.hh | 3 +++ lily/note-head.cc | 2 +- lily/open-type-font.cc | 34 ++++++++++++++++++--------- mf/GNUmakefile | 4 ++-- mf/feta-autometric.mf | 5 ++++ mf/feta-generic.mf | 10 ++++++++ 8 files changed, 73 insertions(+), 20 deletions(-) diff --git a/buildscripts/gen-bigcheese-scripts.py b/buildscripts/gen-bigcheese-scripts.py index 5c20f0209d..01a1cc5b8e 100644 --- a/buildscripts/gen-bigcheese-scripts.py +++ b/buildscripts/gen-bigcheese-scripts.py @@ -60,6 +60,7 @@ MergeFonts("feta-alphabet%(design_size)d.pfa"); MergeKern("feta-alphabet%(design_size)d.tfm"); LoadTableFromFile("LILC", "feta%(design_size)d.otf-table") +LoadTableFromFile("LILY", "feta%(design_size)d.otf-gtable") Generate("%(name)s%(design_size)d.otf"); Generate("%(name)s%(design_size)d.cff");''' % vars() @@ -71,6 +72,7 @@ Generate("%(name)s%(design_size)d.cff");''' % vars() deps = r'''%(name)s%(design_size)d.otf: $(outdir)/feta%(design_size)d.pfa \ $(outdir)/parmesan%(design_size)d.pfa \ - $(outdir)/feta-alphabet%(design_size)d.pfa feta%(design_size)d.otf-table + $(outdir)/feta-alphabet%(design_size)d.pfa feta%(design_size)d.otf-table \ + $(outdir)/feta-alphabet%(design_size)d.pfa feta%(design_size)d.otf-gtable ''' % vars() open (path, 'w').write (deps) diff --git a/buildscripts/mf-to-table.py b/buildscripts/mf-to-table.py index 63632ff899..e75b7c2efa 100644 --- a/buildscripts/mf-to-table.py +++ b/buildscripts/mf-to-table.py @@ -118,6 +118,9 @@ def parse_logfile (fn): global_info['Descender'] = '0' global_info['EncodingScheme'] = encoding + elif tags[0] == 'parameter': + global_info[tags[1]] = tags[2]; + return (global_info, charmetrics, deps) @@ -159,7 +162,7 @@ def write_tex_defs (file, global_info, charmetrics): file.write ('\\endinput\n') -def write_otf_lisp_table (file, global_info, charmetrics): +def write_character_lisp_table (file, global_info, charmetrics): def conv_char_metric (charmetric): f = 1.0 @@ -178,6 +181,20 @@ def write_otf_lisp_table (file, global_info, charmetrics): for c in charmetrics: file.write (conv_char_metric (c)) + + +def write_global_lisp_table (file, global_info): + str = '' + + keys = ['staffsize', 'stafflinethickness', 'staff_space', + 'linethickness', 'black_notehead_width', 'ledgerlinethickness', + 'blot_diameter' + ] + for k in keys: + str = str + "(%s . %s)\n" % (k,global_info[k]) + + file.write (str) + def write_ps_encoding (name, file, global_info, charmetrics): encs = ['.notdef'] * 256 @@ -271,10 +288,11 @@ Options: getopt.getopt (sys.argv[1:], 'a:d:hl:o:p:t:', ['enc=', 'afm=', 'outdir=', 'dep=', 'lisp=', + 'global-lisp=', 'tex=', 'ly=', 'debug', 'help', 'package=']) - -lisp_nm = '' +global_lisp_nm = '' +char_lisp_nm = '' enc_nm = '' texfile_nm = '' depfile_nm = '' @@ -292,7 +310,9 @@ for opt in options: elif o == '--tex' or o == '-t': texfile_nm = a elif o == '--lisp': - lisp_nm = a + char_lisp_nm = a + elif o == '--global-lisp': + global_lisp_nm = a elif o == '--enc': enc_nm = a elif o == '--ly' or o == '-l': @@ -330,7 +350,8 @@ for filenm in files: enc_name = 'FetaBraceEncoding' write_ps_encoding (enc_name, open (enc_nm, 'w'), g, m) - write_otf_lisp_table (open (lisp_nm, 'w'), g, m) + write_character_lisp_table (open (char_lisp_nm, 'w'), g, m) + write_global_lisp_table (open (global_lisp_nm, 'w'), g) if depfile_nm: write_deps (open (depfile_nm, 'wb'), deps, [base + '.dvi', base + '.pfa', base + '.pfb', diff --git a/lily/include/open-type-font.hh b/lily/include/open-type-font.hh index c6e4e0c740..5fe069e1af 100644 --- a/lily/include/open-type-font.hh +++ b/lily/include/open-type-font.hh @@ -16,7 +16,10 @@ class Open_type_font : public Font_metric { FT_Face face_; /* handle to face object */ + SCM lily_character_table_; + SCM lily_global_table_; + Open_type_font(); public: static SCM make_otf (String); diff --git a/lily/note-head.cc b/lily/note-head.cc index d2bd30b576..b5781a7a01 100644 --- a/lily/note-head.cc +++ b/lily/note-head.cc @@ -140,7 +140,7 @@ Note_head::stem_attachment_coordinate (Grob *me, Axis a) if (k >= 0) { Box b = fm->get_indexed_char (k); - Offset wxwy = fm->get_indexed_wxwy (k); + Offset wxwy = fm->attachment_point (key); Interval v = b[a]; if (!v.is_empty ()) return 2 * (wxwy[a] - v.center ()) / v.length (); diff --git a/lily/open-type-font.cc b/lily/open-type-font.cc index b72c242824..50710eb3af 100644 --- a/lily/open-type-font.cc +++ b/lily/open-type-font.cc @@ -39,6 +39,24 @@ load_table (char const *tag_str, FT_Face face, FT_ULong *length) return 0 ; } +SCM +load_scheme_table (char const *tag_str, FT_Face face) +{ + FT_ULong length = 0; + FT_Byte* buffer =load_table ("LILC", face, &length); + + SCM tab = SCM_EOL; + if (buffer) + { + String contents ((Byte const*)buffer, length); + contents = "(quote (" + contents + "))"; + + SCM alist = scm_c_eval_string (contents.to_str0()); + tab = alist_to_hashq (alist); + free (buffer); + } + return tab; +} SCM Open_type_font::make_otf (String str) @@ -57,30 +75,24 @@ Open_type_font::make_otf (String str) } - FT_ULong length = 0; - FT_Byte* buffer =load_table ("LILC", otf->face_, &length); - if (buffer) - { - String contents ((Byte const*)buffer, length); - contents = "(quote (" + contents + "))"; - - SCM alist = scm_c_eval_string (contents.to_str0()); - otf->lily_character_table_ = alist_to_hashq (alist); - free (buffer); - } + otf->lily_character_table_ = load_scheme_table ("LILC", otf->face_); + otf->lily_global_table_ = load_scheme_table ("LILY", otf->face_); + return otf->self_scm (); } Open_type_font::Open_type_font() { lily_character_table_ = SCM_EOL; + lily_global_table_ = SCM_EOL; } void Open_type_font::derived_mark () const { scm_gc_mark (lily_character_table_); + scm_gc_mark (lily_global_table_); } Offset diff --git a/mf/GNUmakefile b/mf/GNUmakefile index 7cb5f56f1e..49b70b3533 100644 --- a/mf/GNUmakefile +++ b/mf/GNUmakefile @@ -162,8 +162,8 @@ get-pfa: get-rpm-pfa ## ## todo: this also depends on .tfm, FIXME. -$(outdir)/%.lisp $(outdir)/%.afm $(outdir)/%.enc $(outdir)/%.tex $(outdir)/%list.ly $(outdir)/%.dep: $(outdir)/%.log $(outdir)/%.tfm - $(PYTHON) $(buildscript-dir)/mf-to-table.py --lisp=$(outdir)/$(