Libgdx scene 2d ui localization - libgdx

I'm Libgdx begginner.
I'm trying to make game menu using scene2d UI.
Once the english version is completed, I am now going to create korean, japanese and chinese version.
but... asian letters are not visible or comes out strange..
So I checked the font using bitmapfont (following codes)
< at constructor >
font = new BitmapFont(Gdx.files.internal("skin/lotte.fnt"), Gdx.files.internal("skin/lotte.png"), false);
< at draw method >
game.batch.begin();
font.draw(game.batch, "안녕하세요?", gameViewport.getWorldWidth()/2,gameViewport.getWorldHeight()/2);
game.batch.end();
Above korean letters works well. But It is not working for scene2d UI skin.
Does scene2d UI skin not support asian letters?

I solved this problem.
the problem comes out reading the string from I18NBundle.
the following code has the problem,
Label titleLabel = new Label(bundle.get("strings/test"), skin, "lotte2", Color.BLACK);
tbl.add(titleLabel).padBottom(stage.getHeight()/20f).row();
but this code works well.
Label titleLabel = new Label("ㄱㄴㄷㄹㅁㅂㅅ", skin, "lotte2", Color.BLACK);
tbl.add(titleLabel).padBottom(stage.getHeight()/20f).row();
Thanks for "Tenfour04" & "Madmenyo" !

Related

Filters on DisplayObject Not working

I'm trying to add DropShadowFilter / BlurFilter / GlowFilter to a simple Sprite on stage.
If i target flash, it looks and behaves fine. When i target HTML5, i see nothing.
The wiki says "Available on all platforms" (link).
Am i doing something wrong?
I'm importing
import openfl.filters.BlurFilter;
import openfl.display.Sprite;
Here is the code im using:
var s:Sprite = new Sprite();
s.graphics.beginFill(0xff0000, 1);
s.graphics.drawCircle(50, 50, 50);
s.graphics.endFill();
var blur:BlurFilter = new BlurFilter(40, 40, 1);
s.filters = [blur];
addChild(s);
HTML5 PRINTSCREEN:
FLASH PRINTSCREEN:
Right now there is little to no support for filters on any target but Flash.
The good news is that we are working on implementing custom shaders and filters for OpenFL next on every target that uses OpenGL. Here is the PR and discussion https://github.com/openfl/openfl/pull/697
I would guess that some filters could be implemented via software for HTML5 canvas, but I'm not focusing on that in that PR.
As far as im aware filters are not supported in legacy or next. Ive never seen them working anyway. I presume eventually they will be supported in next.

Issue with Input TLF textfield in Flash as3 Adobe Air

Input TLF textfield having issue while player inputting text in mobile.
When player focus into the TLF textfield,then mobile keyboard is opened.But when one start to enter text ,then TLF not getting any inputted character.
That means Input TLF not working as Input,its working only as dynamic TLF in mobile version.
To fix this issue,Adobe introduced "StageText" for only Mobile version.
StageText is perfect for mobile devices but it support all features of TLF textfield except RTL direction..
can anyone tell me whether its fixed or not?
If you are develop for iOS, then use FPTextField of the FPNativeUI.ane:
var textField:FPTextField = new FPTextField();
textField.frame = new Rectangle(50, 50, 100, 20);
textField.textAlignment = FPTextAlignment.RIGHT;
textField.setWritingDirection(FPTextWritingDirection.RTL);
textField.stage.addChild(textField);
Download ane: https://github.com/flashpress/FPNativeUI-ANE .
Compare StageText vs FPTextField: http://www.youtube.com/watch?v=BKYaoLtEmCU

StageText multiline problems

So I am pretty new to this whole AIR for iOS development thing and am just dipping my toe into the StageText object for a project I am working on. I am having trouble getting my StageText to be restricted to a single line. (such as for username input)
The documentation is terrible from Adobe but blog posts I have found have said to pass "false" to the StageTextInitOptions which seems to sorta work, but not really. When I do this the read-only multiline property on the stageText option traces as "false" which is good but when I actually type in the field it still breaks and goes to the next line when it is full.
here is my code:
var stageTextInitOptions = new StageTextInitOptions(false);
stageText = new StageText(stageTextInitOptions);
stageText.stage = stage;
stageText.viewPort = new Rectangle(0, 0, w, h);
trace(stageText.multiline); //traces out as false
EDIT: The problem seems to be in desktop only, when the app is placed on an ipad the multiline limitation functions as expected. (The problem is it NEEDS to work on both desktop and ios)
Any ideas? thanks so much!
StageText uses native mobile keyboards only on iOs and Android. You will need to work with the TextField and wordwrapping on the Desktop.
Why would you not use a regular hardware keyboard on a Desktop though? It's as native for Desktops as it gets.
use :
var stageTextInitOptions = new StageTextInitOptions(true);

