private boolean doesfit(int width, int height, int size, String[] text) {
        int currentRow = size;
        int currentColumn = 0;
        int i = 0;
        for (; i < text.length; i++) {
            if (currentColumn + text[i].length()*size <= width ) {
                currentColumn += text[i].length()*size;
                if (currentColumn + size > width) {
                    currentColumn = 0;
                    if (i < text.length - 1)
                        currentRow += size;
                } else {
                    currentColumn += size;
                }
            } else {
                if (currentColumn == 0) {
                    break;
                }

                i--;
                currentColumn = 0;
                currentRow += size;               
            }
        }
        if (currentRow > height || i < text.length)
            return false;
        
        return true;
    }