Unicode character (ரு) in Swing text box - java

In Browser the Unicode character (ரு) is showing properly. If I copy paste it in swing textfield it appears wrong.
PS: it is the combination of two character.
Please help on this.

For this type of characters font and uni coding must be supported by the system.

Related

Swing components does not show thai characters

I have a simple swing application. When i set a thai text to a JLabel or other components they shows question mark like characters instead of thai text.
Is there anything to do to support thai language in swing applications?
There is not a special function or configuration to do.
Be sure that your font supports thai characters.
When i met same problem, component font was set to calibri.
After changing it to sansserif it worked.
But i don't know any other font that supports thai, i just found it with brute force tries.

java swing jtextfiled unicode sinhala

***************************UPDATED***********************************************************************
i have found a similar question :
here : same question by another user
this one is with little details , but i still cant get it to work !
any help would be glad fully accepted !
I want to type Sinhalese words in (J2SE)swing textfileds , but they don't appear correctly in Java , same text in notepad shows correct word. how can i fix this ?
notepad picture:
http://imageupper.com/i/?S0200010080011O13734602521426968
java picture :
http://imageupper.com/i/?A0300010070011I13734604591427932
The same letters are in both images, so it's not problem of encoding.
The problem is that you have to set a proper font to the textfield. You can create the font if you don't have it, check this setting custom font
#AndrewThompson answer :)
Edit: That other user with the same question that you have mentioned is me. :)
As I found out, the char data type is not enough to render letters like "ශ්‍ර" because it needs 3 8bit characters. And the Java language isn't going to change the size of char data type just because we Sri Lankans want to render our characters. I had the similar question previously and I am the user you mentioned in your question.
"ශ්‍ ර" is shown with 2 8bit characters for each character and that's all we got till now. You might want to checout SWT because it shows characters pretty damn well in my experience.

Printing Unicode characters in java

I'm developing a Sinhala-English Unicode translator on Java. When I print a Unicode character in a JTextPane, it only shows a blank box. But when I copy that box to the notepad in windows it shows me the letter.
The problem is that Java not showing the Unicode characters instead windows.
How can I fix this problem ?
It's likely that the font you are using in your JTextPane does not fully support the Unicode range that you are trying to display. Try setting the text area's font to something more Unicode-friendly (see the row labeled "Sinhala (80: 0D80–0DFF)").

English characters don't show up when entering text with Urdu fonts in Swing

This is similar to my own previous question, but that solution didn't work here.
As mentioned in the previous question, I'm working on a cross platform(Windows/Ubuntu) application that has to transliterate English into one of several official Indian languages. The application has a custom input method, and typing in English and pressing space will transliterate the typed text into the specific local language. Urdu is different from the others in being right to left, like Arabic/Hebrew.
I managed to find an open licensed Urdu font that has both English and Urdu glyphs, but when I type characters in English, nothing shows up.
I don't understand whether it's a font painting issue, or related to the input method. So far, if I disable the custom input method (InputMethod.dispatchEvent() ) for this language, I am able to see the English text (but of course no transliteration takes place).
My findings:
Change font to one of Windows' built in Arabic fonts - same result.
Instead of using ComponentOrientation to align text in the text field, I used setHorizontalAlignment for when the locale is Urdu. Same result.
Decompiled the JDK's default input method provider on Windows (sun.awt.windows.WInputMethod). Here I see the dispatchEvent() makes a native call to the OS for handling IME. I can't do that here.
Found a custom IM for Hebrew - my version of dispatchEvent() is essentially the same.
Stepped through code for JTextField in Eclipse - wasn't able to find anything in the AbstractDocument and subclasses. The AbstractDocument.insertUpdate() method checks for and updates bidirectional text input, but there wasn't anything else significant.
I'm unable to understand what happens after the dispatchEvent() call. The characters are being registered, i.e. the transliteration engine is able to detect the typed characters and process them, but they just don't show up on screen.
Workaround
If I let the text field's orientation be as it is for regular left to right languages, I can see the English text. However, this would not be acceptable to an Urdu speaking user.
Can someone point me in the right direction?
I set the locale to ur_IN.
Sadly, ur_IN is not among the supported locales; I only see en_IN and hi_IN. In the example cited, I used the following code to get the image below:
spinner.setLocale(new Locale("hi", "IN"));

Mix of Arabic and English causes problems in JTextArea (Java)

I have a JTextArea which displays HTML of an Arabic web page. So it's essentially a mix of English and Arabic. In the JTextArea, with columns set to 30, certain text just disappears instead of wrapping properly. The weird thing is that if I copy the invisible text and paste it into Notepad, then I can see it in Notepad. If I change the number of columns to 40, everything displays fine. Any ideas?
See this screenshot of the problem:
Elie, thanks for the response. Not sure I explained the problem properly though. On the left in the screenshot is the JTextArea. On the right is the selection from the JTextArea pasted into Notepad. Does this make more sense now?
Is it the 30th character which is disappearing? It's possible due to the script that the JTextArea cannot render the Arabic characters properly. So it's counting the characters correctly, but doesn't realize that they take up more space. Support for such fonts is not great, so you may want to write a custom renderer for your JTextArea to deal with this (so you can manually take into account the proper amount of space required per character in Arabic and adjust the line wrap accordingly).

Categories