AIR:HTMLコンポーネント

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

昨日に引き続き。

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

XML:
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" borderStyle="solid">
  3.     <mx:Script>
  4.         <![CDATA[
  5.             import flash.html.JavaScriptObject;
  6.             function changeFontFamily():void
  7.             {
  8.                 var doc:JavaScriptObject = html.javaScriptDocument.styleSheets;
  9.                 for (var i:int = 0; i <doc.length; i++) {
  10.                     for( var j:int = 0; j <doc[i].cssRules.length; j++) {
  11.                         doc[i].cssRules[j].style.fontFamily = "MS UI Gothic";
  12.                     }
  13.                 }
  14.             }
  15.         ]]>
  16.     </mx:Script>
  17.     <mx:HBox>
  18.         <mx:TextInput id="textBox" width="225" text="http://" change="html.location = textBox.text"/>
  19.         <mx:Button label="移動" click="html.location = textBox.text;"/>
  20.     </mx:HBox>
  21.     <mx:HTML id="html" width="100%" height="100%" y="30" complete="changeFontFamily();"/>
  22. </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>