From c7be17948fb3aec4e57e21027a0eb98f05be43bb Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Mon, 13 Dec 2004 23:32:46 +0000 Subject: [PATCH] *** empty log message *** --- buildscripts/gen-bigcheese-scripts.py | 2 +- lily/open-type-font.cc | 15 ++++---- scm/framework-tex.scm | 53 ++++++++++++++++++++++++++- scm/output-tex.scm | 15 +------- 4 files changed, 62 insertions(+), 23 deletions(-) diff --git a/buildscripts/gen-bigcheese-scripts.py b/buildscripts/gen-bigcheese-scripts.py index 8d590fe0e3..4b066b22c5 100644 --- a/buildscripts/gen-bigcheese-scripts.py +++ b/buildscripts/gen-bigcheese-scripts.py @@ -77,7 +77,7 @@ Generate("%(name)s%(design_size)d.cff");''' % vars() ns = [] for s in subfonts: - ns.append (s % vars()) + ns.append ('"%s"' % (s % vars())) subfonts_str = string.join (ns) diff --git a/lily/open-type-font.cc b/lily/open-type-font.cc index 36eeafb522..9e78737405 100644 --- a/lily/open-type-font.cc +++ b/lily/open-type-font.cc @@ -55,10 +55,10 @@ load_scheme_table (char const *tag_str, FT_Face face) String contents ((Byte const*)buffer, length); contents = "(quote (" + contents + "))"; - SCM expr = scm_c_eval_string (contents.to_str0 ()); + tab = scm_c_eval_string (contents.to_str0 ()); free (buffer); } - return expr; + return tab; } @@ -130,7 +130,8 @@ Open_type_font::Open_type_font (FT_Face face) face_ = face; lily_character_table_ = SCM_EOL; lily_global_table_ = SCM_EOL; - + lily_subfonts_ = 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_); @@ -221,13 +222,13 @@ Open_type_font::sub_fonts () const return lily_subfonts_; } -LY_DEFINE (ly_font_magnification, "ly:font-sub-fonts", 1, 0, 0, +LY_DEFINE (ly_font_sub_fonts, "ly:font-sub-fonts", 1, 0, 0, (SCM font), - "Given the font metric @var{font}, return the " - "magnification, relative to the current outputscale.") + "Given the font metric @var{font} of an OpenType font, return the " + "names of the subfonts within @var{font}.") { Font_metric *fm = unsmob_metrics (font); SCM_ASSERT_TYPE (fm, font, SCM_ARG1, __FUNCTION__, "font-metric"); - return scm_cdr (fm->description_); + return fm->sub_fonts (); } diff --git a/scm/framework-tex.scm b/scm/framework-tex.scm index 988e49e040..1d20344a43 100644 --- a/scm/framework-tex.scm +++ b/scm/framework-tex.scm @@ -32,6 +32,52 @@ (string-append "\\def\\" prefix (symbol->tex-key key) "{" number "}%\n")) + +(define-public (digits->letters str) + (regexp-substitute/global + #f "[-\\._]" + (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) + 'pre "" + 'post)) + +(define (otf-font-load-command paper font) + (let* + ((sub-fonts (ly:font-sub-fonts font)) + (base-name (tex-font-command font))) + + (string-append + (apply string-append + (map + (lambda (sub-name) + (string-append + "\\font\\" (string-append base-name (digits->letters sub-name)) "=" + 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)) + ) + )))) + (define-public (tex-font-command font) (string-append "magfont" @@ -41,7 +87,7 @@ (string-encode-integer (inexact->exact (round (* 1000 (ly:font-magnification font))))))) -(define (font-load-command paper font) +(define (simple-font-load-command paper font) (let* ((coding-alist (ly:font-encoding-alist font)) (font-encoding (assoc-get 'output-name coding-alist))) (string-append @@ -66,6 +112,11 @@ "\\lilypond" (tex-font-command font) "}%\n"))) +(define (font-load-command paper font) + (if (pair? (ly:font-sub-fonts font)) + (otf-font-load-command paper font) + (simple-font-load-command paper font))) + (define (define-fonts paper) (string-append ;; UGH. FIXME. diff --git a/scm/output-tex.scm b/scm/output-tex.scm index e4aab9f613..0f4f5b4f95 100644 --- a/scm/output-tex.scm +++ b/scm/output-tex.scm @@ -89,19 +89,6 @@ (define (dashed-slur thick dash l) (embedded-ps (list 'dashed-slur thick dash `(quote ,l)))) -(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) @@ -109,7 +96,7 @@ (string-append ; (digits->letters (ly:font-name font)) (regexp-substitute/global - #f "[\\._]" + #f "[-\\._]" (digits->letters name) 'pre "" 'post)))) -- 2.39.5