lilypond-user
[Top][All Lists]
Advanced

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

Re: Fonts for TextScripts


From: Aaron Hill
Subject: Re: Fonts for TextScripts
Date: Fri, 26 Jun 2020 07:18:33 -0700
User-agent: Roundcube Webmail/1.4.2

(Adding mailing list for visibility...)

On 2020-06-26 6:19 am, Aberforth D - Instrumentals wrote:
I'm using Inkscape and it runs on the same system as lilypond but somehow
it picks the wrong font for "serif".

This is probably because LilyPond itself is overriding font-config defaults to promote its preferred font families.


However, opera scores are riddled with expressive and dramatic markings so
I would have to type this over and over again. Moreover, this makes it
difficult to change the overall style at a later stage. I have been trying for two full days to achieve a similar result with a user defined function,
but to no avail. Ideally I want to achieve something like this:

c4^\expr "con grazia"
d4^\drama "(she reads the letter)"

The first line would be printed in the normal size, italic. The second line
would be printed in tiny size, upright. The actual font-name, size and
shape would be defined in the respective functions. Is this even possible?

While you can manually define your own event function, it is easier to let LilyPond do the heavy lifting and use \etc:

%%%%
\version "2.20.0"

{ c'4-. \tweak font-name "Times New Roman, Italic"
        \tweak font-size -0.1
        ^"con grazia"
  d'4-. \tweak font-name "Times New Roman,"
        \tweak font-size -2.0
        _"(she reads the letter)" }

expr =
  \tweak font-name "Times New Roman, Italic"
  \tweak font-size -0.1
  -\etc
drama =
  \tweak font-name "Times New Roman,"
  \tweak font-size -2.0
  -\etc

{ c'4-. ^\expr "con grazia"
  d'4-. _\drama "(she reads the letter)" }
%%%%


Even better, but perhaps I'm asking too much now, would be that the
function automatically recognizes text between (...) as being a dramatic
instruction and automatically prints it smaller, so I only need one
function and the script could be reduced to:

c4^\expr "con grazia"
d4^\expr "(she reads the letter)"

I hope I'm not over-asking, but any help is welcome.

You can certainly do things dynamically based on the content of the text markup:

%%%%
\version "2.20.0"

\paper {
  #(define fonts
     (set-global-fonts
       #:roman "Times New Roman"
       #:factor (/ staff-height pt 20)))
}

{ c'4-. \tweak font-shape #'italic
        \tweak font-size -0.1
        ^"con grazia"
  d'4-. \tweak font-size -2.0
        _"(she reads the letter)" }

#(use-modules (ice-9 regex))
expr = #(define-event-function (text) (markup?)
  (if (string-match "^\\(.*\\)$" (markup->string text))
    #{ \tweak font-size -2.0
       - $text #}
    #{ \tweak font-shape #'italic
       \tweak font-size -0.1
       - $text #}))

{ c'4-. ^\expr "con grazia"
  d'4-. _\expr "(she reads the letter)" }
%%%%

Note in this version I am demonstrating using \paper to set the font family, so that we can make use of font-shape.


-- Aaron Hill



reply via email to

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