AIR:HTMLコンポーネント

2007年6月15日 (金曜日) - 13:48:35 by webmaster

昨日に引き続き。

デフォルトの日本語フォントレンダリングの不具合の解決方法(マルチバイトを含まないフォント名を指定する)が見つかったので、これをHTMLコンポーネントに適用してみる。

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" borderStyle="solid">
    <mx:Script>
        <![CDATA[
            import flash.html.JavaScriptObject;
            function changeFontFamily():void
            {
                var doc:JavaScriptObject = html.javaScriptDocument.styleSheets;
                for (var i:int = 0; i <doc.length; i++) {
                    for( var j:int = 0; j <doc[i].cssRules.length; j++) {
                        doc[i].cssRules[j].style.fontFamily = "MS UI Gothic";
                    }
                }
            }
        ]]>

    </mx:Script>
    <mx:HBox>
        <mx:TextInput id="textBox" width="225" text="http://" change="html.location = textBox.text"/>
        <mx:Button label="移動" click="html.location = textBox.text;"/>
    </mx:HBox>
    <mx:HTML id="html" width="100%" height="100%" y="30" complete="changeFontFamily();"/>
</mx:WindowedApplication>

適用前(デフォルト)

test1.gif

適用後

test2.gif

見た目は大事だよね。

Leave a Reply

XHTML: You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>