/*=:project scalable Inman Flash Replacement (sIFR) version 3. =:file Copyright: 2006 Mark Wubben. Author: Mark Wubben, Description: Allows you to edit style definitions in different `parseCSS()` calls. Also adds a `leading` CSS property and fixes `font-weight` and `font-style` on custom tags (such as `strong`). =:history * IFR: Shaun Inman * sIFR 1: Mike Davidson, Shaun Inman and Tomas Jogin * sIFR 2: Mike Davidson, Shaun Inman, Tomas Jogin and Mark Wubben =:license * This software is licensed and provided under the CC-GNU LGPL * See */ import TextField.StyleSheet; class SifrStyleSheet extends TextField.StyleSheet { public function parseCSS(cssText:String) { var native = new TextField.StyleSheet(); var parsed = native.parseCSS(cssText); if(!parsed) return false; var selectors = native.getStyleNames(); for(var i = selectors.length - 1; i >= 0; i--) { var selector = selectors[i]; var nativeStyle = native.getStyle(selector); var style = this.getStyle(selector) || nativeStyle; if(style != nativeStyle) { for(var property in nativeStyle) style[property] = nativeStyle[property]; } this.setStyle(selector, style); } return true; } // Apply leading to the textFormat. Much thanks to . private function applyLeading(format, leading) { if(leading >= 0) { format.leading = leading; return format; } // Workaround for negative leading, which is ignored otherwise. var newFormat = new TextFormat(null, null, null, null, null, null, null, null, null, null, null, null, leading); for(var property in format) if(property != 'leading') newFormat[property] = format[property]; return newFormat; } function transform(style) { var format = super.transform(style); if(style.leading) format = applyLeading(format, style.leading); return format; } }