private static void drawText(Graphics g, Coord position, String content, Coord offset, Dimension maxSpace) {
        g.setColor(Color.black);
        int textHeight = g.getFontMetrics().getHeight();
        int offsetX = offset.getX();
        int offsetY = offset.getY() + textHeight/2;
        String[] lines = content.split("\n");
        for (String string : lines) {
            if (g.getFontMetrics().stringWidth(string) + 2 * offsetX > maxSpace.width) {
                int wordPosition = offsetX;
                String[] words = string.split(" ");

                for (String word : words) {
                    int wordSize = g.getFontMetrics().stringWidth(word);
                    int wordSizeWithSpace = g.getFontMetrics().stringWidth(word + " ");

                    if (wordPosition + wordSize > maxSpace.width + offsetX) {
                        offsetY += textHeight;
                        wordPosition = offsetX;
                    }

                    g.drawString(word + " ", position.getX() + wordPosition, position.getY() + offsetY);
                    wordPosition += wordSizeWithSpace;
                }
            }
            else {
                g.drawString(string, position.getX() + offsetX, position.getY() + offsetY);
            }

            offsetY += textHeight;
        }
    }