<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p><br>
</p>
<br>
<br>
<div style="color: rgb(0, 0, 0);">
<div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Gregory Pittman <gpittman@iglou.com><br>
<b>Sent:</b> Saturday, August 6, 2016 11:32 AM<br>
<b>To:</b> Scribus User Mailing List<br>
<b>Subject:</b> Re: [scribus] Get the width of a piece of text in a Scribus script?</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText">On 08/06/2016 10:04 AM, John Culleton wrote:<br>
> On Fri, 09 Aug 2013 15:43:52 -0700<br>
> Adam <adam@photosynth.ca> wrote:<br>
> <br>
>> Good day,<br>
>> I'm working on a script for laying out a song<br>
>> book that includes lyrics and chords. Chord<br>
>> names need to be placed above each line of<br>
>> lyrics, at the appropriate spot in the lyrics.<br>
>> I've explored a variety of approaches to this<br>
>> using typographic options to try to get the<br>
>> chord letters bumped up above the lyrics line<br>
>> using baseline shift and kerning adjustments,<br>
>> but so far these have not proved effective.<br>
>><br>
>> My present approach is to put each chord in a<br>
>> small text box above the lyrics line. In order<br>
>> to do this, I need to be able to determine the<br>
>> horizontal position of that point in the<br>
>> lyrics, as rendered in the relevant font and<br>
>> type size. Does anyone know of a way to do this?<br>
>><br>
>> Apparently the ImageFont python module (which<br>
>> is a subset of PIL, or the Python Imaging<br>
>> Library), can return the width of a text line<br>
>> as rendered, but I so far have not been able to<br>
>> get this module working properly (there's a C<br>
>> library involved, which is malfunctioning in my<br>
>> installation).<br>
>><br>
>> Does anyone know of any other way to<br>
>> programatically measure the rendered width of a<br>
>> line of text?<br>
>><br>
>> Thanks for your help!<br>
>><br>
>> Adam<br>
<br>
</div>
<div class="PlainText"><br>
</div>
<div class="PlainText">To get the width and depth of something text-like, you can put it into a text frame and do a binary search for the size. See the example at the end of <a href="https://wiki.scribus.net/canvas/Command_line_scripts" class="OWAAutoLink" id="LPlnk717918">https://wiki.scribus.net/canvas/Command_line_scripts</a></div>
<div class="PlainText"><br>
</div>
<div class="PlainText"></div>
<div class="PlainText">Regards, William</div>
<div class="PlainText"><br>
</div>
<div class="PlainText"><br>
</div>
<div class="PlainText"><br>
</div>
</span></font></div>
</div>
</body>
</html>