Skip to main content
Participating Frequently
September 12, 2010
Question

paragraph spacing effected by image baselineShift ONLY if add a subsequent paragraph

  • September 12, 2010
  • 1 reply
  • 1598 views

My problem:

I add a paragraph with inline images set with a -50% baselineShift so that they appear to be centered in line.  It looks fine, only the spacing appropriate to the shift appears between the two lines when the text covers two lines within the container (each line ended up with one image).

This text is in it's own container.

Then, I add another paragraph to the textflow, set such that it is appearing in it's own container with it's own controller.  I am doing this because I need to be able to track some y values for formatting in the future (inserting images next to specific text containers).

When I add this second paragraph and container, two HUGE spaces appears, one before the first line of and one between the two lines of text in the paragraph BEFORE the newly added paragraph.

How is a subsequent paragraph affecting the spacing between lines it does not share a container with... the only thing they share is a TextFlow.

Note: in the XML below, a span with the same baseline shift as the image is added by the TLF, not by me.  I have tried testing a scenario where I add a span after the image without the baseline shift and the automatically added span does not appear.  This, however, does not fix my issue.

Also, all the funky symbols in the spans are a result of passing strings with <b> and <i> tags to create spans.  I am planning on parsing them out and replacing them with formatting in a form acceptable by the TLF, but first I want to work out this issue.

I think I'm missing how this makes any sense?

TextFlow traced via the exporter before adding the next paragraph:

<TextFlow columnCount="inherit" columnGap="inherit" columnWidth="inherit" lineBreak="inherit" paddingBottom="inherit" paddingLeft="inherit" paddingRight="inherit" paddingTop="inherit" verticalAlign="inherit" whiteSpaceCollapse="preserve" xmlns="http://ns.adobe.com/textLayout/2008">

  <p>

    <span>ham-burg-er [or] ham-burg</span>

  </p>

  <p>

    <span>Sounds Like: &lt;b&gt;haem&lt;/b&gt; &lt;i&gt;&lt;b&gt;buhr&lt;/b&gt;&lt;/i&gt; g@r</span>

    <img baselineShift="-50%" height="21.65" width="27.55" source="[object AudioButton]"/>

    <span>[or] &lt;b&gt;haem&lt;/b&gt; &lt;i&gt;&lt;b&gt;buhrg&lt;/b&gt;&lt;/i&gt;</span>

    <img baselineShift="-50%" height="21.65" width="27.55" source="[object AudioButton]"/>

    <span baselineShift="-50%"></span>

  </p>

</TextFlow>

TextFlow traced via the exporter after adding the next paragraph<TextFlow columnCount="inherit" columnGap="inherit" columnWidth="inherit" lineBreak="inherit" paddingBottom="inherit" paddingLeft="inherit" paddingRight="inherit" paddingTop="inherit" verticalAlign="inherit" whiteSpaceCollapse="preserve" xmlns="http://ns.adobe.com/textLayout/2008">

  <p>

    <span>ham-burg-er [or] ham-burg</span>

  </p>

  <p>

    <span>Sounds Like: &lt;b&gt;haem&lt;/b&gt; &lt;i&gt;&lt;b&gt;buhr&lt;/b&gt;&lt;/i&gt; g@r</span>

    <img baselineShift="-50%" height="21.65" width="27.55" source="[object AudioButton]"/>

    <span>[or] &lt;b&gt;haem&lt;/b&gt; &lt;i&gt;&lt;b&gt;buhrg&lt;/b&gt;&lt;/i&gt;</span>

    <img baselineShift="-50%" height="21.65" width="27.55" source="[object AudioButton]"/>

    <span baselineShift="-50%"></span>

  </p>

  <p baselineShift="50%">

    <span>Part of Speech: noun</span>

  </p>

</TextFlow>

This topic has been closed for replies.

1 reply

Adobe Employee
September 14, 2010

It looks like the paragraphs have some extra newlines in them, and since you have whiteSpaceCollapse set to "preserve" these are coming out as part of your paragraph content causing some extra spacing. I would expect content to look like this:

<p><span>Hello</span></p>

instead of like this:

<p>

     <span>Hello</span>

</p>

The latter is how a database program might choose to prettyprint the XML, but will result in whitespace that is likely undesired.

The baselineShift being applied to the following text is trickier, and is (I think) a result of TLF applying the character format from the previous paragraph to the next paragraph when it is created. You could work around this by adding a space after the graphic with no baselineShift applied.

Does this explain what you're seeing?

- robin

Participating Frequently
September 14, 2010

Just on the whiteSpaceCollapse issue...

Here is how I am creating my TextFlow now:

var tf:TextFlow = new TextFlow();

tf.whiteSpaceCollapse = WhiteSpaceCollapse.COLLAPSE;

I then add the ParagraphElements programatically, via the "addChild" method, after creating them from SpanElements, added to the ParagraphElements via the "addChild" method, that get their text from Strings.

When I trace the resulting text flow via:

TextConverter.export(tf, TextConverter.TEXT_LAYOUT_FORMAT, ConversionType.XML_TYPE)

the whiteSpaceCollapse property is still set to "preserve" in the resulting XML

I must be missing something, because that doesn't make sense.