int (Font font, char ch) { if (font.canDisplay(ch)) { Rectangle bounds = font.getStringBounds(new char[]{ch}, 0, 1, DEFAULT_CONTEXT).getBounds(); if (!bounds.isEmpty()) return bounds.width; } return 0; }