Skip to main content
April 16, 2010
Question

TextFlow paddingLeft not working when using RTL and dynamic width

  • April 16, 2010
  • 1 reply
  • 487 views

I having a problem with the rendering of a TextFlow object when using RTL text direction and dynamic width (NaN) in the assigned controller. The problem does not occur when using LTR text or when using a fixed width in the controller. Here are some pictures showing the problem:

This one is using RTL text direction and dynamic with:

And this one is using LTR text direction and dynamic with:

In both cases the text was rendered using this code:

            var container:Sprite = new Sprite;

            var flow:TextFlow = TextConverter.importToFlow(markup, TextConverter.TEXT_FIELD_HTML_FORMAT);
            var controller:* = new ContainerController(container, message_width, message_height);


            flow.paddingTop = layout.messages.padding_top * stage.stageHeight;
            flow.paddingBottom = layout.messages.padding_bottom * stage.stageHeight;
            flow.paddingLeft = layout.messages.padding_left * stage.stageWidth;
            flow.paddingRight = layout.messages.padding_right * stage.stageWidth;
            flow.direction = layout.messages.text_direction;

            flow.flowComposer.addController(controller);
            flow.flowComposer.updateAllControllers();


            if(isNaN(message_width)) {
                message_width = int(layout.messages.padding_left * stage.stageWidth +
                                layout.messages.padding_right * stage.stageWidth +
                                container.width);
            }           
            if(isNaN(message_height)) {
                message_height = int(layout.messages.padding_top * stage.stageHeight +
                                 layout.messages.padding_bottom * stage.stageHeight +
                                 container.height);
            }

            container.graphics.beginFill(parseInt("0x" + layout.messages.background_color.slice(1)), layout.messages.background_opacity);
            container.graphics.drawRect(0, 0, message_width, message_height);
            container.graphics.endFill();              

Any ideas? I looked at the TLF sources trying to find the problem but it resulted harder that I thought

Fran

This topic has been closed for replies.

1 reply

April 17, 2010

I found a way to fix it I made a little change in the TLF source code in this file:

http://opensource.adobe.com/svn/opensource/flex/sdk/trunk/frameworks/projects/textLayout/src/flashx/textLayout/container/ColumnState.as

Here is the diff againts the current SVN:

Index: ColumnState.as
===================================================================
--- ColumnState.as    (revision 15451)
+++ ColumnState.as    (working copy)
@@ -324,7 +324,7 @@
                 else
                 {
                     CONFIG::debug { assert(_columnDirection == Direction.RTL,"bad columndirection in ColumnState.computeColumns"); }
-                    xPos = isNaN(_compositionWidth) ? 0 : _compositionWidth-_paddingRight-_columnWidth;
+                    xPos = isNaN(_compositionWidth) ? _paddingLeft : _compositionWidth-_paddingRight-_columnWidth;
                     delX = -(_columnWidth + _columnGap);
                     colW = _columnWidth;
                 }

I'm not sure if it breaks other code, but paddingLeft is now working in RTL with dynamic width

Someone commited to the SVN a similar change to the code a few lines forward in the same file for RL block progression:

    @@ -338,7 +335,7 @@
                            }
                            else if (_blockProgression == BlockProgression.RL)
                            {
    -                               xPos = isNaN(_compositionWidth) ? 0 : _paddingLeft -_compositionWidth;
    +                               xPos = isNaN(_compositionWidth) ? -_paddingRight : _paddingLeft -_compositionWidth;
                                    yPos = _paddingTop;
                                    delX = 0;
                                    delY = _columnWidth + _columnGap;

Fran

Adobe Employee
April 22, 2010

Makes sense.   I filed a bug - this won't be fixed in 1.1.

Thanks for the report

Richard