Android Khmer support

1.6k views Asked by At

I am creating an app of which its users are Cambodian and mainly speak Khmer.

I need to find a solution to be able to support Khmer for both display and input on a Nexus 7 device or any android device for that matter.

Can anyone shed some light upon where I should go to sort this out.

Thanks

2

There are 2 answers

3
jsambuo On

I'm trying this using Android 4.1.2 and I'm able to have Khmer font show up fine for input and display.

By default, Android uses the Droid font family (Droid Sans, Droid Sans Mono, and Droid Serif). These fonts do not have Khmer characters, so if you try to display a Khmer character, the text will look blank or broken. You need to show the text using a font family that has Khmer characters (like KhmerOS). You'll need to provide the font to the app by placing it in the assets folder. You then need to set the typeface of any views to that font, including TextViews and EditTexts:

TextView textView = (TextView) findViewById(R.id.textView1);
EditText editText = (EditText) findViewById(R.id.editText1);
Typeface tf = Typeface.createFromAsset(getAssets(), "KhmerOS.ttf");
textView.setTypeface(tf);
editText.setTypeface(tf);

If you want your users to type in Khmer, they'll need to have a Khmer keyboard installed (such as Khmer Standard Keyboard).

By doing this, you should be able to have an app that can display Khmer and take Khmer input. The only problem I had when trying this out is that when using Android 2.2, the font was broken (some characters show as dotted circles or plus signs). I'm not sure why this is, but it seems to be fine in newer Android versions.

0
Osify On

If you minimum Android version 4.4.x (API 17), the render and Khmer font should be there, you can program as normal.