Slick Forums

Discuss the Slick 2D Library
It is currently Sat May 18, 2013 10:57 pm

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: serializing UnicodeFont
PostPosted: Wed Mar 21, 2012 8:29 pm 
Offline
Regular

Joined: Thu Sep 22, 2011 4:39 pm
Posts: 165
Location: Belgium
Hey guys,

because of performance (loading) reasons i had the idea to serialize the unicode font and then reload only this when my game starts,
everything goes well but when i display the font i only see "white squares" whitout the font "image" for each character itself..

any idea's?

tx


Top
 Profile  
 
PostPosted: Thu Mar 22, 2012 1:40 am 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1467
UnicodeFont is brutally slow at loading. Your options:
  • Use bitmap fonts instead (AngelCodeFont). This loads and renders much more quickly.
  • If you need a particular feature that AngelCodeFont doesn't support; e.g. truly dynamic fonts, or multiple glyph pages, or a much wider range of code points (e.g. for certain languages), then use TWL's font renderer. This is the best option if you need to use TTFs.
  • Don't add any glyphs; instead let the game decide when to add them based on when they are needed in render(). Then, only load a small number of glyphs per frame. If you try to load all the glyphs at once, the game will generally hang. The UnicodeFontTest shows an example where the text is loaded as the game is running (the result is ugly -- glyphs "appearing" individually over a couple seconds).
  • Alternatively, if you really feel you need UnicodeFonts, you could "cache" your fonts by storing the resulting GlyphPage textures on the user's system, and on the next load simply grab the cached images and use them as if they were bitmap fonts.


Top
 Profile  
 
PostPosted: Thu Mar 22, 2012 7:48 am 
Offline
Regular

Joined: Thu Sep 22, 2011 4:39 pm
Posts: 165
Location: Belgium
hey davedes,

thank you i'll try some of your options and see what's the best option

cheers

-a-


Top
 Profile  
 
PostPosted: Thu Mar 22, 2012 7:18 pm 
Offline
Regular

Joined: Thu Sep 22, 2011 4:39 pm
Posts: 165
Location: Belgium
the hiero application always gives me this error
however it worked last month i think

ava.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.javaws.Launcher.executeApplication(Unknown Source)
at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
at com.sun.javaws.Launcher.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at org.lwjgl.Sys$1.run(Sys.java:75)
at java.security.AccessController.doPrivileged(Native Method)
at org.lwjgl.Sys.doLoadLibrary(Sys.java:68)
at org.lwjgl.Sys.loadLibrary(Sys.java:84)
at org.lwjgl.Sys.<clinit>(Sys.java:101)
at org.lwjgl.opengl.Display.<clinit>(Display.java:128)
at org.newdawn.slick.AppGameContainer$1.run(AppGameContainer.java:39)
at java.security.AccessController.doPrivileged(Native Method)
at org.newdawn.slick.AppGameContainer.<clinit>(AppGameContainer.java:36)
at org.newdawn.slick.CanvasGameContainer.<init>(CanvasGameContainer.java:48)
at org.newdawn.slick.CanvasGameContainer.<init>(CanvasGameContainer.java:29)
at org.newdawn.slick.tools.hiero.Hiero$3.<init>(Hiero.java:287)
at org.newdawn.slick.tools.hiero.Hiero.initialize(Hiero.java:281)
at org.newdawn.slick.tools.hiero.Hiero.<init>(Hiero.java:156)
at org.newdawn.slick.tools.hiero.Hiero.main(Hiero.java:1196)
... 9 more


Top
 Profile  
 
PostPosted: Thu Mar 22, 2012 7:27 pm 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1171
You can use the TWL Theme Editor to create bitmap fonts (Tools -> Create font). Select TEXT format when saving the generated font so that Slick can parse it.

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
PostPosted: Thu Mar 22, 2012 7:29 pm 
Offline
Regular

Joined: Thu Sep 22, 2011 4:39 pm
Posts: 165
Location: Belgium
cool tx !!

any idea if i can add some gradient in my font (from yellow to red)

ok got it :)


Top
 Profile  
 
PostPosted: Fri Mar 23, 2012 12:12 pm 
Offline
Regular

Joined: Thu Sep 22, 2011 4:39 pm
Posts: 165
Location: Belgium
so at the end, (testing all possibilities for fonts in slick) indeed the best way is to use the Angelcodefont, for performance and "drawing" reasons
before i had this issue when i tried to rotate a "string", the font wasn't properly rendered, angelcode font solved both problems

tx !


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group