public int stringWidth(String str) { // this happens often for icons without text and can cost a bit more in the native platform if(str == null || str.length() == 0) { return 0; } // Its common to use a space character to create a label that takes up space but the value // of string width in this case becomes less important if(str == " ") { return 5; } return Display.impl.stringWidth(font, str); }
In some earlier universe, it might have been sensible to simply declare a space as 5 pixels...
in com.codename1.ui.Font
public int stringWidth(String str) { // this happens often for icons without text and can cost a bit more in the native platform if(str == null || str.length() == 0) { return 0; } // Its common to use a space character to create a label that takes up space but the value // of string width in this case becomes less important if(str == " ") { return 5; } return Display.impl.stringWidth(font, str); }
In some earlier universe, it might have been sensible to simply declare a space as 5 pixels...