# StyleSheet + setTextFormat doesn´t work

**URL:** <https://forum.kirupa.com/t/stylesheet-settextformat-doesn-t-work/326591>\
**Category:** flash\
**Created:** [December 27, 2011, 3:27pm UTC](https://forum.kirupa.com/t/stylesheet-settextformat-doesn-t-work/326591 "2011-12-27T15:27:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![magic74](https://avatars.discourse-cdn.com/v4/letter/m/91b2a8/32.png) [@magic74](https://forum.kirupa.com/u/magic74)\
**Post date:** [December 27, 2011, 3:27pm UTC](https://forum.kirupa.com/t/stylesheet-settextformat-doesn-t-work/326591/1 "2011-12-27T15:27:45Z")

</div>

Hi to all,  
i can´t figure out why i can´t combine stylesheet and settextformat together:

```auto

package marek{

    import flash.display.DisplayObject;
    import flash.display.Sprite;
    import flash.text.*;

    public class renderText extends Sprite {

        private var t:TextField = new TextField();
        private var tf:TextFormat = new TextFormat();
        private var css:StyleSheet = new StyleSheet();

        public function renderText($fsize:int, $bold:Boolean, $fcolor:uint, $twidth:int, $fnt:String="Verdana") {
            // CSS
            this.css.parseCSS("a {color: #0000FF;} a:hover {text-decoration: underline;}");
            
            // TextField
            addChild(t);
            t.antiAliasType = AntiAliasType.ADVANCED;
            t.autoSize = TextFieldAutoSize.LEFT;
            t.textColor = $fcolor;
            //t.cacheAsBitmap = true;
            if ($twidth != 0) {
                t.wordWrap = true;
                t.width = $twidth;
            } else {
                t.wordWrap = false;
            }
            
            // Textformat
            tf.font = $fnt;
            tf.size = $fsize;
            tf.bold = $bold;
            tf.align = TextFormatAlign.LEFT;
        }

        public function txt($txt:String, $embeddFont:Boolean=false):void {
            if ($embeddFont) {
              t.embedFonts = true;
                //t.styleSheet = css;
                t.htmlText = $txt;
            } else {
                t.htmlText = $txt;
            }
            t.setTextFormat(tf);
            
        }

        public function set letterSpacing(u:int) {
            var fmt:TextFormat = t.getTextFormat();
            fmt.letterSpacing = u;
            t.setTextFormat(fmt);
        }

    }
}

```

before that i embbed two fonts via

```auto

[Embed(source = 'c:/FrutigerLT47LightCondensed.ttf',fontWeight = "normal",fontFamily = "FrutigerLTlightCN",embedAsCFF = "false")]
public var FrutigerLTlightCN:Class;
[Embed(source = 'c:/FrutigerLT67BoldCondensed.ttf',fontWeight = "bold",fontFamily = "FrutigerLTboldCN",embedAsCFF = "false")]
public var FrutigerLTboldCN:Class;

```

do somebody has a hint for me  
thx in advance
