ns = []
for s in subfonts:
- ns.append (s % vars())
+ ns.append ('"%s"' % (s % vars()))
subfonts_str = string.join (ns)
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;
}
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_);
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 ();
}
(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"
(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
"\\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.
(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)
(string-append
; (digits->letters (ly:font-name font))
(regexp-substitute/global
- #f "[\\._]"
+ #f "[-\\._]"
(digits->letters name)
'pre ""
'post))))