0
Community Beginner
,
/t5/animate-discussions/line-breaks-ignored-when-using-html-text-css-and-embedded-fonts/td-p/98861
Aug 20, 2008
Aug 20, 2008
Copy link to clipboard
Copied
Anyone come accross this.
When using a StyleSheet with html text in a dynamic textfield with embedded fonts line breaks are ignored. It is as if TextField.condenseWhite is being set to true. Essentially the <p> tags are being treated as a <br/> tag.
If I dont embed fonts it works fine. Another weird thing is if i add an empty paragraph <p></p> between the first two paragraphs it makes any subsequent paragraph behave correctly. e.g.
<p>first paragraph text here</p>
<p>second paragraph text here</p>
<p>third paragraph text here</p>
displays as if there are <br/> between each one.
But
<p>first paragraph text here</p>
<p></p>
<p>second paragraph text here</p>
<p>third paragraph text here</p>
behaves correctly even for the third paragraph.
Here is the code i am working with (using XML as i am dynamically populating the textfield from XML)
any help much appreciated
UPDATE:
After reading http://www.kirupa.com/forum/showthread.php?t=307326
i tried the same experiment using a TF drawn in the IDE, the results for each, even though the TextFields are essentially the same are totally different.
updated CODE accordingly - just need a TF on stage, called "ideTextField" with font 'Arial'
When using a StyleSheet with html text in a dynamic textfield with embedded fonts line breaks are ignored. It is as if TextField.condenseWhite is being set to true. Essentially the <p> tags are being treated as a <br/> tag.
If I dont embed fonts it works fine. Another weird thing is if i add an empty paragraph <p></p> between the first two paragraphs it makes any subsequent paragraph behave correctly. e.g.
<p>first paragraph text here</p>
<p>second paragraph text here</p>
<p>third paragraph text here</p>
displays as if there are <br/> between each one.
But
<p>first paragraph text here</p>
<p></p>
<p>second paragraph text here</p>
<p>third paragraph text here</p>
behaves correctly even for the third paragraph.
Here is the code i am working with (using XML as i am dynamically populating the textfield from XML)
any help much appreciated
UPDATE:
After reading http://www.kirupa.com/forum/showthread.php?t=307326
i tried the same experiment using a TF drawn in the IDE, the results for each, even though the TextFields are essentially the same are totally different.
updated CODE accordingly - just need a TF on stage, called "ideTextField" with font 'Arial'
TOPICS
ActionScript
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
1 Correct answer
Community Beginner
,
Sep 04, 2008
Sep 04, 2008
OK,
I have given up messing with stylesheets, trying display: block, inline, different ways of formatting the XML, messing with XML.ignoreWhiteSpace, and XML.prettyPrinting etc.
I went down the route of encodeURI, using a RegExp to strip out all tabs, linefeeds and carriage returns. This now gives consistent results for all situations, even embedded and none embedded fonts.
e.g.
_text:String = TEXT FROM XML, HTML TEXT etc
var st:String = encodeURI(_text);
var pattern:RegExp = /(%09)+|(%0A)+...
I have given up messing with stylesheets, trying display: block, inline, different ways of formatting the XML, messing with XML.ignoreWhiteSpace, and XML.prettyPrinting etc.
I went down the route of encodeURI, using a RegExp to strip out all tabs, linefeeds and carriage returns. This now gives consistent results for all situations, even embedded and none embedded fonts.
e.g.
_text:String = TEXT FROM XML, HTML TEXT etc
var st:String = encodeURI(_text);
var pattern:RegExp = /(%09)+|(%0A)+...
Community Beginner
,
LATEST
/t5/animate-discussions/line-breaks-ignored-when-using-html-text-css-and-embedded-fonts/m-p/98862#M1641
Sep 04, 2008
Sep 04, 2008
Copy link to clipboard
Copied
OK,
I have given up messing with stylesheets, trying display: block, inline, different ways of formatting the XML, messing with XML.ignoreWhiteSpace, and XML.prettyPrinting etc.
I went down the route of encodeURI, using a RegExp to strip out all tabs, linefeeds and carriage returns. This now gives consistent results for all situations, even embedded and none embedded fonts.
e.g.
_text:String = TEXT FROM XML, HTML TEXT etc
var st:String = encodeURI(_text);
var pattern:RegExp = /(%09)+|(%0A)+|(%0D)+/g;
st = st.replace(pattern, "");
st = decodeURI(st);
YOUTEXTFIELD.htmlText = st;
The <p> tags still behave as a <br/> tag, but you can add an extra <br/> to simulate a paragraph.
Here is the example again with the updates,
Hope this helps someone
I have given up messing with stylesheets, trying display: block, inline, different ways of formatting the XML, messing with XML.ignoreWhiteSpace, and XML.prettyPrinting etc.
I went down the route of encodeURI, using a RegExp to strip out all tabs, linefeeds and carriage returns. This now gives consistent results for all situations, even embedded and none embedded fonts.
e.g.
_text:String = TEXT FROM XML, HTML TEXT etc
var st:String = encodeURI(_text);
var pattern:RegExp = /(%09)+|(%0A)+|(%0D)+/g;
st = st.replace(pattern, "");
st = decodeURI(st);
YOUTEXTFIELD.htmlText = st;
The <p> tags still behave as a <br/> tag, but you can add an extra <br/> to simulate a paragraph.
Here is the example again with the updates,
Hope this helps someone
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

