View Full Version : multiline text lineheight (leading)
kayos
07-10-2009, 09:34 AM
I've seen it asked before and can't find a decent answer to the question. Already spent way too much time searching...
How do you control the line height, or 'leading' of multiple lines of text within a single text view?
<text font="akzyLight" fontsize="18" multiline="true" selectable="true" width="200" lineheight="24">This is line one<br/> continued to line two<br/>then to line three.</text>
...doesn't do anything to line height. I want to increase or decrease space between lines of text.
I do not want to use multiple text views w/ simplelayout spacing. That's tedious and doesn't allow all the lines to be highlighted/copy/pasted.
If it helps, we're building solo swf9 app with embedded fonts.
-Don
Squids
09-07-2009, 06:12 PM
Hi...I'd also like to find this out. I really need to alter the line height of a multiline text view. Does anyone know the answer for this?
Squids
09-07-2009, 06:25 PM
I forgot to add which version I am using...I am currently using 4.2.0 and the compiler gives me a warning when I use the lineheight attribute, even though it is clearly listed as a valid attribute in the reference docs:
my_app.lzx:324:86: found an unknown attribute named "lineheight" on element text, however there is an attribute named "height" on class attribute", did you mean to use that?
senshi
09-08-2009, 01:20 AM
Well, it's listed in the refpage for <text>, but only for version 4.3 (http://www.openlaszlo.org/lps4.3/docs/reference/lz.text.html), not for 4.2 (http://www.openlaszlo.org/lps4.2/docs/reference/lz.text.html). Apart from that, "lineheight" is read-only attribute, so it won't help you to change the leading.
LaSlow
07-27-2010, 09:23 AM
Here is a solution for the lineheight problem:
<canvas name="lineHeight" width="100%" height="100%">
<lineHeightText fontsize="11" fgcolor="#000000" bgcolor="#abcdef"
name="textarea1" width="100" selectable="true">
[start]Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum.[end]
</lineHeightText>
<lineHeightText fontsize="11" fgcolor="#000000" x="120" bgcolor="#abcdef"
name="textarea2" width="100" selectable="true">
<handler name="oninit">
<![CDATA[
this.setLineHeight(20);
]]>
</handler>
[start]Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum.[end]
</lineHeightText>
<class name="lineHeightText" extends="text" multiline="true">
<switch>
<unless property="$as3">
<method name="setLineHeight" args="newLineHeight:Number =0">
<![CDATA[
Debug.error("setLineHeight is not supported");
]]>
</method>
</unless>
<otherwise>
<passthrough>
import flash.text.*;
</passthrough>
<method name="setLineHeight" args="newLineHeight:Number =0">
<![CDATA[
Debug.write("new line-height should be: ", newLineHeight);
// get an reference of this text
var test = this.getMCRef();
Debug.write("text lines: ", test.textfield.numLines);
Debug.write("text line-height: ", test.lineheight);
Debug.write("textfield height: ", test.lineheight*test.textfield.numLines);
// set new line-height
var format:TextFormat = new TextFormat();
format.leading = newLineHeight-test.lineheight;
Debug.write("current line-height: ", test.lineheight);
Debug.write("format leading: ", format.leading);
// set line-height in the sprites
test.lineheight = 26;
// make this textfield bigger
this.setAttribute("height", newLineHeight*test.textfield.numLines);
// set the new format
test.textfield.setTextFormat(format);
test.textfield.defaultTextFormat = format;
]]>
</method>
</otherwise>
</switch>
</class>
</canvas>
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.