from typing import Callable


def split_text_on_width_size(text: str, max_width: float, fn_text_to_width: Callable) -> str:
    """
    Split a text given a maximum width
    :param text: Text to be split
    :param max_width: The maximum width that the text should fit
    :param fn_text_to_width: Function to compute the width size given a text
    :return: The text split in order to fit the max_width
    """
    text_words = text.replace("\n", "").split()
    missing_start_index = 0
    text_pieces = []
    while missing_start_index < len(text_words):
        missing_end_index = len(text_words)
        while fn_text_to_width(" ".join(text_words[missing_start_index:missing_end_index])) > max_width:
            missing_end_index -= 1
        if missing_start_index == missing_end_index:
            raise ValueError("Unable to find a split. Most likely the character size is too big.")
        text_pieces.append(" ".join(text_words[missing_start_index:missing_end_index]))
        missing_start_index = missing_end_index
    return "\n".join(text_pieces)