# Text script issue

I'm needing to generate a set of different texts each in their own font so that I can see which one would look best, something like this (have a whole bunch of fonts do do this with).

I created a short test script, which when ran it ends up looking like this.

Here's the script, each individual text works when ran alone, but they won't work if all texts are generated. Any ideas why it won't work? Probably something simple I'm overlooking.

import bpy

bpy.ops.object.text_add(location=(0, 0, 0), rotation=(0, 0, 0))
txt = bpy.data.objects['Text']
txt.data.body = 'Brush Script'
txt.data.font = fnt

bpy.ops.object.text_add(location=(0, 1, 0), rotation=(0, 0, 0))
txt1 = bpy.data.objects['Text']
txt1.data.body = 'Chalkboard'
txt1.data.font = fnt

bpy.ops.object.text_add(location=(0, 2, 0), rotation=(0, 0, 0))
txt2 = bpy.data.objects['Text']
txt2.data.body = 'Chalkduster'
xt2.data.font = fnt

• Related Nov 30 '18 at 9:10

Quick example of all fonts in a directory. I'm sure someone else can improve the coding for optimization.

import bpy
from os import listdir
from os.path import isfile, join

mypath = 'G:\\Blender Working folders\\Fonts'  # your font directory

onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))]
count = 0
for f in onlyfiles: