Exemple #1
0
 private static boolean isMonospaced(FontMetrics fontMetrics) {
   boolean isMonospaced = true;
   int charWidth = -1;
   for (int codePoint = 0; codePoint < 128; codePoint++) {
     if (Character.isValidCodePoint(codePoint)) {
       char character = (char) codePoint;
       if (isWordCharacter(character)) {
         int w = fontMetrics.charWidth(character);
         if (charWidth != -1) {
           if (w != charWidth) {
             isMonospaced = false;
             break;
           }
         } else {
           charWidth = w;
         }
       }
     }
   }
   return isMonospaced;
 }
Exemple #2
0
 private static boolean isWordCharacter(char character) {
   return Character.isLetterOrDigit(character);
 }