public int getStringWidth(String s) {
Metrics fm = getMetrics();
int[] widths = fm.widths;
int width = 0;
for (int i = 0, cnt = s.length(); i < cnt; i++) {
char c = s.charAt(i);
int w=0;
byte b = (byte)c;
w = widths[b - 32];}
width += w;
}
}
return width;
}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2008-02-25
This was an issue some time for MessageBox too but is fixed in latest subversion 1.2 branche.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
when display unicode message,i got exception say
Font.getStringWidth() index out of range :
public int getStringWidth(String s) {
Metrics fm = getMetrics();
int[] widths = fm.widths;
int width = 0;
for (int i = 0, cnt = s.length(); i < cnt; i++) {
char c = s.charAt(i);
int w=0;
byte b = (byte)c;
w = widths[b - 32];}
width += w;
}
}
return width;
}
This was an issue some time for MessageBox too but is fixed in latest subversion 1.2 branche.