def __init__(self): super(TextExample, self).__init__() def_format = TextFormat(size=24, font='_serif') txt = TextField() txt.defaultTextFormat = def_format txt.width = WIDTH txt.height = HEIGHT txt.selectable = False txt.multiline = True formats = [ TextFormat(size=24, font='_serif'), TextFormat(size=26, bold=True, font='_serif'), TextFormat(size=28, bold=True), TextFormat(size=30, color=0xff0000), TextFormat(size=22, bold=True, color=0x0000ff, align='right'), TextFormat(size=22, bold=True, color=0x8080ff, align='center'), TextFormat(size=26, font='_typewriter'), TextFormat(size=30, font='./resources/papercuts-2.ttf'), ] for line_n in range(len(formats)): txt.text += LINE for line_n, fmt in enumerate(formats): txt.setTextFormat(fmt, first=LINE_LEN * line_n, last = LINE_LEN * (line_n + 1)) self.addChild(txt)
def create_text(text): format = TextFormat(size=62, font='./resources/papercuts-2.ttf') tf = TextField() tf.defaultTextFormat = format tf.autoSize = TextFieldAutoSize.LEFT tf.text = text tf.selectable = False tf.x = (WIDTH - tf.textWidth) * 0.5 tf.y = (HEIGHT - tf.textHeight) * 0.5 return tf
def __init__(self): super(HelloWorld, self).__init__() txt = TextField() txt.text = 'Hello World!!!' txt.selectable = False self.addChild(txt)