Hi
I am trying to draw text on a Canvas. I extracted a bitmap font as follows:
java -classpath ./gwt-widgets-0.2.0.jar org.gwtwidgets.fontcreator.BitmapFontCreator sans12 Sans-12-Plain /home/chris 12-128,225-320,330-407
This created 2 files, sans12.png and sans12.txt which i placed in a fonts subdirectory of my war.
In the webapp I then call:
...
font = Canvas.createBitmapFont("fonts/arial12.png", "fonts/arial12.txt", new FontLoadListener() ...
followed by canvas.setFont() API and finally do
canvas.drawText("Some text", 5, 5);
On execution, the createBitmapFont api blows up with a ArrayOutOfBoundsExeption as follows:
java.lang.ArrayIndexOutOfBoundsException: 1
at org.gwtwidgets.client.ui.canvas.impl.BitmapFontImpl.parseHeader(BitmapFontImpl.java:64)
at org.gwtwidgets.client.ui.canvas.impl.BitmapFontImpl.onResponseReceived(BitmapFontImpl.java:194)
at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287)
at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:393)
at sun.reflect.GeneratedMethodAccessor49.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
Can someone help to let me know why. I am using GWT2.0.4 and gwt-widgets-0.2.0.
View and moderate all "support-requests Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Support Requests"
my apologies for the code inaccuracy above. I've tried this twice using sans and arial - neither work. It looks from the code above that this is the problem when it is not!
Hi Chris,
You probably didn't deploy the font descriptor - that's a file which assembles the font glyphs. Please note that the Canvas was an experiment that worked at its time, but there is official Canvas support now from GWT and you better should use that.