public static int stringWidth(String text) {
        if (fontWidth.isEmpty()) {
            return 0;
        }
        char[] chars = text.toCharArray();
        int width = 0;
        int spacepos = 0;
        for (int i = 0; i < chars.length; i++) {
            if (fontWidth.containsKey(String.valueOf(chars[i]))) {
                width += fontWidth.get(String.valueOf(chars[i]));
            } else if (chars[i] == (char) 167) {
                i++;
            }
        }
        return width;
    }