lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Force text on line without using \textLengthOn


From: Thomas Morley
Subject: Re: Force text on line without using \textLengthOn
Date: Fri, 26 Oct 2018 13:58:05 +0200

Hi Urs,

currently I've not the time to dive deeper in your code, maybe later
today or during the upcoming weekend.
For now only about:

Am Fr., 26. Okt. 2018 um 11:54 Uhr schrieb Urs Liska <address@hidden>:
> Additionally (but this is already present
> in your code) when using make-with-dimensions-markup (where is this
> defined? I don't find this with git grep???)

For demonstration purpose I use make-italic-markup, less typing ;)

If you define a markup command using the macro 'define-markup-command'
from 'markup-macros.scm', then this macro returns two procedures.
>From its doc-string (shortened)
"
* Define a COMMAND-markup function after command-and-args and body
* define a make-COMMAND-markup function.
"

So after having done
(define-markup-command (italic layout props arg) ...)
we get the procedures 'italic-markup' and 'make-italic-markup'

How they differ can be watched easily by displaying them in the scheme-sandbox:

guile> (display make-italic-markup)
#<procedure make-italic-markup args>

guile> (display italic-markup)
#<procedure italic-markup (layout props arg)

Note the different arguments.

In usage '(make-italic-markup "foo") will return a procedure, in a
ly-file it can be called directly with $(make-italic-markup "foo")
Whereas 'italic-markup' needs to get proper layout/props-arguments and
it will return a stencil!
Example:
\displayScheme
\markup \stencil
$(italic-markup
  $defaultpaper
  (list
    (cons
      '(font-encoding . latin1)
      (ly:output-def-lookup $defaultlayout 'text-font-defaults)))
  "buzz")

Also, note they difference here:[1]
#(pretty-print (procedure-source make-italic-markup))
->
(lambda args
  (#<procedure make-markup (markup-function make-name args)>
   italic-markup
   "make-italic-markup"
   args))


#(pretty-print (procedure-source italic-markup))
->
(lambda (layout props arg)
  "(arg)
Use italic @code{font-shape} for @var{arg}.

@lilypond[verbatim,quote]
\\markup {
  default
  \\hspace #2
  \\italic
  italic
}
@end lilypond"
  (let ()
    (interpret-markup
      layout
      (prepend-alist-chain
        'font-shape
        'italic
        props)
      arg)))
The latter returns the code from define-markup-commands.

Apart from that we have this syntax as well:
(markup #:italic "foo")
with:
#(pretty-print (markup #:italic "foo"))
returning a procedure(!)
(#<procedure line-markup (layout props args)>
 ((#<procedure italic-markup (layout props arg)>
   "foo")))
callable in a ly-file with $(markup #:italic "foo")

So the italic-markup is wrapped into a line-markup and the
"markup-mode" provides the layout/props-arguments.

All pretty confusing at first glance, but I've found use-cases for all
possibilities.


For basic use: if you happen to see some 'make-whatever-markup' drop
'make-' and '-markup' and see the name of the markup-command-name as
defined in the source or by the user.

HTH a bit,
  Harm

[1]
Regrettable 'procedure-source' is disabled in guilev2, see the thread
starting here:
https://lists.gnu.org/archive/html/guile-user/2012-09/msg00020.html
With the consequence our display-lily-procedures will not always work as before:

\void
\displayLilyMusic
\applyContext #(lambda (ctx) (ly:context-set-property ctx 'fontSize 6))

with guilev1:
\applyContext #(lambda (ctx)
  (ly:context-set-property ctx (quote fontSize) 6))

with guilev2:
\applyContext ##f

I already tried to implement something like ly:procedure-source in
general-scheme.cc based on the old guilev1-coding.
Not sure if it would be possible at all. But pretty sure it's
impossible for me with my lack of C++-knowledge.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]