Welcome!

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

Reply
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified
Accepted Solution

Acceptable ttf fonts for OS 5.0

I've managed to add and use a ttf Font with OS 5.0, following the documentation here:

 

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

 

However I just wondered if there was more detailed information on what is and is not acceptable.  With one font I tried I got

FontManager.EXCEEDS_LIMIT

but there does not seem to any information of what limit has been exceeded.

 

I've looked and not found anything that is more detailed description of what makes a ttf font acceptable (or not), but hopefully someone else has and can tell me, or to point me at the documentation..

 

Thanks.

 

BTW, there is a bug in the sample:

FontFamily typeface = FontFamily.forName("Charming");

should be

FontFamily typeface = FontFamily.forName("MyFont");

Please use plain text.
Developer
rcmaniac25
Posts: 1,804
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.2174, Z10 (STL100-3)-10.3.0.700 Dev OS, Z30 (STA100-5)-10.3.0.700 Dev OS, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon

Re: Acceptable ttf fonts for OS 5.0

[ Edited ]

Look at the FontManager.load(...) documentation. It states that "FontManager.EXCEEDS_LIMIT if font data exceeds 90k in size."

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Please use plain text.
Administrator
MSohm
Posts: 14,362
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: Acceptable ttf fonts for OS 5.0

 


peter_strange wrote:

 

BTW, there is a bug in the sample:

FontFamily typeface = FontFamily.forName("Charming");

should be

FontFamily typeface = FontFamily.forName("MyFont");


Thanks for pointing that out.  I'll have the sample updated.

 

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: Acceptable ttf fonts for OS 5.0

Thanks rcmaniac25, I had completely missed that.

Please use plain text.
Contributor
carldea
Posts: 29
Registered: ‎02-14-2010
My Device: BlackBerry Curve 8530
My Carrier: Verizon Wireless

Re: Acceptable ttf fonts for OS 5.0

Peter,

 

Thanks...

 

Because this is where I found the solution to this same problem, I want to detail it in order to help others and keep the solution and code together (it took me about three threads to lead me here).

 

To others: This is how to set your application to a custom truetype font that exceeds the BlackBerry size limitation.

 

(For brevity imports and try/catches are excluded) use ctrl-shift-o,

 

Steps:

 

1) In Eclipse move somefont.ttf colocated where class is.

 

2) put code where your application is starting. or constructor.

 

InputStream is = this.getClass().getResourceAsStream("somefont.ttf");
int codeNum = FontManager.getInstance().load(is, "somefont", FontManager.APPLICATION_FONT);
System.out.println("codeNum = " + codeNum);
FontFamily fontFam = FontFamily.forName("somefont");
Font myFont = fontFam.getFont(FontFamily.SCALABLE_FONT, 12, Ui.UNITS_pt);
setFont(myFont);

 

Carl

BlackBerry Curve 8530 OS version 5.0.0.734
Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: Acceptable ttf fonts for OS 5.0

My understanding and experience suggests that this way of loading the font is still restricted to a font with a maximum size of 90K.  Is that what you see?

Please use plain text.
Regular Contributor
guydor
Posts: 65
Registered: ‎05-15-2011
My Device: 9700
My Carrier: Att

Re: Acceptable ttf fonts for OS 5.0

[ Edited ]
 
Please use plain text.