private static int getFontWidth(Font font, int mask) {
    if (mask != Font.PLAIN) {
      //noinspection MagicConstant
      font = font.deriveFont(mask ^ font.getStyle());
    }
    font = font.deriveFont(SIZE_FOR_MONOSPACED_CHECK);
    int width = getCharWidth(font, ' ');
    return width == getCharWidth(font, 'l') && width == getCharWidth(font, 'W') ? width : 0;
  }
private static int getFontWidth(Font font, int mask)