5/25/2010 3:13:08 AM
Title:
how to assign unicode?
hi all,
i am working with flash builder 4--web application
i have designed virtual keyboard for english.
now i am trying virtual keyboard for hindi.
here we have to use unicode.
how to assign unicode for hindi?
i dont have any idea about unicode formats.
i have attached virtual keyboard for english code here..
can someone help me...
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
creationComplete="application1_creationCompleteHandler(event)" viewSourceURL="srcview/index.html">
<fx:Script>
<![CDATA[
import flash.utils.getQualifiedSuperclassName;
import mx.events.FlexEvent;
private var inpText:String = 'inp1';
private var shiftState:Boolean = false;
private var capsState:Boolean = false;
protected function keyboard_clickHandler(event:MouseEvent):void
{
this[inpText].text = this[inpText].text+(event.currentTarget as Button).label;
if (shiftState == true) shift_clickHandler(null);
}
protected function caps_clickHandler(event:MouseEvent):void
{
capsState = !capsState;
if (capsState == true)
currentState = "SHIFTED" else currentState = "PRIMARY";
}
protected function tab_clickHandler(event:MouseEvent):void
{
this[inpText].text = this[inpText].text+" ";
}
protected function shift_clickHandler(event:MouseEvent):void
{
shiftState = !shiftState;
if (shiftState == true)
currentState = "SHIFTED" else currentState = "PRIMARY";
}
protected function enter_clickHandler(event:MouseEvent):void
{
this[inpText].text = this[inpText].text+"\n";
}
protected function backspace_clickHandler(event:MouseEvent):void
{
var tmpStr:String = this[inpText].text;
this[inpText].text = tmpStr.substr(0,tmpStr.length-1);
}
protected function application1_creationCompleteHandler(event:FlexEvent):void
{
inp1.setFocus();
}
protected function focus_enterHandler(event:MouseEvent):void
{
inpText = event.currentTarget.id;
}
]]>
</fx:Script>
<s:states>
<s:State name="PRIMARY"/>
<s:State name="SHIFTED"/>
</s:states>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:TextInput id="inp1" y="36" width="151" horizontalCenter="0" click="focus_enterHandler(event)" y.PRIMARY="246" horizontalCenter.PRIMARY="-93" width.PRIMARY="199" height.PRIMARY="31"/>
<s:Group id="keyboard" width="661" height="184" horizontalCenter="0" y="300" focusEnabled="false" height.PRIMARY="226" horizontalCenter.PRIMARY="0" width.PRIMARY="661">
<s:Button x="5" y="5" label="~" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="`"/>
<s:Button x="49" y="5" label="!" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="1"/>
<s:Button x="93" y="5" label="@" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="2"/>
<s:Button x="137" y="5" label="#" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="3"/>
<s:Button x="181" y="5" label="$" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="4"/>
<s:Button x="225" y="5" label="%" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="5"/>
<s:Button x="269" y="5" label="^" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="6"/>
<s:Button x="313" y="5" label="&" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="7"/>
<s:Button x="357" y="5" label="*" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="8"/>
<s:Button x="401" y="5" label="(" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="9"/>
<s:Button x="445" y="5" label=")" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="0"/>
<s:Button x="489" y="5" label="_" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="-"/>
<s:Button x="533" y="5" label="+" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="="/>
<s:Button x="577" y="5" label="Backspace" height="43" width="80" fontSize="11" fontWeight="bold" click="backspace_clickHandler(event)"/>
<s:Button x="5" y="48" label="Tab" height="43" width="67" fontSize="12" fontWeight="bold" click="tab_clickHandler(event)" label.PRIMARY="Tab"/>
<s:Button x="72" y="48" label="Q" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="q"/>
<s:Button x="116" y="48" label="W" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="w"/>
<s:Button x="160" y="48" label="E" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="e"/>
<s:Button x="204" y="48" label="R" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="r"/>
<s:Button x="248" y="48" label="T" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="t"/>
<s:Button x="292" y="48" label="Y" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="y"/>
<s:Button x="336" y="48" label="U" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="u"/>
<s:Button x="380" y="48" label="I" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="i"/>
<s:Button x="424" y="48" label="O" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="o"/>
<s:Button x="468" y="48" label="P" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="p"/>
<s:Button x="512" y="48" label="{" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="["/>
<s:Button x="556" y="48" label="}" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="]"/>
<s:Button x="600" y="48" label="|" height="43" width="57" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="\"/>
<s:Button x="5" y="91" label="CapsLock" height="43" width="80" fontSize="12" fontWeight="bold" click="caps_clickHandler(event)"/>
<s:Button x="85" y="91" label="A" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="a"/>
<s:Button x="129" y="91" label="S" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="s"/>
<s:Button x="173" y="91" label="D" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="d"/>
<s:Button x="217" y="91" label="F" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="f"/>
<s:Button x="261" y="91" label="G" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="g"/>
<s:Button x="305" y="91" label="H" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="h"/>
<s:Button x="349" y="91" label="J" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="j"/>
<s:Button x="393" y="91" label="K" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="k"/>
<s:Button x="437" y="91" label="L" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="l"/>
<s:Button x="481" y="91" label=":" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY=";"/>
<s:Button x="525" y="91" label=""" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="'"/>
<s:Button x="569" y="91" label="Enter" height="43" width="88" fontSize="24" fontWeight="bold" click="enter_clickHandler(event)" label.PRIMARY="Enter"/>
<s:Button x="5" y="134" label="Shift" height="43" width="106" fontSize="24" fontWeight="bold" click="shift_clickHandler(event)"/>
<s:Button x="111" y="134" label="Z" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="z"/>
<s:Button x="155" y="134" label="X" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="x"/>
<s:Button x="199" y="134" label="C" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="c"/>
<s:Button x="243" y="134" label="V" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="v"/>
<s:Button x="287" y="134" label="B" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="b"/>
<s:Button x="331" y="134" label="N" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="n"/>
<s:Button x="375" y="134" label="M" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="m"/>
<s:Button x="419" y="134" label="<" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY=","/>
<s:Button x="463" y="134" label=">" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="."/>
<s:Button x="507" y="134" label="?" height="43" width="44" fontSize="24" fontWeight="bold" click="keyboard_clickHandler(event)" label.PRIMARY="/"/>
<s:Button x="551" y="134" label="Shift" height="43" width="106" fontSize="24" fontWeight="bold" click="shift_clickHandler(event)"/>
<s:Button x="551" y="134" label="ctrl" height="43" width="106" fontSize="24" fontWeight="bold" click="shift_clickHandler(event)" x.PRIMARY="551" y.PRIMARY="176" width.PRIMARY="106"/>
<s:Button x="551" y="134" label="delete" height="43" width="106" fontSize="24" fontWeight="bold" click="shift_clickHandler(event)" x.PRIMARY="437" y.PRIMARY="176" width.PRIMARY="114"/>
<s:Button x="551" y="134" label="insert" height="43" width="106" fontSize="24" fontWeight="bold" click="shift_clickHandler(event)" x.PRIMARY="129" y.PRIMARY="176" width.PRIMARY="106" label.PRIMARY="insert"/>
<s:Button x="551" y="134" label="spacebar" height="43" width="106" fontSize="24" fontWeight="bold" click="shift_clickHandler(event)" x.PRIMARY="234" y.PRIMARY="176" width.PRIMARY="203"/>
<s:Button x="551" y="134" label="ctrl" height="43" width="106" fontSize="24" fontWeight="bold" click="shift_clickHandler(event)" x.PRIMARY="6" y.PRIMARY="176" label.PRIMARY="ctrl" width.PRIMARY="123"/>
</s:Group>
</s:Application>
Inder
Points: 2880
Posts:0
5/25/2010 5:34:04 AM
To implement HINDI Unicode font inside flex 4.0 . First of all download the "kundli hindi font" that I have used in this sample. Place it under fonts directory.
http://dsh.cs.washington.edu:8000/player/kundli.ttf
Now use stylesheet to declare and embed the font inside your swf file:
<fx:Style>
@namespace s "library://ns.adobe.com/flex/spark";
@namespace mx "library://ns.adobe.com/flex/mx";
@font-face
{
src: url("fonts/kundli.ttf");
fontFamily: "Kundli Hindi Heavy";
fontWeight: "normal";
fontAntiAliasType: "advanced";
fontThickness: 800;
fontGridFitType: "subpixel";
}
.myTextBoxClass{
fontFamily: "Kundli Hindi Heavy";
}
</fx:Style>
//Now you can use the class in your textbox where you want to use Hindi fonts.
<s:TextInput id="inp1" styleName="myTextBoxClass" y="36" width="151">
5/25/2010 5:54:21 AM
You can use this, I found this code on some where while browsing:
<mx:Style>
@font-face {
src:url("fonts/mangal.ttf");
fontFamily:myMangal;
flashType: true;
unicodeRange:U+0900-U+097F;
}
.myTextArea {
fontFamily: myMangal;
fontSize: 16;
}
</mx:Style>