Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9144013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:09:54+00:00 2026-06-17T10:09:54+00:00

In application i have to use custom font. First i create class that extends

  • 0

In application i have to use custom font. First i create class that extends VerticalFieldManager class. In this class i want to use custom font. I have TTF file (name is AGENCYB.TTF). I kept this file in res/img folder. To load this file i use following code:

if (FontManager.getInstance().load("AGENCYB.TTF", "MyFont",
        FontManager.APPLICATION_FONT) == FontManager.SUCCESS)
{
   System.out.println("**************************IF SUCCESS*******");
   try
   {
      FontFamily typeface = FontFamily.forName("MyFont");
      myFont = typeface.getFont(Font.BOLD, 50);
      label2.setFont(myFont);
   }
   catch (ClassNotFoundException e)
   {
      System.out.println(e.getMessage());
   }
}

But it is not changing font of label field. I implemented code by using this link:
http://docs.blackberry.com/en/developers/deliverables/18095/BlackBerry_Java_SDK-Development_Guide–1239696-0730090812-001-6.0-US.pdf

Any idea would be great help.

Thanks

**********EDIT**************

if (FontManager.getInstance().load("AGENCYB.TTF", "AGENCYB", FontManager.APPLICATION_FONT) == FontManager.SUCCESS)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T10:09:55+00:00Added an answer on June 17, 2026 at 10:09 am

    First of all, this is the BlackBerry tutorial I’ve used for loading custom fonts

    Second of all, I don’t see a return code of 8 in any of the values that the API docs says FontManager.load() returns. SUCCESS is a value of 0, so you’re not successfully calling load().

    http://www.blackberry.com/developers/docs/7.0.0api/net/rim/device/api/ui/FontManager.html

    Returns:
    FontManager.SUCCESS if font loads successfully.
    FontManager.FONTS_ARRAY_FULL if too many fonts loaded.
    FontManager.MISSING_TYPEFACE_NAME if typeface name is invalid.
    FontManager.DUPLICATE_NAME if font name is duplicate.
    FontManager.DUPLICATE_DATA if font data is duplicate.
    FontManager.NO_FONT_DATA if no font data is found.
    FontManager.EXCEEDS_LIMIT if font data exceeds 60k in size.
    FontManager.MISS_RESOURCE if font file cannot be found.
    FontManager.FAILED_TO_LOAD_FILE if font data is invalid or font format is invalid.

    When I ran in the debugger on OS 5.0 and 7.1, I saw that -8 was equal to FontManager.DUPLICATE_NAME, but didn’t see any code equal to 8.

    Also, did you generate this font file yourself (AGENCYB.TTF)? Because your code is asking for a font named MyFont in the AGENCYB.TTF file. I wouldn’t expect a font to actually be named MyFont unless it was somebody writing a Hello World program (and homemade .ttf file).

    If this is a custom font, provided by a 3rd-party font library, or bought from someone else, I would expect the font names to be something other than MyFont, which is what they have in the BlackBerry sample that you probably copied your code from.

    So, double-check that, and let us know if it’s still not working.


    Update: since it looks like you also fail when you use the string "AGENCYB" in your code, I think the problem is that you’re using the wrong font name. Even though the file is AGENCYB.TTF, I bet the font name inside that file is not AGENCYB. Is this the same file that you find in Windows under C:\Windows\fonts? If so, you can use Windows (7, at least) to look at the font file.

    Just double-click the .ttf file in Windows Explorer, and it should give you a preview, that shows the proper font name. That name is the name you use in the two java calls, where the sample code has "MyFont". In this case, you see that the font name is probably "Agency FB". Try that.

    enter image description here


    Update 2: I also tried loading the Agency FB font from the AGENCYR.TTF file that can be found in C:\windows\Fonts\AGENCYR.TTF on a Windows 7 machine. This exact code worked for me on a 5.0 8900 simulator:

      int result = FontManager.getInstance().load("AGENCYR.TTF", "Agency FB", FontManager.APPLICATION_FONT);
    
      if (result == FontManager.SUCCESS)
      {
         try 
         {
            FontFamily typeface = FontFamily.forName("Agency FB");
            Font myFont = typeface.getFont(Font.PLAIN, 50);
            helloWorld.setFont(myFont); 
         }
         catch (ClassNotFoundException ex) 
         {
         }
      }
    

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have download a ttf file for a custom font I want to use
How to use custom font asp.net application. I have a font file with me.
I want to use a custom font for my android application which I am
How do I use a custom .tff font file I have with my current
i want to use custom fonts in y application. i have declared the Fonts
For an application I have to use a custom button that react when one
I have a web application that is using CSS3's @font-face to embed custom fonts.
i have application who use specific process during running and i want to sample
I have an external (.Net) dll that I have to use for an application.
I am creating a chat application. In this chat application, I have to use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.