Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.

Posts: 41
Registered: ‎11-11-2010
My Device: Not Specified
Accepted Solution

Font only shows correctly on first run after installation

I have a really weird problem whereby my custom font only shows up correctly on the first run of my app after installing in the simulator or on a device. Subsequent runs of the app, show the fields with the default system font.


The function I am using is as follows:


public static Font GetCustomFont(boolean bold, int size)
	Font myFont = null;

	if (FontManager.getInstance().load("customfont.ttf", "custom", FontManager.APPLICATION_FONT) ==FontManager.SUCCESS)
			FontFamily typeface = FontFamily.forName("custom");
			if (bold) myFont = typeface.getFont(Font.BOLD, size);
			else myFont = typeface.getFont(Font.ITALIC, size);
		catch (Exception e)
		{ e.printStackTrace(); }
	return myFont;

 and the font is used as follows:


LabelField myLabel = new LabelField("TESTING CUSTOM FONT");
myLabel.setFont(GetCustomFont(false, 24));


The font shows up ok the first time I run the app. Even if I call System.exit(0), then restart the app, it comes back up with the system font. My font is a 46kB TTF file, added to the res folder of my project and I am developing for BB 7.0.0.


Can anyone please help?

Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Font only shows correctly on first run after installation

You need to check the return code from




You only accept SUCCESS, I think you will find in subsequent runs that the return code is something like 'Already loaded' and so you can use it in this circumstance too. 

Posts: 41
Registered: ‎11-11-2010
My Device: Not Specified

Re: Font only shows correctly on first run after installation

Fixed! This is the exact problem. I now accept FontManager.DUPLICATE_NAME and FontManager.DUPLICATE_DATA in addition to FontManager.SUCCESS, although I suspect I should not be accepting duplicate data since it would not be found using a different name.

Thanks Peter!