Im trying to make an “Insert Symbol” dialog. I want to get a list of the Unicode Characters and add them to JList and potentially categorize in to “Greek, etc.”. I came accross this very crude method:
for (int i=0; i<=Integer.MAX_VALUE; i++) {
if (Character.isDefined(i)) {
list.add(new String(Character.toChars(i)));
}
}
But it takes FOREVER to initialise and load. I need a more efficient way of displaying the characters. Also preferably just displaying the characters that display something, as some characters appear blank and leave big ugly gaps.
Font#canDisplay()is fast, although not perfectly reliable. Even if a code point is defined, it may not have a glyph in a particular font. There’s an example here.