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 6834639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:08:10+00:00 2026-05-26T23:08:10+00:00

I want to use custom fonts in my j2me application. so I created a

  • 0

I want to use custom fonts in my j2me application. so I created a png file contains all needed glyph and an array of glyphs width and another for glyphs offset in PNG file.

Now, I want to render a text in my app using above font within a gameCanvas class. but when I use the following code, rendering text in real device is very slow.

Note: the text is coded(for some purposes) to bytes and stored in this.text variable. 242=[space],241=[\n] and 243=[\r].

int textIndex = 0;
while(textIndex < this.text.length)
{
  int index = this.text[textIndex] & 0xFF;
  if(index > 243)
  {
      continue;
  }
  else if(index == 242) lineLeft += 3;
  else if(index == 241 || index == 243) 
  {
      top += font.getHeight();
      lineLeft = 0;
      continue;
  }
  else
  {
    lineLeft += widths[index];
    if(lineLeft <= getWidth()) 
        lineLeft = 0;
    int left = starts[index];
    int charWidth = widths[index];
    try{
        bg.drawRegion(font, left, 0, charWidth, font.getHeight(), 0, lineLeft, top, Graphics.LEFT|Graphics.TOP);
    }catch(Exception ee)
    {
    }
  }
  textIndex++;
}

Can anyone help me to improve performance and speed in my code?

At end sorry for my bad English and thanks in advanced.:)

Edit: I changed line

 bg.drawRegion(font, left, 0, charWidth, font.getHeight(), 0, lineLeft, top, Graphics.LEFT|Graphics.TOP);

To:

bg.clipRect(left, top, charWidth, font.getHeight());
bg.drawImage(font, lineLeft - left, top,0)
bg.setClip(0, 0, getWidth(), getHeight());

but there was no difference in speed!!

any help please!!


Can anyone plz help me to improve my app?

text will appear after 2-3 seconds in real device by this code, I want reduce this time to milliseconds. this is very important for me.

Can I use threads? If yes, How?

  • 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-05-26T23:08:10+00:00Added an answer on May 26, 2026 at 11:08 pm

    I can’t sure why your code’s performance is not good in real device.
    But, how about refer some well known open source J2ME libraries to check it’s text drawing implementation for example, LWUIT.

    http://java.net/projects/lwuit/sources/svn/content/LWUIT_1_5/UI/src/com/sun/lwuit/CustomFont.java?rev=1628

    You can find from the above link it’s font drawing implementation. It uses drawImage rather than drawRegion.

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

Sidebar

Related Questions

i want to use custom fonts in y application. i have declared the Fonts
I want to use Custom URL Scheme to transfer data from application to other
I want to use a custom template file which shoud use the base layout
I have download a ttf file for a custom font I want to use
I want to use a custom font for my android application which I am
No, like others, I don't want to use custom fonts. I am looking for
How to use custom font asp.net application. I have a font file with me.
In my rails(2.x) application. I want to use custom font in my view. So
I want to use custom exception handling, for example instead of using (Exception ex)
For example I want to use custom logger: logger = require('basic-logger'), logger.setLevel('info') var customConfig

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.