Emoji (Emoticons) on Blackberry and Android App. How to support? - android

I wonder how whatsapp gives support for that. I could use emojis on iPhone because it is natively supported. I'm not developing for bb neither android but I need to help a coder with this stuff.
The bb guy told me that he can add a font as a project resource (ttf), but since emojis are colored graphics, I'm not sure if i can create a ttf. I do not know anything about fonts either.
As you can see, my unknowledge is huge on this. I just need some tips that point me to the right way to research.
Thanks!

On Android you can make a BitMap font with the tutorial i found here. Then you can embed all your Emoji into that font.
For making this on the BlackBerry you can use the FontFamily class. Here is a tutorial that explains how this works.
Have fun! :-)

From my experience most emoticons (emoji) do not use a font, but are rather bitmap graphics (e.g. emoticons in the default Android text editor). There are several downsides to using a font:
Suppose you made the characters a, b, c, d etc into emoticons - the user would then be unable to read/send messages with those characters in without them turning to emoticons.
Fonts are generally quite large as they contain a lot of information for displaying the text at different sizes/styles
Using bitmap graphics will allow you to easily use the same emoticons across a wide range of devices, whilst using standard device fonts the text around the emoticons.
You will have to parse the string that you are displaying, find the emoticons, and replace them with images.
On Android for instance you would accomplish this with:
Search the string for all emoticon occurences (regex can do this easily enough)
Replace all emoticons with the string <img src="emoticon.png" /> (althugh change emoticon.png based on the type of emoticon)
Convert the String to HTML with String myHtmlString = Html.fromHtml(myEmoticonString, myImageGetter, null);
Display the string in a TextView myTextView.setText(myHtmlString)
In step 3 myImageGetter needs to be an instance of Html.ImageGetter which returns a graphic (drawable) based on the src attribute of the images in the string (ie it converts a string file name to an actual graphic)
The steps on other platforms would be different but you should be able to use the same basic method (parse string, replace emoticons with images).

Let me tell what I know, I dont know emoji, but googling it had me thinking it is a set of emoticons, primarily Japanese in origin. If that is true I would like to point out that it is common to create custom fonts using a font file (shown here). And in that font file you should be able to embed these emoticons and use them.
The link I provided above, is for J2ME, but the logic and design should be similar. Hope this helps.

Related

Generate pdf in android with hindi or custom fonts

Do we have some clear guide on how to generate pdf in android which includes tabular data too, with custom fonts like devnagri etc? I have tried itext pdf but text other than English shows blank. Any free or paid library will be helpful.
If you can draw it on screen then you can draw it to a pdf with the built in PdfDocument Class as you can use any laid out view (either got from what is already on screen or manually laying it out yourself) and then use the View's draw method to draw it to the PDF.
So for the tabular data you can use a TableLayout or other methods and the standard fonts available to your app.
Note the Pdf is a bitmap of the contents (e.g. the text is not editable)

Encoding Issue in Android String

Encoding Problem in android String
Web service return below string response
ãñøþ1219
but i getting response like ����1219
I am using below code to convert but it is not working
URLEncoder.encode(result, "UTF-8");
Please Help Me how i can fix this problem
Thanks In Advance
you must use Unicode font in order to display correctly Unicode text.
Most Android devices do not come with a complete set of Unicode fonts. Also in order to display Unicode text in a way that can be read properly you need to include a proper font for the script concerned.
Hence you can try as follows :
Typeface tf =Typeface.createFromAsset(getApplicationContext().getAssets(), "your_font.ttf");
text.setTypeface(tf,Typeface.BOLD);
text.setText(Html.fromHtml(your_text_with_unicode));
When you are getting response like ����1219, it is a font problem. When Android renders symbols as empty squares or the squares shown in above response,it means that Unicode support is working, but the font does not have those symbols. Adding to that the complex scripts like Indic scripts (e.g. Devanagari) require special rendering engine on top of that.

Heavy asterisk (u2731) in Android 2.x

