<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def text(space, text, font=None, border=0.2, inverted=True):
 """Create phantom from text. The text is represented by a scalar image taking values in [0, 1]. Depending on the choice of font, the text may or may not be anti-aliased. anti-aliased text can take any value between 0 and 1, while non-anti-aliased text produces a binary image. This method requires the ``pillow`` package. Parameters space : `DiscreteLp` Discretized space in which the phantom is supposed to be created. Must be two-dimensional. text : str The text that should be written onto the background. font : str, optional The font that should be used to write the text. Available options are platform dependent. Default: Platform dependent. 'arial' for windows, 'LiberationSans-Regular' for linux and 'Helvetica' for OSX border : float, optional Padding added around the text. 0.0 indicates that the phantom should occupy all of the space along its largest dimension while 1.0 gives a maximally padded image (text not visible). inverted : bool, optional If the phantom should be given in inverted style, i.e. white on black. Returns ------- phantom : ``space`` element The text phantom in ``space``. Notes ----- The set of available fonts is highly platform dependent, and there is no obvious way (except from trial and error) to find what fonts are supported on an arbitrary platform. In general, the fonts ``'arial'``, ``'calibri'`` and ``'impact'`` tend to be available on windows. Platform dependent tricks: **Linux**:: $ find /usr/share/fonts -name "*.[to]tf" """

    from PIL import Image, ImageDraw, ImageFont

    if space.ndim != 2:
        raise ValueError('`space` must be two-dimensional')

    if font is None:
        platform = sys.platform
        if platform == 'win32':
            # Windows
            font = 'arial'
        elif platform == 'darwin':
            # Mac OSX
            font = 'Helvetica'
        else:
            # Assume platform is linux
            font = 'LiberationSans-Regular'

    text = str(text)

    # Figure out what font size we should use by creating a very high
    # resolution font and calculating the size of the text in this font
    init_size = 1000
    init_pil_font = ImageFont.truetype(font + ".ttf", size=init_size,
                                       encoding="unic")
    init_text_width, init_text_height = init_pil_font.getsize(text)

    # True size is given by how much too large (or small) the example was
    scaled_init_size = (1.0 - border) * init_size
    size = scaled_init_size * min([space.shape[0] / init_text_width,
                                   space.shape[1] / init_text_height])
    size = int(size)

    # Create font
    pil_font = ImageFont.truetype(font + ".ttf", size=size,
                                  encoding="unic")
    text_width, text_height = pil_font.getsize(text)

    # create a blank canvas with extra space between lines
    canvas = Image.new('RGB', space.shape, (255, 255, 255))

    # draw the text onto the canvas
    draw = ImageDraw.Draw(canvas)
    offset = ((space.shape[0] - text_width) // 2,
              (space.shape[1] - text_height) // 2)
    white = "#000000"
    draw.text(offset, text, font=pil_font, fill=white)

    # Convert the canvas into an array with values in [0, 1]
    arr = np.asarray(canvas)
    arr = np.sum(arr, -1)
    arr = arr / np.max(arr)
    arr = np.rot90(arr, -1)

    if inverted:
        arr = 1 - arr

    return space.element(arr)