[JW Lua] Adding MIDI controller messages / Calculating expression width

Jari Williamsson jari.williamsson at mailbox.swipnet.se
Tue Jan 14 19:17:31 CET 2014


On 2014-01-14 14:22, Jan Angermüller wrote:

> Another question came up:
> Is it possible to calculate the width of a text expression to improve
> the placing of the expression ?
> Something like |GetTextExtentPoint32| on Windows.
> For example to calculate from the width of a measure and the width of
> the expression
> the best placement ? When I look at the code of your dynamics_horizpos.lua,
> it seems like you hard-coded the positions (i.e. the widths) manually.
> If this is not a function of the Finale PDK, maybe that would be a
> helpful function
> that JW Lua could provide ?

You're correct that my scripts use tables to get measurements from 
handles to edge-of-glyph. For many years, I've asked MM to provide the 
actual boundary rectangles for an object. What I do in my scripts is 
basically that I mimic the behaviour of the FAN information. In C++, 
it's too time consuming to test positioning tables (which I did in JW 
Yada Yada Tremolo), but in scripting it's ok as long as I know what 
fonts/characters to support.

However, as I said, I have needed such a feature for many years. For 
pure text, a "GetTextExtentPoint32 approach" would work (the only thing 
would be to get similar returns on both Windows and Cocoa).

For the music glyphs, using the APIs from the OS would not work well at 
all. One approach would be to read the FAN file information and provide 
that to JW Lua. However, the FAN file info is relative to the font's 
metrics info for each glyph, so that could be potentially problematic.

The real challenge comes with text that is a mix of normal text and 
glyphs, such as "poco f".

I'll investigate...


Best regards,

Jari Williamsson






More information about the JWLua mailing list