I need Heavy asterisk (u2731) character in my app.
For android 3 and later I used the the following in my TextView:
android:text="\u2731"
and it works fine. But in android 2.x I see a rectangle instead of asterisk. I think that the specific Unicode character is missing in default fonts of Android 2.x .
So what can I do to see this character in Android 2.x? May be I need to load a custom font?
Which font contains this character?
As far as I know, Android 3.0 uses the Roboto font.
You can easily find it for free as a ttf font you might want to store in your assets folder.
Here is the reference and downlad site
[EDIT]
A workaround could be something like this:
String str = "your string containing fat asterisks (**)";
str = str.replace("**", "<b>*</b>");
myTextView.setText(Html.fromHtml(str));
It will make all the ** occurrences become a BOLD *

Customize Android Fonts

Now, I'm developing an android application, which needs to show some special characters. I need this font "Arial Unicode MS" to show the characters correctly. And I add the following code in my main activity:
EditText editText = (EditText) findViewById(R.id.flipped_window);
Typeface font = Typeface.createFromAsset(getAssets(),"ARIALUNI.TTF");
editText.setTypeface(font);
It does work. However, the size of this font file is too big, it's 22,731 kb.
Is there better solution for this problem? Thanks.
Your real problem is redistributing a copyrighted font. :-)
As Craig mentioned, you're illegally redistributing a copyrighted font.
My best guess would be to first look at all the glyphs available in Droid Sans; in my experience, it should be good enough unless you're looking to use it for formatting.
If you can't do that, create the symbols you need as PNG or GIF images and insert them inline. (GIFs will be substantially smaller for black & white).
buddy, you can decrease font size with Font creator software with elimination unused characters in font. you can decrease it to 50,60kb also :-)
password download link : www.downloadsoftware.ir

complex text rendering by avoiding the built in canvas.drawText - any way to render text to a bitmap and then display in an imageview instead?

I've been struggling with androids limited support for complex text rendering, particularly lack of arabic support for ligatures and shaping. Although you can get around the shaping problem by using the specific unicode escape codes to display the arabic string, it doesn't handle displaying diacratics correctly since it renders them on top of each other.
The text renders properly on a graphic using java.awt.Graphics2D but that isn't supported in android, that code is:
InputStream is = converter.class.getResourceAsStream("ARIAL.TTF");
Font font = Font.createFont(Font.TRUETYPE_FONT, is);
Font medium_font = font.deriveFont(32f);
BufferedImage sizedBufferedImage = new BufferedImage((rounded_width+10),(rounded_height+14), BufferedImage.TYPE_INT_ARGB);
Graphics2D g_sized = sizedBufferedImage.createGraphics();
g_sized.setColor(Color.black);
g_sized.setFont(medium_font);
g_sized.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g_sized.drawString(word_arabic, 5, 7+max_ascent);
ByteArrayOutputStream imgoutstr = new ByteArrayOutputStream();
ImageIO.write(sizedBufferedImage, "png", imgoutstr);
I can then get the Graphics2D object into a Bitmap using the ImageIO class and finally display it into an ImageView. I need to do this at runtime because the strings are coming from a database.
My problem is I can't find any alternative way of writing the word into a graphics object that I can then eventually get into a drawable/bitmap for display in android as an imageview, I'm trying to bypass androids text rendering and use an alternative text renderer that fully supports unicode and can handle the complext text rendering I need. Putting it into an image allows me to have android display the word verbatim as an image rather than trying to render it.
Is there any way to draw text into a graphics object instead of androids canvas, eventually putting the rendered graphics object into a bitmap that android can use? Androids canvas.drawString doesn't render the string properly and renders text differently than Graphics2D for complex text.
Hopefully the complex text rendering system from Honeycomb will get incorporated into Android phones soon. Without full support for complex text rendering, Android phones can only have a limited success in the Arabic, South Asian and South East Asian markets.
It was very short sighted of Google to release an operating system for mobile communications devices which does not have proper underlying support for the languages used in much of the world.

Categories

Resources