Skip to main content
June 9, 2009
Answered

Space not preserving for span elements

  • June 9, 2009
  • 1 reply
  • 2964 views

Hi,

I am using TLF version 442 for my application.

When i am doing some changes like making text bold like below:

"For Flash 10" to "For Flash 10". Then it shows it correctly.

But again if I export this and and reimport it shows "ForFlash10" i.e. It eliminates the spaces.

I have tried for "XML.ignoreWhitespace", it solves this but if I am having multiple span elements with this then it will take each one on next line. As it preserves the spaces now.

I want it on same line. Is there any way of doing this, ignoreWhiteSpaces is also not as per the expectation as it leaves unneccessary spaces for lines.

Regards,

Rajesh

This topic has been closed for replies.
Correct answer rdermer

Hi Richard,

while loading for the first time I have below markup:

<TextFlow whiteSpaceCollapse="preserve" paddingBottom="10" paddingLeft="10" paddingRight="10" paddingTop="10" lineBreak="inherit" verticalAlign="middle" xmlns="http://ns.adobe.com/textLayout/2008">
  <p textAlign="center">
    <span fontFamily="Verdana" fontSize="41" color="0x0" LETTERSPACING="0" KERNING="0">
      For Flash 10 Please Do not Delete This Template
    </span>
  </p>
</TextFlow>

after I make "Flash" Italic the markup becomes:

<TextFlow whiteSpaceCollapse="preserve" paddingBottom="10" paddingLeft="10" paddingRight="10" paddingTop="10" lineBreak="inherit" verticalAlign="middle" xmlns="http://ns.adobe.com/textLayout/2008">
  <p textAlign="center">
    <span fontFamily="Verdana" fontSize="41" color="0x0" LETTERSPACING="0" KERNING="0">
      For
    </span>
    <span fontFamily="Verdana" fontStyle="italic" fontSize="41" color="0x0" LETTERSPACING="0" KERNING="0">
      Flash
    </span>
    <span fontFamily="Verdana" fontSize="41" color="0x0" LETTERSPACING="0" KERNING="0">
      10 Please Do not Delete This Template
    </span>
  </p>
</TextFlow>

If we notice here it removes the space after "For" in first <span> and space before "10" in last <span>.

I am getting these after I export this when I am done with Italic on word "Flash".

For exporting I am using  below code:

var exportXML:XML = XML(TextFilter.export(textFlow,TextFilter.TEXT_LAYOUT_FORMAT,ConversionType.XML_TYPE));

Please let me know if I am making any mistake in this. My TLF version is 442 and Flex SDK is 3.2.

Regards,

Rajesh


Its not going to work to support the round trip import/export with the spans on separate lines nicely indented.

Our test app wraps the export like this:

const xmlBoilerPlate:String = '<?xml version="1.0" encoding="utf-8"?>\n';

var originalSettings:Object = XML.settings();

try

{

XML.ignoreProcessingInstructions = false;

XML.ignoreWhitespace = false;

XML.prettyPrinting = false;

var exporter:ITextExporter = TextFilter.getExporter(format);

var xmlExport:XML = exporter.export(defaultFlow, ConversionType.XML_TYPE) as XML;

var result:String = xmlBoilerPlate + xmlExport;

XML.setSettings(originalSettings);

}

catch(e:Error)

{

XML.setSettings(originalSettings);

throw(e);

}

The importer does this for you.

Hope that helps,

Richard

1 reply

Adobe Employee
June 9, 2009

By turning on XML.ignoreWhitespace the XML parser will ignore the spaces and they get to TLF.

TLF has the whiteSpaceCollapse property.  Try setting it to collapse.

http://livedocs.adobe.com/flex/gumbo/langref/flashx/textLayout/formats/TextLayoutFormat.html#whiteSpaceCollapse

There was a lot of discussion on how to deal with whitespace when it was being implemented.  The result was that having the spans together on the same line with the paragraph tags looked gave the best results with the XML settings and the whiteSpaceCollapse property.

     <p><span>...</span><span>..</span></p>

Regards,

Richard

June 10, 2009

Hi Richard,

I have tried below combinations.

XML.ignoreWhiteSpaces = false;

and

textFlow.whiteSpaceCollapse = "preserve";

but it shows(below is sample output)

For

Flash

10 Please Do not Delete This Template

instead of "For Flash 10 Do not Delete This Template"

Then I tried for:

XML.ignoreWhiteSpaces = true(which is default);

and

textFlow.whiteSpaceCollapse = "preserve";

it shows:

"ForFlash10 Please Do not Delete This Template"

then I tried for:

XML.ignoreWhiteSpaces = true(which is default);

and

textFlow.whiteSpaceCollapse = "collapse";

then it shows:

"ForFlash10 Please Do not Delete This Template"

and last I tried:

XML.ignoreWhiteSpaces = false;

and

textFlow.whiteSpaceCollapse = "collapse";

then also it shows:

For

Flash

10 Please Do not Delete This Template

Please let me know if I am doing any mistake.

Regards,

Rajesh

Adobe Employee
June 10, 2009

Your not showing what markup you are using - but in the end I don't think you'll be able to put the span elements on separate lines.

Richard