0

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

hippietrail
  • 15,848
  • 18
  • 99
  • 158
nmyster
  • 454
  • 1
  • 7
  • 20
  • See my answer here http://stackoverflow.com/a/26082046/1922144 You may also want to try using http://www.google.com/get/noto/#/ – davidcondrey Sep 28 '14 at 05:55

2 Answers2

0

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.

jsambuo
  • 137
  • 8
  • where do I get this font from? – nmyster Nov 13 '13 at 18:03
  • You can get KhmerOS from the Khmer Software Initiative at http://www.khmeros.info/ – jsambuo Dec 17 '13 at 23:20
  • If you are programming to target Android version 4.1.2, generally your solution need additional work on end user: http://osify.com/2012/02/install-khmer-font-on-galaxy-s2-without-rooting-system/ and your selected font as in this answer likely cannot use, please use the font as I stated in the link. – Osify Mar 16 '17 at 11:22
0

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

Osify
  • 2,253
  • 25
  • 42