def METHOD_NAME(
    text, font_name, font_size, max_width, keep_leading_whitespace=False
):
    """
    Wraps `text` within given `max_width` limit (measured in px), keeping
    initial indentation of each line (and generated lines) if
    `keep_leading_whitespace` is True.
    :param text: Text to be split.
    :param font_name: Font name.
    :param font_size: Font size.
    :param max_width: Maximum length of each line (unit: px).
    :param keep_leading_whitespace: each split line keeps the leading
                                    whitespace.
    :return: list of lines
    """
    def get_text_width(text, name=font_name, size=font_size):
        return stringWidth(text, name, size)
    result = []
    lines = [line for line in re.split(r"[\r\n]+", text) if line]
    for line in lines:
        line_list = split_line(line, max_width, get_text_width)
        if keep_leading_whitespace and len(line_list) > 1:
            first, rest = line_list[0], line_list[1:]
            indent_match = _DESCRIPTION_CUTOFF_REGEX.match(first)
            if indent_match:
                prefix = first[indent_match.start() : indent_match.end()]
                line_list = [first] + ["{}{}".format(prefix, s) for s in rest]
        result.extend(line_list)
    return os.linesep.join(result)