We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOther Libraries › controlP5 - scrollList
Page Index Toggle Pages: 1
controlP5 - scrollList (Read 1249 times)
controlP5 - scrollList
Mar 5th, 2009, 11:56am
 
hey,
i have some problems with scrollList.
I need to use letters "č","ž","š", but if i use them i get these exception:
Exception in thread "Animation Thread" java.lang.ArrayIndexOutOfBoundsException: 320
at controlP5.BitFontRenderer.getWidth(Unknown Source)
at controlP5.Label.<init>(Unknown Source)
at controlP5.Label.<init>(Unknown Source)
at controlP5.Controller.<init>(Unknown Source)
at controlP5.Button.<init>(Unknown Source)
at controlP5.ScrollList.addItem(Unknown Source)
and i know it is because these letters, coz otherwise - without them it works just fine. is there any chance to avoid exception and get scrollist to work as it should, no matter what letters am i useing?
tnx, kaja
Re: controlP5 - scrollList
Reply #1 - Apr 27th, 2009, 3:27am
 
I found your message incidentally when researching to answer the ControlP5_font size() question. See this thread for the gory details...
But in short, controlP5 uses custom bitmap fonts with limited character sets, and stops on low Ascii (char code 127) although it supports char width up to code 255 (but forgot the Unicode ranges!).

So in short you cannot use non-Ascii chars in controlP5.
Re: controlP5 - scrollList
Reply #2 - Apr 28th, 2009, 12:50pm
 
So any ideas on how to convert unicode strings to ascii, so that they could be used?  I understand that it can't convert characters it doesn't understand, but I think it can place a "?" or something.
Re: controlP5 - scrollList
Reply #3 - Apr 28th, 2009, 1:07pm
 
Code:
String unicode = "éçč ŕžošů";
try
{
byte[] bytes = unicode.getBytes("LATIN1"); // US-ASCII for stricter conversion
String ascii = new String(bytes);
println(ascii);
}
catch (UnsupportedEncodingException uee)
{
}
Re: controlP5 - scrollList
Reply #4 - Apr 28th, 2009, 2:27pm
 
Thanks, worked great!  I had tried something similar but had forgotten the "try" statement, which resulted in an UnsupportedEncodingException error.
Page Index Toggle Pages: 1