• Post Reply Bookmark Topic Watch Topic
  • New Topic

Initialising fonts to prevent lag  RSS feed

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have just begun using fonts, and have noticed that the first time a font is used, it causes a significant delay - over half a second. I looked around on the internet and found references to it being because of having to load the font "on the fly". Someone also stated that having just:

doesn't actually load it for use, and I have noticed that having done so has not remove the delay. Someone suggest storing the font in a data-field, but I don't know how to do that.

A way to fix it is to use a default name for the font, however, won't that then affect what the font is?

How can I preload the font(s) so I don't get the delay? Thanks for any help.
 
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alfie Noakes wrote:and I have noticed that having done so has not remove the delay. Someone suggest storing the font in a data-field, but I don't know how to do that.

Hmm. I'm no expert, but it suggests to me that there's some "lazy initialization" going on. What you need to find out is how to turn that into "eager" initialization, and my suggestion would be to actually USE it, even if it's only to create a "dummy" output.

On the other hand - and before you go down that route - I'd suggest that a careful read of the class docs is in order, because there may be a very simple alternative.

Winston
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!