AS3: Arabic Embed Fonts

I am using as3 and trying to use embed fonts with Arabic text but it doesn't work
So is there a way that I can access from .tff file the shape of the character or make it works using embed fonts
As using system fonts works but at same time its bad as on some machines it is reverted so I want to use embed font
Hope anyone can help
I found code by some one to change the input arabic text to the correct shape based on the position in text and I modified it to work perfectly with my code :)
here the AS3 code file: http://www.akhalifa.com/testing/ArabicAS3File/ArabicStringUtils.as
and here an example on how to use it: http://www.akhalifa.com/testing/ArabicAS3File/Main.as
You can use any arabic/persian input language like Maryam4
then write your sentence in this program after that copy it and paste in your code
also as #Goran Mottram said embed your font (for this situation if you use Maryam you must select F_fonts)
but noticed that in your code if you paste your arabic language it shows you wired character like ÂMoø , but dont worry if you publish you see a correct arabic word with rtl support
If you have the font installed on your system, make sure to import the font into your library and tick the box "Export for ActionScript" and give it an appropriate name, say MyArabicFont, then bind it to textfield using the following code:
// create the font
var myFont:Font = new MyArabicFont();
// assign to textformat
var myTextFormat:TextFormat = new TextFormat();
myTextFormat.font = myFont.fontName;
// assign to textfield
var myTextField:TextField = new TextField();
myTextField.defaultTextFormat = myTextFormat;
myTextField.embedFonts = true;
myTextField.text = "Hello, world";
this.addChild(myTextField);

Arabic text in as3

How can I display arabic text from right to left with as3?
This code will do the trick:
import flash.text.AntiAliasType;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.external.*
import fl.text.TLFTextField;
import flash.text.TextFormat;
import flashx.textLayout.formats.TextLayoutFormat;
import flashx.textLayout.elements.TextFlow;
var arabicTextField:TLFTextField = new TLFTextField();
arabicTextField.antiAliasType = AntiAliasType.ADVANCED;
arabicTextField.mouseEnabled = false;
arabicTextField.selectable = false;
arabicTextField.direction = flashx.textLayout.formats.Direction.RTL;
var fmt:TextFormat = new TextFormat();
fmt.color = 0xFFFFFF;
fmt.font = "arialArabic"
arabicTextField.embedFonts = false;
arabicTextField.defaultTextFormat = fmt;
arabicTextField.setTextFormat(fmt);
The Text Layout Framework can handle right to left text.
I know this is an old thread. But still the most useful snippet around for RTL Text. Thanks Ellen.
Let me add some experiences in coding for iOS on Flash Builder 4.7 in times of CC:
Flash Builder doesn't ship with the TLFTextField and its supporting classes needed to display Arabic and other RTL languages on iOS.
Between CS6 and CC Adobe has even dropped those classes from Flash Professional. Probably because the standard TextField class has been improved.
Still, on iOS RTL and and Arabic Ligatures will not work out of the Box. If you use the TextField class AirSimulator of FlashBuilder will display correctly. Not if you run the same code on iOS.
StageText and its NativeText wrapper will render correctly but do have disadvantages for static text.
You might think of reintroducing TLFTextField. Here's how you can do it:
Install Flash Professional CS6 (!) from the Creative Cloud
In the "libs" subfolder of the programfolder you'll find two SWCs that contain the classes needed to use TLFTextField: TLFRuntime.swc & textLayout.swc
Copy the SWC in your ProjectFolder and include it in Flash Builder by opening your project's properties -> ActionScript Build Path -> Library Path -> Add SWC (or Add SWC-Folder)
This should make Ellen's code work on FlashBuilder 4.7 for iOS with Air SDK 3.9
You could probably expect the standard TextField display Arabic and other RTL languages correctly in future releases of Air.
Additionally, you probably will need to include the fonts you use in your library
try to add textformat with propriety right alignment
var txtFormat:TextFormat = new TextFormat();
txtFormat.align = "right";
I've also had success with FlarabySWF - it costs some money (not alot) but it actually works quite well in my experience.
If you're not opposed to the flex framework, it now includes a decent internationalization library that should allow you to do this easily. Here's a decent place to get started http://devgirl.org/2011/03/15/flex-4-localization/