public int getHeight(String text) {
        DisplayList displayList = null;
        if (displayListCaching) {
            displayList = (DisplayList) displayLists.get(text);
            if (displayList != null && displayList.height != null) {
                return displayList.height.intValue();
            }
        }

        int lines = 0;
        int maxHeight = 0;
        for (int i = 0; i < text.length(); i++) {
            int id = text.charAt(i);
            if (id == '\n') {
                lines++;
                maxHeight = 0;
                continue;
            }
            // ignore space, it doesn't contribute to height
            if (id == ' ') {
                continue;
            }
            CharDef charDef = chars[id];
            if (charDef == null) {
                continue;
            }

            maxHeight = Math.max(charDef.height + charDef.yoffset, maxHeight);
        }

        maxHeight += lines * getLineHeight();

        if (displayList != null) {
            displayList.height = Short.valueOf((short) maxHeight);
        }

        return maxHeight;
    }