;;;; define-markup-commands.scm -- markup commands
;;;;
;;;; source file of the GNU LilyPond music typesetter
-;;;;
+;;;;
;;;; (c) 2000--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
;;;; Jan Nieuwenhuizen <janneke@gnu.org>
;;; markup commands
;;; * each markup function should have a doc string with
-;; syntax, description and example.
+;; syntax, description and example.
(use-modules (ice-9 regex))
(half (/ thickness 2)))
(ly:make-stencil
- `(polygon ',(list
+ `(polygon ',(list
0 (/ thickness -2)
width (+ (* width slope) (/ thickness -2))
width (+ (* width slope) (/ thickness 2))
}
}
c,8. c16 c4 r
-@end lilypond"
+@end lilypond"
(let ((th (* (ly:output-def-lookup layout 'line-thickness)
thickness))
(pad (* (magstep font-size) box-padding))
"Extract the bbox from STRING, or return #f if not present."
(let*
((match (regexp-exec bbox-regexp string)))
-
+
(if match
(map (lambda (x)
(string->number (match:substring match x)))
(cdr (iota 5)))
-
+
#f)))
(define-builtin-markup-command (epsfile layout props axis size file-name)
(join-stencil (interpret-markup layout props tie-str))
)
- (interpret-markup layout
+ (interpret-markup layout
(prepend-alist-chain
'word-space
(/ (interval-length (ly:stencil-extent join-stencil X)) -3.5)
Return a list of paddings."
(cond
((null? text-widths) '())
-
+
;; special case first padding
((= (length text-widths) word-count)
- (cons
+ (cons
(- (- (/ line-width (1- word-count)) (car text-widths))
(/ (car (cdr text-widths)) 2))
(get-fill-space word-count line-width (cdr text-widths))))
(list (- (/ line-width (1- word-count))
(+ (/ (car text-widths) 2) (car (cdr text-widths)))) 0))
(else
- (cons
+ (cons
(- (/ line-width (1- word-count))
(/ (+ (car text-widths) (car (cdr text-widths))) 2))
(get-fill-space word-count line-width (cdr text-widths))))))
(line-width (or line-width (ly:output-def-lookup layout 'line-width)))
(fill-space
(cond
- ((= word-count 1)
+ ((= word-count 1)
(list
(/ (- line-width text-width) 2)
(/ (- line-width text-width) 2)))
((= word-count 2)
(list
(- line-width text-width)))
- (else
+ (else
(get-fill-space word-count line-width text-widths))))
(fill-space-normal
(map (lambda (x)
word-space
x))
fill-space))
-
+
(line-stencils (if (= word-count 1)
(list
point-stencil
empty-stencil
(stack-stencils-padding-list X
RIGHT fill-space-normal line-stencils))))
-
+
(define-builtin-markup-command (line layout props args)
(markup-list?)
align
(define (wordwrap-stencils stencils
justify base-space line-width text-dir)
- "Perform simple wordwrap, return stencil of each line."
+ "Perform simple wordwrap, return stencil of each line."
(define space (if justify
;; justify only stretches lines.
(* 0.7 base-space)
line-stencils))))
(line-word-space (cond ((not justify) space)
;; don't stretch last line of paragraph.
- ;; hmmm . bug - will overstretch the last line in some case.
+ ;; hmmm . bug - will overstretch the last line in some case.
((null? (cdr line-break))
base-space)
((null? line-stencils) 0.0)
((baseline-skip)
wordwrap-string-internal-markup-list)
"Wordwrap a string. Paragraphs may be separated with double newlines.
-
+
@lilypond[verbatim,quote]
\\markup {
\\override #'(line-width . 40)
((baseline-skip)
wordwrap-string-internal-markup-list)
"Justify a string. Paragraphs may be separated with double newlines
-
+
@lilypond[verbatim,quote]
\\markup {
\\override #'(line-width . 40)
align
()
"Wordwrap the data which has been assigned to @var{symbol}.
-
+
@lilypond[verbatim,quote]
\\header {
title = \"My title\"
align
()
"Justify the data which has been assigned to @var{symbol}.
-
+
@lilypond[verbatim,quote]
\\header {
title = \"My title\"
;;
;; TODO: should extract baseline-skip from each argument somehow..
-;;
+;;
(define-builtin-markup-command (column layout props args)
(markup-list?)
align
(define (general-column align-dir baseline mols)
"Stack @var{mols} vertically, aligned to @var{align-dir} horizontally."
-
+
(let* ((aligned-mols (map (lambda (x) (ly:stencil-aligned-to x X align-dir)) mols)))
(stack-lines -1 0.0 baseline aligned-mols)))
align
((baseline-skip))
"
-@cindex text columns, left-aligned
+@cindex text columns, left-aligned
Put @code{args} in a left-aligned column.
"
@cindex setting extent of text objects
-Set the dimensions of @var{arg} to @var{x} and@tie{}@var{y}."
+Set the dimensions of @var{arg} to @var{x} and@tie{}@var{y}."
(let* ((m (interpret-markup layout props arg)))
(ly:make-stencil (ly:stencil-expr m) x y)))
align
()
"Add padding @var{amount} all around @var{arg}.
-
+
@lilypond[verbatim,quote]
\\markup {
\\box {
other
()
"Make @var{arg} transparent.
-
+
@lilypond[verbatim,quote]
\\markup {
\\transparent {
font
()
"Decrease the font size relative to the current setting.
-
+
@lilypond[verbatim,quote]
\\markup {
\\fontsize #3.5 {
}
@end lilypond"
(interpret-markup
- layout
+ layout
(prepend-alist-chain 'font-size (magnification->font-size sz) props)
arg))
font
()
"Switch to bold font-series.
-
+
@lilypond[verbatim,quote]
\\markup {
default
font
()
"Switch to the sans serif font family.
-
+
@lilypond[verbatim,quote]
\\markup {
default
font
()
"Set font family to @code{roman}.
-
+
@lilypond[verbatim,quote]
\\markup {
\\sans \\bold {
font
()
"Set font size to default.
-
+
@lilypond[verbatim,quote]
\\markup {
\\teeny {
font
()
"Set font size to -1.
-
+
@lilypond[verbatim,quote]
\\markup {
default
font
()
"Set font size to -2.
-
+
@lilypond[verbatim,quote]
\\markup {
default
font
()
"Set font size to -3.
-
+
@lilypond[verbatim,quote]
\\markup {
default
font
()
"Set @code{font-shape} to @code{caps}
-
+
Note: @code{\\fontCaps} requires the installation and selection of
fonts which support the @code{caps} font shape."
(interpret-markup layout (prepend-alist-chain 'font-shape 'caps props) arg))
font
()
"Use a text font instead of music symbol or music alphabet font.
-
+
@lilypond[verbatim,quote]
\\markup {
\\number {
font
()
"Use @code{font-family} typewriter for @var{arg}.
-
+
@lilypond[verbatim,quote]
\\markup {
default
\\sesquisharp
}
@end lilypond"
- (interpret-markup layout props (markup #:musicglyph (assoc-get 3/4 standard-alteration-glyph-name-alist ""))))
+ (interpret-markup layout props (markup #:musicglyph (assoc-get 3/4 standard-alteration-glyph-name-alist ""))))
(define-builtin-markup-command (sharp layout props)
()
(ly:make-stencil (list 'color color (ly:stencil-expr stil))
(ly:stencil-extent stil X)
(ly:stencil-extent stil Y))))
-\f
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; glyphs
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(let* ((font (ly:paper-get-font layout
(cons '((font-encoding . fetaMusic)
(font-name . #f))
-
+
props)))
(glyph (ly:font-get-glyph font glyph-name)))
(if (null? (ly:stencil-expr glyph))
other
()
"Lookup a glyph by name.
-
+
@lilypond[verbatim,quote]
\\markup {
\\override #'(font-encoding . fetaBraces) {
(define (number->markletter-string vec n)
"Double letters for big marks."
(let* ((lst (vector-length vec)))
-
+
(if (>= n lst)
(string-append (number->markletter-string vec (1- (quotient n lst)))
(number->markletter-string vec (remainder n lst)))
(num-y (interval-widen (cons center center) (abs dy)))
(is-sane (and (interval-sane? num-x) (interval-sane? num-y)))
(slash-stencil (if is-sane
- (make-line-stencil thickness
+ (make-line-stencil thickness
(car num-x) (- (interval-center num-y) dy)
(cdr num-x) (+ (interval-center num-y) dy))
#f)))
(slashed-digit-internal layout props num #f font-size thickness))
;; eyeglasses
-(define eyeglassesps
+(define eyeglassesps
"0.15 setlinewidth
-0.9 0 translate
1.1 1.1 scale
"")))
(list (if (= dir UP) "u" "d")
"s")))
-
+
(define (get-glyph-name font cands)
(if (null? cands)
""
(if (ly:stencil-empty? (ly:font-get-glyph font (car cands)))
(get-glyph-name font (cdr cands))
(car cands))))
-
+
(let* ((font (ly:paper-get-font layout (cons '((font-encoding . fetaMusic)) props)))
(size-factor (magstep font-size))
(stem-length (* size-factor (max 3 (- log 1))))
(cons (min stemy (cdr attach-off))
(max stemy (cdr attach-off)))
(/ stem-thickness 3))))
-
+
(dot (ly:font-get-glyph font "dots.dot"))
(dotwid (interval-length (ly:stencil-extent dot X)))
(dots (and (> dot-count 0)
stem-glyph)))
stem-glyph))
-(define-public log2
+(define-public log2
(let ((divisor (log 2)))
(lambda (z) (inexact->exact (/ (log z) divisor)))))
()
"
@cindex raising text
-
+
Raise @var{arg} by the distance @var{amount}.
A negative @var{amount} indicates lowering, see also @code{\\lower}.
font
((font-size 0)
(baseline-skip))
- "
+ "
@cindex superscript text
Set @var{arg} in superscript.
()
"
@cindex translating text
-
+
Translate @var{arg} relative to its surroundings. @var{offset}
is a pair of numbers representing the displacement in the X and Y axis.
(interpret-markup layout props arg)
(* -0.5 baseline-skip)
Y))
-\f
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; brackets.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
()
"
@cindex placing horizontal brackets around text
-
+
Draw horizontal brackets around @var{arg}.
@lilypond[verbatim,quote]
()
"
@cindex placing vertical brackets around text
-
+
Draw vertical brackets around @var{arg}.
@lilypond[verbatim,quote]
(let ((th 0.1) ;; todo: take from GROB.
(m (interpret-markup layout props arg)))
(bracketify-stencil m Y th (* 2.5 th) th)))
-\f
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Delayed markup evaluation
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
`(delay-stencil-evaluation
,(delay (ly:stencil-expr
(let* ((table (ly:output-def-lookup layout 'label-page-table))
- (label-page (and (list? table) (assoc label table)))
- (page-number (and label-page (cdr label-page)))
+ (page-number (if (list? table)
+ (assoc-get label table)
+ #f))
(page-markup (if page-number (format "~a" page-number) default))
(page-stencil (interpret-markup layout props page-markup))
(gap (- (interval-length x-ext)
(markup #:concat (#:hspace gap page-markup)))))))
x-ext
y-ext)))
-\f
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Markup list commands
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;