Hi Kieren,
I did some checks on the absolute font-sizes:
- If you do a stencil-add on a stencil created via grob-interpret-markup
and interpret-markup inside a normal markup, they exactly match-
- If you do a pixel by pixel compare (I did in gimp) a Lyric markup with
an abs-font-size with different global-staff-sizes, they also match ...
... but you have to move the letter. IMO this is reasonable, because
different staff-sizes mean different scaling of anything else but these
absolute scaled fonts.
Now if you import a simple PDF with a single 'X' 42pt into
Libre/OpenOffice, it will show the found font-sizes of the text-objects.
If you create the PDF with LibreOffice Century Schoolbook L 42pt and
reimport that PDF, you will have exactly 42pt.
If you create PDF files with an absolute-font-size of 42pt, it will
result in 41,9pt in the reimported file - regardless of the
global-staff-size.
AFAICS the font-size is absolute, but there seems to be a calculation
inaccuracy of 0.1pt.
Best, Jan-Peter
Am 01.08.2013 06:33, schrieb Kieren MacMillan:
Here's a side-by-side comparison with the default staff size (on the
right) and set-global-size 25 (on the left), each blown up to 600% in
a PDF viewer:
\version "2.17"
allowGrobCallback =
#(define-scheme-function (parser location syms) (symbol-list?)
(let ((interface (car syms))
(sym (cadr syms)))
#{
\with {
\consists #(lambda (context)
`((acknowledgers .
((,interface . ,(lambda (engraver grob source-engraver)
(let ((prop (ly:grob-property grob sym)))
(if (procedure? prop) (ly:grob-set-property! grob sym (prop grob)))
))))
))
)
}
#}))
absFontSize =
#(define-scheme-function (parser location pt)(number?)
(lambda (grob)
(let* ((layout (ly:grob-layout grob))
(ref-size (ly:output-def-lookup (ly:grob-layout grob) 'text-font-size 12)))
(magnification->font-size (/ pt ref-size))
)))
\layout {
\context {
\Score
\allowGrobCallback font-interface.font-size
% some "global" overrides
\override TextScript #'font-size = \absFontSize #16
\override LyricText #'font-size = \absFontSize #7
\override InstrumentName #'font-size = \absFontSize #24
\override BarNumber #'font-size = \absFontSize #18
}
}
% example Music
\paper {
% just to make the huge instrument name fit
left-margin = 2\cm
}
\new Staff \with {
instrumentName = "Melodie"
shortInstrumentName = "Mel"
} \new Voice {
\repeat unfold 19 \relative c'' { bes4^"Hello" a c b }
\break
\once \override Score.BarNumber #'font-size = \absFontSize 40
\once \override TextScript #'font-size = \absFontSize 30
\once \override Score.LyricText #'font-size = \absFontSize 40
\once \override Score.LyricText #'stencil =
#(lambda (grob)
(let* ((lyr (ly:grob-property grob 'text))
(stil (lyric-text::print grob))
(stil-ref (grob-interpret-markup grob (markup #:with-color red #:abs-fontsize 40 lyr))))
; store lyric-text stencil and lyric markup
(ly:parser-define! parser 'lyrstil stil)
(ly:parser-define! parser 'lyrmup lyr)
(ly:stencil-add stil stil-ref)))
\repeat unfold 6 \relative c'' {
bes4^"World" a c b
}
} \addlyrics {
\repeat unfold 25 { B A C H }
}
% create a markup from stored lyric stencil and markup
#(define-markup-command (debug layout props)()
(ly:stencil-add lyrstil (interpret-markup layout props (markup #:with-color red #:abs-fontsize 40 lyrmup))))
\markup { \debug }
\version "2.17"
\paper {
oddHeaderMarkup = \markup \null
oddFooterMarkup = \markup \null
}
#(set-global-staff-size
(let ((gss (ly:parser-lookup parser 'mysize)))
(if (number? gss) gss 14)))
allowGrobCallback =
#(define-scheme-function (parser location syms) (symbol-list?)
(let ((interface (car syms))
(sym (cadr syms)))
#{
\with {
\consists #(lambda (context)
`((acknowledgers .
((,interface . ,(lambda (engraver grob source-engraver)
(let ((prop (ly:grob-property grob sym)))
(if (procedure? prop) (ly:grob-set-property! grob sym (prop grob)))
))))
))
)
}
#}))
absFontSize =
#(define-scheme-function (parser location pt)(number?)
(lambda (grob)
(let* ((layout (ly:grob-layout grob))
(ref-size (ly:output-def-lookup (ly:grob-layout grob) 'text-font-size 12)))
(magnification->font-size (/ pt ref-size))
)))
\layout {
\context {
\Score
\allowGrobCallback font-interface.font-size
\override LyricText #'font-size = \absFontSize #42
\override LyricText #'stencil =
#(lambda (grob)
(let* ((stil (lyric-text::print grob))
(yx (ly:stencil-extent stil Y)))
(ly:message "Y-extent-diff: ~A" (/ (cdr yx) (- (cdr yx)(car yx))))l
stil))
}
}
% just one letter ... it should be 42pt
\new Lyrics \lyricmode { X }
\version "2.17"
mysize = #24
\include "abs-font-size-14.ly"
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user