bug-lilypond
[Top][All Lists]
Advanced

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

Re: Pango font tree not handled at non-default score size


From: Neil Puttock
Subject: Re: Pango font tree not handled at non-default score size
Date: Wed, 27 Jan 2010 00:04:55 +0000

2010/1/26 Jiri Zurek (Prague) <address@hidden>:
>
> Fonts set in the make-pango-font-tree are used only in the default score
> size. As soon as the score size is changed with the layout-set-staff-size to
> any specific value, the fonts used for the lyrics become the default (a sort
> of Century Schoolbook). This behavior is observed at least throughout the
> versions 2.12.2-2.13.11

Unfortunately, when you call make-pango-font-tree, the font names
aren't cached anywhere, which means there's no way of regenerating the
same settings in a layout block with a change of scale.  Currently all
the staff-size setting functions reset 'fonts using
make-century-schoolbook-tree instead.

> I need that the lyrics in the whole book is typeset with the specific font
> regardless of the size of the corresponding staff. Is there a workaround to
> the above mentioned bug?

Try this:

#(define-public (layout-set-staff-size staff-size)

  (define (calc-line-thickness staff-space pt)
    (let* ((x1 (* 4.125 pt))
           (x0 (* 5 pt))
           (f1 (* 0.47 pt))
           (f0 (* 0.50 pt)))

      (/
       (+
        (* f1 (- staff-space x0))
        (* f0 (- x1 staff-space)))
       (- x1 x0))))

  (let* ((module (current-module))
         (pt (eval 'pt module))
         (staff-height (* pt staff-size))
         (ss (/ staff-height 4))
         (factor (/ staff-height (* 20 pt)))
         (setm! (lambda (sym val)
                  (module-define! module sym val)))
         (parser (eval 'parser module))
         (pap (ly:parser-lookup parser '$defaultpaper))
         (pango-fonts (ly:output-def-lookup pap 'pango-font-list #f)))

    (setm! 'text-font-size (* 12 factor))
    (setm! 'output-scale ss)
    (setm! 'fonts (if pango-fonts
                      (make-pango-font-tree (car pango-fonts)
                                            (cadr pango-fonts)
                                            (caddr pango-fonts)
                                            factor)
                      (make-century-schoolbook-tree factor)))
    (setm! 'staff-height staff-height)
    (setm! 'staff-space ss)
    (setm! 'line-thickness (calc-line-thickness ss pt))
    (setm! 'ledger-line-thickness (+ (* 0.5 pt) (/ ss 10)))
    (setm! 'blot-diameter (* 0.4 pt))))

#(define-public (pango-font-tree-wrapper roman sans typewriter factor)
  "Call make-pango-font-tree, binding the result to 'fonts
and cache the font names in a paper variable (pango-font-list)."
  (let ((parser (eval 'parser (current-module))))

    (ly:parser-define! parser 'pango-font-list (list roman sans typewriter))
    (ly:parser-define! parser 'fonts
                       (make-pango-font-tree roman sans typewriter factor))))

In your \paper block call `pango-font-tree-wrapper' as follows:

#(pango-font-tree-wrapper "Arial"
 "Nimbus Sans"
 "Luxi Mono"
                         (/ 20 20))

Regards,
Neil




reply via email to

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