Skip to main content
April 29, 2009
Question

Bug with leadingModel and alignmentBaseline

  • April 29, 2009
  • 1 reply
  • 1532 views

To help solve the problem of overlapping fonts (per post http://forums.adobe.com/thread/210312?tstart=90), I have been trying to adjust the baseline, leading, etc.  This setting seems to produce what I am looking for:

     textFlow.alignmentBaseline = TextBaseline.IDEOGRAPHIC_BOTTOM;
     textFlow.leadingModel = LeadingModel.IDEOGRAPHIC_TOP_DOWN;

However, an error happens when clicking the last line if all the text does not fit into the container.

TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at flashx.textLayout.elements::TextFlowLine/http://ns.adobe.com/textLayout/internal/2008::getRomanSelectionHeightAndVerticalAdjustment()
    at flashx.textLayout.elements::TextFlowLine/computePointSelectionRectangle()
    at flashx.textLayout.elements::TextFlowLine/http://ns.adobe.com/textLayout/internal/2008::hilitePointSelection()
    at flashx.textLayout.container::ContainerController/http://ns.adobe.com/textLayout/internal/2008::addSelectionShapes()
    at flashx.textLayout.compose::StandardFlowComposer/showSelection()
    at flashx.textLayout.edit::SelectionManager/addSelectionShapes()
    at flashx.textLayout.edit::SelectionManager/mouseDownHandler()
    at flashx.textLayout.container::ContainerController/mouseDownHandler()
    at flashx.textLayout.container::ContainerController/http://ns.adobe.com/textLayout/internal/2008::requiredMouseDownHandler()

I am using the release from 4/23/09 (Build 418).

Here is code to recreate the problem.  The problem happens when clicking on the last line.

public class TestTextLayoutCode extends Canvas {
    private var markup:String = "<TextFlow xmlns='http://ns.adobe.com/textLayout/2008'>" +
            "<p fontSize='48' fontFamily='Arial'>Very Big Font</p>" +
            "<p fontSize='12' fontFamily='Times New Roman'><span>" +
            "This is a normal font size to show how the text functionality works. " +
            "</span></p>" +
            "</TextFlow>";

    private var textFlow:TextFlow;
   
    public function TestTextLayoutCode() {
        textFlow = TextFilter.importToFlow(markup, TextFilter.TEXT_LAYOUT_FORMAT);
        textFlow.leadingModel = LeadingModel.IDEOGRAPHIC_TOP_DOWN;
        textFlow.alignmentBaseline = TextBaseline.IDEOGRAPHIC_BOTTOM;
        textFlow.flowComposer = new StandardFlowComposer();

        var container:Sprite = new Sprite();
        var controller:ContainerController = new ContainerController(container);
        controller.verticalScrollPolicy = ScrollPolicy.OFF;
        textFlow.flowComposer.addController(controller);
        controller.setCompositionSize(300, 80);
        rawChildren.addChild(container);
        textFlow.flowComposer.updateAllControllers();
       
        textFlow.interactionManager = new EditManager();
    }
}

This topic has been closed for replies.

1 reply

Participating Frequently
April 30, 2009

Andy,

Thanks for reporting the bug.The combination of Down leading direction and OFF scroll policy is required to reproduce it (alignmentBaseline setting is not).

As a workraround (if enabling scrolling is not what you want), did you try using different approaches to leading:

- Larger lineHeight for text with smaller font sizes as suggested by Robin in her reply to the original post

- Using the new ASCENT_DESCENT_UP leading model (MS Word-style line spacing which guarantees non-overlapping lines so long as line height is positive)

Abhishek

(Adobe Systems Inc.)

April 30, 2009

Thanks for your reply.  When I use ASCENT_DESCENT_UP, it does not match MS-Word spacing, it appears to be "double-spaced".  If I set textFlow.lineHeight = "40%" then it gets pretty close to matching MS-Word spacing.

I don't think Robin's approach will help me since the text can have mixed fonts/sizes and the user can change the text and formatting.  I don't really know how to manually adjust the spacing to keep it spaced out correctly.

April 30, 2009

Actually it looks like textFlow.lineHeight = "20%" with textFlow.leadingModel = LeadingModel.ASCENT_DESCENT_UP matchs MS-Word spacing pretty close.  However, when I do that, I see 2 problems:

1. The selection highlight is not positioned correctly.  It is shifted up so it selects from the baseline up to the baseline in the prior line.

2. The flow allow the last line to appear if there is only room up to the baseline, so the descents can get chopped off.