Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Line breaks ignored when using HTML text CSS and embedded fonts

Community Beginner ,
Aug 20, 2008 Aug 20, 2008
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'



TOPICS
ActionScript
1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 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)+...
Translate
Community Beginner ,
Sep 04, 2008 Sep 04, 2008
LATEST
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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines