0

enter image description hereAs I'm novice in Blackberry/Java development, I don't know how to use "telugu" font in my Blackberry application. Please give an example.

enter image description here see the difference between three simulators 9300-OS6 not displaying 9790-os7 displays only in this device . 9900-os7 even OS7 it is not displaying.

Raj Kamal
  • 149
  • 9

1 Answers1

1
import net.rim.device.api.system.*;
import net.rim.device.api.ui.*; 
import net.rim.device.api.ui.container.*;
import net.rim.device.api.ui.component.*;
import java.util.*;

public class FontLoadingDemo extends UiApplication
{
    public static void main(String[] args)
    {
        FontLoadingDemo app = new FontLoadingDemo();
        app.enterEventDispatcher();
    }

    public FontLoadingDemo()
    {
        pushScreen(new FontLoadingDemoScreen());
    }
}

class FontLoadingDemoScreen extends MainScreen
{   
    public FontLoadingDemoScreen()
    {
        setTitle("Font Loading Demo");

        LabelField helloWorld = new LabelField("Hello World");

        if (FontManager.getInstance().load("Myfont.ttf", "MyFont", FontManager.APPLICATION_FONT) == FontManager.SUCCESS) 
        {
            try 
            {
                FontFamily typeface = FontFamily.forName("MyFont");
                Font myFont = typeface.getFont(Font.PLAIN, 50);
                helloWorld.setFont(myFont); 
            }
            catch (ClassNotFoundException e) 
            {
                System.out.println(e.getMessage());
            }
        }
        add(helloWorld);
    }
}

Source: http://docs.blackberry.com/en/developers/deliverables/11958/Load_and_use_a_custom_font_899948_11.jsp

Ashraf Bashir
  • 9,686
  • 15
  • 57
  • 82
  • I tried this by replacing Myfont.ttf as SHREE940.ttf.......for ur kind information I had placed this file in myproject 'res' folder,still getting boxes – Raj Kamal May 24 '12 at 04:49
  • Could you please explain your current state in details ? Or did you mean that this solved the issue ? if it solved please push it up and mark it as solution, if not give to me more details so that I can help you .... what do you mean by "boxes" ? – Ashraf Bashir May 24 '12 at 22:25
  • yes I changed my SDK and also font.....then my simulator displayed TELUGU(gouthami.ttf) font.but it displays only in 9790 simulatior in other simulators same previous problem – Raj Kamal May 25 '12 at 05:43
  • when I placed same code in my project,it is not displaying telugu font even in 9790. – Raj Kamal May 31 '12 at 11:53
  • 9790 OS is 7 my app works only in this device......but in other devices of same OS like 9900 and other its not working. – Raj Kamal Jun 04 '12 at 04:43
  • Are you working on simulator or device ? Be aware that system fonts may affect simulator font and conflicts may occur on simulators. Test it on device to ensure the same issue exists – Ashraf Bashir Jun 05 '12 at 11:14
  • Edit your question and in the toolbar for editing you will find an icon to add images, you can add from there – Ashraf Bashir Jun 06 '12 at 12:36
  • What about other fonts? are all of them causing the same issue? if yes then I think the font itself has a problem – Ashraf Bashir Jun 06 '12 at 12:38
  • there is no problem in font file because even I delete the font file from the project it displays the font because Iam getting the data from XML. – Raj Kamal Jun 07 '12 at 05:44
  • Add screenshots, and try another font and tell me the results – Ashraf Bashir Jun 07 '12 at 08:57
  • Above images are the screen shots of my test app.Even I tried different fonts also.....same issue .. – Raj Kamal Jun 07 '12 at 09:19
  • Kindly try this workaround, whatever text you want to display, pass it first to this tool: http://www.rishida.net/tools/conversion/ ... put your text in the green textbox and press the cpnvert button, Finally take the results of "JavaScript escapes" and use it as the text in your app, it will be auto-translated back to the right characters, try it and tell me the results. (PS, by this method we are forcing unicode translation manually in display and draw methods' engine) – Ashraf Bashir Jun 07 '12 at 09:28
  • I had placed telugu font in green textbox and selected UTF-8 units and pressed converte button it converts the fonts as JavaScript escapes ( \u0C30\u0C3E\u0C37\u0C4D\u0C1F\u0C4D\u0C30\u0C02\u0C32\u0C4B \u0C38\u0C02\u0C1A\u0C32\u0C28\u0C02 \u0C38\u0C43\u0C37\u0C4D\u0C1F\u0C3F\u0C02\u0C1A\u0C3F\u0C28 )...I had placed this converted code in my app... and it displayed same boxes – Raj Kamal Jun 07 '12 at 09:41
  • IS There any posiblity to happen this issue with blackberry SDK verions,OS supporting issues .....? – Raj Kamal Jun 07 '12 at 10:04
  • Yes, this possibility exists. And the model also may not support some font. But this is too rare to happen especially in new devices models. – Ashraf Bashir Jun 07 '12 at 11:48