Skip to main content
Participating Frequently
January 9, 2012
Question

TLF and spaces between styled <span/> and other tags

  • January 9, 2012
  • 1 reply
  • 957 views

Hi guys,

I have a thing to ask you that is making me crazy...

I'm working on an application with text editor that uses TLF.

I can apply styles and I can save persistently the text in an external xml file.

When I play with text and styles it's all right.

Problems arrive when I save the <TextFlow/> block in an external file and then reloads it in the application.

(I save text with TextConverter.export() method );

1st way I've tryed:

when I reload text it misses space between styled text and common text:

(myTextFlow.importToFlow( mySavedTextFlow, TextConverter.TEXT_LAYOUT_FORMAT);)

for example when I save this text:

"this is bold and this is normal but this is italic."

I reload and view this:

"this isboldand this is normal but this isitalic."

2nd way I have tryied...

is converting the xml <TextFlow/> block in a string and then assigning it to myTextFlow.tlfMarkup...

If this was the original string: 

"this is bold and this is normal but this is italic."

the loaded text appears like:

"this is

     bold

and this is normal but this is

italic."

So, I feel a bit down... what I'm going wrong?

Thanks in advance for your help!

This topic has been closed for replies.

1 reply

Participating Frequently
January 10, 2012

Hi,

I write a test code and try to repro your problem, but my code worked correctly. See code below please: 

// First import a TLF markup with bold text

var textFlow:TextFlow = SelManager.textFlow;               

textFlow.whiteSpaceCollapse = WhiteSpaceCollapse.COLLAPSE;               

var markup:String ='<TextFlow  version="2.0.0" xmlns="http://ns.adobe.com/textLayout/2008"><p><span>this is </span><span fontWeight="bold">bold</span><span> and</span></p></TextFlow>'

             

var textFlowNew:TextFlow = TextConverter.importToFlow(markup, TextConverter.TEXT_LAYOUT_FORMAT);

textFlow.replaceChildren(0, textFlow.numChildren, textFlowNew.mxmlChildren);                                              

// Export textFlow as your saving text for import usage

var savingMark:String = TextConverter.export(textFlow, TextConverter.TEXT_LAYOUT_FORMAT, ConversionType.STRING_TYPE) as String;                                        

// Then uses savingMark to import to TLF                        

var textFlowLoaded:TextFlow = TextConverter.importToFlow(savingMark, TextConverter.TEXT_LAYOUT_FORMAT);                        

textFlow.replaceChildren(0, textFlow.numChildren, textFlowNew.mxmlChildren);                              

SelManager.updateAllControllers();              

SelManager.textFlow.flowComposer.compose();

After import -> export -> import, the spaces still there as exepcted.

lelegueraAuthor
Participating Frequently
January 10, 2012

Hi mjzhang!

thanks for your replay.

I definitely resolve the problem adding this code at the top of the application:

XML.ignoreWhitespace = false;

XML.prettyPrinting = false;

found in this thread http://forums.adobe.com/message/3823103 (suggested by forum in the right column )

Bye!