[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Maintaining font-size regardless of staff-size
From: |
Torsten Hämmerle |
Subject: |
Re: Maintaining font-size regardless of staff-size |
Date: |
Sat, 19 May 2018 11:00:35 -0700 (MST) |
Thomas Morley-2 wrote
> Hmm, there's still some horizontal difference.
Hi Harm,
The idea of adding 'pt was brilliant, because it lead me into the right
direction:
*The exact reason...*
... is the co-operation between the (outside) Pango world and the (inside)
TeX-like world:
An American (Pango) point is 1/72 inch, a TeX point used internally is
1/72.27 inch - that's all!
This tiny deviation leads to an enormous mismatch between glyph and font
metrics scaling.
This can be corrected directly in the calculation of magnification by adding
a correctional value to ref-size:
(magnification (/ size (+ ref-size 0.04215))))
11 * 72.27/72 - 11 = 0.04215
Using this effective magnification (also for baseline-skip and word-space),
the resulting texts will retain exactly the same glyph height and the same
spacing:
<http://lilypond.1069038.n5.nabble.com/file/t3887/abs-fontsize.png>
I've also added some TextScript \markup including skylines (can't be seen in
the above illustration), because this didn't work correctly either with the
original \abs-fontsize command.
%%%%%%%%%%
\version "2.19.81"
#(ly:set-option 'debug-skylines #t)
#(define-markup-command (abs-fontsize-torsten layout props size arg)
(number? markup?)
#:properties ((word-space 0.6) (baseline-skip 3))
#:category font
"Use @var{size} as the absolute font size (in points) to display
@var{arg}.
Adjusts @code{baseline-skip} and @code{word-space} accordingly.
@lilypond[verbatim,quote]
\\markup {
default text font size
\\hspace #2
\\abs-fontsize #16 { text font size 16 }
\\hspace #2
\\abs-fontsize #12 { text font size 12 }
}
@end lilypond"
(let* ((ref-size (ly:output-def-lookup layout 'text-font-size 11))
(text-props (list (ly:output-def-lookup layout
'text-font-defaults)))
(magnification (/ size (+ ref-size 0.04215))))
(interpret-markup
layout
(cons
`((baseline-skip . ,(* magnification baseline-skip))
(word-space . ,(* magnification word-space))
(font-size . ,(magnification->font-size magnification)))
props)
arg)))
\header {
title =
\markup
\override #'(box-padding . 0)
\box \concat {
\abs-fontsize-torsten #11 "X let’s see how long X"
\with-color #red \abs-fontsize #11 "XX"
}
}
#(set-global-staff-size 18)
\book { { b'1^\markup \abs-fontsize-torsten #20 "Test" } }
#(set-global-staff-size 26)
\book { { b'1^\markup \abs-fontsize-torsten #20 "Test" } }
#(set-global-staff-size 10)
\book { { b'1^\markup \abs-fontsize-torsten #20 "Test" } }
%%%%%
All the best,
Torsten
--
Sent from: http://lilypond.1069038.n5.nabble.com/User-f3.html
Re: Maintaining font-size regardless of staff-size, Thomas Morley, 2018/05/19