[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Re: Font questions about absolute

**From**: |
Aaron Hill |

**Subject**: |
Re: Font questions about absolute |

**Date**: |
Sat, 11 May 2019 12:16:01 -0700 |

**User-agent**: |
Roundcube Webmail/1.3.8 |

On 2019-05-11 10:52 am, Reggie wrote:

`Is there any easy way to quickly see or convert absolutely font to #3
``or #5
``and so on? In frescobaldi like a function() or something. Thank you for
``any
`help.

`Within \markup, you can use \abs-fontsize to get a specific size that
``will not scale based on the global staff size. That does not require
``any conversion.
`

`If you are trying to set the relative font size of a grob that produces
``text and you want it to match a specific absolute font size, then you
``are going to need to break out your calculator and do some arithmetic.
``(LilyPond has some Scheme functions to assist here.)
`

`One thing to understand is the logarithmic scale that LilyPond uses for
``relative font sizes. A value of 6 results in doubling the size of a
``font, whereas a value of -6 will halve the size of the font. Each
``increment of 6 in either direction is another doubling or halving. So
``in this system, adding an amount on the logarithmic scale results in
``multiplying the value on the linear scale.
`

`The magstep and magnification->font-size procedures help with converting
``between linear and logarithmic. So (magstep 6) will produce 2.0 as
``output, and (magnification->font-size 1/2) will produce -6.0 as output.
``But if you need to do the math by hand, here are those functions:
`
magstep(x) = 2 ^ (x / 6)
magnification->font-size(x) = 6 * log_2(x)

`(Recall that a logarithm of any one base can be used to compute the
``logarithm of any other base. So to compute the base-two log above using
``the natural log is simply: ln(x) / ln(2).)
`

`Another thing to be aware of is how the global staff size plays into
``font size. The default is a 20pt staff (5pt staff spaces) and a
``resulting font size of 11pt. The ratio of 11/20 is important, since if
``you were to shrink the staff size to 16, for example, the resulting font
``will be 16 * 11/20 = 8.8.
`

`Putting this together, we can calculate precisely what the resulting
``font size would be given our knowledge of the global staff size and the
``relative font size of a text element. Likewise, we can determine a
``relative font size that will result in an absolute font size.
`

`For the first case--going from relative to absolute--let us assume we
``have a staff size of 18 and our grob's font-size is 2. The global font
``size is 18 x 11/20 = 9.9 and the magnification factor is 2^(2/6) ~=
``1.26, so our result is approximately 12.5pt. And in Scheme, we could
``say:
`
(* 18 11/20 (magstep 2))
--> 12.4732183939592

`For the second case--going from absolute to relative--let us assume we
``have a staff size of 24 and need to set the grob's font-size so that the
``result is exactly 18pt. The global font size is 24 * 11/20 = 13.2. To
``get from 13.2 to 18 requires a magnification of 18 / 13.2 ~= 1.36.
``This, in the logarithm scale, is 6 * log_2(1.36) ~= 2.68. In Scheme, we
``do:
`
(magnification->font-size (/ 18 (* 24 11/20)))
--> 2.68475386182733

`Now all that said, is this "easy"? Depends on your comfortability with
``maths, I suppose. I usually stick to relative font sizes and do not
``concern myself with the absolutes, since it is my eye that determines
``whether something is big enough or small enough, not a ruler.
`

`Of course, I recently did have to use the above computations when I was
``typesetting hymns for projection. I needed to have the flexibility of
``changing the staff size independent of the lyric font size as I was
``experimenting with what would look good. So rather than have to compute
``things by hand, I used something similar to the absolute-to-relative
``Scheme code above.
`
-- Aaron Hill