I am seeing some terrible problems when attempting to make my html
text look nice in a TextArea component that uses embedded fonts.  

It seems that my <br/> tags and my spaces are not being respected.

Here is some sample code that shows it all.  I have embedded arial.ttf
font in this example since it would be simple for anyone to get this
ttf and compile the code:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="absolute" creationComplete="init()" xmlns:local="*">
        <mx:Script>
                <![CDATA[
                        [Embed(source="../assets/arial.ttf", fontName="Arial")]
                        public static var arialFont:Class;
        
                        private function init():void
                        {
                                // register arial font
                            Font.registerFont(arialFont);
                            
                            inHTML.text = "<font color='#000000' size='12'> 
Jack Frost -
<i>b. 1948</i></font><br /><font color='#000000' size='12'> & Suzy
Snowflake - <i>b. 1948, m. 1970</i></font><br /><br />  <font
color='#000000' size='10'>&#8226; Nicholas Claus - <i>b.
1971</i></font><br />   <font color='#695e49' size='10'>    <i>Spouse</i
> - Mrs. Claus - <i>b. 1973, m. 1993</i></font><br />";
                            inHTML2.text = "<font face='Arial' color='#000000' 
size='12'>
Jack Frost - <i>b. 1948</i></font><br /><font face='Arial'
color='#000000' size='12'> & Suzy Snowflake - <i>b. 1948, m.
1970</i></font><br /><br />     <font face='Arial' color='#000000'
size='10'>&#8226; Nicholas Claus - <i>b. 1971</i></font><br />  <font
face='Arial' color='#695e49' size='10'>    <i>Spouse</i > - Mrs. Claus
- <i>b. 1973, m. 1993</i></font><br />";
                        }                       
                ]]>
        </mx:Script>
        <mx:RichTextEditor id="editor" x="10" y="395" title="Title"/>
        <local:CustomTextArea id="outHTML" x="353" y="0" width="383"
height="333" editable="false" htmlText="{editor.htmlText}"/>
        <mx:TextArea id="outText" x="353" y="362" width="383" height="333"
editable="false" text="{editor.htmlText}"/>
        <mx:TextArea id="inHTML" x="10" y="10" width="314" height="161"
editable="true"/>
        <mx:TextArea id="inHTML2" x="10" y="179" width="314" height="145"
editable="true"/>
        <mx:Button x="10" y="352" label="IN" click="editor.htmlText =
inHTML.text"/>
        <mx:Button x="58" y="352" label="IN-2" click="editor.htmlText =
inHTML2.text"/>
        <mx:Button x="118" y="352" label="OUT" click="outHTML.htmlText =
editor.htmlText; outText.text = editor.htmlText"/>
</mx:Application>

And here is my "CustomTextArea" component:
<?xml version="1.0" encoding="utf-8"?>
<mx:TextArea xmlns:mx="http://www.adobe.com/2006/mxml";
creationComplete="init()">
        <mx:Script>
                <![CDATA[
                        private function init():void
                        {
                                this.textField.embedFonts = true;
                        }
                ]]>
        </mx:Script>
</mx:TextArea>


Click on the "IN-2" button to put the HTML in the second box into the
RTE and the box on the right.  You will notice that the RTE, which
does not use the embedded font, will display with correct
formatting...the CustomTextArea on the right, which is setup to use
the embeded font will not display correctly.

If you push the "IN" button, the HTML from the first box will get
pushed in...it does not have font "face" defined...in this case none
of the text shows up...IMHO it should show the text anyway with some
sort of "default" font.

What am I doing incorrectly?  I need HTML formatting to work correctly
with my embedded fonts.

Thanks,
Gary




Reply via email to