# How can I compare already imported Fonts with the loaded filepath?

I'm working on a part of my plugin easyText. (http://ranincodes.wix.com/easytext)

I want the import Font part to automaticly check if the Font is already imported. How do I get the name of the selected file (=filebuff)? If it is, the font should not be imported

This is the part of the code wich is important for it

#Atribute
atr = bpy.types.Scene
atr.font = StringProperty(name = "Text Font", description = "Font of the Text")
atr.filebuff = StringProperty(name = "", description = "Choose Font to Import", subtype="FILE_PATH")

#window
class windowFont (bpy.types.Panel):
bl_space_type = "VIEW_3D"
bl_region_type = "TOOLS"
bl_label = "Import Font"
bl_category = "easyText"

def draw(self, context):
scene = bpy.context.scene
layout = self.layout
layout.label("Choose + Import Font")
col = layout.column(align = True)
layout.prop(scene, "filebuff")

#button
bl_description = "Import the choosen Font"

def execute(self, context):
scene = bpy.context.scene
fontb = scene.filebuff
bpy.ops.font.open(filepath=fontb, relative_path=False)
return{'FINISHED'}


UI:

Thank you!

Instead of using the bpy.fonts.open(... operator you can use the load() command for Font Datablocks which has a check_existing property built in, which should do exactly what you want:
bpy.data.fonts.load(filepath=fontb, check_existing=True)

When check_existing is set to True if a font datablock already exists in the blend file from that path then it won't be loaded, otherwise it will.
For more information on why it is generally better avoid bpy.ops commands read here: