import blf
import bpy
from bpy_extras.view3d_utils import location_3d_to_region_2d as l2r
defdraw_callback_px(region, rv3d):'''
Draw on the viewports
'''# BLF drawing routine
font_id =0
o = bpy.context.objectif o:
loc = l2r(region, rv3d, o.location)
blf.position(font_id, loc[0], loc[1],0)
blf.size(font_id,50,72)
blf.draw(font_id, o.name)definit():"""
init function - runs-onces
"""# set the font drawing routine to run ecery framefor a in bpy.data.screens['Layout'].areas:if a.type=="VIEW_3D":breakfor region in a.regions:if region.type=="WINDOW":break
rv3d = a.spaces[0].region_3d
handler = bpy.types.SpaceView3D.draw_handler_add(
draw_callback_px,(region, rv3d),'WINDOW','POST_PIXEL')if __name__ =='__main__':
init()