#!bpy
"""
Name: 'Flying Letters'
Blender: 2.7x
Group: 'Animation'
Tooltip: 'Helperscripts to animate letters'
"""
import bpy


def textToSingleLetters(text="Hallo", x_start=0, y_start=0):
    """ A given text line is divided in single letters (objects). """

    counter = 1
    kerning = .1
    pos_next_x = 0
    for letter in text:
        name = "row_%s_%s" % (y_start, counter)
        myFontCurve = bpy.data.curves.new(type="FONT", name=name)
        myFontOb = bpy.data.objects.new(name, myFontCurve)
        myFontOb.location = (x_start + pos_next_x, y_start, 0)
        myFontOb.data.body = letter
        bpy.context.scene.objects.link(myFontOb)
        bpy.context.scene.update()
        counter += 1
        pos_next_x = pos_next_x + myFontOb.dimensions.x + kerning


def defineEndPosition(d=None):
    """ Register endposition of all text objects. """
    pass


def calcStartPosition(d=None):
    """ Calculate random start position of all text objects. """
    pass


def setkeyframes(d=None):
    """ One line describing the task of this function  """
    pass


if __name__ == '__main__':

    bpy.ops.object.select_by_type(type='FONT')
    bpy.ops.object.delete()
    textToSingleLetters("Python", y_start=-1, x_start=-2)
    textToSingleLetters("Blender", y_start=0, x_start=-2)
    textToSingleLetters("Blend4Web", y_start=1, x_start=-2)