lilypond-user
[Top][All Lists]
Advanced

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

Re: How to get text width in Scheme?


From: Risto Vääräniemi
Subject: Re: How to get text width in Scheme?
Date: Fri, 19 Sep 2008 16:41:50 +0300

Hi Valentin,

2008/9/19 Valentin Villenave <address@hidden>:
> 2008/9/19 Risto Vääräniemi <address@hidden>:
>
>> Can someone tell me how I can get the text width inside scheme?
>
> I think you might be interested in using ly:stencil-extent
> (not sure though)

Yes, that might be another option. However, I've got a egg-hen problem
here. Trevor's code creates the "X bis" text/stencil and I would like
to move the whole schmeer to the right by the width of the " bis". I
can get the width of the BarNumber #'stencil but that's not enough
because the width already contains the width of the " bis". The
X-offset is taken into account after the stencil has been formed.

It seems that there is a way to change a piece of text into a stencil
(fontify-text), however that uses the same ly:text-dimension
font-metric text function. :-) Is there another way?

I was hoping for something like this:
#(define (bar-number-X BarNumber)
 "Move the text right by the width of bis"
 (let* (
    (textBis " bis")
    (extentOrig (ly:stencil-extent (ly:grob-property BarNumber 'stencil) 0))
    (widthOrig (- (cdr extentOrig) (car extentOrig)))
    (widthBis (ly:some-magical-function-to-get-width textBis)))
    (- widthBis widthOrig)))

I could use it like this BarNumber #'X-offset = #bar-number-X

This might be usable only for bar numbers that are positioned at the
beginning of the staff. It would be a nice feature, anyway.

-Risto




reply via email to

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