Justified word spacing condensed
For some reason, word spacing is compressed for TextAlign.JUSTIFY. If I set to left, center, or right justify, it does not alter the line breaking. If I set to full justified, the word wrapping changes altering my text lines and overall height. Is there a reason for this or a way to disable that behavior?
Here is sample code to demonstrate the problem:
public class TestTextLayoutCode extends Canvas {
private var markup:String = "<TextFlow xmlns='http://ns.adobe.com/textLayout/2008'>" +
"<p fontSize='12' fontFamily='Times New Roman'><span>" +
"This is a normal font size to show how the text functionality works with justified text." +
"</span></p>" +
"</TextFlow>";
private var textFlow:TextFlow;
public function TestTextLayoutCode() {
textFlow = TextFilter.importToFlow(markup, TextFilter.TEXT_LAYOUT_FORMAT);
textFlow.flowComposer = new StandardFlowComposer();
var container:Sprite = new Sprite();
container.x = 5;
container.y = 5;
var controller:ContainerController = new ContainerController(container);
controller.verticalScrollPolicy = ScrollPolicy.OFF;
textFlow.flowComposer.addController(controller);
controller.setCompositionSize(200, 40);
rawChildren.addChild(container);
textFlow.flowComposer.updateAllControllers();
textFlow.interactionManager = new EditManager();
graphics.lineStyle(1,0x000000,1);
graphics.drawRect(container.x-1,container.y-1,container.width+1,container.height+1);
var button:Button = new Button();
button.label = "Left";
button.y = 50;
addChild(button);
button.addEventListener(MouseEvent.CLICK, onClickLeft);
button = new Button();
button.label = "Justify";
button.x = 70;
button.y = 50;
addChild(button);
button.addEventListener(MouseEvent.CLICK, onClickJustify);
}
private function onClickLeft(e:MouseEvent):void {
var fmt:TextLayoutFormat = new TextLayoutFormat();
fmt.textAlign = TextAlign.LEFT;
setFormat(fmt);
}
private function onClickJustify(e:MouseEvent):void {
var fmt:TextLayoutFormat = new TextLayoutFormat();
fmt.textAlign = TextAlign.JUSTIFY;
setFormat(fmt);
}
private function setFormat(fmt:TextLayoutFormat):void {
if (textFlow && textFlow.interactionManager is IEditManager) {
if (textFlow.textLength > 0) {
textFlow.interactionManager.setSelection(0, textFlow.textLength);
textFlow.interactionManager.refreshSelection();
IEditManager(textFlow.interactionManager).applyParagraphFormat(fmt);
textFlow.interactionManager.setSelection(-1,-1);
textFlow.interactionManager.refreshSelection();
}
}
}
}
