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
m-romanuik
Posts: 114
Registered: ‎04-28-2010
My Device: Storm 9530
Accepted Solution

FontManager; CustomFonts

Heyy,

 

        I am trying to use my own custom font and reading the documentation it states that the .ttf file cannot be larger than 60kb. However my true-type font file is 63.3kb :smileysad: .. Does anyone know or can suggest a way that i can lower the size of this file by editing it or compressing it somehow?

 

Mitchell Romanuik.

Developer
peter_strange
Posts: 19,609
Registered: ‎07-14-2008
My Device: Not Specified

Re: FontManager; CustomFonts

Have you tried this size?  I seem to remember loading a font that was bigger than this. 

Developer
m-romanuik
Posts: 114
Registered: ‎04-28-2010
My Device: Storm 9530

Re: FontManager; CustomFonts

for some strange reason the loading of the font doesn't work.

 

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

 

 I have been using this sample to help me out. I have the code within my screen and passes it along to my field. The field then calls graphics.setFont(this.getFont()).. However I debugged my program and font wont load inside the screen. Im guessing its because the file is too large. Perhaps I should read the file from the inputstream. However I do not know how to approach this from this direction.

Developer
m-romanuik
Posts: 114
Registered: ‎04-28-2010
My Device: Storm 9530

Re: FontManager; CustomFonts

This is my solution. Instead of loading directly from file I used the inputStream..

 

 

InputStream stream = this.getClass().getResourceAsStream("font.ttf");
        if (FontManager.getInstance().load(stream, "MyFont", FontManager.APPLICATION_FONT) == FontManager.SUCCESS){
            try{
                FontFamily family = FontFamily.forName("MyFont");
                Font myFont = family.getFont(Font.PLAIN, 50);
                gamer.getInfo().setFont(myFont);
            } 
            catch (ClassNotFoundException e){System.out.println(e.getMessage());}
        }

 

Mitchell Romanuik.