lilypond-user
[Top][All Lists]
Advanced

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

Re: Usage of ly:stencil-fonts ??


From: Thomas Morley
Subject: Re: Usage of ly:stencil-fonts ??
Date: Sun, 21 Oct 2018 17:50:24 +0200

Hi Torsten,
Am So., 21. Okt. 2018 um 17:17 Uhr schrieb Torsten Hämmerle
<address@hidden>:
>
> Hi Harm,
>
> As it looks like, this function has not been working for some time, I've
> tested it back to 2.14.2

I even checked with 2.12.3 (without useful result)

> What does it do?
>
> In lily/stencil-interpret.cc, the function find_expression_fonts gets a
> scheme variable called expr with the following contents:
>
>
> *(A) in your NoteHead example:*
>
> (named-glyph #<Font_metric ("emmentaler-20" . 0.569055118110236)>
> noteheads.s0)
>
> -> Font_metric contains "Emmentaler-20"
>
>
> *(B) I've changed the TextScript example to \markup \italic "italic"*
>
> Now, the expressiong gets a bit convoluted, but there's still a
> <Font_metric> information contained (but with font-name #f and dummy size
> 1.0), but there still are font names in the glyph-string (this time it is
> "TeXGyreSchola-Italic")
>
> (translate-stencil (0.0 . 0.0) (glyph-string #<Font_metric (#f . 1.0)>
> TeXGyreSchola-Italic 3.865234375 #f (quote ((0.717009448818898
> (-0.0341433070866142 . 1.4340188976378) 0.0 0.0 i) (0.785296062992126
> (-0.0341433070866142 . 1.36573228346457) 0.0 0.0 t) (1.26330236220472
> (-0.0341433070866142 . 1.02429921259843) 0.0 0.0 a) (0.717009448818898
> (-0.0341433070866142 . 1.60473543307087) 0.0 0.0 l) (0.717009448818898
> (-0.0341433070866142 . 1.4340188976378) 0.0 0.0 i) (0.990155905511811
> (-0.0341433070866142 . 1.05844251968504) 0.0 0.0 c)))))
>

Yep, (A) and (B) is the the stencil-expression.
It's what you get, after uncommenting the lines starting with
(pretty-print (ly:stencil-expr ...
in my example-code.

>
> It calls function *interpret_stencil_expression* and (in our two cases),
> "named-glyph" and "glyph-string" should use function *find_font_function*
>
> But this function just takes care of "text" and "char".
>
> Unfortunately, we have "named-glyph" and "glyph-string" instead (I think
> font handling has considerably changed in the meantime), so that the
> function returns nothing.
>
>
> *Experimental correction*
>
> When implementing "named-glyph" (giving back cadr) and "glyph-string"
> (giving back caddr), we actually get
>
> (#<Font_metric ("emmentaler-20" . 0.569055118110236)>) for the NoteHead and
> ("TeXGyreSchola-Italic") for the TextScript in a first simple attempt.
>
> With just your \number "1" example, TextScript will report ("Emmentaler-20")
>
> So, basically, the information is there and it could be done.
> But this looks like a tracker issue, because, as you found out, the function
> currently just does nothing where it should give back a result.

Agreed, I'll put up a tracker issue.

Some background:

I'm pretty sure I can get the used fonts from (ly:stencil-expr
some-stencil), though this is tedious (I did similar before) and I
hoped ly:stencil-fonts could do the work for me ;)

My goal would be to understand how exatly in/decreased fonts affect
the final stencil and how to get this info out of a given stencil
compared to a default font size.

As an intermediate step, look at the stencil-expression from:

\markup "g"

You'll get:

(translate-stencil
  (0.0 . 0.0)
  (glyph-string
    #<Font_metric (#f . 1.0)>
    "TeXGyreSchola-Regular"
    3.865234375
    #f
    '((1.1950157480315
       (-0.443862992125984 . 1.09258582677165)
       0.0
       0.0
       "g"))))

I like to understand the numerical values.
The pair (-0.443862992125984 . 1.09258582677165) seems to be the
extent in Y-axis.

But what about 3.865234375 and 1.1950157480315?

Any hints?

Thanks.
  Harm



reply via email to

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